#endif\r
\r
#ifndef pvPortMallocAligned\r
- #define pvPortMallocAligned( x, puxStackBuffer ) ( ( puxStackBuffer == NULL ) ? ( pvPortMalloc( x ) ) : ( puxStackBuffer ) )\r
+ #define pvPortMallocAligned( x, puxStackBuffer ) ( ( ( puxStackBuffer ) == NULL ) ? ( pvPortMalloc( ( x ) ) ) : ( puxStackBuffer ) )\r
#endif\r
\r
#ifndef vPortFreeAligned\r
/* Only the current stack state is to be checked. */\r
#define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \\r
{ \\r
- extern void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ); \\r
- \\r
/* Is the currently saved stack pointer within the stack limit? */ \\r
if( pxCurrentTCB->pxTopOfStack <= pxCurrentTCB->pxStack ) \\r
{ \\r
/* Only the current stack state is to be checked. */\r
#define taskFIRST_CHECK_FOR_STACK_OVERFLOW() \\r
{ \\r
- extern void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ); \\r
\\r
/* Is the currently saved stack pointer within the stack limit? */ \\r
if( pxCurrentTCB->pxTopOfStack >= pxCurrentTCB->pxEndOfStack ) \\r
\r
#if( ( configCHECK_FOR_STACK_OVERFLOW > 1 ) && ( portSTACK_GROWTH < 0 ) )\r
\r
- #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \\r
- { \\r
- extern void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ); \\r
- static const unsigned char ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \\r
- tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \\r
- tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \\r
- tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \\r
- tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \\r
- \\r
- \\r
- /* Has the extremity of the task stack ever been written over? */ \\r
- if( memcmp( ( void * ) pxCurrentTCB->pxStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \\r
- { \\r
- vApplicationStackOverflowHook( ( xTaskHandle ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \\r
- } \\r
+ #define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \\r
+ { \\r
+ static const unsigned char ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \\r
+ tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \\r
+ tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \\r
+ tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \\r
+ tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE }; \\r
+ \\r
+ \\r
+ /* Has the extremity of the task stack ever been written over? */ \\r
+ if( memcmp( ( void * ) pxCurrentTCB->pxStack, ( void * ) ucExpectedStackBytes, sizeof( ucExpectedStackBytes ) ) != 0 ) \\r
+ { \\r
+ vApplicationStackOverflowHook( ( xTaskHandle ) pxCurrentTCB, pxCurrentTCB->pcTaskName ); \\r
+ } \\r
}\r
\r
#endif /* #if( configCHECK_FOR_STACK_OVERFLOW > 1 ) */\r
\r
#define taskSECOND_CHECK_FOR_STACK_OVERFLOW() \\r
{ \\r
- extern void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName ); \\r
char *pcEndOfStack = ( char * ) pxCurrentTCB->pxEndOfStack; \\r
static const unsigned char ucExpectedStackBytes[] = { tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \\r
tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, tskSTACK_FILL_BYTE, \\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
- 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
+ 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
by writing to Richard Barry, contact details for whom are available on the\r
FreeRTOS WEB site.\r
\r
licensing and training services.\r
*/\r
\r
+#ifndef CO_ROUTINE_H\r
+#define CO_ROUTINE_H\r
+\r
#ifndef INC_FREERTOS_H\r
#error "include FreeRTOS.h must appear in source files before include croutine.h"\r
#endif\r
\r
-\r
-\r
-\r
-#ifndef CO_ROUTINE_H\r
-#define CO_ROUTINE_H\r
-\r
#include "list.h"\r
\r
#ifdef __cplusplus\r
* \defgroup crSTART crSTART\r
* \ingroup Tasks\r
*/\r
-#define crSTART( pxCRCB ) switch( ( ( corCRCB * )pxCRCB )->uxState ) { case 0:\r
+#define crSTART( pxCRCB ) switch( ( ( corCRCB * )( pxCRCB ) )->uxState ) { case 0:\r
\r
/**\r
* croutine. h\r
* These macros are intended for internal use by the co-routine implementation\r
* only. The macros should not be used directly by application writers.\r
*/\r
-#define crSET_STATE0( xHandle ) ( ( corCRCB * )xHandle)->uxState = (__LINE__ * 2); return; case (__LINE__ * 2):\r
-#define crSET_STATE1( xHandle ) ( ( corCRCB * )xHandle)->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1):\r
+#define crSET_STATE0( xHandle ) ( ( corCRCB * )( xHandle ) )->uxState = (__LINE__ * 2); return; case (__LINE__ * 2):\r
+#define crSET_STATE1( xHandle ) ( ( corCRCB * )( xHandle ) )->uxState = ((__LINE__ * 2)+1); return; case ((__LINE__ * 2)+1):\r
\r
/**\r
* croutine. h\r
* \ingroup Tasks\r
*/\r
#define crDELAY( xHandle, xTicksToDelay ) \\r
- if( xTicksToDelay > 0 ) \\r
+ if( ( xTicksToDelay ) > 0 ) \\r
{ \\r
- vCoRoutineAddToDelayedList( xTicksToDelay, NULL ); \\r
+ vCoRoutineAddToDelayedList( ( xTicksToDelay ), NULL ); \\r
} \\r
- crSET_STATE0( xHandle );\r
+ crSET_STATE0( ( xHandle ) );\r
\r
/**\r
* <pre>\r
*/\r
#define crQUEUE_SEND( xHandle, pxQueue, pvItemToQueue, xTicksToWait, pxResult ) \\r
{ \\r
- *pxResult = xQueueCRSend( pxQueue, pvItemToQueue, xTicksToWait ); \\r
+ *( pxResult ) = xQueueCRSend( ( pxQueue) , ( pvItemToQueue) , ( xTicksToWait ) ); \\r
if( *pxResult == errQUEUE_BLOCKED ) \\r
{ \\r
- crSET_STATE0( xHandle ); \\r
- *pxResult = xQueueCRSend( pxQueue, pvItemToQueue, 0 ); \\r
+ crSET_STATE0( ( xHandle ) ); \\r
+ *pxResult = xQueueCRSend( ( pxQueue ), ( pvItemToQueue ), 0 ); \\r
} \\r
if( *pxResult == errQUEUE_YIELD ) \\r
{ \\r
- crSET_STATE1( xHandle ); \\r
+ crSET_STATE1( ( xHandle ) ); \\r
*pxResult = pdPASS; \\r
} \\r
}\r
*/\r
#define crQUEUE_RECEIVE( xHandle, pxQueue, pvBuffer, xTicksToWait, pxResult ) \\r
{ \\r
- *pxResult = xQueueCRReceive( pxQueue, pvBuffer, xTicksToWait ); \\r
- if( *pxResult == errQUEUE_BLOCKED ) \\r
+ *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), ( xTicksToWait ) ); \\r
+ if( *( pxResult ) == errQUEUE_BLOCKED ) \\r
{ \\r
- crSET_STATE0( xHandle ); \\r
- *pxResult = xQueueCRReceive( pxQueue, pvBuffer, 0 ); \\r
+ crSET_STATE0( ( xHandle ) ); \\r
+ *( pxResult ) = xQueueCRReceive( ( pxQueue) , ( pvBuffer ), 0 ); \\r
} \\r
- if( *pxResult == errQUEUE_YIELD ) \\r
+ if( *( pxResult ) == errQUEUE_YIELD ) \\r
{ \\r
- crSET_STATE1( xHandle ); \\r
- *pxResult = pdPASS; \\r
+ crSET_STATE1( ( xHandle ) ); \\r
+ *( pxResult ) = pdPASS; \\r
} \\r
}\r
\r
* \defgroup crQUEUE_SEND_FROM_ISR crQUEUE_SEND_FROM_ISR\r
* \ingroup Tasks\r
*/\r
-#define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) xQueueCRSendFromISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken )\r
+#define crQUEUE_SEND_FROM_ISR( pxQueue, pvItemToQueue, xCoRoutinePreviouslyWoken ) xQueueCRSendFromISR( ( pxQueue ), ( pvItemToQueue ), ( xCoRoutinePreviouslyWoken ) )\r
\r
\r
/**\r
* \defgroup crQUEUE_RECEIVE_FROM_ISR crQUEUE_RECEIVE_FROM_ISR\r
* \ingroup Tasks\r
*/\r
-#define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) xQueueCRReceiveFromISR( pxQueue, pvBuffer, pxCoRoutineWoken )\r
+#define crQUEUE_RECEIVE_FROM_ISR( pxQueue, pvBuffer, pxCoRoutineWoken ) xQueueCRReceiveFromISR( ( pxQueue ), ( pvBuffer ), ( pxCoRoutineWoken ) )\r
\r
/*\r
* This function is intended for internal use by the co-routine macros only.\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
- 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
+ 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
by writing to Richard Barry, contact details for whom are available on the\r
FreeRTOS WEB site.\r
\r
* \page listSET_LIST_ITEM_OWNER listSET_LIST_ITEM_OWNER\r
* \ingroup LinkedList\r
*/\r
-#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner ) ( pxListItem )->pvOwner = ( void * ) pxOwner\r
+#define listSET_LIST_ITEM_OWNER( pxListItem, pxOwner ) ( pxListItem )->pvOwner = ( void * ) ( pxOwner )\r
\r
/*\r
* Access macro to set the value of the list item. In most cases the value is\r
* \page listSET_LIST_ITEM_VALUE listSET_LIST_ITEM_VALUE\r
* \ingroup LinkedList\r
*/\r
-#define listSET_LIST_ITEM_VALUE( pxListItem, xValue ) ( pxListItem )->xItemValue = xValue\r
+#define listSET_LIST_ITEM_VALUE( pxListItem, xValue ) ( pxListItem )->xItemValue = ( xValue )\r
\r
/*\r
* Access macro the retrieve the value of the list item. The value can\r
*/\r
#define listGET_OWNER_OF_NEXT_ENTRY( pxTCB, pxList ) \\r
{ \\r
-xList * const pxConstList = pxList; \\r
+xList * const pxConstList = ( pxList ); \\r
/* Increment the index to the next item and return the item, ensuring */ \\r
/* we don't return the marker used at the end of the list. */ \\r
( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \\r
{ \\r
( pxConstList )->pxIndex = ( pxConstList )->pxIndex->pxNext; \\r
} \\r
- pxTCB = ( pxConstList )->pxIndex->pvOwner; \\r
+ ( pxTCB ) = ( pxConstList )->pxIndex->pvOwner; \\r
}\r
\r
\r
* \page listGET_OWNER_OF_HEAD_ENTRY listGET_OWNER_OF_HEAD_ENTRY\r
* \ingroup LinkedList\r
*/\r
-#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( (&( pxList->xListEnd ))->pxNext->pvOwner )\r
+#define listGET_OWNER_OF_HEAD_ENTRY( pxList ) ( (&( ( pxList )->xListEnd ))->pxNext->pvOwner )\r
\r
/*\r
* Check to see if a list item is within a list. The list item maintains a\r
* @return pdTRUE is the list item is in the list, otherwise pdFALSE.\r
* pointer against\r
*/\r
-#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( pxListItem )->pvContainer == ( void * ) pxList )\r
+#define listIS_CONTAINED_WITHIN( pxList, pxListItem ) ( ( pxListItem )->pvContainer == ( void * ) ( pxList ) )\r
\r
/*\r
* Must be called before a list is used! This initialises all the members\r
* \defgroup xQueueSend xQueueSend\r
* \ingroup QueueManagement\r
*/\r
-signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );\r
+signed portBASE_TYPE xQueueGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );\r
\r
/**\r
* queue. h\r
* \page vQueueDelete vQueueDelete\r
* \ingroup QueueManagement\r
*/\r
-void vQueueDelete( xQueueHandle xQueue );\r
+void vQueueDelete( xQueueHandle pxQueue );\r
\r
/**\r
* queue. h\r
* For internal use only. Use xSemaphoreTakeMutexRecursive() or\r
* xSemaphoreGiveMutexRecursive() instead of calling these functions directly.\r
*/\r
-portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle xMutex, portTickType xBlockTime );\r
-portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle xMutex );\r
+portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle pxMutex, portTickType xBlockTime );\r
+portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle pxMutex );\r
\r
/*\r
* The registry is provided as a means for kernel aware debuggers to\r
*/\r
\r
\r
+#ifndef TASK_H\r
+#define TASK_H\r
+\r
#ifndef INC_FREERTOS_H\r
#error "include FreeRTOS.h must appear in source files before include task.h"\r
#endif\r
\r
-\r
-\r
-#ifndef TASK_H\r
-#define TASK_H\r
-\r
#include "portable.h"\r
#include "list.h"\r
\r
* \defgroup vTaskDelete vTaskDelete\r
* \ingroup Tasks\r
*/\r
-void vTaskDelete( xTaskHandle pxTask ) PRIVILEGED_FUNCTION;\r
-\r
+void vTaskDelete( xTaskHandle pxTaskToDelete ) PRIVILEGED_FUNCTION;\r
\r
/*-----------------------------------------------------------\r
* TASK CONTROL API\r
*\r
* Returns the high water mark of the stack associated with xTask. That is,\r
* the minimum free stack space there has been (in words, so on a 32 bit machine\r
- * a value of 1 means 4 bytes) since the task started. The smaller the returned \r
+ * a value of 1 means 4 bytes) since the task started. The smaller the returned\r
* number the closer the task has come to overflowing its stack.\r
*\r
* @param xTask Handle of the task associated with the stack to be checked.\r
* Generic version of the task creation function which is in turn called by the\r
* xTaskCreate() and xTaskCreateRestricted() macros.\r
*/\r
-signed portBASE_TYPE xTaskGenericCreate( pdTASK_CODE pvTaskCode, const signed char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask, portSTACK_TYPE *puxStackBuffer, const xMemoryRegion * const xRegions ) PRIVILEGED_FUNCTION;\r
+signed portBASE_TYPE xTaskGenericCreate( pdTASK_CODE pxTaskCode, const signed char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask, portSTACK_TYPE *puxStackBuffer, const xMemoryRegion * const xRegions ) PRIVILEGED_FUNCTION;\r
\r
#ifdef __cplusplus\r
}\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
- 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
+ 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
by writing to Richard Barry, contact details for whom are available on the\r
FreeRTOS WEB site.\r
\r
pxList->xListEnd.pxNext = ( xListItem * ) &( pxList->xListEnd );\r
pxList->xListEnd.pxPrevious = ( xListItem * ) &( pxList->xListEnd );\r
\r
- pxList->uxNumberOfItems = 0;\r
+ pxList->uxNumberOfItems = ( unsigned portBASE_TYPE ) 0U;\r
}\r
/*-----------------------------------------------------------*/\r
\r
/* If the list already contains a list item with the same item value then\r
the new list item should be placed after it. This ensures that TCB's which\r
are stored in ready lists (all of which have the same ulListItem value)\r
- get an equal share of the CPU. However, if the xItemValue is the same as \r
+ get an equal share of the CPU. However, if the xItemValue is the same as\r
the back marker the iteration loop below will not end. This means we need\r
- to guard against this by checking the value first and modifying the \r
+ to guard against this by checking the value first and modifying the\r
algorithm slightly if necessary. */\r
if( xValueOfInsertion == portMAX_DELAY )\r
{\r
{\r
/* *** NOTE ***********************************************************\r
If you find your application is crashing here then likely causes are:\r
- 1) Stack overflow - \r
+ 1) Stack overflow -\r
see http://www.freertos.org/Stacks-and-stack-overflow-checking.html\r
- 2) Incorrect interrupt priority assignment, especially on Cortex-M3 \r
- parts where numerically high priority values denote low actual \r
- interrupt priories, which can seem counter intuitive. See \r
+ 2) Incorrect interrupt priority assignment, especially on Cortex-M3\r
+ parts where numerically high priority values denote low actual\r
+ interrupt priories, which can seem counter intuitive. See\r
configMAX_SYSCALL_INTERRUPT_PRIORITY on http://www.freertos.org/a00110.html\r
3) Calling an API function from within a critical section or when\r
the scheduler is suspended.\r
4) Using a queue or semaphore before it has been initialised or\r
before the scheduler has been started (are interrupts firing\r
before vTaskStartScheduler() has been called?).\r
- See http://www.freertos.org/FAQHelp.html for more tips. \r
+ See http://www.freertos.org/FAQHelp.html for more tips.\r
**********************************************************************/\r
\r
for( pxIterator = ( xListItem * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext )\r
/* The location of the software interrupt register. Software interrupts use\r
vector 27. */\r
#define portITU_SWINTR ( ( unsigned char * ) 0x000872E0 )\r
-#define portYIELD() *portITU_SWINTR = 0x01; portNOP(); portNOP(); portNOP(); portNOP(); portNOP()\r
-#define portYIELD_FROM_ISR( x ) if( x != pdFALSE ) portYIELD()\r
+#define portYIELD() *portITU_SWINTR = ( unsigned char ) 0x01; portNOP(); portNOP(); portNOP(); portNOP(); portNOP()\r
+#define portYIELD_FROM_ISR( x ) if( ( x ) != pdFALSE ) portYIELD()\r
\r
/*\r
* These macros should be called directly, but through the taskENTER_CRITICAL()\r
* and taskEXIT_CRITICAL() macros.\r
*/\r
-#define portENABLE_INTERRUPTS() __set_interrupt_level( 0 )\r
-#define portDISABLE_INTERRUPTS() __set_interrupt_level( configMAX_SYSCALL_INTERRUPT_PRIORITY )\r
+#define portENABLE_INTERRUPTS() __set_interrupt_level( ( unsigned char ) 0 )\r
+#define portDISABLE_INTERRUPTS() __set_interrupt_level( ( unsigned char ) configMAX_SYSCALL_INTERRUPT_PRIORITY )\r
\r
/* Critical nesting counts are stored in the TCB. */\r
#define portCRITICAL_NESTING_IN_TCB ( 1 )\r
/* The critical nesting functions defined within tasks.c. */\r
extern void vTaskEnterCritical( void );\r
extern void vTaskExitCritical( void );\r
-#define portENTER_CRITICAL() vTaskEnterCritical();\r
-#define portEXIT_CRITICAL() vTaskExitCritical();\r
+#define portENTER_CRITICAL() vTaskEnterCritical()\r
+#define portEXIT_CRITICAL() vTaskExitCritical()\r
\r
/* As this port allows interrupt nesting... */\r
unsigned long ulPortGetIPL( void );\r
void vPortSetIPL( unsigned long ulNewIPL );\r
#define portSET_INTERRUPT_MASK_FROM_ISR() __get_interrupt_level(); portDISABLE_INTERRUPTS()\r
-#define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ) __set_interrupt_level( uxSavedInterruptStatus )\r
+#define portCLEAR_INTERRUPT_MASK_FROM_ISR( uxSavedInterruptStatus ) __set_interrupt_level( ( unsigned char ) ( uxSavedInterruptStatus ) )\r
\r
/*-----------------------------------------------------------*/\r
\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
- 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
+ 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
by writing to Richard Barry, contact details for whom are available on the\r
FreeRTOS WEB site.\r
\r
* Macro to mark a queue as locked. Locking a queue prevents an ISR from\r
* accessing the queue event lists.\r
*/\r
-#define prvLockQueue( pxQueue ) \\r
-{ \\r
- taskENTER_CRITICAL(); \\r
- { \\r
- if( pxQueue->xRxLock == queueUNLOCKED ) \\r
- { \\r
- pxQueue->xRxLock = queueLOCKED_UNMODIFIED; \\r
- } \\r
- if( pxQueue->xTxLock == queueUNLOCKED ) \\r
- { \\r
- pxQueue->xTxLock = queueLOCKED_UNMODIFIED; \\r
- } \\r
- } \\r
- taskEXIT_CRITICAL(); \\r
-}\r
+#define prvLockQueue( pxQueue ) \\r
+ taskENTER_CRITICAL(); \\r
+ { \\r
+ if( ( pxQueue )->xRxLock == queueUNLOCKED ) \\r
+ { \\r
+ ( pxQueue )->xRxLock = queueLOCKED_UNMODIFIED; \\r
+ } \\r
+ if( ( pxQueue )->xTxLock == queueUNLOCKED ) \\r
+ { \\r
+ ( pxQueue )->xTxLock = queueLOCKED_UNMODIFIED; \\r
+ } \\r
+ } \\r
+ taskEXIT_CRITICAL()\r
/*-----------------------------------------------------------*/\r
\r
\r
{\r
xQUEUE *pxNewQueue;\r
size_t xQueueSizeInBytes;\r
+xQueueHandle xReturn = NULL;\r
\r
/* Allocate the new queue structure. */\r
if( uxQueueLength > ( unsigned portBASE_TYPE ) 0 )\r
/* Initialise the queue members as described above where the\r
queue type is defined. */\r
pxNewQueue->pcTail = pxNewQueue->pcHead + ( uxQueueLength * uxItemSize );\r
- pxNewQueue->uxMessagesWaiting = 0;\r
+ pxNewQueue->uxMessagesWaiting = ( unsigned portBASE_TYPE ) 0U;\r
pxNewQueue->pcWriteTo = pxNewQueue->pcHead;\r
- pxNewQueue->pcReadFrom = pxNewQueue->pcHead + ( ( uxQueueLength - 1 ) * uxItemSize );\r
+ pxNewQueue->pcReadFrom = pxNewQueue->pcHead + ( ( uxQueueLength - ( unsigned portBASE_TYPE ) 1U ) * uxItemSize );\r
pxNewQueue->uxLength = uxQueueLength;\r
pxNewQueue->uxItemSize = uxItemSize;\r
pxNewQueue->xRxLock = queueUNLOCKED;\r
vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );\r
\r
traceQUEUE_CREATE( pxNewQueue );\r
- return pxNewQueue;\r
+ xReturn = pxNewQueue;\r
}\r
else\r
{\r
}\r
}\r
\r
- /* Will only reach here if we could not allocate enough memory or no memory\r
- was required. */\r
- return NULL;\r
+ return xReturn;\r
}\r
/*-----------------------------------------------------------*/\r
\r
/* Each mutex has a length of 1 (like a binary semaphore) and\r
an item size of 0 as nothing is actually copied into or out\r
of the mutex. */\r
- pxNewQueue->uxMessagesWaiting = 0;\r
- pxNewQueue->uxLength = 1;\r
- pxNewQueue->uxItemSize = 0;\r
+ pxNewQueue->uxMessagesWaiting = ( unsigned portBASE_TYPE ) 0U;\r
+ pxNewQueue->uxLength = ( unsigned portBASE_TYPE ) 1U;\r
+ pxNewQueue->uxItemSize = ( unsigned portBASE_TYPE ) 0U;\r
pxNewQueue->xRxLock = queueUNLOCKED;\r
pxNewQueue->xTxLock = queueUNLOCKED;\r
\r
vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );\r
\r
/* Start with the semaphore in the expected state. */\r
- xQueueGenericSend( pxNewQueue, NULL, 0, queueSEND_TO_BACK );\r
+ xQueueGenericSend( pxNewQueue, NULL, ( portTickType ) 0U, queueSEND_TO_BACK );\r
\r
traceCREATE_MUTEX( pxNewQueue );\r
}\r
* The value used to fill the stack of a task when the task is created. This\r
* is used purely for checking the high water mark for tasks.\r
*/\r
-#define tskSTACK_FILL_BYTE ( 0xa5 )\r
+#define tskSTACK_FILL_BYTE ( 0xa5U )\r
\r
/*\r
* Macros used by vListTask to indicate which state a task is in.\r
PRIVILEGED_DATA static signed char *pcTraceBufferStart;\r
PRIVILEGED_DATA static signed char *pcTraceBufferEnd;\r
PRIVILEGED_DATA static signed portBASE_TYPE xTracing = pdFALSE;\r
- static unsigned portBASE_TYPE uxPreviousTask = 255;\r
+ static unsigned portBASE_TYPE uxPreviousTask = 255U;\r
PRIVILEGED_DATA static char pcStatusString[ 50 ];\r
\r
#endif\r
* executing task, then it will only be rescheduled after the currently\r
* executing task has been rescheduled.\r
*/\r
-#define prvAddTaskToReadyQueue( pxTCB ) \\r
-{ \\r
- if( pxTCB->uxPriority > uxTopReadyPriority ) \\r
- { \\r
- uxTopReadyPriority = pxTCB->uxPriority; \\r
- } \\r
- vListInsertEnd( ( xList * ) &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ); \\r
-}\r
+#define prvAddTaskToReadyQueue( pxTCB ) \\r
+ if( ( pxTCB )->uxPriority > uxTopReadyPriority ) \\r
+ { \\r
+ uxTopReadyPriority = ( pxTCB )->uxPriority; \\r
+ } \\r
+ vListInsertEnd( ( xList * ) &( pxReadyTasksLists[ ( pxTCB )->uxPriority ] ), &( ( pxTCB )->xGenericListItem ) )\r
/*-----------------------------------------------------------*/\r
\r
/*\r
* task should be used in place of the parameter. This macro simply checks to\r
* see if the parameter is NULL and returns a pointer to the appropriate TCB.\r
*/\r
-#define prvGetTCBFromHandle( pxHandle ) ( ( pxHandle == NULL ) ? ( tskTCB * ) pxCurrentTCB : ( tskTCB * ) pxHandle )\r
-\r
+#define prvGetTCBFromHandle( pxHandle ) ( ( ( pxHandle ) == NULL ) ? ( tskTCB * ) pxCurrentTCB : ( tskTCB * ) ( pxHandle ) )\r
\r
+/* Callback function prototypes. --------------------------*/\r
+extern void vApplicationStackOverflowHook( xTaskHandle *pxTask, signed char *pcTaskName );\r
+ \r
/* File private functions. --------------------------------*/\r
\r
/*\r
required by the port. */\r
#if( portSTACK_GROWTH < 0 )\r
{\r
- pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - 1 );\r
+ pxTopOfStack = pxNewTCB->pxStack + ( usStackDepth - ( unsigned short ) 1 );\r
pxTopOfStack = ( portSTACK_TYPE * ) ( ( ( unsigned long ) pxTopOfStack ) & ( ( unsigned long ) ~portBYTE_ALIGNMENT_MASK ) );\r
}\r
#else\r
\r
/* We are going to manipulate the task queues to add this task to a\r
ready list, so must make sure no interrupts occur. */\r
- portENTER_CRITICAL();\r
+ taskENTER_CRITICAL();\r
{\r
uxCurrentNumberOfTasks++;\r
if( pxCurrentTCB == NULL )\r
xReturn = pdPASS;\r
traceTASK_CREATE( pxNewTCB );\r
}\r
- portEXIT_CRITICAL();\r
+ taskEXIT_CRITICAL();\r
}\r
else\r
{\r
{\r
tskTCB *pxTCB;\r
\r
- portENTER_CRITICAL();\r
+ taskENTER_CRITICAL();\r
{\r
/* Ensure a yield is performed if the current task is being\r
deleted. */\r
\r
traceTASK_DELETE( pxTCB );\r
}\r
- portEXIT_CRITICAL();\r
+ taskEXIT_CRITICAL();\r
\r
/* Force a reschedule if we have just deleted the current task. */\r
if( xSchedulerRunning != pdFALSE )\r
tskTCB *pxTCB;\r
unsigned portBASE_TYPE uxReturn;\r
\r
- portENTER_CRITICAL();\r
+ taskENTER_CRITICAL();\r
{\r
/* If null is passed in here then we are changing the\r
priority of the calling function. */\r
pxTCB = prvGetTCBFromHandle( pxTask );\r
uxReturn = pxTCB->uxPriority;\r
}\r
- portEXIT_CRITICAL();\r
+ taskEXIT_CRITICAL();\r
\r
return uxReturn;\r
}\r
void vTaskPrioritySet( xTaskHandle pxTask, unsigned portBASE_TYPE uxNewPriority )\r
{\r
tskTCB *pxTCB;\r
- unsigned portBASE_TYPE uxCurrentPriority, xYieldRequired = pdFALSE;\r
+ unsigned portBASE_TYPE uxCurrentPriority;\r
+ portBASE_TYPE xYieldRequired = pdFALSE;\r
\r
/* Ensure the new priority is valid. */\r
if( uxNewPriority >= configMAX_PRIORITIES )\r
{\r
- uxNewPriority = configMAX_PRIORITIES - 1;\r
+ uxNewPriority = configMAX_PRIORITIES - ( unsigned portBASE_TYPE ) 1U;\r
}\r
\r
- portENTER_CRITICAL();\r
+ taskENTER_CRITICAL();\r
{\r
if( pxTask == pxCurrentTCB )\r
{\r
}\r
}\r
}\r
- portEXIT_CRITICAL();\r
+ taskEXIT_CRITICAL();\r
}\r
\r
#endif\r
{\r
tskTCB *pxTCB;\r
\r
- portENTER_CRITICAL();\r
+ taskENTER_CRITICAL();\r
{\r
/* Ensure a yield is performed if the current task is being\r
suspended. */\r
\r
vListInsertEnd( ( xList * ) &xSuspendedTaskList, &( pxTCB->xGenericListItem ) );\r
}\r
- portEXIT_CRITICAL();\r
+ taskEXIT_CRITICAL();\r
\r
if( ( void * ) pxTaskToSuspend == NULL )\r
{\r
/* The scheduler is not running, but the task that was pointed\r
to by pxCurrentTCB has just been suspended and pxCurrentTCB\r
must be adjusted to point to a different task. */\r
- if( uxCurrentNumberOfTasks == 1 )\r
+ if( uxCurrentNumberOfTasks == ( unsigned portBASE_TYPE ) 1U )\r
{\r
/* No other tasks are defined, so set pxCurrentTCB back to\r
NULL so when the next task is created pxCurrentTCB will\r
currently executing task. */\r
if( ( pxTCB != NULL ) && ( pxTCB != pxCurrentTCB ) )\r
{\r
- portENTER_CRITICAL();\r
+ taskENTER_CRITICAL();\r
{\r
if( xTaskIsTaskSuspended( pxTCB ) == pdTRUE )\r
{\r
}\r
}\r
}\r
- portEXIT_CRITICAL();\r
+ taskEXIT_CRITICAL();\r
}\r
}\r
\r
removed task will have been added to the xPendingReadyList. Once the\r
scheduler has been resumed it is safe to move all the pending ready\r
tasks from this list into their appropriate ready list. */\r
- portENTER_CRITICAL();\r
+ taskENTER_CRITICAL();\r
{\r
--uxSchedulerSuspended;\r
\r
}\r
}\r
}\r
- portEXIT_CRITICAL();\r
+ taskEXIT_CRITICAL();\r
\r
return xAlreadyYielded;\r
}\r
portTickType xTicks;\r
\r
/* Critical section required if running on a 16 bit processor. */\r
- portENTER_CRITICAL();\r
+ taskENTER_CRITICAL();\r
{\r
xTicks = xTickCount;\r
}\r
- portEXIT_CRITICAL();\r
+ taskEXIT_CRITICAL();\r
\r
return xTicks;\r
}\r
/* Run through all the lists that could potentially contain a TCB and\r
report the task name, state and stack high water mark. */\r
\r
- pcWriteBuffer[ 0 ] = ( signed char ) 0x00;\r
+ *pcWriteBuffer = ( signed char ) 0x00;\r
strcat( ( char * ) pcWriteBuffer, ( const char * ) "\r\n" );\r
\r
- uxQueue = uxTopUsedPriority + 1;\r
+ uxQueue = uxTopUsedPriority + ( unsigned portBASE_TYPE ) 1U;\r
\r
do\r
{\r
generating a table of run timer percentages in the provided\r
buffer. */\r
\r
- pcWriteBuffer[ 0 ] = ( signed char ) 0x00;\r
+ *pcWriteBuffer = ( signed char ) 0x00;\r
strcat( ( char * ) pcWriteBuffer, ( const char * ) "\r\n" );\r
\r
- uxQueue = uxTopUsedPriority + 1;\r
+ uxQueue = uxTopUsedPriority + ( unsigned portBASE_TYPE ) 1U;\r
\r
do\r
{\r
\r
void vTaskStartTrace( signed char * pcBuffer, unsigned long ulBufferSize )\r
{\r
- portENTER_CRITICAL();\r
+ taskENTER_CRITICAL();\r
{\r
pcTraceBuffer = ( signed char * )pcBuffer;\r
pcTraceBufferStart = pcBuffer;\r
pcTraceBufferEnd = pcBuffer + ( ulBufferSize - tskSIZE_OF_EACH_TRACE_LINE );\r
xTracing = pdTRUE;\r
}\r
- portEXIT_CRITICAL();\r
+ taskEXIT_CRITICAL();\r
}\r
\r
#endif\r
{\r
unsigned long ulBufferLength;\r
\r
- portENTER_CRITICAL();\r
+ taskENTER_CRITICAL();\r
xTracing = pdFALSE;\r
- portEXIT_CRITICAL();\r
+ taskEXIT_CRITICAL();\r
\r
ulBufferLength = ( unsigned long ) ( pcTraceBuffer - pcTraceBufferStart );\r
\r
xNumOfOverflows++;\r
if( listLIST_IS_EMPTY( pxDelayedTaskList ) != pdFALSE )\r
{\r
- /* The delayed list is empty. Set xNextTaskUnblockTime to the \r
- maximum possible value so it is extremely unlikely that the \r
+ /* The delayed list is empty. Set xNextTaskUnblockTime to the\r
+ maximum possible value so it is extremely unlikely that the\r
if( xTickCount >= xNextTaskUnblockTime ) test will pass\r
until there is an item in the delayed list. */\r
xNextTaskUnblockTime = portMAX_DELAY;\r
{\r
tskTCB * pxTCB;\r
\r
- /* The delayed list is not empty, get the value of the item at \r
+ /* The delayed list is not empty, get the value of the item at\r
the head of the delayed list. This is the time at which the\r
task at the head of the delayed list should be removed from\r
the Blocked state. */\r
\r
/* Save the hook function in the TCB. A critical section is required as\r
the value can be accessed from an interrupt. */\r
- portENTER_CRITICAL();\r
+ taskENTER_CRITICAL();\r
xTCB->pxTaskTag = pxTagValue;\r
- portEXIT_CRITICAL();\r
+ taskEXIT_CRITICAL();\r
}\r
\r
#endif\r
\r
/* Save the hook function in the TCB. A critical section is required as\r
the value can be accessed from an interrupt. */\r
- portENTER_CRITICAL();\r
+ taskENTER_CRITICAL();\r
xReturn = xTCB->pxTaskTag;\r
- portEXIT_CRITICAL();\r
+ taskEXIT_CRITICAL();\r
\r
return xReturn;\r
}\r
/* The scheduler is currently suspended - do not allow a context\r
switch. */\r
xMissedYield = pdTRUE;\r
- return;\r
}\r
-\r
- traceTASK_SWITCHED_OUT();\r
-\r
- #if ( configGENERATE_RUN_TIME_STATS == 1 )\r
- {\r
- unsigned long ulTempCounter;\r
- \r
- #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE\r
- portALT_GET_RUN_TIME_COUNTER_VALUE( ulTempCounter );\r
- #else\r
- ulTempCounter = portGET_RUN_TIME_COUNTER_VALUE();\r
- #endif\r
-\r
- /* Add the amount of time the task has been running to the accumulated\r
- time so far. The time the task started running was stored in\r
- ulTaskSwitchedInTime. Note that there is no overflow protection here\r
- so count values are only valid until the timer overflows. Generally\r
- this will be about 1 hour assuming a 1uS timer increment. */\r
- pxCurrentTCB->ulRunTimeCounter += ( ulTempCounter - ulTaskSwitchedInTime );\r
- ulTaskSwitchedInTime = ulTempCounter;\r
- }\r
- #endif\r
-\r
- taskFIRST_CHECK_FOR_STACK_OVERFLOW();\r
- taskSECOND_CHECK_FOR_STACK_OVERFLOW();\r
-\r
- /* Find the highest priority queue that contains ready tasks. */\r
- while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) )\r
+ else\r
{\r
- --uxTopReadyPriority;\r
+ traceTASK_SWITCHED_OUT();\r
+ \r
+ #if ( configGENERATE_RUN_TIME_STATS == 1 )\r
+ {\r
+ unsigned long ulTempCounter;\r
+ \r
+ #ifdef portALT_GET_RUN_TIME_COUNTER_VALUE\r
+ portALT_GET_RUN_TIME_COUNTER_VALUE( ulTempCounter );\r
+ #else\r
+ ulTempCounter = portGET_RUN_TIME_COUNTER_VALUE();\r
+ #endif\r
+ \r
+ /* Add the amount of time the task has been running to the accumulated\r
+ time so far. The time the task started running was stored in\r
+ ulTaskSwitchedInTime. Note that there is no overflow protection here\r
+ so count values are only valid until the timer overflows. Generally\r
+ this will be about 1 hour assuming a 1uS timer increment. */\r
+ pxCurrentTCB->ulRunTimeCounter += ( ulTempCounter - ulTaskSwitchedInTime );\r
+ ulTaskSwitchedInTime = ulTempCounter;\r
+ }\r
+ #endif\r
+ \r
+ taskFIRST_CHECK_FOR_STACK_OVERFLOW();\r
+ taskSECOND_CHECK_FOR_STACK_OVERFLOW();\r
+ \r
+ /* Find the highest priority queue that contains ready tasks. */\r
+ while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) )\r
+ {\r
+ --uxTopReadyPriority;\r
+ }\r
+ \r
+ /* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the tasks of the\r
+ same priority get an equal share of the processor time. */\r
+ listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) );\r
+ \r
+ traceTASK_SWITCHED_IN();\r
+ vWriteTraceToBuffer();\r
}\r
-\r
- /* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the tasks of the\r
- same priority get an equal share of the processor time. */\r
- listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) );\r
-\r
- traceTASK_SWITCHED_IN();\r
- vWriteTraceToBuffer();\r
}\r
/*-----------------------------------------------------------*/\r
\r
\r
If an event is for a queue that is locked then this function will never\r
get called - the lock count on the queue will get modified instead. This\r
- means we can always expect exclusive access to the event list here. \r
+ means we can always expect exclusive access to the event list here.\r
\r
This function assumes that a check has already been made to ensure that\r
pxEventList is not empty. */\r
{\r
portBASE_TYPE xReturn;\r
\r
- portENTER_CRITICAL();\r
+ taskENTER_CRITICAL();\r
{\r
#if ( INCLUDE_vTaskSuspend == 1 )\r
/* If INCLUDE_vTaskSuspend is set to 1 and the block time specified is\r
xReturn = pdTRUE;\r
}\r
}\r
- portEXIT_CRITICAL();\r
+ taskEXIT_CRITICAL();\r
\r
return xReturn;\r
}\r
strncpy( ( char * ) pxTCB->pcTaskName, ( const char * ) pcName, ( unsigned short ) configMAX_TASK_NAME_LEN );\r
}\r
#endif\r
- pxTCB->pcTaskName[ ( unsigned short ) configMAX_TASK_NAME_LEN - ( unsigned short ) 1 ] = '\0';\r
+ pxTCB->pcTaskName[ ( unsigned short ) configMAX_TASK_NAME_LEN - ( unsigned short ) 1 ] = ( signed char ) '\0';\r
\r
/* This is used as an array index so must ensure it's not too large. First\r
remove the privilege bit if one is present. */\r
if( uxPriority >= configMAX_PRIORITIES )\r
{\r
- uxPriority = configMAX_PRIORITIES - 1;\r
+ uxPriority = configMAX_PRIORITIES - ( unsigned portBASE_TYPE ) 1U;\r
}\r
\r
pxTCB->uxPriority = uxPriority;\r
{\r
unsigned portBASE_TYPE uxPriority;\r
\r
- for( uxPriority = 0; uxPriority < configMAX_PRIORITIES; uxPriority++ )\r
+ for( uxPriority = ( unsigned portBASE_TYPE ) 0U; uxPriority < configMAX_PRIORITIES; uxPriority++ )\r
{\r
vListInitialise( ( xList * ) &( pxReadyTasksLists[ uxPriority ] ) );\r
}\r
{\r
tskTCB *pxTCB;\r
\r
- portENTER_CRITICAL();\r
+ taskENTER_CRITICAL();\r
{\r
pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( ( ( xList * ) &xTasksWaitingTermination ) );\r
vListRemove( &( pxTCB->xGenericListItem ) );\r
--uxCurrentNumberOfTasks;\r
--uxTasksDeleted;\r
}\r
- portEXIT_CRITICAL();\r
+ taskEXIT_CRITICAL();\r
\r
prvDeleteTCB( pxTCB );\r
}\r
else\r
{\r
/* What percentage of the total run time has the task used?\r
- This will always be rounded down to the nearest integer. \r
+ This will always be rounded down to the nearest integer.\r
ulTotalRunTime has already been divided by 100. */\r
ulStatsAsPercentage = pxNextTCB->ulRunTimeCounter / ulTotalRunTime;\r
\r