]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/include/timers.h
Add event_groups.c and associated functions in other core files.
[freertos] / FreeRTOS / Source / include / timers.h
index 01a09f371f7b2ab19b26b680abf4f1417643c756..f41ac583b920c9e7e0e66c5293dd3e1b8a6cdb28 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
@@ -83,6 +83,7 @@ extern "C" {
 /* IDs for commands that can be sent/received on the timer queue.  These are to\r
 be used solely through the macros that make up the public software timer API,\r
 as defined below. */\r
+#define tmrCOMMAND_EXECUTE_CALLBACK                    ( ( portBASE_TYPE ) -1 )\r
 #define tmrCOMMAND_START                                       ( ( portBASE_TYPE ) 0 )\r
 #define tmrCOMMAND_STOP                                                ( ( portBASE_TYPE ) 1 )\r
 #define tmrCOMMAND_CHANGE_PERIOD                       ( ( portBASE_TYPE ) 2 )\r
@@ -170,7 +171,7 @@ typedef void (*tmrTIMER_CALLBACK)( xTimerHandle xTimer );
  *\r
  *        // Optionally do something if the pxTimer parameter is NULL.\r
  *        configASSERT( pxTimer );\r
- *     \r
+ *\r
  *     // Which timer expired?\r
  *     lArrayIndex = ( long ) pvTimerGetTimerID( pxTimer );\r
  *\r
@@ -293,7 +294,7 @@ void *pvTimerGetTimerID( xTimerHandle xTimer ) PRIVILEGED_FUNCTION;
 portBASE_TYPE xTimerIsTimerActive( xTimerHandle xTimer ) PRIVILEGED_FUNCTION;\r
 \r
 /**\r
- * xTimerGetTimerDaemonTaskHandle() is only available if \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
@@ -944,6 +945,95 @@ xTaskHandle xTimerGetTimerDaemonTaskHandle( void );
  */\r
 #define xTimerResetFromISR( xTimer, pxHigherPriorityTaskWoken ) xTimerGenericCommand( ( xTimer ), tmrCOMMAND_START, ( xTaskGetTickCountFromISR() ), ( pxHigherPriorityTaskWoken ), 0U )\r
 \r
+\r
+/**\r
+ * portBASE_TYPE xTimerPendCallbackFromISR( pdAPPLICATION_CALLBACK_CODE pvCallbackFunction,\r
+ *                                          void *pvParameter1,\r
+ *                                          unsigned long ulParameter2,\r
+ *                                          portBASE_TYPE *pxHigherPriorityTaskWoken );\r
+ *\r
+ *\r
+ * Can be used by interrupt service routines to request that a function (the\r
+ * callback function) is executed from a task context.\r
+ *\r
+ * Ideally an interrupt service routine (ISR) is kept as short as possible, but\r
+ * sometimes an ISR either has a lot of processing to do, or needs to perform\r
+ * processing that is not deterministic.  In these cases the processing can be\r
+ * deferred to be performed in a task - allowing the ISR to exit.  The timer\r
+ * daemon service/daemon task is already responsible for executing software\r
+ * timer callback functions, so is also used to executed callback functions that\r
+ * are pended from interrupts.\r
+ *\r
+ * A mechanism is provided that allows the interrupt to return directly to the\r
+ * task that will subsequently execute the pended callback function.  This\r
+ * allows the callback function to execute contiguously in time with the\r
+ * interrupt - just as if the callback had executed in the interrupt itself.\r
+ *\r
+ * @param pvCallbackFunction The function to execute from the timer service/\r
+ * daemon task.  The function must conform to the pdAPPLICATION_CALLBACK_CODE\r
+ * prototype.\r
+ *\r
+ * @param pvParameter1 The value of the callback function's first parameter.\r
+ * The parameter has a void * type to allow it to be used to pass any type.\r
+ * For example, unsigned longs can be cast to a void *, or the void * can be\r
+ * used to point to a structure.\r
+ *\r
+ * @param ulParameter2 The value of the callback function's second parameter.\r
+ *\r
+ * @param pxHigherPriorityTaskWoken As mentioned above, calling this function\r
+ * will result in a message being sent to the timer daemon task.  If the\r
+ * priority of the timer daemon task (which is set using\r
+ * configTIMER_TASK_PRIORITY in FreeRTOSConfig.h) is higher than the priority of\r
+ * the currently running task (the task the interrupt interrupted) then\r
+ * *pxHigherPriorityTaskWoken will be set to pdTRUE within\r
+ * xTimerPendCallbackFromISR(), indicating that a context switch should be\r
+ * requested before the interrupt exits.  For that reason\r
+ * *pxHigherPriorityTaskWoken must be initialised to pdFALSE.  See the\r
+ * example code below.\r
+ *\r
+ * Example usage:\r
+ * @verbatim\r
+ *\r
+ *     // The callback function that will execute in the context of the daemon task.\r
+ *  // Note callback functions must all use this same prototype.\r
+ *  void vProcessInterface( void *pvParameter1, unsigned long ulParameter2 )\r
+ *     {\r
+ *             portBASE_TYPE xInterfaceToService;\r
+ *\r
+ *             // The interface that requires servicing is passed in the second\r
+ *      // parameter.  The first parameter is not used in this case.\r
+ *             xInterfaceToService = ( portBASE_TYPE ) ulParameter2;\r
+ *\r
+ *             // ...Perform the processing here...\r
+ *     }\r
+ *\r
+ *     // An ISR that receives data packets from multiple interfaces\r
+ *  void vAnISR( void )\r
+ *     {\r
+ *             portBASE_TYPE xInterfaceToService, xHigherPriorityTaskWoken;\r
+ *\r
+ *             // Query the hardware to determine which interface needs processing.\r
+ *             xInterfaceToService = prvCheckInterfaces();\r
+ *\r
+ *      // The actual processing is to be deferred to a task.  Request the\r
+ *      // vProcessInterface() callback function is executed, passing in the\r
+ *             // number of the interface that needs processing.  The interface to\r
+ *             // service is passed in the second parameter.  The first parameter is\r
+ *             // not used in this case.\r
+ *             xHigherPriorityTaskWoken = pdFALSE;\r
+ *             xTimerPendCallbackFromISR( vProcessInterface, NULL, ( unsigned long ) xInterfaceToService, &xHigherPriorityTaskWoken );\r
+ *\r
+ *             // If xHigherPriorityTaskWoken is now set to pdTRUE then a context\r
+ *             // switch should be requested.  The macro used is port specific and will\r
+ *             // be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - refer to\r
+ *             // the documentation page for the port being used.\r
+ *             portYIELD_FROM_ISR( xHigherPriorityTaskWoken );\r
+ *\r
+ *     }\r
+ * @endverbatim\r
+ */\r
+portBASE_TYPE xTimerPendCallbackFromISR( pdAPPLICATION_CALLBACK_CODE pvCallbackFunction, void *pvParameter1, unsigned long ulParameter2, portBASE_TYPE *pxHigherPriorityTaskWoken );\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