![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
very simple Freertos hello world
Dependencies: mbed freertos_test FreeRTOS
main.cpp@1:be76e6fdff84, 2015-09-13 (annotated)
- Committer:
- chalikias
- Date:
- Sun Sep 13 11:18:57 2015 +0000
- Revision:
- 1:be76e6fdff84
- Parent:
- 0:7f7fa5e631ec
- Child:
- 2:7a112956091c
updated blink times, easy to test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chalikias | 0:7f7fa5e631ec | 1 | // http://www.radekdostal.com/content/freertos-610-minimal-example |
chalikias | 0:7f7fa5e631ec | 2 | |
chalikias | 0:7f7fa5e631ec | 3 | #include "mbed.h" |
chalikias | 0:7f7fa5e631ec | 4 | #include "FreeRTOS.h" |
chalikias | 0:7f7fa5e631ec | 5 | #include "task.h" |
chalikias | 0:7f7fa5e631ec | 6 | |
chalikias | 0:7f7fa5e631ec | 7 | DigitalOut led1(LED1); |
chalikias | 0:7f7fa5e631ec | 8 | DigitalOut led2(LED2); |
chalikias | 0:7f7fa5e631ec | 9 | DigitalOut led3(LED3); |
chalikias | 0:7f7fa5e631ec | 10 | DigitalOut led4(LED4); |
chalikias | 0:7f7fa5e631ec | 11 | |
chalikias | 0:7f7fa5e631ec | 12 | void Task1 (void* pvParameters) |
chalikias | 0:7f7fa5e631ec | 13 | { |
chalikias | 0:7f7fa5e631ec | 14 | (void) pvParameters; // Just to stop compiler warnings. |
chalikias | 0:7f7fa5e631ec | 15 | for (;;) { |
chalikias | 0:7f7fa5e631ec | 16 | led1 = !led1; |
chalikias | 0:7f7fa5e631ec | 17 | printf("Task A\n"); |
chalikias | 0:7f7fa5e631ec | 18 | vTaskDelay(500); |
chalikias | 0:7f7fa5e631ec | 19 | } |
chalikias | 0:7f7fa5e631ec | 20 | } |
chalikias | 0:7f7fa5e631ec | 21 | |
chalikias | 0:7f7fa5e631ec | 22 | void Task2 (void* pvParameters) |
chalikias | 0:7f7fa5e631ec | 23 | { |
chalikias | 0:7f7fa5e631ec | 24 | (void) pvParameters; // Just to stop compiler warnings. |
chalikias | 0:7f7fa5e631ec | 25 | for (;;) { |
chalikias | 0:7f7fa5e631ec | 26 | led2= !led2; |
chalikias | 0:7f7fa5e631ec | 27 | printf("Task B\n"); |
chalikias | 0:7f7fa5e631ec | 28 | vTaskDelay(5000); |
chalikias | 0:7f7fa5e631ec | 29 | } |
chalikias | 0:7f7fa5e631ec | 30 | } |
chalikias | 0:7f7fa5e631ec | 31 | |
chalikias | 0:7f7fa5e631ec | 32 | int main (void) |
chalikias | 0:7f7fa5e631ec | 33 | { |
chalikias | 0:7f7fa5e631ec | 34 | xTaskCreate( Task1, ( signed char * ) "TaskA", configMINIMAL_STACK_SIZE, NULL, |
chalikias | 0:7f7fa5e631ec | 35 | tskIDLE_PRIORITY, ( xTaskHandle * ) NULL ); |
chalikias | 0:7f7fa5e631ec | 36 | xTaskCreate( Task2, ( signed char * ) "TaskB", configMINIMAL_STACK_SIZE, NULL, |
chalikias | 0:7f7fa5e631ec | 37 | tskIDLE_PRIORITY, ( xTaskHandle * ) NULL ); |
chalikias | 0:7f7fa5e631ec | 38 | |
chalikias | 0:7f7fa5e631ec | 39 | vTaskStartScheduler(); |
chalikias | 0:7f7fa5e631ec | 40 | |
chalikias | 0:7f7fa5e631ec | 41 | //should never get here |
chalikias | 0:7f7fa5e631ec | 42 | printf("ERORR: vTaskStartScheduler returned!"); |
chalikias | 0:7f7fa5e631ec | 43 | for (;;); |
chalikias | 0:7f7fa5e631ec | 44 | } |