* MACROS AND DEFINITIONS\r
*----------------------------------------------------------*/\r
\r
-#define tskKERNEL_VERSION_NUMBER "V10.2.0"\r
+#define tskKERNEL_VERSION_NUMBER "V10.2.1"\r
#define tskKERNEL_VERSION_MAJOR 10\r
#define tskKERNEL_VERSION_MINOR 2\r
-#define tskKERNEL_VERSION_BUILD 0\r
+#define tskKERNEL_VERSION_BUILD 1\r
\r
/* MPU region parameters passed in ulParameters\r
* of MemoryRegion_t struct. */\r
// an automatic stack variable it might no longer exist, or at least have been corrupted, by the time\r
// the new task attempts to access it.\r
xTaskCreate( vTaskCode, "NAME", STACK_SIZE, &ucParameterToPass, tskIDLE_PRIORITY, &xHandle );\r
- configASSERT( xHandle );\r
+ configASSERT( xHandle );\r
\r
// Use the handle to delete the task.\r
- if( xHandle != NULL )\r
- {\r
- vTaskDelete( xHandle );\r
- }\r
+ if( xHandle != NULL )\r
+ {\r
+ vTaskDelete( xHandle );\r
+ }\r
}\r
</pre>\r
* \defgroup xTaskCreate xTaskCreate\r
// for full information.\r
{\r
// Base address Length Parameters\r
- { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },\r
- { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },\r
- { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }\r
+ { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },\r
+ { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },\r
+ { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }\r
}\r
};\r
\r
// for full information.\r
{\r
// Base address Length Parameters\r
- { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },\r
- { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },\r
- { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }\r
+ { cReadWriteArray, 32, portMPU_REGION_READ_WRITE },\r
+ { cReadOnlyArray, 32, portMPU_REGION_READ_ONLY },\r
+ { cPrivilegedOnlyAccessArray, 128, portMPU_REGION_PRIVILEGED_READ_WRITE }\r
}\r
\r
&xTaskBuffer; // Holds the task's data structure.\r
\r
/**\r
* task. h\r
-* <PRE>TickType_t xTaskGetIdleRunTimeCounter( void );</PRE>\r
+* <PRE>uint32_t ulTaskGetIdleRunTimeCounter( void );</PRE>\r
*\r
* configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS\r
* must both be defined as 1 for this function to be available. The application\r
* of the accumulated time value depends on the frequency of the timer\r
* configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.\r
* While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total\r
-* execution time of each task into a buffer, xTaskGetIdleRunTimeCounter()\r
+* execution time of each task into a buffer, ulTaskGetIdleRunTimeCounter()\r
* returns the total execution time of just the idle task.\r
*\r
* @return The total run time of the idle task. This is the amount of time the\r
* frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and\r
* portGET_RUN_TIME_COUNTER_VALUE() macros.\r
*\r
-* \defgroup xTaskGetIdleRunTimeCounter xTaskGetIdleRunTimeCounter\r
+* \defgroup ulTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter\r
* \ingroup TaskUtils\r
*/\r
-TickType_t xTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION;\r
+uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION;\r
\r
/**\r
* task. h\r
*/\r
BaseType_t xTaskNotifyStateClear( TaskHandle_t xTask );\r
\r
+/**\r
+ * task.h\r
+ * <pre>void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut )</pre>\r
+ *\r
+ * Capture the current time for future use with xTaskCheckForTimeOut().\r
+ *\r
+ * @param pxTimeOut Pointer to a timeout object into which the current time\r
+ * is to be captured. The captured time includes the tick count and the number\r
+ * of times the tick count has overflowed since the system first booted.\r
+ * \defgroup vTaskSetTimeOutState vTaskSetTimeOutState\r
+ * \ingroup TaskCtrl\r
+ */\r
+void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;\r
+\r
+/**\r
+ * task.h\r
+ * <pre>BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait );</pre>\r
+ *\r
+ * Determines if pxTicksToWait ticks has passed since a time was captured\r
+ * using a call to vTaskSetTimeOutState(). The captured time includes the tick\r
+ * count and the number of times the tick count has overflowed.\r
+ *\r
+ * @param pxTimeOut The time status as captured previously using\r
+ * vTaskSetTimeOutState. If the timeout has not yet occurred, it is updated\r
+ * to reflect the current time status.\r
+ * @param pxTicksToWait The number of ticks to check for timeout i.e. if\r
+ * pxTicksToWait ticks have passed since pxTimeOut was last updated (either by\r
+ * vTaskSetTimeOutState() or xTaskCheckForTimeOut()), the timeout has occurred.\r
+ * If the timeout has not occurred, pxTIcksToWait is updated to reflect the\r
+ * number of remaining ticks.\r
+ *\r
+ * @return If timeout has occurred, pdTRUE is returned. Otherwise pdFALSE is\r
+ * returned and pxTicksToWait is updated to reflect the number of remaining\r
+ * ticks.\r
+ *\r
+ * @see https://www.freertos.org/xTaskCheckForTimeOut.html\r
+ *\r
+ * Example Usage:\r
+ * <pre>\r
+ // Driver library function used to receive uxWantedBytes from an Rx buffer\r
+ // that is filled by a UART interrupt. If there are not enough bytes in the\r
+ // Rx buffer then the task enters the Blocked state until it is notified that\r
+ // more data has been placed into the buffer. If there is still not enough\r
+ // data then the task re-enters the Blocked state, and xTaskCheckForTimeOut()\r
+ // is used to re-calculate the Block time to ensure the total amount of time\r
+ // spent in the Blocked state does not exceed MAX_TIME_TO_WAIT. This\r
+ // continues until either the buffer contains at least uxWantedBytes bytes,\r
+ // or the total amount of time spent in the Blocked state reaches\r
+ // MAX_TIME_TO_WAIT – at which point the task reads however many bytes are\r
+ // available up to a maximum of uxWantedBytes.\r
+\r
+ size_t xUART_Receive( uint8_t *pucBuffer, size_t uxWantedBytes )\r
+ {\r
+ size_t uxReceived = 0;\r
+ TickType_t xTicksToWait = MAX_TIME_TO_WAIT;\r
+ TimeOut_t xTimeOut;\r
+\r
+ // Initialize xTimeOut. This records the time at which this function\r
+ // was entered.\r
+ vTaskSetTimeOutState( &xTimeOut );\r
+\r
+ // Loop until the buffer contains the wanted number of bytes, or a\r
+ // timeout occurs.\r
+ while( UART_bytes_in_rx_buffer( pxUARTInstance ) < uxWantedBytes )\r
+ {\r
+ // The buffer didn't contain enough data so this task is going to\r
+ // enter the Blocked state. Adjusting xTicksToWait to account for\r
+ // any time that has been spent in the Blocked state within this\r
+ // function so far to ensure the total amount of time spent in the\r
+ // Blocked state does not exceed MAX_TIME_TO_WAIT.\r
+ if( xTaskCheckForTimeOut( &xTimeOut, &xTicksToWait ) != pdFALSE )\r
+ {\r
+ //Timed out before the wanted number of bytes were available,\r
+ // exit the loop.\r
+ break;\r
+ }\r
+\r
+ // Wait for a maximum of xTicksToWait ticks to be notified that the\r
+ // receive interrupt has placed more data into the buffer.\r
+ ulTaskNotifyTake( pdTRUE, xTicksToWait );\r
+ }\r
+\r
+ // Attempt to read uxWantedBytes from the receive buffer into pucBuffer.\r
+ // The actual number of bytes read (which might be less than\r
+ // uxWantedBytes) is returned.\r
+ uxReceived = UART_read_from_receive_buffer( pxUARTInstance,\r
+ pucBuffer,\r
+ uxWantedBytes );\r
+\r
+ return uxReceived;\r
+ }\r
+ </pre>\r
+ * \defgroup xTaskCheckForTimeOut xTaskCheckForTimeOut\r
+ * \ingroup TaskCtrl\r
+ */\r
+BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;\r
+\r
/*-----------------------------------------------------------\r
* SCHEDULER INTERNALS AVAILABLE FOR PORTING PURPOSES\r
*----------------------------------------------------------*/\r
*/\r
TaskHandle_t xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;\r
\r
-/*\r
- * Capture the current time status for future reference.\r
- */\r
-void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;\r
-\r
-/*\r
- * Compare the time status now with that previously captured to see if the\r
- * timeout has expired.\r
- */\r
-BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) PRIVILEGED_FUNCTION;\r
-\r
/*\r
* Shortcut used by the queue implementation to prevent unnecessary call to\r
* taskYIELD();\r
*/\r
void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION;\r
\r
+/* Correct the tick count value after the application code has held\r
+interrupts disabled for an extended period. xTicksToCatchUp is the number\r
+of tick interrupts that have been missed due to interrupts being disabled.\r
+Its value is not computed automatically, so must be computed by the\r
+application writer.\r
+\r
+This function is similar to vTaskStepTick(), however, unlike\r
+vTaskStepTick(), xTaskCatchUpTicks() may move the tick count forward past a\r
+time at which a task should be removed from the blocked state. That means\r
+tasks may have to be removed from the blocked state as the tick count is\r
+moved. */\r
+BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp ) PRIVILEGED_FUNCTION;\r
+\r
/*\r
* Only available when configUSE_TICKLESS_IDLE is set to 1.\r
* Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port\r