summaryrefslogtreecommitdiff
path: root/FreeRTOS/Demo/Common/Full/flash.c
diff options
context:
space:
mode:
Diffstat (limited to 'FreeRTOS/Demo/Common/Full/flash.c')
-rw-r--r--FreeRTOS/Demo/Common/Full/flash.c103
1 files changed, 51 insertions, 52 deletions
diff --git a/FreeRTOS/Demo/Common/Full/flash.c b/FreeRTOS/Demo/Common/Full/flash.c
index 67f3137f7..0b9686f75 100644
--- a/FreeRTOS/Demo/Common/Full/flash.c
+++ b/FreeRTOS/Demo/Common/Full/flash.c
@@ -27,13 +27,13 @@
/**
- * Creates eight tasks, each of which flash an LED at a different rate. The first
+ * Creates eight tasks, each of which flash an LED at a different rate. The first
* LED flashes every 125ms, the second every 250ms, the third every 375ms, etc.
*
- * The LED flash tasks provide instant visual feedback. They show that the scheduler
+ * The LED flash tasks provide instant visual feedback. They show that the scheduler
* is still operational.
*
- * The PC port uses the standard parallel port for outputs, the Flashlite 186 port
+ * The PC port uses the standard parallel port for outputs, the Flashlite 186 port
* uses IO port F.
*
* \page flashC flash.c
@@ -42,16 +42,16 @@
*/
/*
-Changes from V2.0.0
-
- + Delay periods are now specified using variables and constants of
- TickType_t rather than unsigned long.
-
-Changes from V2.1.1
-
- + The stack size now uses configMINIMAL_STACK_SIZE.
- + String constants made file scope to decrease stack depth on 8051 port.
-*/
+ * Changes from V2.0.0
+ *
+ + Delay periods are now specified using variables and constants of
+ + TickType_t rather than unsigned long.
+ +
+ + Changes from V2.1.1
+ +
+ + The stack size now uses configMINIMAL_STACK_SIZE.
+ + String constants made file scope to decrease stack depth on 8051 port.
+ */
#include <stdlib.h>
@@ -64,18 +64,18 @@ Changes from V2.1.1
#include "flash.h"
#include "print.h"
-#define ledSTACK_SIZE configMINIMAL_STACK_SIZE
+#define ledSTACK_SIZE configMINIMAL_STACK_SIZE
/* Structure used to pass parameters to the LED tasks. */
typedef struct LED_PARAMETERS
{
- unsigned portBASE_TYPE uxLED; /*< The output the task should use. */
- TickType_t xFlashRate; /*< The rate at which the LED should flash. */
+ unsigned portBASE_TYPE uxLED; /*< The output the task should use. */
+ TickType_t xFlashRate; /*< The rate at which the LED should flash. */
} xLEDParameters;
-/* The task that is created eight times - each time with a different xLEDParaemtes
-structure passed in as the parameter. */
-static void vLEDFlashTask( void *pvParameters );
+/* The task that is created eight times - each time with a different xLEDParaemtes
+ * structure passed in as the parameter. */
+static void vLEDFlashTask( void * pvParameters );
/* String to print if USE_STDIO is defined. */
const char * const pcTaskStartMsg = "LED flash task started.\r\n";
@@ -84,45 +84,44 @@ const char * const pcTaskStartMsg = "LED flash task started.\r\n";
void vStartLEDFlashTasks( unsigned portBASE_TYPE uxPriority )
{
-unsigned portBASE_TYPE uxLEDTask;
-xLEDParameters *pxLEDParameters;
-const unsigned portBASE_TYPE uxNumOfLEDs = 8;
-const TickType_t xFlashRate = 125;
-
- /* Create the eight tasks. */
- for( uxLEDTask = 0; uxLEDTask < uxNumOfLEDs; ++uxLEDTask )
- {
- /* Create and complete the structure used to pass parameters to the next
- created task. */
- pxLEDParameters = ( xLEDParameters * ) pvPortMalloc( sizeof( xLEDParameters ) );
- pxLEDParameters->uxLED = uxLEDTask;
- pxLEDParameters->xFlashRate = ( xFlashRate + ( xFlashRate * ( TickType_t ) uxLEDTask ) );
- pxLEDParameters->xFlashRate /= portTICK_PERIOD_MS;
-
- /* Spawn the task. */
- xTaskCreate( vLEDFlashTask, "LEDx", ledSTACK_SIZE, ( void * ) pxLEDParameters, uxPriority, ( TaskHandle_t * ) NULL );
- }
+ unsigned portBASE_TYPE uxLEDTask;
+ xLEDParameters * pxLEDParameters;
+ const unsigned portBASE_TYPE uxNumOfLEDs = 8;
+ const TickType_t xFlashRate = 125;
+
+ /* Create the eight tasks. */
+ for( uxLEDTask = 0; uxLEDTask < uxNumOfLEDs; ++uxLEDTask )
+ {
+ /* Create and complete the structure used to pass parameters to the next
+ * created task. */
+ pxLEDParameters = ( xLEDParameters * ) pvPortMalloc( sizeof( xLEDParameters ) );
+ pxLEDParameters->uxLED = uxLEDTask;
+ pxLEDParameters->xFlashRate = ( xFlashRate + ( xFlashRate * ( TickType_t ) uxLEDTask ) );
+ pxLEDParameters->xFlashRate /= portTICK_PERIOD_MS;
+
+ /* Spawn the task. */
+ xTaskCreate( vLEDFlashTask, "LEDx", ledSTACK_SIZE, ( void * ) pxLEDParameters, uxPriority, ( TaskHandle_t * ) NULL );
+ }
}
/*-----------------------------------------------------------*/
-static void vLEDFlashTask( void *pvParameters )
+static void vLEDFlashTask( void * pvParameters )
{
-xLEDParameters *pxParameters;
+ xLEDParameters * pxParameters;
- /* Queue a message for printing to say the task has started. */
- vPrintDisplayMessage( &pcTaskStartMsg );
+ /* Queue a message for printing to say the task has started. */
+ vPrintDisplayMessage( &pcTaskStartMsg );
- pxParameters = ( xLEDParameters * ) pvParameters;
+ pxParameters = ( xLEDParameters * ) pvParameters;
- for(;;)
- {
- /* Delay for half the flash period then turn the LED on. */
- vTaskDelay( pxParameters->xFlashRate / ( TickType_t ) 2 );
- vParTestToggleLED( pxParameters->uxLED );
+ for( ; ; )
+ {
+ /* Delay for half the flash period then turn the LED on. */
+ vTaskDelay( pxParameters->xFlashRate / ( TickType_t ) 2 );
+ vParTestToggleLED( pxParameters->uxLED );
- /* Delay for half the flash period then turn the LED off. */
- vTaskDelay( pxParameters->xFlashRate / ( TickType_t ) 2 );
- vParTestToggleLED( pxParameters->uxLED );
- }
+ /* Delay for half the flash period then turn the LED off. */
+ vTaskDelay( pxParameters->xFlashRate / ( TickType_t ) 2 );
+ vParTestToggleLED( pxParameters->uxLED );
+ }
}
-