/*\r
- FreeRTOS V6.1.1 - Copyright (C) 2011 Real Time Engineers Ltd.\r
+ FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.\r
+\r
\r
***************************************************************************\r
- * *\r
- * If you are: *\r
- * *\r
- * + New to FreeRTOS, *\r
- * + Wanting to learn FreeRTOS or multitasking in general quickly *\r
- * + Looking for basic training, *\r
- * + Wanting to improve your FreeRTOS skills and productivity *\r
- * *\r
- * then take a look at the FreeRTOS books - available as PDF or paperback *\r
- * *\r
- * "Using the FreeRTOS Real Time Kernel - a Practical Guide" *\r
- * http://www.FreeRTOS.org/Documentation *\r
- * *\r
- * A pdf reference manual is also available. Both are usually delivered *\r
- * to your inbox within 20 minutes to two hours when purchased between 8am *\r
- * and 8pm GMT (although please allow up to 24 hours in case of *\r
- * exceptional circumstances). Thank you for your support! *\r
- * *\r
+ * *\r
+ * FreeRTOS tutorial books are available in pdf and paperback. *\r
+ * Complete, revised, and edited pdf reference manuals are also *\r
+ * available. *\r
+ * *\r
+ * Purchasing FreeRTOS documentation will not only help you, by *\r
+ * ensuring you get running as quickly as possible and with an *\r
+ * in-depth knowledge of how to use FreeRTOS, it will also help *\r
+ * the FreeRTOS project to continue with its mission of providing *\r
+ * professional grade, cross platform, de facto standard solutions *\r
+ * for microcontrollers - completely free of charge! *\r
+ * *\r
+ * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *\r
+ * *\r
+ * Thank you for using FreeRTOS, and thank you for your support! *\r
+ * *\r
***************************************************************************\r
\r
+\r
This file is part of the FreeRTOS distribution.\r
\r
FreeRTOS is free software; you can redistribute it and/or modify it under\r
the terms of the GNU General Public License (version 2) as published by the\r
Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
- ***NOTE*** The exception to the GPL is included to allow you to distribute\r
- a combined work that includes FreeRTOS without being obliged to provide the\r
- source code for proprietary components outside of the FreeRTOS kernel.\r
- FreeRTOS is distributed in the hope that it will be useful, but WITHOUT\r
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
+ >>>NOTE<<< The modification to the GPL is included to allow you to\r
+ distribute a combined work that includes FreeRTOS without being obliged to\r
+ provide the source code for proprietary components outside of the FreeRTOS\r
+ kernel. FreeRTOS is distributed in the hope that it will be useful, but\r
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for\r
more details. You should have received a copy of the GNU General Public\r
License and the FreeRTOS license exception along with FreeRTOS; if not it\r
can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
FreeRTOS WEB site.\r
\r
1 tab == 4 spaces!\r
+ \r
+ ***************************************************************************\r
+ * *\r
+ * Having a problem? Start by reading the FAQ "My application does *\r
+ * not run, what could be wrong? *\r
+ * *\r
+ * http://www.FreeRTOS.org/FAQHelp.html *\r
+ * *\r
+ ***************************************************************************\r
\r
- http://www.FreeRTOS.org - Documentation, latest information, license and\r
- contact details.\r
-\r
- http://www.SafeRTOS.com - A version that is certified for use in safety\r
- critical systems.\r
-\r
- http://www.OpenRTOS.com - Commercial support, development, porting,\r
- licensing and training services.\r
+ \r
+ http://www.FreeRTOS.org - Documentation, training, latest information, \r
+ license and contact details.\r
+ \r
+ http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+ including FreeRTOS+Trace - an indispensable productivity tool.\r
+\r
+ Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
+ the code with commercial support, indemnification, and middleware, under \r
+ the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also\r
+ provide a safety engineered and independently SIL3 certified version under \r
+ the SafeRTOS brand: http://www.SafeRTOS.com.\r
*/\r
\r
\r
\r
#include "portable.h"\r
#include "list.h"\r
+#include "task.h"\r
\r
#ifdef __cplusplus\r
extern "C" {\r
*----------------------------------------------------------*/\r
\r
/**\r
- * Type by which software timers are referenced. For example, a call to \r
+ * Type by which software timers are referenced. For example, a call to\r
* xTimerCreate() returns an xTimerHandle variable that can then be used to\r
* reference the subject timer in calls to other software timer API functions\r
* (for example, xTimerStart(), xTimerReset(), etc.).\r
typedef void (*tmrTIMER_CALLBACK)( xTimerHandle xTimer );\r
\r
/**\r
- * xTimerHandle xTimerCreate( const signed char *pcTimerName, \r
- * portTickType xTimerPeriod, \r
- * unsigned portBASE_TYPE uxAutoReload, \r
- * void * pvTimerID, \r
+ * xTimerHandle xTimerCreate( const signed char *pcTimerName,\r
+ * portTickType xTimerPeriodInTicks,\r
+ * unsigned portBASE_TYPE uxAutoReload,\r
+ * void * pvTimerID,\r
* tmrTIMER_CALLBACK pxCallbackFunction );\r
*\r
- * Creates a new software timer instance. This allocates the storage required \r
- * by the new timer, initialises the new timers internal state, and returns a \r
+ * Creates a new software timer instance. This allocates the storage required\r
+ * by the new timer, initialises the new timers internal state, and returns a\r
* handle by which the new timer can be referenced.\r
*\r
* Timers are created in the dormant state. The xTimerStart(), xTimerReset(),\r
* xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and\r
- * xTimerChangePeriodFromISR() can all be used to transition a timer into the\r
+ * xTimerChangePeriodFromISR() API functions can all be used to transition a timer into the\r
* active state.\r
*\r
* @param pcTimerName A text name that is assigned to the timer. This is done\r
* purely to assist debugging. The kernel itself only ever references a timer by\r
* its handle, and never by its name.\r
*\r
- * @param xTimerPeriod The timer period. The time is defined in tick periods so \r
+ * @param xTimerPeriodInTicks The timer period. The time is defined in tick periods so\r
* the constant portTICK_RATE_MS can be used to convert a time that has been\r
* specified in milliseconds. For example, if the timer must expire after 100\r
- * ticks, then xTimerPeriod should be set to 100. Alternatively, if the timer\r
+ * ticks, then xTimerPeriodInTicks should be set to 100. Alternatively, if the timer\r
* must expire after 500ms, then xPeriod can be set to ( 500 / portTICK_RATE_MS )\r
- * provided configTICK_RATE_HZ is set to less than or equal to 1000.\r
+ * provided configTICK_RATE_HZ is less than or equal to 1000.\r
*\r
* @param uxAutoReload If uxAutoReload is set to pdTRUE then the timer will\r
- * expire repeatedly with a frequency set by the xTimerPeriod parameter. If\r
+ * expire repeatedly with a frequency set by the xTimerPeriodInTicks parameter. If\r
* uxAutoReload is set to pdFALSE then the timer will be a one-shot timer and\r
- * will expire once only xTimerPeriod ticks from the time it is started.\r
+ * enter the dormant state after it expires.\r
*\r
- * @param pvTimerID An identifier to assign to the timer being created. \r
- * Typically this would be used to identify the timer that expired within the\r
- * timers callback function when multiple timers are assigned the same callback\r
- * function.\r
+ * @param pvTimerID An identifier that is assigned to the timer being created.\r
+ * Typically this would be used in the timer callback function to identify which\r
+ * timer expired when the same callback function is assigned to more than one\r
+ * timer.\r
*\r
* @param pxCallbackFunction The function to call when the timer expires.\r
+ * Callback functions must have the prototype defined by tmrTIMER_CALLBACK,\r
+ * which is "void vCallbackFunction( xTimerHandle xTimer );".\r
*\r
* @return If the timer is successfully create then a handle to the newly\r
* created timer is returned. If the timer cannot be created (because either\r
- * there is insufficient FreeRTOS heap remaining to allocate the timer \r
+ * there is insufficient FreeRTOS heap remaining to allocate the timer\r
* structures, or the timer period was set to 0) then 0 is returned.\r
*\r
* Example usage:\r
*\r
- * \r
* #define NUM_TIMERS 5\r
- * \r
+ *\r
* // An array to hold handles to the created timers.\r
* xTimerHandle xTimers[ NUM_TIMERS ];\r
- * \r
+ *\r
* // An array to hold a count of the number of times each timer expires.\r
* long lExpireCounters[ NUM_TIMERS ] = { 0 };\r
- * \r
- * // Define a callback function that will be used by multiple timer instances. \r
- * // The callback function does nothing but count the number of times the \r
+ *\r
+ * // Define a callback function that will be used by multiple timer instances.\r
+ * // The callback function does nothing but count the number of times the\r
* // associated timer expires, and stop the timer once the timer has expired\r
* // 10 times.\r
- * void vTimerCallback( xTIMER *pxTimer )\r
+ * void vTimerCallback( xTimerHandle pxTimer )\r
* {\r
* long lArrayIndex;\r
* const long xMaxExpiryCountBeforeStopping = 10;\r
- * \r
+ *\r
* // Optionally do something if the pxTimer parameter is NULL.\r
* configASSERT( pxTimer );\r
* \r
* // Which timer expired?\r
* lArrayIndex = ( long ) pvTimerGetTimerID( pxTimer );\r
- * \r
+ *\r
* // Increment the number of times that pxTimer has expired.\r
* lExpireCounters[ lArrayIndex ] += 1;\r
*\r
* xTimerStop( pxTimer, 0 );\r
* }\r
* }\r
- * \r
+ *\r
* void main( void )\r
* {\r
* long x;\r
- * \r
+ *\r
* // Create then start some timers. Starting the timers before the scheduler\r
* // has been started means the timers will start running immediately that\r
* // the scheduler starts.\r
* ( void * ) x, // Assign each timer a unique id equal to its array index.\r
* vTimerCallback // Each timer calls the same callback when it expires.\r
* );\r
- * \r
+ *\r
* if( xTimers[ x ] == NULL )\r
* {\r
* // The timer was not created.\r
* {\r
* // Start the timer. No block time is specified, and even if one was\r
* // it would be ignored because the scheduler has not yet been\r
- * // started. \r
+ * // started.\r
* if( xTimerStart( xTimers[ x ], 0 ) != pdPASS )\r
* {\r
* // The timer could not be set into the Active state.\r
* }\r
* }\r
* }\r
- * \r
+ *\r
* // ...\r
* // Create tasks here.\r
* // ...\r
- * \r
+ *\r
* // Starting the scheduler will start the timers running as they have already\r
* // been set into the active state.\r
* xTaskStartScheduler();\r
- * \r
+ *\r
* // Should not reach here.\r
* for( ;; );\r
* }\r
*/\r
-xTimerHandle xTimerCreate( const signed char *pcTimerName, portTickType xTimerPeriod, unsigned portBASE_TYPE uxAutoReload, void * pvTimerID, tmrTIMER_CALLBACK pxCallbackFunction ) PRIVILEGED_FUNCTION;\r
+xTimerHandle xTimerCreate( const signed char *pcTimerName, portTickType xTimerPeriodInTicks, unsigned portBASE_TYPE uxAutoReload, void * pvTimerID, tmrTIMER_CALLBACK pxCallbackFunction ) PRIVILEGED_FUNCTION;\r
\r
/**\r
* void *pvTimerGetTimerID( xTimerHandle xTimer );\r
*\r
- * Returns the ID assigned to the xTimer parameter. \r
- * \r
+ * Returns the ID assigned to the timer.\r
+ *\r
* IDs are assigned to timers using the pvTimerID parameter of the call to\r
- * xTimerCreated() used to create the timer.\r
+ * xTimerCreated() that was used to create the timer.\r
*\r
- * If the same callback function is assigned to multiple tasks then the timer\r
+ * If the same callback function is assigned to multiple timers then the timer\r
* ID can be used within the callback function to identify which timer actually\r
* expired.\r
*\r
* Queries a timer to see if it is active or dormant.\r
*\r
* A timer will be dormant if:\r
- * 1) It has been created but not started, or \r
+ * 1) It has been created but not started, or\r
* 2) It is an expired on-shot timer that has not been restarted.\r
*\r
- * Timers can be started using the xTimerStart(), xTimerReset(),\r
+ * Timers are created in the dormant state. The xTimerStart(), xTimerReset(),\r
* xTimerStartFromISR(), xTimerResetFromISR(), xTimerChangePeriod() and\r
- * xTimerChangePeriodFromISR() API functions.\r
+ * xTimerChangePeriodFromISR() API functions can all be used to transition a timer into the\r
+ * active state.\r
*\r
* @param xTimer The timer being queried.\r
*\r
* // This function assumes xTimer has already been created.\r
* void vAFunction( xTimerHandle xTimer )\r
* {\r
- * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer )" )\r
+ * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )"\r
* {\r
* // xTimer is active, do something.\r
* }\r
* else\r
* {\r
* // xTimer is not active, do something else.\r
- * } \r
+ * }\r
* }\r
*/\r
portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION;\r
\r
+/**\r
+ * xTimerGetTimerDaemonTaskHandle() is only available if \r
+ * INCLUDE_xTimerGetTimerDaemonTaskHandle is set to 1 in FreeRTOSConfig.h.\r
+ *\r
+ * Simply returns the handle of the timer service/daemon task. It it not valid\r
+ * to call xTimerGetTimerDaemonTaskHandle() before the scheduler has been started.\r
+ */\r
+xTaskHandle xTimerGetTimerDaemonTaskHandle( void );\r
+\r
/**\r
* portBASE_TYPE xTimerStart( xTimerHandle xTimer, portTickType xBlockTime );\r
*\r
* Timer functionality is provided by a timer service/daemon task. Many of the\r
- * public FreeRTOS timer API functions send commands to the timer service task \r
- * though a queue called the timer command queue. The timer command queue is \r
- * private to the kernel itself and is not directly accessible to application \r
- * code. The length of the timer command queue is set by the \r
+ * public FreeRTOS timer API functions send commands to the timer service task\r
+ * though a queue called the timer command queue. The timer command queue is\r
+ * private to the kernel itself and is not directly accessible to application\r
+ * code. The length of the timer command queue is set by the\r
* configTIMER_QUEUE_LENGTH configuration constant.\r
*\r
- * xTimerStart() starts a timer that was previously created using the \r
+ * xTimerStart() starts a timer that was previously created using the\r
* xTimerCreate() API function. If the timer had already been started and was\r
* already in the active state, then xTimerStart() has equivalent functionality\r
* to the xTimerReset() API function.\r
*\r
* Starting a timer ensures the timer is in the active state. If the timer\r
* is not stopped, deleted, or reset in the mean time, the callback function\r
- * associated with the timer will get called 'n 'ticks after xTimerStart() was \r
+ * associated with the timer will get called 'n' ticks after xTimerStart() was\r
* called, where 'n' is the timers defined period.\r
*\r
* It is valid to call xTimerStart() before the scheduler has been started, but\r
*\r
* @param xBlockTime Specifies the time, in ticks, that the calling task should\r
* be held in the Blocked state to wait for the start command to be successfully\r
- * sent to the timer command queue, should the queue already be full when \r
+ * sent to the timer command queue, should the queue already be full when\r
* xTimerStart() was called. xBlockTime is ignored if xTimerStart() is called\r
- * before the scheduler is started. \r
+ * before the scheduler is started.\r
*\r
- * @return pdFAIL will be returned if the start command could not be sent to \r
+ * @return pdFAIL will be returned if the start command could not be sent to\r
* the timer command queue even after xBlockTime ticks had passed. pdPASS will\r
- * be returned if the command was successfully send to the timer command queue.\r
+ * be returned if the command was successfully sent to the timer command queue.\r
* When the command is actually processed will depend on the priority of the\r
* timer service/daemon task relative to other tasks in the system, although the\r
- * timers expiry time is relative to when xTimerStart() is actually called. The \r
- * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY \r
+ * timers expiry time is relative to when xTimerStart() is actually called. The\r
+ * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY\r
* configuration constant.\r
*\r
* Example usage:\r
- * \r
+ *\r
* See the xTimerCreate() API function example usage scenario.\r
*\r
*/\r
-#define xTimerStart( xTimer, xBlockTime ) xTimerGenericCommand( xTimer, tmrCOMMAND_START, xTaskGetTickCount(), NULL, xBlockTime )\r
+#define xTimerStart( xTimer, xBlockTime ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xBlockTime ) )\r
\r
/**\r
* portBASE_TYPE xTimerStop( xTimerHandle xTimer, portTickType xBlockTime );\r
*\r
* Timer functionality is provided by a timer service/daemon task. Many of the\r
- * public FreeRTOS timer API functions send commands to the timer service task \r
- * though a queue called the timer command queue. The timer command queue is \r
- * private to the kernel itself and is not directly accessible to application \r
- * code. The length of the timer command queue is set by the \r
+ * public FreeRTOS timer API functions send commands to the timer service task\r
+ * though a queue called the timer command queue. The timer command queue is\r
+ * private to the kernel itself and is not directly accessible to application\r
+ * code. The length of the timer command queue is set by the\r
* configTIMER_QUEUE_LENGTH configuration constant.\r
*\r
- * xTimerStop() stops a timer that was previously started using either of the \r
- * The xTimerStart(), xTimerReset(), xTimerStartFromISR(), xTimerResetFromISR(), \r
+ * xTimerStop() stops a timer that was previously started using either of the\r
+ * The xTimerStart(), xTimerReset(), xTimerStartFromISR(), xTimerResetFromISR(),\r
* xTimerChangePeriod() or xTimerChangePeriodFromISR() API functions.\r
*\r
* Stopping a timer ensures the timer is not in the active state.\r
*\r
* @param xBlockTime Specifies the time, in ticks, that the calling task should\r
* be held in the Blocked state to wait for the stop command to be successfully\r
- * sent to the timer command queue, should the queue already be full when \r
+ * sent to the timer command queue, should the queue already be full when\r
* xTimerStop() was called. xBlockTime is ignored if xTimerStop() is called\r
- * before the scheduler is started. \r
+ * before the scheduler is started.\r
*\r
- * @return pdFAIL will be returned if the stop command could not be sent to \r
+ * @return pdFAIL will be returned if the stop command could not be sent to\r
* the timer command queue even after xBlockTime ticks had passed. pdPASS will\r
- * be returned if the command was successfully send to the timer command queue.\r
+ * be returned if the command was successfully sent to the timer command queue.\r
* When the command is actually processed will depend on the priority of the\r
- * timer service/daemon task relative to other tasks in the system. The timer \r
- * service/daemon task priority is set by the configTIMER_TASK_PRIORITY \r
+ * timer service/daemon task relative to other tasks in the system. The timer\r
+ * service/daemon task priority is set by the configTIMER_TASK_PRIORITY\r
* configuration constant.\r
*\r
* Example usage:\r
- * \r
+ *\r
* See the xTimerCreate() API function example usage scenario.\r
*\r
*/\r
-#define xTimerStop( xTimer, xBlockTime ) xTimerGenericCommand( xTimer, tmrCOMMAND_STOP, 0, NULL, xBlockTime )\r
+#define xTimerStop( xTimer, xBlockTime ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0U, NULL, ( xBlockTime ) )\r
\r
/**\r
- * portBASE_TYPE xTimerChangePeriod( xTimerHandle xTimer, \r
+ * portBASE_TYPE xTimerChangePeriod( xTimerHandle xTimer,\r
* portTickType xNewPeriod,\r
* portTickType xBlockTime );\r
*\r
* Timer functionality is provided by a timer service/daemon task. Many of the\r
- * public FreeRTOS timer API functions send commands to the timer service task \r
- * though a queue called the timer command queue. The timer command queue is \r
- * private to the kernel itself and is not directly accessible to application \r
- * code. The length of the timer command queue is set by the \r
+ * public FreeRTOS timer API functions send commands to the timer service task\r
+ * though a queue called the timer command queue. The timer command queue is\r
+ * private to the kernel itself and is not directly accessible to application\r
+ * code. The length of the timer command queue is set by the\r
* configTIMER_QUEUE_LENGTH configuration constant.\r
*\r
- * xTimerChangePeriod() changes the period of a timer that was previously \r
+ * xTimerChangePeriod() changes the period of a timer that was previously\r
* created using the xTimerCreate() API function.\r
*\r
* xTimerChangePeriod() can be called to change the period of an active or\r
* dormant state timer.\r
*\r
- * The configUSE_TIMERS configuration constant must be set to 1 for \r
+ * The configUSE_TIMERS configuration constant must be set to 1 for\r
* xTimerChangePeriod() to be available.\r
*\r
* @param xTimer The handle of the timer that is having its period changed.\r
*\r
- * @param xNewPeriod The new period for xTimer. Timer periods are specified in \r
- * tick periods, so the constant portTICK_RATE_MS can be used to convert a time \r
- * that has been specified in milliseconds. For example, if the timer must \r
- * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively, \r
- * if the timer must expire after 500ms, then xNewPeriod can be set to \r
- * ( 500 / portTICK_RATE_MS ) provided configTICK_RATE_HZ is set to less than\r
+ * @param xNewPeriod The new period for xTimer. Timer periods are specified in\r
+ * tick periods, so the constant portTICK_RATE_MS can be used to convert a time\r
+ * that has been specified in milliseconds. For example, if the timer must\r
+ * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively,\r
+ * if the timer must expire after 500ms, then xNewPeriod can be set to\r
+ * ( 500 / portTICK_RATE_MS ) provided configTICK_RATE_HZ is less than\r
* or equal to 1000.\r
*\r
* @param xBlockTime Specifies the time, in ticks, that the calling task should\r
- * be held in the Blocked state to wait for the change period command to be \r
- * successfully sent to the timer command queue, should the queue already be \r
- * full when xTimerChangePeriod() was called. xBlockTime is ignored if \r
- * xTimerChangePeriod() is called before the scheduler is started. \r
- *\r
- * @return pdFAIL will be returned if the change period command could not be \r
- * sent to the timer command queue even after xBlockTime ticks had passed. \r
- * pdPASS will be returned if the command was successfully send to the timer \r
- * command queue. When the command is actually processed will depend on the \r
- * priority of the timer service/daemon task relative to other tasks in the \r
- * system. The timer service/daemon task priority is set by the \r
+ * be held in the Blocked state to wait for the change period command to be\r
+ * successfully sent to the timer command queue, should the queue already be\r
+ * full when xTimerChangePeriod() was called. xBlockTime is ignored if\r
+ * xTimerChangePeriod() is called before the scheduler is started.\r
+ *\r
+ * @return pdFAIL will be returned if the change period command could not be\r
+ * sent to the timer command queue even after xBlockTime ticks had passed.\r
+ * pdPASS will be returned if the command was successfully sent to the timer\r
+ * command queue. When the command is actually processed will depend on the\r
+ * priority of the timer service/daemon task relative to other tasks in the\r
+ * system. The timer service/daemon task priority is set by the\r
* configTIMER_TASK_PRIORITY configuration constant.\r
*\r
* Example usage:\r
*\r
* // This function assumes xTimer has already been created. If the timer\r
- * // referenced by xTimer is already active when it is called, then the timer \r
+ * // referenced by xTimer is already active when it is called, then the timer\r
* // is deleted. If the timer referenced by xTimer is not active when it is\r
* // called, then the period of the timer is set to 500ms and the timer is\r
* // started.\r
* void vAFunction( xTimerHandle xTimer )\r
* {\r
- * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer )" )\r
+ * if( xTimerIsTimerActive( xTimer ) != pdFALSE ) // or more simply and equivalently "if( xTimerIsTimerActive( xTimer ) )"\r
* {\r
* // xTimer is already active - delete it.\r
* xTimerDelete( xTimer );\r
* {\r
* // The command could not be sent, even after waiting for 100 ticks\r
* // to pass. Take appropriate action here.\r
- * {\r
- * } \r
+ * }\r
+ * }\r
* }\r
*/\r
- #define xTimerChangePeriod( xTimer, xNewPeriod, xBlockTime ) xTimerGenericCommand( xTimer, tmrCOMMAND_CHANGE_PERIOD, xNewPeriod, NULL, xBlockTime )\r
+ #define xTimerChangePeriod( xTimer, xNewPeriod, xBlockTime ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), NULL, ( xBlockTime ) )\r
\r
/**\r
* portBASE_TYPE xTimerDelete( xTimerHandle xTimer, portTickType xBlockTime );\r
*\r
* Timer functionality is provided by a timer service/daemon task. Many of the\r
- * public FreeRTOS timer API functions send commands to the timer service task \r
- * though a queue called the timer command queue. The timer command queue is \r
- * private to the kernel itself and is not directly accessible to application \r
- * code. The length of the timer command queue is set by the \r
+ * public FreeRTOS timer API functions send commands to the timer service task\r
+ * though a queue called the timer command queue. The timer command queue is\r
+ * private to the kernel itself and is not directly accessible to application\r
+ * code. The length of the timer command queue is set by the\r
* configTIMER_QUEUE_LENGTH configuration constant.\r
*\r
* xTimerDelete() deletes a timer that was previously created using the\r
* xTimerCreate() API function.\r
*\r
- * The configUSE_TIMERS configuration constant must be set to 1 for \r
+ * The configUSE_TIMERS configuration constant must be set to 1 for\r
* xTimerDelete() to be available.\r
*\r
- * @param xTimer The handle of the timer being stopped.\r
+ * @param xTimer The handle of the timer being deleted.\r
*\r
* @param xBlockTime Specifies the time, in ticks, that the calling task should\r
- * be held in the Blocked state to wait for the delete command to be \r
- * successfully sent to the timer command queue, should the queue already be \r
- * full when xTimerDelete() was called. xBlockTime is ignored if xTimerDelete() \r
- * is called before the scheduler is started. \r
+ * be held in the Blocked state to wait for the delete command to be\r
+ * successfully sent to the timer command queue, should the queue already be\r
+ * full when xTimerDelete() was called. xBlockTime is ignored if xTimerDelete()\r
+ * is called before the scheduler is started.\r
*\r
- * @return pdFAIL will be returned if the delete command could not be sent to \r
+ * @return pdFAIL will be returned if the delete command could not be sent to\r
* the timer command queue even after xBlockTime ticks had passed. pdPASS will\r
- * be returned if the command was successfully send to the timer command queue.\r
+ * be returned if the command was successfully sent to the timer command queue.\r
* When the command is actually processed will depend on the priority of the\r
- * timer service/daemon task relative to other tasks in the system. The timer \r
- * service/daemon task priority is set by the configTIMER_TASK_PRIORITY \r
+ * timer service/daemon task relative to other tasks in the system. The timer\r
+ * service/daemon task priority is set by the configTIMER_TASK_PRIORITY\r
* configuration constant.\r
*\r
* Example usage:\r
- * \r
+ *\r
* See the xTimerChangePeriod() API function example usage scenario.\r
*/\r
-#define xTimerDelete( xTimer, xBlockTime ) xTimerGenericCommand( xTimer, tmrCOMMAND_DELETE, 0, NULL, xBlockTime )\r
+#define xTimerDelete( xTimer, xBlockTime ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_DELETE, 0U, NULL, ( xBlockTime ) )\r
\r
/**\r
* portBASE_TYPE xTimerReset( xTimerHandle xTimer, portTickType xBlockTime );\r
*\r
* Timer functionality is provided by a timer service/daemon task. Many of the\r
- * public FreeRTOS timer API functions send commands to the timer service task \r
- * though a queue called the timer command queue. The timer command queue is \r
- * private to the kernel itself and is not directly accessible to application \r
- * code. The length of the timer command queue is set by the \r
+ * public FreeRTOS timer API functions send commands to the timer service task\r
+ * though a queue called the timer command queue. The timer command queue is\r
+ * private to the kernel itself and is not directly accessible to application\r
+ * code. The length of the timer command queue is set by the\r
* configTIMER_QUEUE_LENGTH configuration constant.\r
*\r
- * xTimerReset() re-starts a timer that was previously created using the \r
+ * xTimerReset() re-starts a timer that was previously created using the\r
* xTimerCreate() API function. If the timer had already been started and was\r
* already in the active state, then xTimerReset() will cause the timer to\r
* re-evaluate its expiry time so that it is relative to when xTimerReset() was\r
- * called. If the timer was in the dormant state then xTimerReset() has \r
+ * called. If the timer was in the dormant state then xTimerReset() has\r
* equivalent functionality to the xTimerStart() API function.\r
*\r
* Resetting a timer ensures the timer is in the active state. If the timer\r
* is not stopped, deleted, or reset in the mean time, the callback function\r
- * associated with the timer will get called 'n 'ticks after xTimerReset() was \r
+ * associated with the timer will get called 'n' ticks after xTimerReset() was\r
* called, where 'n' is the timers defined period.\r
*\r
* It is valid to call xTimerReset() before the scheduler has been started, but\r
* The configUSE_TIMERS configuration constant must be set to 1 for xTimerReset()\r
* to be available.\r
*\r
- * @param xTimer The handle of the timer being started/restarted.\r
+ * @param xTimer The handle of the timer being reset/started/restarted.\r
*\r
* @param xBlockTime Specifies the time, in ticks, that the calling task should\r
* be held in the Blocked state to wait for the reset command to be successfully\r
- * sent to the timer command queue, should the queue already be full when \r
+ * sent to the timer command queue, should the queue already be full when\r
* xTimerReset() was called. xBlockTime is ignored if xTimerReset() is called\r
- * before the scheduler is started. \r
+ * before the scheduler is started.\r
*\r
- * @return pdFAIL will be returned if the reset command could not be sent to \r
+ * @return pdFAIL will be returned if the reset command could not be sent to\r
* the timer command queue even after xBlockTime ticks had passed. pdPASS will\r
- * be returned if the command was successfully send to the timer command queue.\r
+ * be returned if the command was successfully sent to the timer command queue.\r
* When the command is actually processed will depend on the priority of the\r
* timer service/daemon task relative to other tasks in the system, although the\r
- * timers expiry time is relative to when xTimerStart() is actually called. The \r
- * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY \r
+ * timers expiry time is relative to when xTimerStart() is actually called. The\r
+ * timer service/daemon task priority is set by the configTIMER_TASK_PRIORITY\r
* configuration constant.\r
*\r
* Example usage:\r
- * \r
- * // When a key is pressed, an LCD back-light is switched on. If 5 seconds pass \r
- * // without a key being pressed, then the LCD back-light is switched off. In \r
+ *\r
+ * // When a key is pressed, an LCD back-light is switched on. If 5 seconds pass\r
+ * // without a key being pressed, then the LCD back-light is switched off. In\r
* // this case, the timer is a one-shot timer.\r
*\r
* xTimerHandle xBacklightTimer = NULL;\r
*\r
* // The callback function assigned to the one-shot timer. In this case the\r
* // parameter is not used.\r
- * void vBacklightTimerCallback( xTIMER *pxTimer )\r
+ * void vBacklightTimerCallback( xTimerHandle pxTimer )\r
* {\r
* // The timer expired, therefore 5 seconds must have passed since a key\r
* // was pressed. Switch off the LCD back-light.\r
* void vKeyPressEventHandler( char cKey )\r
* {\r
* // Ensure the LCD back-light is on, then reset the timer that is\r
- * // responsible for turning the back-light off after 5 seconds of \r
+ * // responsible for turning the back-light off after 5 seconds of\r
* // key inactivity. Wait 10 ticks for the command to be successfully sent\r
* // if it cannot be sent immediately.\r
* vSetBacklightState( BACKLIGHT_ON );\r
* void main( void )\r
* {\r
* long x;\r
- * \r
+ *\r
* // Create then start the one-shot timer that is responsible for turning\r
* // the back-light off if no keys are pressed within a 5 second period.\r
* xBacklightTimer = xTimerCreate( "BacklightTimer", // Just a text name, not used by the kernel.\r
* 0, // The id is not used by the callback so can take any value.\r
* vBacklightTimerCallback // The callback function that switches the LCD back-light off.\r
* );\r
- * \r
+ *\r
* if( xBacklightTimer == NULL )\r
* {\r
* // The timer was not created.\r
* {\r
* // Start the timer. No block time is specified, and even if one was\r
* // it would be ignored because the scheduler has not yet been\r
- * // started. \r
+ * // started.\r
* if( xTimerStart( xBacklightTimer, 0 ) != pdPASS )\r
* {\r
* // The timer could not be set into the Active state.\r
* }\r
* }\r
- * \r
+ *\r
* // ...\r
* // Create tasks here.\r
* // ...\r
- * \r
+ *\r
* // Starting the scheduler will start the timer running as it has already\r
* // been set into the active state.\r
* xTaskStartScheduler();\r
- * \r
+ *\r
* // Should not reach here.\r
* for( ;; );\r
* }\r
*/\r
-#define xTimerReset( xTimer, xBlockTime ) xTimerGenericCommand( xTimer, tmrCOMMAND_START, xTaskGetTickCount(), NULL, xBlockTime )\r
+#define xTimerReset( xTimer, xBlockTime ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCount() ), NULL, ( xBlockTime ) )\r
\r
/**\r
- * portBASE_TYPE xTimerStartFromISR( xTimerHandle xTimer, \r
+ * portBASE_TYPE xTimerStartFromISR( xTimerHandle xTimer,\r
* portBASE_TYPE *pxHigherPriorityTaskWoken );\r
*\r
* A version of xTimerStart() that can be called from an interrupt service\r
* xTimerStartFromISR() sets this value to pdTRUE then a context switch should\r
* be performed before the interrupt exits.\r
*\r
- * @return pdFAIL will be returned if the start command could not be sent to \r
- * the timer command queue. pdPASS will be returned if the command was \r
- * successfully send to the timer command queue. When the command is actually \r
- * processed will depend on the priority of the timer service/daemon task \r
- * relative to other tasks in the system, although the timers expiry time is \r
- * relative to when xTimerStart() is actually called. The timer service/daemon \r
- * task priority is set by the configTIMER_TASK_PRIORITY configuration constant. \r
+ * @return pdFAIL will be returned if the start command could not be sent to\r
+ * the timer command queue. pdPASS will be returned if the command was\r
+ * successfully sent to the timer command queue. When the command is actually\r
+ * processed will depend on the priority of the timer service/daemon task\r
+ * relative to other tasks in the system, although the timers expiry time is\r
+ * relative to when xTimerStartFromISR() is actually called. The timer service/daemon\r
+ * task priority is set by the configTIMER_TASK_PRIORITY configuration constant.\r
*\r
* Example usage:\r
- * \r
- * // This scenario assumes xBacklightTimer has already been created. When a \r
- * // key is pressed, an LCD back-light is switched on. If 5 seconds pass \r
- * // without a key being pressed, then the LCD back-light is switched off. In \r
- * // this case, the timer is a one-shot timer, and unlike the example given for \r
+ *\r
+ * // This scenario assumes xBacklightTimer has already been created. When a\r
+ * // key is pressed, an LCD back-light is switched on. If 5 seconds pass\r
+ * // without a key being pressed, then the LCD back-light is switched off. In\r
+ * // this case, the timer is a one-shot timer, and unlike the example given for\r
* // the xTimerReset() function, the key press event handler is an interrupt\r
* // service routine.\r
*\r
* // The callback function assigned to the one-shot timer. In this case the\r
* // parameter is not used.\r
- * void vBacklightTimerCallback( xTIMER *pxTimer )\r
+ * void vBacklightTimerCallback( xTimerHandle pxTimer )\r
* {\r
* // The timer expired, therefore 5 seconds must have passed since a key\r
* // was pressed. Switch off the LCD back-light.\r
* portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
*\r
* // Ensure the LCD back-light is on, then restart the timer that is\r
- * // responsible for turning the back-light off after 5 seconds of \r
+ * // responsible for turning the back-light off after 5 seconds of\r
* // key inactivity. This is an interrupt service routine so can only\r
* // call FreeRTOS API functions that end in "FromISR".\r
* vSetBacklightState( BACKLIGHT_ON );\r
* }\r
* }\r
*/\r
-#define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( xTimer, tmrCOMMAND_START, xTaskGetTickCountFromISR(), pxHigherPriorityTaskWoken, 0 )\r
+#define xTimerStartFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )\r
\r
/**\r
- * portBASE_TYPE xTimerStopFromISR( xTimerHandle xTimer, \r
+ * portBASE_TYPE xTimerStopFromISR( xTimerHandle xTimer,\r
* portBASE_TYPE *pxHigherPriorityTaskWoken );\r
*\r
* A version of xTimerStop() that can be called from an interrupt service\r
* xTimerStopFromISR() sets this value to pdTRUE then a context switch should\r
* be performed before the interrupt exits.\r
*\r
- * @return pdFAIL will be returned if the stop command could not be sent to \r
- * the timer command queue. pdPASS will be returned if the command was \r
- * successfully send to the timer command queue. When the command is actually \r
- * processed will depend on the priority of the timer service/daemon task \r
- * relative to other tasks in the system. The timer service/daemon task \r
- * priority is set by the configTIMER_TASK_PRIORITY configuration constant. \r
+ * @return pdFAIL will be returned if the stop command could not be sent to\r
+ * the timer command queue. pdPASS will be returned if the command was\r
+ * successfully sent to the timer command queue. When the command is actually\r
+ * processed will depend on the priority of the timer service/daemon task\r
+ * relative to other tasks in the system. The timer service/daemon task\r
+ * priority is set by the configTIMER_TASK_PRIORITY configuration constant.\r
*\r
* Example usage:\r
*\r
* }\r
* }\r
*/\r
-#define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( xTimer, tmrCOMMAND_STOP, 0, pxHigherPriorityTaskWoken, 0 )\r
+#define xTimerStopFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_STOP, 0, ( pxHigherPriorityTaskWoken ), 0U )\r
\r
/**\r
- * portBASE_TYPE xTimerChangePeriodFromISR( xTimerHandle xTimer, \r
+ * portBASE_TYPE xTimerChangePeriodFromISR( xTimerHandle xTimer,\r
* portTickType xNewPeriod,\r
* portBASE_TYPE *pxHigherPriorityTaskWoken );\r
*\r
- * A version of xTimerChangePeriod() that can be called from an interrupt \r
+ * A version of xTimerChangePeriod() that can be called from an interrupt\r
* service routine.\r
*\r
* @param xTimer The handle of the timer that is having its period changed.\r
*\r
+ * @param xNewPeriod The new period for xTimer. Timer periods are specified in\r
+ * tick periods, so the constant portTICK_RATE_MS can be used to convert a time\r
+ * that has been specified in milliseconds. For example, if the timer must\r
+ * expire after 100 ticks, then xNewPeriod should be set to 100. Alternatively,\r
+ * if the timer must expire after 500ms, then xNewPeriod can be set to\r
+ * ( 500 / portTICK_RATE_MS ) provided configTICK_RATE_HZ is less than\r
+ * or equal to 1000.\r
+ *\r
* @param pxHigherPriorityTaskWoken The timer service/daemon task spends most\r
* of its time in the Blocked state, waiting for messages to arrive on the timer\r
- * command queue. Calling xTimerChangePeriodFromISR() writes a message to the \r
+ * command queue. Calling xTimerChangePeriodFromISR() writes a message to the\r
* timer command queue, so has the potential to transition the timer service/\r
- * daemon task out of the Blocked state. If calling xTimerChangePeriodFromISR() \r
- * causes the timer service/daemon task to leave the Blocked state, and the \r
- * timer service/daemon task has a priority equal to or greater than the \r
- * currently executing task (the task that was interrupted), then \r
- * *pxHigherPriorityTaskWoken will get set to pdTRUE internally within the \r
- * xTimerChangePeriodFromISR() function. If xTimerChangePeriodFromISR() sets \r
- * this value to pdTRUE then a context switch should be performed before the \r
+ * daemon task out of the Blocked state. If calling xTimerChangePeriodFromISR()\r
+ * causes the timer service/daemon task to leave the Blocked state, and the\r
+ * timer service/daemon task has a priority equal to or greater than the\r
+ * currently executing task (the task that was interrupted), then\r
+ * *pxHigherPriorityTaskWoken will get set to pdTRUE internally within the\r
+ * xTimerChangePeriodFromISR() function. If xTimerChangePeriodFromISR() sets\r
+ * this value to pdTRUE then a context switch should be performed before the\r
* interrupt exits.\r
*\r
* @return pdFAIL will be returned if the command to change the timers period\r
- * could not be sent to the timer command queue. pdPASS will be returned if the \r
- * command was successfully send to the timer command queue. When the command \r
- * is actually processed will depend on the priority of the timer service/daemon \r
- * task relative to other tasks in the system. The timer service/daemon task \r
- * priority is set by the configTIMER_TASK_PRIORITY configuration constant. \r
+ * could not be sent to the timer command queue. pdPASS will be returned if the\r
+ * command was successfully sent to the timer command queue. When the command\r
+ * is actually processed will depend on the priority of the timer service/daemon\r
+ * task relative to other tasks in the system. The timer service/daemon task\r
+ * priority is set by the configTIMER_TASK_PRIORITY configuration constant.\r
*\r
* Example usage:\r
*\r
* // FreeRTOS API functions that end in "FromISR" can be used.\r
* if( xTimerChangePeriodFromISR( xTimer, &xHigherPriorityTaskWoken ) != pdPASS )\r
* {\r
- * // The command to change the timers period was not executed \r
+ * // The command to change the timers period was not executed\r
* // successfully. Take appropriate action here.\r
* }\r
*\r
* }\r
* }\r
*/\r
-#define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( xTimer, tmrCOMMAND_CHANGE_PERIOD, xNewPeriod, pxHigherPriorityTaskWoken, 0 )\r
+#define xTimerChangePeriodFromISR( xTimer, xNewPeriod, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_CHANGE_PERIOD, ( xNewPeriod ), ( pxHigherPriorityTaskWoken ), 0U )\r
\r
/**\r
- * portBASE_TYPE xTimerResetFromISR( xTimerHandle xTimer, \r
+ * portBASE_TYPE xTimerResetFromISR( xTimerHandle xTimer,\r
* portBASE_TYPE *pxHigherPriorityTaskWoken );\r
*\r
* A version of xTimerReset() that can be called from an interrupt service\r
* xTimerResetFromISR() sets this value to pdTRUE then a context switch should\r
* be performed before the interrupt exits.\r
*\r
- * @return pdFAIL will be returned if the reset command could not be sent to \r
- * the timer command queue. pdPASS will be returned if the command was \r
- * successfully send to the timer command queue. When the command is actually \r
- * processed will depend on the priority of the timer service/daemon task \r
- * relative to other tasks in the system, although the timers expiry time is \r
- * relative to when xTimerStart() is actually called. The timer service/daemon \r
- * task priority is set by the configTIMER_TASK_PRIORITY configuration constant. \r
+ * @return pdFAIL will be returned if the reset command could not be sent to\r
+ * the timer command queue. pdPASS will be returned if the command was\r
+ * successfully sent to the timer command queue. When the command is actually\r
+ * processed will depend on the priority of the timer service/daemon task\r
+ * relative to other tasks in the system, although the timers expiry time is\r
+ * relative to when xTimerResetFromISR() is actually called. The timer service/daemon\r
+ * task priority is set by the configTIMER_TASK_PRIORITY configuration constant.\r
*\r
* Example usage:\r
- * \r
- * // This scenario assumes xBacklightTimer has already been created. When a \r
- * // key is pressed, an LCD back-light is switched on. If 5 seconds pass \r
- * // without a key being pressed, then the LCD back-light is switched off. In \r
- * // this case, the timer is a one-shot timer, and unlike the example given for \r
+ *\r
+ * // This scenario assumes xBacklightTimer has already been created. When a\r
+ * // key is pressed, an LCD back-light is switched on. If 5 seconds pass\r
+ * // without a key being pressed, then the LCD back-light is switched off. In\r
+ * // this case, the timer is a one-shot timer, and unlike the example given for\r
* // the xTimerReset() function, the key press event handler is an interrupt\r
* // service routine.\r
*\r
* // The callback function assigned to the one-shot timer. In this case the\r
* // parameter is not used.\r
- * void vBacklightTimerCallback( xTIMER *pxTimer )\r
+ * void vBacklightTimerCallback( xTimerHandle pxTimer )\r
* {\r
* // The timer expired, therefore 5 seconds must have passed since a key\r
* // was pressed. Switch off the LCD back-light.\r
* portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;\r
*\r
* // Ensure the LCD back-light is on, then reset the timer that is\r
- * // responsible for turning the back-light off after 5 seconds of \r
+ * // responsible for turning the back-light off after 5 seconds of\r
* // key inactivity. This is an interrupt service routine so can only\r
* // call FreeRTOS API functions that end in "FromISR".\r
* vSetBacklightState( BACKLIGHT_ON );\r
* }\r
* }\r
*/\r
-#define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( xTimer, tmrCOMMAND_START, xTaskGetTickCountFromISR(), pxHigherPriorityTaskWoken, 0 )\r
+#define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )\r
\r
/*\r
* Functions beyond this part are not part of the public API and are intended\r
* for use by the kernel only.\r
*/\r
portBASE_TYPE xTimerCreateTimerTask( void ) PRIVILEGED_FUNCTION;\r
-portBASE_TYPE xTimerGenericCommand( xTimerHandle xTimer, portBASE_TYPE xCommandID, portTickType xOptionalValue, portBASE_TYPE *pxHigherPriorityTaskWoken, portTickType xBlockTime ) PRIVILEGED_FUNCTION;\r
+portBASE_TYPE xTimerGenericCommand( xTimerHandle xTimer, portBASE_TYPE xCommandID, portTickType xOptionalValue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portTickType xBlockTime ) PRIVILEGED_FUNCTION;\r
\r
#ifdef __cplusplus\r
}\r