/*\r
- FreeRTOS V7.6.0 - Copyright (C) 2013 Real Time Engineers Ltd.\r
+ FreeRTOS V8.0.0 - Copyright (C) 2014 Real Time Engineers Ltd.\r
All rights reserved\r
\r
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
#include "queue.h"\r
#include "timers.h"\r
\r
-#if ( INCLUDE_xTimerPendCallbackFromISR == 1 ) && ( configUSE_TIMERS == 0 )\r
- #error configUSE_TIMERS must be set to 1 to make the INCLUDE_xTimerPendCallbackFromISR() function available.\r
+#if ( INCLUDE_xTimerPendFunctionCall == 1 ) && ( configUSE_TIMERS == 0 )\r
+ #error configUSE_TIMERS must be set to 1 to make the xTimerPendFunctionCall() function available.\r
#endif\r
\r
/* Lint e961 and e750 are suppressed as a MISRA exception justified because the\r
/* The definition of the timers themselves. */\r
typedef struct tmrTimerControl\r
{\r
- const char *pcTimerName; /*<< Text name. This is not used by the kernel, it is included simply to make debugging easier. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
- ListItem_t xTimerListItem; /*<< Standard linked list item as used by all kernel features for event management. */\r
- TickType_t xTimerPeriodInTicks;/*<< How quickly and often the timer expires. */\r
- UBaseType_t uxAutoReload; /*<< Set to pdTRUE if the timer should be automatically restarted once expired. Set to pdFALSE if the timer is, in effect, a one-shot timer. */\r
- void *pvTimerID; /*<< An ID to identify the timer. This allows the timer to be identified when the same callback is used for multiple timers. */\r
- tmrTIMER_CALLBACK pxCallbackFunction; /*<< The function that will be called when the timer expires. */\r
-} Timer_t;\r
+ const char *pcTimerName; /*<< Text name. This is not used by the kernel, it is included simply to make debugging easier. */ /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+ ListItem_t xTimerListItem; /*<< Standard linked list item as used by all kernel features for event management. */\r
+ TickType_t xTimerPeriodInTicks;/*<< How quickly and often the timer expires. */\r
+ UBaseType_t uxAutoReload; /*<< Set to pdTRUE if the timer should be automatically restarted once expired. Set to pdFALSE if the timer is, in effect, a one-shot timer. */\r
+ void *pvTimerID; /*<< An ID to identify the timer. This allows the timer to be identified when the same callback is used for multiple timers. */\r
+ TimerCallbackFunction_t pxCallbackFunction; /*<< The function that will be called when the timer expires. */\r
+ #if( configUSE_TRACE_FACILITY == 1 )\r
+ UBaseType_t uxTimerNumber; /*<< An ID assigned by trace tools such as FreeRTOS+Trace */\r
+ #endif\r
+} xTIMER;\r
+\r
+/* The old xTIMER name is maintained above then typedefed to the new Timer_t\r
+name below to enable the use of older kernel aware debuggers. */\r
+typedef xTIMER Timer_t;\r
\r
/* The definition of messages that can be sent and received on the timer queue.\r
Two types of message can be queued - messages that manipulate a software timer,\r
\r
typedef struct tmrCallbackParameters\r
{\r
- pdAPPLICATION_CALLBACK_CODE pxCallbackFunction; /* << The callback function to execute. */\r
- void *pvParameter1; /* << The value that will be used as the callback functions first parameter. */\r
- uint32_t ulParameter2; /* << The value that will be used as the callback functions second parameter. */\r
+ PendedFunction_t pxCallbackFunction; /* << The callback function to execute. */\r
+ void *pvParameter1; /* << The value that will be used as the callback functions first parameter. */\r
+ uint32_t ulParameter2; /* << The value that will be used as the callback functions second parameter. */\r
} CallbackParameters_t;\r
\r
/* The structure that contains the two message types, along with an identifier\r
\r
/* Don't include xCallbackParameters if it is not going to be used as\r
it makes the structure (and therefore the timer queue) larger. */\r
- #if ( INCLUDE_xTimerPendCallbackFromISR == 1 )\r
+ #if ( INCLUDE_xTimerPendFunctionCall == 1 )\r
CallbackParameters_t xCallbackParameters;\r
- #endif /* INCLUDE_xTimerPendCallbackFromISR */\r
+ #endif /* INCLUDE_xTimerPendFunctionCall */\r
} u;\r
} DaemonTaskMessage_t;\r
\r
}\r
/*-----------------------------------------------------------*/\r
\r
-TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, tmrTIMER_CALLBACK pxCallbackFunction ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+TimerHandle_t xTimerCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
{\r
Timer_t *pxNewTimer;\r
\r
}\r
/*-----------------------------------------------------------*/\r
\r
-BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xBlockTime )\r
+BaseType_t xTimerGenericCommand( TimerHandle_t xTimer, const BaseType_t xCommandID, const TickType_t xOptionalValue, BaseType_t * const pxHigherPriorityTaskWoken, const TickType_t xTicksToWait )\r
{\r
BaseType_t xReturn = pdFAIL;\r
DaemonTaskMessage_t xMessage;\r
xMessage.u.xTimerParameters.xMessageValue = xOptionalValue;\r
xMessage.u.xTimerParameters.pxTimer = ( Timer_t * ) xTimer;\r
\r
- if( pxHigherPriorityTaskWoken == NULL )\r
+ if( xCommandID < tmrFIRST_FROM_ISR_COMMAND )\r
{\r
if( xTaskGetSchedulerState() == taskSCHEDULER_RUNNING )\r
{\r
- xReturn = xQueueSendToBack( xTimerQueue, &xMessage, xBlockTime );\r
+ xReturn = xQueueSendToBack( xTimerQueue, &xMessage, xTicksToWait );\r
}\r
else\r
{\r
{\r
/* The timer expired before it was added to the active timer\r
list. Reload it now. */\r
- xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xNextExpireTime, NULL, tmrNO_DELAY );\r
+ xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START_DONT_TRACE, xNextExpireTime, NULL, tmrNO_DELAY );\r
configASSERT( xResult );\r
( void ) xResult;\r
}\r
\r
while( xQueueReceive( xTimerQueue, &xMessage, tmrNO_DELAY ) != pdFAIL ) /*lint !e603 xMessage does not have to be initialised as it is passed out, not in, and it is not used unless xQueueReceive() returns pdTRUE. */\r
{\r
- #if ( INCLUDE_xTimerPendCallbackFromISR == 1 )\r
+ #if ( INCLUDE_xTimerPendFunctionCall == 1 )\r
{\r
- if( xMessage.xMessageID == tmrCOMMAND_EXECUTE_CALLBACK )\r
+ /* Negative commands are pended function calls rather than timer\r
+ commands. */\r
+ if( xMessage.xMessageID < 0 )\r
{\r
const CallbackParameters_t * const pxCallback = &( xMessage.u.xCallbackParameters );\r
\r
mtCOVERAGE_TEST_MARKER();\r
}\r
}\r
- #endif /* INCLUDE_xTimerPendCallbackFromISR */\r
+ #endif /* INCLUDE_xTimerPendFunctionCall */\r
\r
- if( xMessage.xMessageID != tmrCOMMAND_EXECUTE_CALLBACK )\r
+ /* Commands that are positive are timer commands rather than pended\r
+ function calls. */\r
+ if( xMessage.xMessageID >= ( BaseType_t ) 0 )\r
{\r
/* The messages uses the xTimerParameters member to work on a\r
software timer. */\r
switch( xMessage.xMessageID )\r
{\r
case tmrCOMMAND_START :\r
+ case tmrCOMMAND_START_FROM_ISR :\r
+ case tmrCOMMAND_RESET :\r
+ case tmrCOMMAND_RESET_FROM_ISR :\r
+ case tmrCOMMAND_START_DONT_TRACE :\r
/* Start or restart a timer. */\r
if( prvInsertTimerInActiveList( pxTimer, xMessage.u.xTimerParameters.xMessageValue + pxTimer->xTimerPeriodInTicks, xTimeNow, xMessage.u.xTimerParameters.xMessageValue ) == pdTRUE )\r
{\r
\r
if( pxTimer->uxAutoReload == ( UBaseType_t ) pdTRUE )\r
{\r
- xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xMessage.u.xTimerParameters.xMessageValue + pxTimer->xTimerPeriodInTicks, NULL, tmrNO_DELAY );\r
+ xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START_DONT_TRACE, xMessage.u.xTimerParameters.xMessageValue + pxTimer->xTimerPeriodInTicks, NULL, tmrNO_DELAY );\r
configASSERT( xResult );\r
( void ) xResult;\r
}\r
break;\r
\r
case tmrCOMMAND_STOP :\r
+ case tmrCOMMAND_STOP_FROM_ISR :\r
/* The timer has already been removed from the active list.\r
There is nothing to do here. */\r
break;\r
\r
case tmrCOMMAND_CHANGE_PERIOD :\r
+ case tmrCOMMAND_CHANGE_PERIOD_FROM_ISR :\r
pxTimer->xTimerPeriodInTicks = xMessage.u.xTimerParameters.xMessageValue;\r
configASSERT( ( pxTimer->xTimerPeriodInTicks > 0 ) );\r
\r
}\r
else\r
{\r
- xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START, xNextExpireTime, NULL, tmrNO_DELAY );\r
+ xResult = xTimerGenericCommand( pxTimer, tmrCOMMAND_START_DONT_TRACE, xNextExpireTime, NULL, tmrNO_DELAY );\r
configASSERT( xResult );\r
( void ) xResult;\r
}\r
taskEXIT_CRITICAL();\r
\r
return xTimerIsInActiveList;\r
-}\r
+} /*lint !e818 Can't be pointer to const due to the typedef. */\r
/*-----------------------------------------------------------*/\r
\r
void *pvTimerGetTimerID( const TimerHandle_t xTimer )\r
}\r
/*-----------------------------------------------------------*/\r
\r
-#if( INCLUDE_xTimerPendCallbackFromISR == 1 )\r
+#if( INCLUDE_xTimerPendFunctionCall == 1 )\r
\r
- BaseType_t xTimerPendCallbackFromISR( pdAPPLICATION_CALLBACK_CODE pvCallbackFunction, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken )\r
+ BaseType_t xTimerPendFunctionCallFromISR( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, BaseType_t *pxHigherPriorityTaskWoken )\r
{\r
DaemonTaskMessage_t xMessage;\r
BaseType_t xReturn;\r
\r
/* Complete the message with the function parameters and post it to the\r
daemon task. */\r
- xMessage.xMessageID = tmrCOMMAND_EXECUTE_CALLBACK;\r
- xMessage.u.xCallbackParameters.pxCallbackFunction = pvCallbackFunction;\r
+ xMessage.xMessageID = tmrCOMMAND_EXECUTE_CALLBACK_FROM_ISR;\r
+ xMessage.u.xCallbackParameters.pxCallbackFunction = xFunctionToPend;\r
xMessage.u.xCallbackParameters.pvParameter1 = pvParameter1;\r
xMessage.u.xCallbackParameters.ulParameter2 = ulParameter2;\r
\r
xReturn = xQueueSendFromISR( xTimerQueue, &xMessage, pxHigherPriorityTaskWoken );\r
+ \r
+ tracePEND_FUNC_CALL_FROM_ISR( xFunctionToPend, pvParameter1, ulParameter2, xReturn );\r
+\r
+ return xReturn;\r
+ }\r
+\r
+#endif /* INCLUDE_xTimerPendFunctionCall */\r
+/*-----------------------------------------------------------*/\r
+\r
+#if( INCLUDE_xTimerPendFunctionCall == 1 )\r
+\r
+ BaseType_t xTimerPendFunctionCall( PendedFunction_t xFunctionToPend, void *pvParameter1, uint32_t ulParameter2, TickType_t xTicksToWait )\r
+ {\r
+ DaemonTaskMessage_t xMessage;\r
+ BaseType_t xReturn;\r
+\r
+ /* Complete the message with the function parameters and post it to the\r
+ daemon task. */\r
+ xMessage.xMessageID = tmrCOMMAND_EXECUTE_CALLBACK;\r
+ xMessage.u.xCallbackParameters.pxCallbackFunction = xFunctionToPend;\r
+ xMessage.u.xCallbackParameters.pvParameter1 = pvParameter1;\r
+ xMessage.u.xCallbackParameters.ulParameter2 = ulParameter2;\r
+\r
+ xReturn = xQueueSendToBack( xTimerQueue, &xMessage, xTicksToWait );\r
\r
+ tracePEND_FUNC_CALL( xFunctionToPend, pvParameter1, ulParameter2, xReturn );\r
+ \r
return xReturn;\r
}\r
\r
-#endif /* INCLUDE_xTimerPendCallbackFromISR */\r
+#endif /* INCLUDE_xTimerPendFunctionCall */\r
/*-----------------------------------------------------------*/\r
\r
/* This entire source file will be skipped if the application is not configured\r