/*\r
- FreeRTOS V8.2.0rc1 - Copyright (C) 2014 Real Time Engineers Ltd.\r
+ FreeRTOS V8.2.3 - Copyright (C) 2015 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
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
+ Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.\r
\r
+ ***************************************************************************\r
>>! NOTE: The modification to the GPL is included to allow you to !<<\r
>>! distribute a combined work that includes FreeRTOS without being !<<\r
>>! obliged to provide the source code for proprietary components !<<\r
>>! outside of the FreeRTOS kernel. !<<\r
+ ***************************************************************************\r
\r
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
FOR A PARTICULAR PURPOSE. Full license text is available on the following\r
link: http://www.freertos.org/a00114.html\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?". Have you defined configASSERT()? *\r
- * *\r
- * http://www.FreeRTOS.org/FAQHelp.html *\r
- * *\r
- ***************************************************************************\r
-\r
***************************************************************************\r
* *\r
* FreeRTOS provides completely free yet professionally developed, *\r
* *\r
***************************************************************************\r
\r
- ***************************************************************************\r
- * *\r
- * Investing in training allows your team to be as productive as *\r
- * possible as early as possible, lowering your overall development *\r
- * cost, and enabling you to bring a more robust product to market *\r
- * earlier than would otherwise be possible. Richard Barry is both *\r
- * the architect and key author of FreeRTOS, and so also the world's *\r
- * leading authority on what is the world's most popular real time *\r
- * kernel for deeply embedded MCU designs. Obtaining your training *\r
- * from Richard ensures your team will gain directly from his in-depth *\r
- * product knowledge and years of usage experience. Contact Real Time *\r
- * Engineers Ltd to enquire about the FreeRTOS Masterclass, presented *\r
- * by Richard Barry: http://www.FreeRTOS.org/contact\r
- * *\r
- ***************************************************************************\r
+ http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading\r
+ the FAQ page "My application does not run, what could be wrong?". Have you\r
+ defined configASSERT()?\r
\r
- ***************************************************************************\r
- * *\r
- * You are receiving this top quality software for free. Please play *\r
- * fair and reciprocate by reporting any suspected issues and *\r
- * participating in the community forum: *\r
- * http://www.FreeRTOS.org/support *\r
- * *\r
- * Thank you! *\r
- * *\r
- ***************************************************************************\r
+ http://www.FreeRTOS.org/support - In return for receiving this top quality\r
+ embedded software for free we request you assist our global community by\r
+ participating in the support forum.\r
\r
- http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
- license and Real Time Engineers Ltd. contact details.\r
+ http://www.FreeRTOS.org/training - Investing in training allows your team to\r
+ be as productive as possible as early as possible. Now you can receive\r
+ FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
+ Ltd, and the world's leading authority on the world's leading RTOS.\r
\r
http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
\r
- http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+ http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS\r
licenses offer ticketed support, indemnification and commercial middleware.\r
\r
\r
/*-----------------------------------------------------------*/\r
\r
+#if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+\r
+ /* If static allocation is supported then the application must provide the\r
+ following callback function - which enables the application to optionally\r
+ provide the memory that will be used by the timer task as the task's stack\r
+ and TCB. */\r
+ extern void vApplicationGetTimerTaskMemory( DummyTCB_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint16_t *pusTimerTaskStackSize );\r
+\r
+#endif\r
+\r
/*\r
* Initialise the infrastructure used by the timer service task if it has not\r
* been initialised already.\r
* Called by the timer service task to interpret and process a command it\r
* received on the timer queue.\r
*/\r
-static void prvProcessReceivedCommands( void ) PRIVILEGED_FUNCTION;\r
+static void prvProcessReceivedCommands( void ) PRIVILEGED_FUNCTION;\r
\r
/*\r
* Insert the timer into either xActiveTimerList1, or xActiveTimerList2,\r
* If a timer has expired, process it. Otherwise, block the timer service task\r
* until either a timer does expire or a command is received.\r
*/\r
-static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, const BaseType_t xListWasEmpty ) PRIVILEGED_FUNCTION;\r
+static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, BaseType_t xListWasEmpty ) PRIVILEGED_FUNCTION;\r
\r
/*-----------------------------------------------------------*/\r
\r
BaseType_t xTimerCreateTimerTask( void )\r
{\r
BaseType_t xReturn = pdFAIL;\r
+DummyTCB_t *pxTimerTaskTCBBuffer = NULL;\r
+StackType_t *pxTimerTaskStackBuffer = NULL;\r
+uint16_t usTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;\r
+\r
\r
/* This function is called when the scheduler is started if\r
configUSE_TIMERS is set to 1. Check that the infrastructure used by the\r
\r
if( xTimerQueue != NULL )\r
{\r
+\r
+ #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
+ {\r
+ vApplicationGetTimerTaskMemory( &pxTimerTaskTCBBuffer, &pxTimerTaskStackBuffer, &usTimerTaskStackSize );\r
+ }\r
+ #endif /* configSUPPORT_STATIC_ALLOCATION */\r
+\r
+\r
#if ( INCLUDE_xTimerGetTimerDaemonTaskHandle == 1 )\r
{\r
/* Create the timer task, storing its handle in xTimerTaskHandle so\r
it can be returned by the xTimerGetTimerDaemonTaskHandle() function. */\r
- xReturn = xTaskCreate( prvTimerTask, "Tmr Svc", ( uint16_t ) configTIMER_TASK_STACK_DEPTH, NULL, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, &xTimerTaskHandle );\r
+ xReturn = xTaskGenericCreate( prvTimerTask, "Tmr Svc", usTimerTaskStackSize, NULL, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, &xTimerTaskHandle, pxTimerTaskStackBuffer, pxTimerTaskTCBBuffer, NULL );\r
}\r
#else\r
{\r
/* Create the timer task without storing its handle. */\r
- xReturn = xTaskCreate( prvTimerTask, "Tmr Svc", ( uint16_t ) configTIMER_TASK_STACK_DEPTH, NULL, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, NULL);\r
+ xReturn = xTaskGenericCreate( prvTimerTask, "Tmr Svc", usTimerTaskStackSize, NULL, ( ( UBaseType_t ) configTIMER_TASK_PRIORITY ) | portPRIVILEGE_BIT, NULL, pxTimerTaskStackBuffer, pxTimerTaskTCBBuffer, NULL );\r
}\r
#endif\r
}\r
BaseType_t xReturn = pdFAIL;\r
DaemonTaskMessage_t xMessage;\r
\r
+ configASSERT( xTimer );\r
+\r
/* Send a message to the timer service task to perform a particular action\r
on a particular timer definition. */\r
if( xTimerQueue != NULL )\r
{\r
Timer_t *pxTimer = ( Timer_t * ) xTimer;\r
\r
+ configASSERT( xTimer );\r
return pxTimer->pcTimerName;\r
}\r
/*-----------------------------------------------------------*/\r
}\r
/*-----------------------------------------------------------*/\r
\r
-static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, const BaseType_t xListWasEmpty )\r
+static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, BaseType_t xListWasEmpty )\r
{\r
TickType_t xTimeNow;\r
BaseType_t xTimerListsWereSwitched;\r
received - whichever comes first. The following line cannot\r
be reached unless xNextExpireTime > xTimeNow, except in the\r
case when the current timer list is empty. */\r
- vQueueWaitForMessageRestricted( xTimerQueue, ( xNextExpireTime - xTimeNow ) );\r
+ if( xListWasEmpty != pdFALSE )\r
+ {\r
+ /* The current timer list is empty - is the overflow list\r
+ also empty? */\r
+ xListWasEmpty = listLIST_IS_EMPTY( pxOverflowTimerList );\r
+ }\r
+\r
+ vQueueWaitForMessageRestricted( xTimerQueue, ( xNextExpireTime - xTimeNow ), xListWasEmpty );\r
\r
if( xTaskResumeAll() == pdFALSE )\r
{\r
BaseType_t xTimerIsInActiveList;\r
Timer_t *pxTimer = ( Timer_t * ) xTimer;\r
\r
+ configASSERT( xTimer );\r
+\r
/* Is the timer in the list of active timers? */\r
taskENTER_CRITICAL();\r
{\r
\r
void *pvTimerGetTimerID( const TimerHandle_t xTimer )\r
{\r
+Timer_t * const pxTimer = ( Timer_t * ) xTimer;\r
+void *pvReturn;\r
+\r
+ configASSERT( xTimer );\r
+\r
+ taskENTER_CRITICAL();\r
+ {\r
+ pvReturn = pxTimer->pvTimerID;\r
+ }\r
+ taskEXIT_CRITICAL();\r
+\r
+ return pvReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vTimerSetTimerID( TimerHandle_t xTimer, void *pvNewID )\r
+{\r
Timer_t * const pxTimer = ( Timer_t * ) xTimer;\r
\r
- return pxTimer->pvTimerID;\r
+ configASSERT( xTimer );\r
+\r
+ taskENTER_CRITICAL();\r
+ {\r
+ pxTimer->pvTimerID = pvNewID;\r
+ }\r
+ taskEXIT_CRITICAL();\r
}\r
/*-----------------------------------------------------------*/\r
\r
DaemonTaskMessage_t xMessage;\r
BaseType_t xReturn;\r
\r
+ /* This function can only be called after a timer has been created or\r
+ after the scheduler has been started because, until then, the timer\r
+ queue does not exist. */\r
+ configASSERT( xTimerQueue );\r
+\r
/* Complete the message with the function parameters and post it to the\r
daemon task. */\r
xMessage.xMessageID = tmrCOMMAND_EXECUTE_CALLBACK;\r