/*\r
- FreeRTOS V8.2.3 - Copyright (C) 2015 Real Time Engineers Ltd.\r
+ FreeRTOS V9.0.0rc1 - Copyright (C) 2016 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 demo\r
- * that demonstrates tickless low power operation, and a more comprehensive test\r
- * and demo application. The mainCREATE_LOW_POWER_DEMO setting in main.c is\r
- * used to select between the two. See the notes on using\r
- * mainCREATE_LOW_POWER_DEMO in main.c. This file implements the low power\r
- * version.\r
+ * that demonstrates tickless low power operation, and a more comprehensive\r
+ * test and demo application. The configCREATE_LOW_POWER_DEMO setting in\r
+ * FreeRTOSConfig.h is used to select between the two, and to select the clock\r
+ * used when tickless low power operation is demonstrated. See the notes on\r
+ * using configCREATE_LOW_POWER_DEMO in main.c. This file implements the low\r
+ * power version.\r
*\r
* NOTE 2: This file only contains the source code that is specific to the\r
* low power demo. Generic functions, such FreeRTOS hook functions, and\r
*\r
* The Queue Send Task:\r
* The queue send task is implemented by the prvQueueSendTask() function in\r
- * this file. prvQueueSendTask() sits in a loop that causes it to repeatedly\r
- * block for 200 milliseconds, before sending the value 100 to the queue that\r
- * was created within main_low_power(). Once the value is sent, the task loops\r
- * back around to block for another 200 milliseconds...and so on.\r
+ * this file. It sends the value 100 to the queue every second.\r
*\r
* The Queue Receive Task:\r
* The queue receive task is implemented by the prvQueueReceiveTask() function\r
- * in this file. prvQueueReceiveTask() sits in a loop where it repeatedly\r
- * blocks on attempts to read data from the queue that was created within\r
- * main_low_power(). When data is received, the task checks the value of the\r
- * data, and if the value equals the expected 100, toggles an LED. The 'block\r
- * time' parameter passed to the queue receive function specifies that the\r
- * task should be held in the Blocked state indefinitely to wait for data to\r
- * be available on the queue. The queue receive task will only leave the\r
- * Blocked state when the queue send task writes to the queue. As the queue\r
- * send task writes to the queue every 200 milliseconds, the queue receive\r
- * task leaves the Blocked state every 200 milliseconds, and therefore toggles\r
- * the LED every 200 milliseconds.\r
+ * in this file. prvQueueReceiveTask() blocks on the queue, blipping (quickly\r
+ * turn on then off again) the LED each time it received the value 100 from the\r
+ * queue send task. The queue send task writes to the queue every second, so\r
+ * the LED will blip once a second.\r
+ *\r
+ * The RTOS tick is turned off when the queue send task and queue receive task\r
+ * are both in the Blocked state.\r
+ *\r
*/\r
\r
-#warning Description of demo in comments above is not correct.\r
\r
/* Kernel includes. */\r
#include "FreeRTOS.h"\r
\r
/* The rate at which data is sent to the queue. The 200ms value is converted\r
to ticks using the portTICK_PERIOD_MS constant. */\r
-#define mainQUEUE_SEND_FREQUENCY_MS ( 200 / portTICK_PERIOD_MS )\r
+#define mainQUEUE_SEND_FREQUENCY_MS pdMS_TO_TICKS( 1000 )\r
\r
/* The number of items the queue can hold. This is 1 as the receive task\r
will remove items as they are added, meaning the send task should always find\r
static void prvQueueSendTask( void *pvParameters )\r
{\r
TickType_t xNextWakeTime;\r
-const unsigned long ulValueToSend = 100UL;\r
+const uint32_t ulValueToSend = 100UL;\r
\r
/* Remove compiler warning about unused parameter. */\r
( void ) pvParameters;\r
\r
static void prvQueueReceiveTask( void *pvParameters )\r
{\r
-unsigned long ulReceivedValue;\r
-const unsigned long ulExpectedValue = 100UL;\r
+uint32_t ulReceivedValue;\r
+const uint32_t ulExpectedValue = 100UL;\r
+const TickType_t xShortDelay = pdMS_TO_TICKS( 10 );\r
\r
/* Remove compiler warning about unused parameter. */\r
( void ) pvParameters;\r
is it the expected value? If it is, toggle the LED. */\r
if( ulReceivedValue == ulExpectedValue )\r
{\r
- BSP_LedToggle( mainTASK_LED );\r
+ /* Turn the LED on for a brief time only so it doens't distort the\r
+ energy reading. */\r
+ BSP_LedSet( mainTASK_LED );\r
+ vTaskDelay( xShortDelay );\r
+ BSP_LedClear( mainTASK_LED );\r
ulReceivedValue = 0U;\r
}\r
}\r