]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_M4_ATSAM4E_Atmel_Studio/src/main_blinky.c
Add additional comments to SAM4E demo.
[freertos] / FreeRTOS / Demo / CORTEX_M4_ATSAM4E_Atmel_Studio / src / main_blinky.c
index 1e52ba68ae647ece5ced00ae0b48f185c809debf..c49f9a9e1983b63a27ad708095e9d97284553ff8 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
-    FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd. \r
+    FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.\r
     All rights reserved\r
 \r
     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
 \r
 /******************************************************************************\r
  * NOTE 1:  This project provides two demo applications.  A simple blinky style\r
- * project, and a more comprehensive demo application that makes use of some\r
- * add-on components.  The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c \r
- * is used to select between the two.  See the notes on using \r
- * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY in main.c.  This file implements the \r
- * simply blinky style version.\r
+ * project, and a more comprehensive demo application that makes use of\r
+ * FreeRTOS_CLI, FreeRTOS+UDP and FreeRTOS+FAT SL.  The\r
+ * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select\r
+ * between the two.  See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY\r
+ * in main.c.  This file implements the simply blinky style version.\r
  *\r
  * NOTE 2:  This file only contains the source code that is specific to the\r
  * basic demo.  Generic functions, such FreeRTOS hook functions, and functions\r
  * required to configure the hardware, are defined in main.c.\r
  ******************************************************************************\r
  *\r
- * main_blinky() creates one queue, and two tasks and one software timer.  It \r
- * then starts the scheduler.\r
+ * main_blinky() creates one queue, two tasks and one software timer.  It then\r
+ * starts the scheduler.\r
  *\r
  * The Queue Send Task:\r
  * The queue send task is implemented by the prvQueueSendTask() function in\r
@@ -116,11 +116,6 @@ will remove items as they are added, meaning the send task should always find
 the queue empty. */\r
 #define mainQUEUE_LENGTH                                       ( 1 )\r
 \r
-/* Values passed to the two tasks just to check the task parameter\r
-functionality. */\r
-#define mainQUEUE_SEND_PARAMETER                       ( 0x1111UL )\r
-#define mainQUEUE_RECEIVE_PARAMETER                    ( 0x22UL )\r
-\r
 /* The period of the blinky software timer.  The period is specified in ms and\r
 converted to ticks using the portTICK_RATE_MS constant. */\r
 #define mainBLINKY_TIMER_PERIOD                                ( 50 / portTICK_RATE_MS )\r
@@ -128,7 +123,7 @@ converted to ticks using the portTICK_RATE_MS constant. */
 /* A block time of zero simply means "don't block". */\r
 #define mainDONT_BLOCK                                         ( 0 )\r
 \r
-/* The LEDs toggled by the timer and queue receive task respectively. */\r
+/* The LEDs toggled by the timer callback and queue receive task respectively. */\r
 #define mainTIMER_LED                                          0\r
 #define mainTASK_LED                                           1\r
 \r
@@ -154,14 +149,10 @@ void main_blinky( void );
 \r
 /*-----------------------------------------------------------*/\r
 \r
-/* The queue used by both tasks. */\r
-static xQueueHandle xQueue = NULL;\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
 void main_blinky( void )\r
 {\r
 xTimerHandle xTimer;\r
+xQueueHandle xQueue;\r
 \r
        /* Create the queue. */\r
        xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) );\r
@@ -173,13 +164,13 @@ xTimerHandle xTimer;
                xTaskCreate( prvQueueReceiveTask,                                       /* The function that implements the task. */\r
                                        ( signed char * ) "Rx",                                 /* The text name assigned to the task - for debug only as it is not used by the kernel. */\r
                                        configMINIMAL_STACK_SIZE,                               /* The size of the stack to allocate to the task. */\r
-                                       ( void * ) mainQUEUE_RECEIVE_PARAMETER, /* The parameter passed to the task - just to check the functionality. */\r
+                                       ( void * ) xQueue,                                              /* Pass the queue into the task using the task parameter. */\r
                                        mainQUEUE_RECEIVE_TASK_PRIORITY,                /* The priority assigned to the task. */\r
                                        NULL );                                                                 /* The task handle is not required, so NULL is passed. */\r
 \r
-               xTaskCreate( prvQueueSendTask, ( signed char * ) "TX", configMINIMAL_STACK_SIZE, ( void * ) mainQUEUE_SEND_PARAMETER, mainQUEUE_SEND_TASK_PRIORITY, NULL );\r
+               xTaskCreate( prvQueueSendTask, ( signed char * ) "TX", configMINIMAL_STACK_SIZE, ( void * ) xQueue, mainQUEUE_SEND_TASK_PRIORITY, NULL );\r
 \r
-               /* Create the blinky software timer as described at the top of this \r
+               /* Create the blinky software timer as described at the top of this\r
                file. */\r
                xTimer = xTimerCreate(  ( const signed char * ) "Blinky",/* A text name, purely to help debugging. */\r
                                                                ( mainBLINKY_TIMER_PERIOD ),    /* The timer period. */\r
@@ -211,9 +202,10 @@ static void prvQueueSendTask( void *pvParameters )
 {\r
 portTickType xNextWakeTime;\r
 const unsigned long ulValueToSend = 100UL;\r
+xQueueHandle xQueue;\r
 \r
-       /* Check the task parameter is as expected. */\r
-       configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_SEND_PARAMETER );\r
+       /* The handle of the queue is passed in using the task's parameter. */\r
+       xQueue = ( xQueueHandle ) pvParameters;\r
 \r
        /* Initialise xNextWakeTime - this only needs to be done once. */\r
        xNextWakeTime = xTaskGetTickCount();\r
@@ -230,7 +222,7 @@ const unsigned long ulValueToSend = 100UL;
                toggle the LED.  0 is used as the block time so the sending operation\r
                will not block - it shouldn't need to block as the queue should always\r
                be empty at this point in the code. */\r
-               xQueueSend( xQueue, &ulValueToSend, 0U );\r
+               xQueueSend( xQueue, &ulValueToSend, mainDONT_BLOCK );\r
        }\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -238,9 +230,10 @@ const unsigned long ulValueToSend = 100UL;
 static void prvQueueReceiveTask( void *pvParameters )\r
 {\r
 unsigned long ulReceivedValue;\r
+xQueueHandle xQueue;\r
 \r
-       /* Check the task parameter is as expected. */\r
-       configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_RECEIVE_PARAMETER );\r
+       /* The queue is passed in as the task's parameter. */\r
+       xQueue = ( xQueueHandle ) pvParameters;\r
 \r
        for( ;; )\r
        {\r