-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
52 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ | |
platform = teensy | ||
framework = mbed | ||
board = teensy31 | ||
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ | |
platform = teensy | ||
framework = mbed | ||
board = teensy31 | ||
build_flags = -DPIO_FRAMEWORK_MBED_RTOS_PRESENT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,34 @@ | ||
#include "mbed.h" | ||
#include "rtos.h" | ||
|
||
/* | ||
* The stack size is defined in cmsis_os.h mainly dependent on the underlying toolchain and | ||
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes | ||
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize. | ||
*/ | ||
#if defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8) | ||
#define STACK_SIZE DEFAULT_STACK_SIZE/4 | ||
#else | ||
#define STACK_SIZE DEFAULT_STACK_SIZE | ||
#endif | ||
|
||
void print_char(char c = '*') { | ||
printf("%c", c); | ||
fflush(stdout); | ||
|
||
Queue<uint32_t, 5> queue; | ||
|
||
DigitalOut myled(LED1); | ||
|
||
void queue_isr() { | ||
queue.put((uint32_t*)2); | ||
myled = !myled; | ||
} | ||
|
||
DigitalOut led1(LED1); | ||
DigitalOut led2(LED2); | ||
|
||
void led2_thread(void const *argument) { | ||
|
||
void queue_thread(void const *args) { | ||
while (true) { | ||
led2 = !led2; | ||
queue.put((uint32_t*)1); | ||
Thread::wait(1000); | ||
print_char(); | ||
} | ||
} | ||
|
||
int main() { | ||
Thread thread(led2_thread, NULL, osPriorityNormal, STACK_SIZE); | ||
|
||
|
||
int main (void) { | ||
Thread thread(queue_thread); | ||
|
||
Ticker ticker; | ||
ticker.attach(queue_isr, 1.0); | ||
|
||
while (true) { | ||
led1 = !led1; | ||
Thread::wait(500); | ||
osEvent evt = queue.get(); | ||
if (evt.status != osEventMessage) { | ||
printf("queue->get() returned %02x status\n\r", evt.status); | ||
} else { | ||
printf("queue->get() returned %d\n\r", evt.value.v); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters