#include "FreeRTOS.h"
#include "croutine.h"
#include "queue.h"
#include "partest.h"
#include "crflash.h"
Go to the source code of this file.
Defines | |
#define | crfFIXED_DELAY_PRIORITY 0 |
#define | crfFLASH_INDEX 0 |
#define | crfFLASH_PRIORITY 1 |
#define | crfMAX_FLASH_TASKS 8 |
#define | crfPOSTING_BLOCK_TIME 0 |
#define | crfQUEUE_LENGTH 1 |
Functions | |
static void | prvFixedDelayCoRoutine (xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex) |
static void | prvFlashCoRoutine (xCoRoutineHandle xHandle, unsigned portBASE_TYPE uxIndex) |
void | vStartFlashCoRoutines (unsigned portBASE_TYPE uxNumberToCreate) |
portBASE_TYPE | xAreFlashCoRoutinesStillRunning (void) |
Variables | |
static portBASE_TYPE | xCoRoutineFlashStatus = pdPASS |
static xQueueHandle | xFlashQueue |
#define crfFIXED_DELAY_PRIORITY 0 |
#define crfFLASH_INDEX 0 |
#define crfFLASH_PRIORITY 1 |
#define crfMAX_FLASH_TASKS 8 |
Definition at line 101 of file crflash.c.
Referenced by prvFixedDelayCoRoutine(), and vStartFlashCoRoutines().
#define crfPOSTING_BLOCK_TIME 0 |
#define crfQUEUE_LENGTH 1 |
static void prvFixedDelayCoRoutine | ( | xCoRoutineHandle | xHandle, | |
unsigned portBASE_TYPE | uxIndex | |||
) | [static] |
Definition at line 154 of file crflash.c.
References crDELAY, crEND, crfMAX_FLASH_TASKS, crfPOSTING_BLOCK_TIME, crQUEUE_SEND, crSTART, pdFAIL, pdPASS, portBASE_TYPE, portTICK_RATE_MS, xCoRoutineFlashStatus, and xFlashQueue.
Referenced by vStartFlashCoRoutines().
00155 { 00156 /* Even though this is a co-routine the xResult variable does not need to be 00157 static as we do not need it to maintain its state between blocks. */ 00158 signed portBASE_TYPE xResult; 00159 /* The uxIndex parameter of the co-routine function is used as an index into 00160 the xFlashRates array to obtain the delay period to use. */ 00161 static const portTickType xFlashRates[ crfMAX_FLASH_TASKS ] = { 150 / portTICK_RATE_MS, 00162 200 / portTICK_RATE_MS, 00163 250 / portTICK_RATE_MS, 00164 300 / portTICK_RATE_MS, 00165 350 / portTICK_RATE_MS, 00166 400 / portTICK_RATE_MS, 00167 450 / portTICK_RATE_MS, 00168 500 / portTICK_RATE_MS }; 00169 00170 /* Co-routines MUST start with a call to crSTART. */ 00171 crSTART( xHandle ); 00172 00173 for( ;; ) 00174 { 00175 /* Post our uxIndex value onto the queue. This is used as the LED to 00176 flash. */ 00177 crQUEUE_SEND( xHandle, xFlashQueue, ( void * ) &uxIndex, crfPOSTING_BLOCK_TIME, &xResult ); 00178 00179 if( xResult != pdPASS ) 00180 { 00181 /* For the reasons stated at the top of the file we should always 00182 find that we can post to the queue. If we could not then an error 00183 has occurred. */ 00184 xCoRoutineFlashStatus = pdFAIL; 00185 } 00186 00187 crDELAY( xHandle, xFlashRates[ uxIndex ] ); 00188 } 00189 00190 /* Co-routines MUST end with a call to crEND. */ 00191 crEND(); 00192 }
static void prvFlashCoRoutine | ( | xCoRoutineHandle | xHandle, | |
unsigned portBASE_TYPE | uxIndex | |||
) | [static] |
Definition at line 195 of file crflash.c.
References crEND, crQUEUE_RECEIVE, crSTART, pdFAIL, pdPASS, portBASE_TYPE, portMAX_DELAY, vParTestToggleLED(), xCoRoutineFlashStatus, and xFlashQueue.
Referenced by vStartFlashCoRoutines().
00196 { 00197 /* Even though this is a co-routine the variable do not need to be 00198 static as we do not need it to maintain their state between blocks. */ 00199 signed portBASE_TYPE xResult; 00200 unsigned portBASE_TYPE uxLEDToFlash; 00201 00202 /* Co-routines MUST start with a call to crSTART. */ 00203 crSTART( xHandle ); 00204 ( void ) uxIndex; 00205 00206 for( ;; ) 00207 { 00208 /* Block to wait for the number of the LED to flash. */ 00209 crQUEUE_RECEIVE( xHandle, xFlashQueue, &uxLEDToFlash, portMAX_DELAY, &xResult ); 00210 00211 if( xResult != pdPASS ) 00212 { 00213 /* We would not expect to wake unless we received something. */ 00214 xCoRoutineFlashStatus = pdFAIL; 00215 } 00216 else 00217 { 00218 /* We received the number of an LED to flash - flash it! */ 00219 vParTestToggleLED( uxLEDToFlash ); 00220 } 00221 } 00222 00223 /* Co-routines MUST end with a call to crEND. */ 00224 crEND(); 00225 }
void vStartFlashCoRoutines | ( | unsigned portBASE_TYPE | uxNumberToCreate | ) |
Definition at line 128 of file crflash.c.
References crfFIXED_DELAY_PRIORITY, crfFLASH_INDEX, crfFLASH_PRIORITY, crfMAX_FLASH_TASKS, crfQUEUE_LENGTH, portBASE_TYPE, prvFixedDelayCoRoutine(), prvFlashCoRoutine(), xCoRoutineCreate(), xFlashQueue, and xQueueCreate().
00129 { 00130 unsigned portBASE_TYPE uxIndex; 00131 00132 if( uxNumberToCreate > crfMAX_FLASH_TASKS ) 00133 { 00134 uxNumberToCreate = crfMAX_FLASH_TASKS; 00135 } 00136 00137 /* Create the queue used to pass data between the co-routines. */ 00138 xFlashQueue = xQueueCreate( crfQUEUE_LENGTH, sizeof( unsigned portBASE_TYPE ) ); 00139 00140 if( xFlashQueue ) 00141 { 00142 /* Create uxNumberToCreate 'fixed delay' co-routines. */ 00143 for( uxIndex = 0; uxIndex < uxNumberToCreate; uxIndex++ ) 00144 { 00145 xCoRoutineCreate( prvFixedDelayCoRoutine, crfFIXED_DELAY_PRIORITY, uxIndex ); 00146 } 00147 00148 /* Create the 'flash' co-routine. */ 00149 xCoRoutineCreate( prvFlashCoRoutine, crfFLASH_PRIORITY, crfFLASH_INDEX ); 00150 } 00151 }
portBASE_TYPE xAreFlashCoRoutinesStillRunning | ( | void | ) |
Definition at line 228 of file crflash.c.
References xCoRoutineFlashStatus.
00229 { 00230 /* Return pdPASS or pdFAIL depending on whether an error has been detected 00231 or not. */ 00232 return xCoRoutineFlashStatus; 00233 }
portBASE_TYPE xCoRoutineFlashStatus = pdPASS [static] |
Definition at line 121 of file crflash.c.
Referenced by prvFixedDelayCoRoutine(), prvFlashCoRoutine(), and xAreFlashCoRoutinesStillRunning().
xQueueHandle xFlashQueue [static] |
Definition at line 118 of file crflash.c.
Referenced by prvFixedDelayCoRoutine(), prvFlashCoRoutine(), and vStartFlashCoRoutines().