Same as freertos_bluetooth but now with FreeRTOS v_8.2.1
Dependencies: mbed m3pi FreeRTOS_V8_2_1_LPC1768
main.cpp@2:7a112956091c, 2015-09-13 (annotated)
- Committer:
- chalikias
- Date:
- Sun Sep 13 11:29:18 2015 +0000
- Revision:
- 2:7a112956091c
- Parent:
- 1:be76e6fdff84
- Child:
- 3:d577dbef65a2
updated task names for consistency
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
chalikias | 2:7a112956091c | 1 | // N.C. Freertos mbed minimal example based on below: |
chalikias | 2:7a112956091c | 2 | // https://developer.mbed.org/users/rgrover1/code/FreeRTOS/ |
chalikias | 0:7f7fa5e631ec | 3 | // http://www.radekdostal.com/content/freertos-610-minimal-example |
chalikias | 0:7f7fa5e631ec | 4 | |
chalikias | 0:7f7fa5e631ec | 5 | #include "mbed.h" |
chalikias | 0:7f7fa5e631ec | 6 | #include "FreeRTOS.h" |
chalikias | 0:7f7fa5e631ec | 7 | #include "task.h" |
chalikias | 0:7f7fa5e631ec | 8 | |
chalikias | 0:7f7fa5e631ec | 9 | DigitalOut led1(LED1); |
chalikias | 0:7f7fa5e631ec | 10 | DigitalOut led2(LED2); |
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 | 2:7a112956091c | 17 | printf("Task1\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 | 2:7a112956091c | 27 | printf("Task2\n"); |
chalikias | 0:7f7fa5e631ec | 28 | vTaskDelay(5000); |
chalikias | 0:7f7fa5e631ec | 29 | } |
chalikias | 0:7f7fa5e631ec | 30 | } |
chalikias | 0:7f7fa5e631ec | 31 | |
chalikias | 2:7a112956091c | 32 | |
chalikias | 0:7f7fa5e631ec | 33 | int main (void) |
chalikias | 0:7f7fa5e631ec | 34 | { |
chalikias | 2:7a112956091c | 35 | xTaskCreate( Task1, ( signed char * ) "Task1", configMINIMAL_STACK_SIZE, NULL, |
chalikias | 0:7f7fa5e631ec | 36 | tskIDLE_PRIORITY, ( xTaskHandle * ) NULL ); |
chalikias | 2:7a112956091c | 37 | xTaskCreate( Task2, ( signed char * ) "Task2", configMINIMAL_STACK_SIZE, NULL, |
chalikias | 0:7f7fa5e631ec | 38 | tskIDLE_PRIORITY, ( xTaskHandle * ) NULL ); |
chalikias | 0:7f7fa5e631ec | 39 | |
chalikias | 0:7f7fa5e631ec | 40 | vTaskStartScheduler(); |
chalikias | 0:7f7fa5e631ec | 41 | |
chalikias | 0:7f7fa5e631ec | 42 | //should never get here |
chalikias | 0:7f7fa5e631ec | 43 | printf("ERORR: vTaskStartScheduler returned!"); |
chalikias | 0:7f7fa5e631ec | 44 | for (;;); |
chalikias | 0:7f7fa5e631ec | 45 | } |