2 // This code was from the original demo package. Although it is no longer
3 // used, it shows an excellent example of how to reuse task code with
6 // Each time the task is create with xTaskCreate, it increment the task
7 // number, which it uses to calculate a flash rate and which LED to
13 #include "../cpu/cpu.h"
19 #define ledFLASH_RATE_BASE ((portTickType) 333)
20 static portBASE_TYPE uxFlashTaskNumber = 0;
22 portTASK_FUNCTION (vLEDFlashTask, pvParameters __attribute__ ((unused)))
24 portTickType xFlashRate;
25 portTickType xLastFlashTime;
26 unsigned portBASE_TYPE uxLED;
29 // Calculate the LED and flash rate
31 portENTER_CRITICAL ();
33 uxLED = uxFlashTaskNumber;
38 xFlashRate = ledFLASH_RATE_BASE + (ledFLASH_RATE_BASE * (portTickType) uxLED);
39 xFlashRate /= portTICK_RATE_MS;
42 // We will turn the LED on and off again in the delay period, so each delay is only half the total period
44 xFlashRate /= (portTickType) 2;
47 // We need to initialise xLastFlashTime prior to the first call to vTaskDelayUntil()
49 xLastFlashTime = xTaskGetTickCount();
53 vTaskDelayUntil (&xLastFlashTime, xFlashRate);
55 vTaskDelayUntil (&xLastFlashTime, xFlashRate);