*/\r
\r
/*\r
- * Demonstrates the creation an use of queue sets.\r
+ * Tests the use of queue sets.\r
*\r
* A receive task creates a number of queues and adds them to a queue set before\r
* blocking on the queue set receive. A transmit task and (optionally) an\r
* the queues and flags an error if the received message does not match that\r
* expected. The task sends values in the range 0 to\r
* queuesetINITIAL_ISR_TX_VALUE, and the ISR sends value in the range\r
- * queuesetINITIAL_ISR_TX_VALUE to 0xffffffffUL;\r
+ * queuesetINITIAL_ISR_TX_VALUE to ULONG_MAX.\r
*/\r
\r
/* Standard includes. */\r
#include <stdlib.h>\r
+#include <limits.h>\r
\r
/* Kernel includes. */\r
#include "FreeRTOS.h"\r
\r
/* Messages are sent in incrementing order from both a task and an interrupt.\r
The task sends values in the range 0 to 0xfffe, and the interrupt sends values\r
-in the range of 0xffff to 0xffffffff; */\r
+in the range of 0xffff to ULONG_MAX. */\r
#define queuesetINITIAL_ISR_TX_VALUE 0xffffUL\r
\r
/* The priorities used in this demo. */\r
#define queuesetPRIORITY_CHANGE_LOOPS 100UL\r
\r
/* The ISR sends to the queue every queuesetISR_TX_PERIOD ticks. */\r
-#define queuesetISR_TX_PERIOD ( 100UL )\r
+#define queuesetISR_TX_PERIOD 2//( 100UL )\r
\r
+/* The allowable maximum deviation between a received value and the expected\r
+received value. A deviation will occur when data is received from a queue\r
+inside an ISR in between a task receiving from a queue and the task checking\r
+the received value. */\r
+#define queuesetALLOWABLE_RX_DEVIATION 5\r
/*\r
* The task that periodically sends to the queue set.\r
*/\r
*/\r
static void prvQueueSetReceivingTask( void *pvParameters );\r
\r
+/*\r
+ * Check the value received from a queue is the expected value. Some values\r
+ * originate from the send task, some values originate from the ISR, with the\r
+ * range of the value being used to distinguish between the two message\r
+ * sources.\r
+ */\r
+static void prvCheckReceivedValue( unsigned long ulReceived );\r
+\r
+/*\r
+ * For purposes of test coverage, functions that read from and write to a\r
+ * queue set from an ISR respectively.\r
+ */\r
+static void prvReceiveFromQueueInSetFromISR( void );\r
+static void prvSendToQueueInSetFromISR( void );\r
+\r
+/*\r
+ * Create the queues and add them to a queue set before resuming the Tx\r
+ * task.\r
+ */\r
+static void prvSetupTest( xTaskHandle xQueueSetSendingTask );\r
+\r
+/*\r
+ * Checks a value received from a queue falls within the range of expected\r
+ * values.\r
+ */\r
+static portBASE_TYPE prvCheckReceivedValueWithinExpectedRange( unsigned long ulReceived, unsigned long ulExpectedReceived );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
/* The queues that are added to the set. */\r
static xQueueHandle xQueues[ queuesetNUM_QUEUES_IN_SET ] = { 0 };\r
\r
/* Create the two queues. The handle of the sending task is passed into\r
the receiving task using the task parameter. The receiving task uses the\r
handle to resume the sending task after it has created the queues. */\r
- xTaskCreate( prvQueueSetSendingTask, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, queuesetMEDIUM_PRIORITY, &xQueueSetSendingTask );\r
- xTaskCreate( prvQueueSetReceivingTask, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, ( void * ) xQueueSetSendingTask, queuesetMEDIUM_PRIORITY, NULL );\r
+ xTaskCreate( prvQueueSetSendingTask, ( signed char * ) "SetTx", configMINIMAL_STACK_SIZE, NULL, queuesetMEDIUM_PRIORITY, &xQueueSetSendingTask );\r
+ xTaskCreate( prvQueueSetReceivingTask, ( signed char * ) "SetRx", configMINIMAL_STACK_SIZE, ( void * ) xQueueSetSendingTask, queuesetMEDIUM_PRIORITY, NULL );\r
\r
/* It is important that the sending task does not attempt to write to a\r
queue before the queue has been created. It is therefore placed into the\r
}\r
/*-----------------------------------------------------------*/\r
\r
-void vQueueSetWriteToQueueFromISR( void )\r
-{\r
-portBASE_TYPE x = 0;\r
-static unsigned long ulCallCount = 0;\r
-\r
- /* xSetupComplete is set to pdTRUE when the queues have been created and\r
- are available for use. */\r
- if( xSetupComplete == pdTRUE )\r
- {\r
- /* It is intended that this function is called from the tick hook\r
- function, so each call is one tick period apart. */\r
- ulCallCount++;\r
- if( ulCallCount > queuesetISR_TX_PERIOD )\r
- {\r
- ulCallCount = 0;\r
-\r
- /* Look for a queue that can be written to. */\r
- for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )\r
- {\r
- if( xQueues[ x ] != NULL )\r
- {\r
- /* xQueues[ x ] can be written to. Send the next value. */\r
- if( xQueueSendFromISR( xQueues[ x ], ( void * ) &ulISRTxValue, NULL ) == pdPASS )\r
- {\r
- ulISRTxValue++;\r
-\r
- /* If the Tx value has wrapped then set it back to its\r
- initial value. */\r
- if( ulISRTxValue == 0UL )\r
- {\r
- ulISRTxValue = queuesetINITIAL_ISR_TX_VALUE;\r
- }\r
- }\r
-\r
- break;\r
- }\r
- }\r
- }\r
- }\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
static void prvQueueSetSendingTask( void *pvParameters )\r
{\r
unsigned long ulTaskTxValue = 0;\r
xQueueSetTasksStatus = pdFAIL;\r
}\r
\r
- /* Attempt to remove the queue from a queue set it does not belong\r
- to (NULL being passed as the queue set in this case). */\r
- if( xQueueRemoveFromQueueSet( xQueueInUse, NULL ) != pdFAIL )\r
- {\r
- /* It is not possible to successfully remove a queue from a queue\r
- set it does not belong to. */\r
- xQueueSetTasksStatus = pdFAIL;\r
- }\r
-\r
- /* Mark the space in the array of queues as being empty before actually\r
- removing the queue from the queue set. This is to prevent the code\r
- that accesses the queue set from an interrupt from attempting to access\r
- a queue that is no longer in the set. */\r
- xQueues[ xQueueToWriteTo ] = 0;\r
-\r
- /* Attempt to remove the queue from the queue set it does belong to. */\r
- if( xQueueRemoveFromQueueSet( xQueueInUse, xQueueSet ) != pdPASS )\r
- {\r
- /* It should be possible to remove the queue from the queue set it\r
- does belong to. */\r
- xQueueSetTasksStatus = pdFAIL;\r
- }\r
-\r
- /* Add the queue back before cycling back to run again. */\r
- if( xQueueAddToQueueSet( xQueueInUse, xQueueSet ) != pdPASS )\r
- {\r
- /* If the queue was successfully removed from the queue set then it\r
- should be possible to add it back in again. */\r
- xQueueSetTasksStatus = pdFAIL;\r
- }\r
-\r
- /* Now the queue is back in the set it is ok for the interrupt that\r
- writes to the queues to access it again. */\r
- xQueues[ xQueueToWriteTo ] = xQueueInUse;\r
-\r
ulTaskTxValue++;\r
\r
/* If the Tx value has reached the range used by the ISR then set it\r
\r
static void prvQueueSetReceivingTask( void *pvParameters )\r
{\r
-unsigned long ulReceived, ulExpectedReceivedFromTask = 0, ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;\r
+unsigned long ulReceived;\r
xQueueHandle xActivatedQueue;\r
-portBASE_TYPE x;\r
xTaskHandle xQueueSetSendingTask;\r
\r
/* The handle to the sending task is passed in using the task parameter. */\r
xQueueSetSendingTask = ( xTaskHandle ) pvParameters;\r
\r
- /* Ensure the queues are created and the queue set configured before the\r
- sending task is unsuspended.\r
-\r
- First Create the queue set such that it will be able to hold a message for\r
- every space in every queue in the set. */\r
- xQueueSet = xQueueSetCreate( queuesetNUM_QUEUES_IN_SET * queuesetQUEUE_LENGTH );\r
-\r
- for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )\r
- {\r
- /* Create the queue and add it to the set. The queue is just holding\r
- unsigned long value. */\r
- xQueues[ x ] = xQueueCreate( queuesetQUEUE_LENGTH, sizeof( unsigned long ) );\r
- configASSERT( xQueues[ x ] );\r
- if( xQueueAddToQueueSet( xQueues[ x ], xQueueSet ) != pdPASS )\r
- {\r
- xQueueSetTasksStatus = pdFAIL;\r
- }\r
-\r
- /* The queue has now been added to the queue set and cannot be added to\r
- another. */\r
- if( xQueueAddToQueueSet( xQueues[ x ], xQueueSet ) != pdFAIL )\r
- {\r
- xQueueSetTasksStatus = pdFAIL;\r
- }\r
- }\r
-\r
- /* The task that sends to the queues is not running yet, so attempting to\r
- read from the queue set should fail, resulting in xActivatedQueue being set\r
- to NULL. */\r
- xActivatedQueue = xQueueBlockMultiple( xQueueSet, queuesetSHORT_DELAY );\r
- configASSERT( xActivatedQueue == NULL );\r
-\r
- /* Resume the task that writes to the queues. */\r
- vTaskResume( xQueueSetSendingTask );\r
-\r
- /* Let the ISR access the queues also. */\r
- xSetupComplete = pdTRUE;\r
+ /* Create the queues and add them to the queue set before resuming the Tx\r
+ task. */\r
+ prvSetupTest( xQueueSetSendingTask );\r
\r
for( ;; )\r
{\r
/* Wait for a message to arrive on one of the queues in the set. */\r
- xActivatedQueue = xQueueBlockMultiple( xQueueSet, portMAX_DELAY );\r
+ xActivatedQueue = xQueueSelectFromSet( xQueueSet, portMAX_DELAY );\r
configASSERT( xActivatedQueue );\r
\r
if( xActivatedQueue == NULL )\r
xQueueSetTasksStatus = pdFAIL;\r
}\r
\r
- /* If the received value is equal to or greater than\r
- queuesetINITIAL_ISR_TX_VALUE then it was sent by an ISR. */\r
- if( ulReceived >= queuesetINITIAL_ISR_TX_VALUE )\r
+ /* Ensure the value received was the value expected. This function\r
+ manipulates file scope data and is also called from an ISR, hence\r
+ the critical section. */\r
+ taskENTER_CRITICAL();\r
{\r
- /* The value was sent from the ISR. Check it against its\r
- expected value. */\r
- configASSERT( ulReceived == ulExpectedReceivedFromISR );\r
- if( ulReceived != ulExpectedReceivedFromISR )\r
- {\r
- xQueueSetTasksStatus = pdFAIL;\r
- }\r
- else\r
- {\r
- /* It is expected to receive an incrementing value. */\r
- ulExpectedReceivedFromISR++;\r
-\r
- /* If the expected value has wrapped then set it back to\r
- its initial value. */\r
- if( ulExpectedReceivedFromISR == 0 )\r
- {\r
- ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;\r
- }\r
- }\r
+ prvCheckReceivedValue( ulReceived );\r
+ }\r
+ taskEXIT_CRITICAL();\r
+ }\r
+\r
+ if( xQueueSetTasksStatus == pdPASS )\r
+ {\r
+ ulCycleCounter++;\r
+ }\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vQueueSetAccessQueueSetFromISR( void )\r
+{\r
+static unsigned long ulCallCount = 0;\r
+\r
+ /* xSetupComplete is set to pdTRUE when the queues have been created and\r
+ are available for use. */\r
+ if( xSetupComplete == pdTRUE )\r
+ {\r
+ /* It is intended that this function is called from the tick hook\r
+ function, so each call is one tick period apart. */\r
+ ulCallCount++;\r
+ if( ulCallCount > queuesetISR_TX_PERIOD )\r
+ {\r
+ ulCallCount = 0;\r
+\r
+ /* First attempt to read from the queue set. */\r
+ prvReceiveFromQueueInSetFromISR();\r
+\r
+ /* Then write to the queue set. */\r
+ prvSendToQueueInSetFromISR();\r
+ }\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCheckReceivedValue( unsigned long ulReceived )\r
+{\r
+static unsigned long ulExpectedReceivedFromTask = 0, ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;\r
+\r
+ /* Values are received in tasks and interrupts. It is likely that the\r
+ receiving task will sometimes get preempted by the receiving interrupt\r
+ between reading a value from the queue and calling this function. When\r
+ that happens, if the receiving interrupt calls this function the values\r
+ will get passed into this function slightly out of order. For that\r
+ reason the value passed in is tested against a small range of expected\r
+ values, rather than a single absolute value. To make the range testing\r
+ easier values in the range limits are ignored. */\r
+\r
+ /* If the received value is equal to or greater than\r
+ queuesetINITIAL_ISR_TX_VALUE then it was sent by an ISR. */\r
+ if( ulReceived >= queuesetINITIAL_ISR_TX_VALUE )\r
+ {\r
+ /* The value was sent from the ISR. */\r
+ if( ( ulReceived - queuesetINITIAL_ISR_TX_VALUE ) < queuesetALLOWABLE_RX_DEVIATION )\r
+ {\r
+ /* The value received is at the lower limit of the expected range.\r
+ Don't test it and expect to receive one higher next time. */\r
+ ulExpectedReceivedFromISR++;\r
+ }\r
+ else if( ( ULONG_MAX - ulReceived ) <= queuesetALLOWABLE_RX_DEVIATION )\r
+ {\r
+ /* The value received is at the higher limit of the expected range.\r
+ Don't test it and expect to wrap soon. */\r
+ ulExpectedReceivedFromISR = queuesetINITIAL_ISR_TX_VALUE;\r
+ }\r
+ else\r
+ {\r
+ /* Check the value against its expected value range. */\r
+ if( prvCheckReceivedValueWithinExpectedRange( ulReceived, ulExpectedReceivedFromISR ) != pdPASS )\r
+ {\r
+ xQueueSetTasksStatus = pdFAIL;\r
+ }\r
+ else\r
+ {\r
+ /* It is expected to receive an incrementing value. */\r
+ ulExpectedReceivedFromISR++;\r
+ }\r
+ }\r
+ }\r
+ else\r
+ {\r
+ /* The value was sent from the Tx task. */\r
+ if( ulReceived < queuesetALLOWABLE_RX_DEVIATION )\r
+ {\r
+ /* The value received is at the lower limit of the expected range.\r
+ Don't test it, and expect to receive one higher next time. */\r
+ ulExpectedReceivedFromTask++;\r
+ }\r
+ else if( ( ( queuesetINITIAL_ISR_TX_VALUE - 1 ) - ulReceived ) <= queuesetALLOWABLE_RX_DEVIATION )\r
+ {\r
+ /* The value received is at the higher limit of the expected range.\r
+ Don't test it and expect to wrap soon. */\r
+ ulExpectedReceivedFromTask = 0;\r
+ }\r
+ else\r
+ {\r
+ /* Check the value against its expected value range. */\r
+ if( prvCheckReceivedValueWithinExpectedRange( ulReceived, ulExpectedReceivedFromTask ) != pdPASS )\r
+ {\r
+ xQueueSetTasksStatus = pdFAIL;\r
}\r
else\r
{\r
- /* The value was sent from the Tx task. Check it against its\r
- expected value. */\r
- configASSERT( ulReceived == ulExpectedReceivedFromTask );\r
- if( ulReceived != ulExpectedReceivedFromTask )\r
- {\r
- xQueueSetTasksStatus = pdFAIL;\r
- }\r
- else\r
- {\r
- /* It is expected to receive an incrementing value. */\r
- ulExpectedReceivedFromTask++;\r
-\r
- /* If the expected value has reached the range of values\r
- used by the ISR then set it back to 0. */\r
- if( ulExpectedReceivedFromTask >= queuesetINITIAL_ISR_TX_VALUE )\r
- {\r
- ulExpectedReceivedFromTask = 0;\r
- }\r
- }\r
+ /* It is expected to receive an incrementing value. */\r
+ ulExpectedReceivedFromTask++;\r
}\r
}\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static portBASE_TYPE prvCheckReceivedValueWithinExpectedRange( unsigned long ulReceived, unsigned long ulExpectedReceived )\r
+{\r
+portBASE_TYPE xReturn = pdPASS;\r
+\r
+ if( ulReceived > ulExpectedReceived )\r
+ {\r
+ configASSERT( ( ulReceived - ulExpectedReceived ) <= queuesetALLOWABLE_RX_DEVIATION );\r
+ if( ( ulReceived - ulExpectedReceived ) > queuesetALLOWABLE_RX_DEVIATION )\r
+ {\r
+ xReturn = pdFALSE;\r
+ }\r
+ }\r
+ else\r
+ {\r
+ configASSERT( ( ulExpectedReceived - ulReceived ) <= queuesetALLOWABLE_RX_DEVIATION );\r
+ if( ( ulExpectedReceived - ulReceived ) > queuesetALLOWABLE_RX_DEVIATION )\r
+ {\r
+ xReturn = pdFALSE;\r
+ }\r
+ }\r
\r
- if( xQueueSetTasksStatus == pdPASS )\r
+ return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvReceiveFromQueueInSetFromISR( void )\r
+{\r
+xQueueSetMemberHandle xActivatedQueue;\r
+unsigned long ulReceived;\r
+\r
+ /* See if any of the queues in the set contain data. */\r
+ xActivatedQueue = xQueueSelectFromSetFromISR( xQueueSet );\r
+\r
+ if( xActivatedQueue != NULL )\r
+ {\r
+ /* Reading from the queue for test purposes only. */\r
+ if( xQueueReceiveFromISR( xActivatedQueue, &ulReceived, NULL ) != pdPASS )\r
{\r
- ulCycleCounter++;\r
+ /* Data should have been available as the handle was returned from\r
+ xQueueSelectFromSetFromISR(). */\r
+ xQueueSetTasksStatus = pdFAIL;\r
+ }\r
+\r
+ /* Ensure the value received was the value expected. */\r
+ prvCheckReceivedValue( ulReceived );\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvSendToQueueInSetFromISR( void )\r
+{\r
+static portBASE_TYPE xQueueToWriteTo = 0;\r
+\r
+ if( xQueueSendFromISR( xQueues[ xQueueToWriteTo ], ( void * ) &ulISRTxValue, NULL ) == pdPASS )\r
+ {\r
+ ulISRTxValue++;\r
+\r
+ /* If the Tx value has wrapped then set it back to its\r
+ initial value. */\r
+ if( ulISRTxValue == 0UL )\r
+ {\r
+ ulISRTxValue = queuesetINITIAL_ISR_TX_VALUE;\r
+ }\r
+\r
+ /* Use a different queue next time. */\r
+ xQueueToWriteTo++;\r
+ if( xQueueToWriteTo >= queuesetNUM_QUEUES_IN_SET )\r
+ {\r
+ xQueueToWriteTo = 0;\r
}\r
}\r
}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvSetupTest( xTaskHandle xQueueSetSendingTask )\r
+{\r
+portBASE_TYPE x;\r
+xQueueSetMemberHandle xActivatedQueue;\r
+\r
+ /* Ensure the queues are created and the queue set configured before the\r
+ sending task is unsuspended.\r
+\r
+ First Create the queue set such that it will be able to hold a message for\r
+ every space in every queue in the set. */\r
+ xQueueSet = xQueueCreateSet( queuesetNUM_QUEUES_IN_SET * queuesetQUEUE_LENGTH );\r
+\r
+ for( x = 0; x < queuesetNUM_QUEUES_IN_SET; x++ )\r
+ {\r
+ /* Create the queue and add it to the set. The queue is just holding\r
+ unsigned long value. */\r
+ xQueues[ x ] = xQueueCreate( queuesetQUEUE_LENGTH, sizeof( unsigned long ) );\r
+ configASSERT( xQueues[ x ] );\r
+ if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdPASS )\r
+ {\r
+ xQueueSetTasksStatus = pdFAIL;\r
+ }\r
+ else\r
+ {\r
+ /* The queue has now been added to the queue set and cannot be added to\r
+ another. */\r
+ if( xQueueAddToSet( xQueues[ x ], xQueueSet ) != pdFAIL )\r
+ {\r
+ xQueueSetTasksStatus = pdFAIL;\r
+ }\r
+ }\r
+ }\r
+\r
+ /* Attempt to remove a queue from a queue set it does not belong\r
+ to (NULL being passed as the queue set in this case). */\r
+ if( xQueueRemoveFromSet( xQueues[ 0 ], NULL ) != pdFAIL )\r
+ {\r
+ /* It is not possible to successfully remove a queue from a queue\r
+ set it does not belong to. */\r
+ xQueueSetTasksStatus = pdFAIL;\r
+ }\r
+\r
+ /* Attempt to remove a queue from the queue set it does belong to. */\r
+ if( xQueueRemoveFromSet( xQueues[ 0 ], xQueueSet ) != pdPASS )\r
+ {\r
+ /* It should be possible to remove the queue from the queue set it\r
+ does belong to. */\r
+ xQueueSetTasksStatus = pdFAIL;\r
+ }\r
\r
+ /* Add the queue back again before starting the dynamic tests. */\r
+ if( xQueueAddToSet( xQueues[ 0 ], xQueueSet ) != pdPASS )\r
+ {\r
+ /* If the queue was successfully removed from the queue set then it\r
+ should be possible to add it back in again. */\r
+ xQueueSetTasksStatus = pdFAIL;\r
+ }\r
+\r
+ /* The task that sends to the queues is not running yet, so attempting to\r
+ read from the queue set should fail, resulting in xActivatedQueue being set\r
+ to NULL. */\r
+ xActivatedQueue = xQueueSelectFromSet( xQueueSet, queuesetSHORT_DELAY );\r
+ configASSERT( xActivatedQueue == NULL );\r
+\r
+ /* Resume the task that writes to the queues. */\r
+ vTaskResume( xQueueSetSendingTask );\r
+\r
+ /* Let the ISR access the queues also. */\r
+ xSetupComplete = pdTRUE;\r
+}\r
\r
void vStartQueueSetTasks( void );\r
portBASE_TYPE xAreQueueSetTasksStillRunning( void );\r
-void vQueueSetWriteToQueueFromISR( void );\r
+void vQueueSetAccessQueueSetFromISR( void );\r
\r
#endif /* QUEUE_WAIT_MULTIPLE_H */\r
\r
#define configIDLE_SHOULD_YIELD 1\r
#define configUSE_CO_ROUTINES 0\r
#define configUSE_MUTEXES 1\r
-#define configGENERATE_RUN_TIME_STATS 0\r
#define configCHECK_FOR_STACK_OVERFLOW 0\r
#define configUSE_RECURSIVE_MUTEXES 1\r
#define configQUEUE_REGISTRY_SIZE 0\r
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )\r
\r
\r
+/* Run time stats gathering definitions. */\r
+unsigned long ulGetRunTimeCounterValue( void );\r
+void vConfigureTimerForRunTimeStats( void );\r
+#define configGENERATE_RUN_TIME_STATS 1\r
+#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()\r
+#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue()\r
+\r
/* Co-routine definitions. */\r
#define configUSE_CO_ROUTINES 0\r
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )\r
version. */\r
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1\r
\r
+/* Include the FreeRTOS+Trace recorder hooks. */\r
+#include "trcHooks.h"\r
\r
#endif /* FREERTOS_CONFIG_H */\r
--- /dev/null
+/*\r
+ FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.\r
+\r
+ FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT \r
+ http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+ ***************************************************************************\r
+ * *\r
+ * FreeRTOS tutorial books are available in pdf and paperback. *\r
+ * Complete, revised, and edited pdf reference manuals are also *\r
+ * available. *\r
+ * *\r
+ * Purchasing FreeRTOS documentation will not only help you, by *\r
+ * ensuring you get running as quickly as possible and with an *\r
+ * in-depth knowledge of how to use FreeRTOS, it will also help *\r
+ * the FreeRTOS project to continue with its mission of providing *\r
+ * professional grade, cross platform, de facto standard solutions *\r
+ * for microcontrollers - completely free of charge! *\r
+ * *\r
+ * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *\r
+ * *\r
+ * Thank you for using FreeRTOS, and thank you for your support! *\r
+ * *\r
+ ***************************************************************************\r
+\r
+\r
+ This file is part of the FreeRTOS distribution.\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
+ >>>NOTE<<< The modification to the GPL is included to allow you to\r
+ distribute a combined work that includes FreeRTOS without being obliged to\r
+ provide the source code for proprietary components outside of the FreeRTOS\r
+ kernel. FreeRTOS is distributed in the hope that it will be useful, but\r
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\r
+ or 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
+ by writing to Richard Barry, contact details for whom are available on the\r
+ FreeRTOS WEB site.\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?" *\r
+ * *\r
+ * http://www.FreeRTOS.org/FAQHelp.html *\r
+ * *\r
+ ***************************************************************************\r
+\r
+ \r
+ http://www.FreeRTOS.org - Documentation, training, latest versions, license \r
+ and contact details. \r
+ \r
+ http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+ including FreeRTOS+Trace - an indispensable productivity tool.\r
+\r
+ Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
+ the code with commercial support, indemnification, and middleware, under \r
+ the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also\r
+ provide a safety engineered and independently SIL3 certified version under \r
+ the SafeRTOS brand: http://www.SafeRTOS.com.\r
+*/\r
+\r
+/*\r
+ * Utility functions required to gather run time statistics. See:\r
+ * http://www.freertos.org/rtos-run-time-stats.html\r
+ *\r
+ * Note that this is a simulated port, where simulated time is a lot slower than\r
+ * real time, therefore the run time counter values have no real meaningful\r
+ * units.\r
+ *\r
+ * Also note that it is assumed this demo is going to be used for short periods\r
+ * of time only, and therefore timer overflows are not handled.\r
+*/\r
+\r
+/* FreeRTOS includes. */\r
+#include <FreeRTOS.h>\r
+\r
+/* FreeRTOS+Trace includes. */\r
+#include "trcUser.h"\r
+\r
+/* Variables used in the creation of the run time stats time base. Run time \r
+stats record how much time each task spends in the Running state. */\r
+static long long llInitialRunTimeCounterValue = 0LL, llTicksPerHundedthMillisecond = 0LL;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void vConfigureTimerForRunTimeStats( void )\r
+{\r
+LARGE_INTEGER liPerformanceCounterFrequency, liInitialRunTimeValue;\r
+\r
+ /* Initialise the variables used to create the run time stats time base.\r
+ Run time stats record how much time each task spends in the Running \r
+ state. */\r
+\r
+ if( QueryPerformanceFrequency( &liPerformanceCounterFrequency ) == 0 )\r
+ {\r
+ llTicksPerHundedthMillisecond = 1;\r
+ }\r
+ else\r
+ {\r
+ /* How many times does the performance counter increment in 1/100th\r
+ millisecond. */\r
+ llTicksPerHundedthMillisecond = liPerformanceCounterFrequency.QuadPart / 100000LL;\r
+\r
+ /* What is the performance counter value now, this will be subtracted\r
+ from readings taken at run time. */\r
+ QueryPerformanceCounter( &liInitialRunTimeValue );\r
+ llInitialRunTimeCounterValue = liInitialRunTimeValue.QuadPart;\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+unsigned long ulGetRunTimeCounterValue( void )\r
+{\r
+LARGE_INTEGER liCurrentCount;\r
+unsigned long ulReturn;\r
+\r
+ /* What is the performance counter value now? */\r
+ QueryPerformanceCounter( &liCurrentCount );\r
+\r
+ /* Subtract the performance counter value reading taken when the \r
+ application started to get a count from that reference point, then\r
+ scale to (simulated) 1/100ths of a millisecond. */\r
+ if( llTicksPerHundedthMillisecond == 0 )\r
+ {\r
+ /* The trace macros are probably calling this function before the\r
+ scheduler has been started. */\r
+ ulReturn = 0;\r
+ }\r
+ else\r
+ {\r
+ ulReturn = ( unsigned long ) ( ( liCurrentCount.QuadPart - llInitialRunTimeCounterValue ) / llTicksPerHundedthMillisecond );\r
+ }\r
+\r
+ return ulReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
--- /dev/null
+/*******************************************************************************\r
+ * FreeRTOS+Trace v2.2.2 Recorder Library\r
+ * Percepio AB, www.percepio.se\r
+ *\r
+ * trcConfig.h\r
+ *\r
+ * Configuration parameters for the trace recorder library. Before using the \r
+ * trace recorder library, please check that the default settings are \r
+ * appropriate for your system, and if necessary adjust these. Most likely, you \r
+ * will need to adjust the NTask, NISR, NQueue, NMutex and NSemaphore values to \r
+ * reflect the number of such objects in your system. These may be \r
+ * overapproximated, although larger values values implies more RAM usage.\r
+ *\r
+ * Terms of Use\r
+ * This software is copyright Percepio AB. The recorder library is free for\r
+ * use together with Percepio products. You may distribute the recorder library\r
+ * in its original form, including modifications in trcPort.c and trcPort.h\r
+ * given that these modification are clearly marked as your own modifications\r
+ * and documented in the initial comment section of these source files. \r
+ * This software is the intellectual property of Percepio AB and may not be \r
+ * sold or in other ways commercially redistributed without explicit written \r
+ * permission by Percepio AB.\r
+ *\r
+ * Disclaimer \r
+ * The trace tool and recorder library is being delivered to you AS IS and \r
+ * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
+ * not and cannot warrant the performance or results you may obtain by using the \r
+ * software or documentation. Percepio AB make no warranties, express or \r
+ * implied, as to noninfringement of third party rights, merchantability, or \r
+ * fitness for any particular purpose. In no event will Percepio AB, its \r
+ * technology partners, or distributors be liable to you for any consequential, \r
+ * incidental or special damages, including any lost profits or lost savings, \r
+ * even if a representative of Percepio AB has been advised of the possibility \r
+ * of such damages, or for any claim by any third party. Some jurisdictions do \r
+ * not allow the exclusion or limitation of incidental, consequential or special \r
+ * damages, or the exclusion of implied warranties or limitations on how long an \r
+ * implied warranty may last, so the above limitations may not apply to you.\r
+ *\r
+ * FreeRTOS+Trace is available as Free Edition and in two premium editions.\r
+ * You may use the premium features during 30 days for evaluation.\r
+ * Download FreeRTOS+Trace at http://www.percepio.se/index.php?page=downloads\r
+ *\r
+ * Copyright Percepio AB, 2012.\r
+ * www.percepio.se\r
+ ******************************************************************************/\r
+\r
+#ifndef TRCCONFIG_H\r
+#define TRCCONFIG_H\r
+\r
+/*******************************************************************************\r
+ * CONFIGURATION RELATED TO CAPACITY AND ALLOCATION \r
+ ******************************************************************************/\r
+\r
+/*******************************************************************************\r
+ * EVENT_BUFFER_SIZE\r
+ *\r
+ * Macro which should be defined as an integer value.\r
+ *\r
+ * This defines the capacity of the event buffer, i.e., the number of records\r
+ * it may store. Each registered event typically use one record (4 byte), but\r
+ * vTracePrintF may use multiple records depending on the number of data args.\r
+ ******************************************************************************/\r
+\r
+#if WIN32\r
+ #define EVENT_BUFFER_SIZE 3000\r
+#else\r
+ #define EVENT_BUFFER_SIZE 1000 /* Adjust wrt. to available RAM */\r
+#endif\r
+\r
+/*******************************************************************************\r
+ * SYMBOL_TABLE_SIZE\r
+ *\r
+ * Macro which should be defined as an integer value.\r
+ *\r
+ * This defines the capacity of the symbol table, in bytes. This symbol table \r
+ * stores User Events labels and names of deleted tasks, queues, or other kernel\r
+ * objects. Note that the names of active objects not stored here but in the \r
+ * Object Table. Thus, if you don't use User Events or delete any kernel \r
+ * objects you set this to zero (0) to minimize RAM usage.\r
+ ******************************************************************************/\r
+#define SYMBOL_TABLE_SIZE 1000\r
+\r
+/*******************************************************************************\r
+ * NTask, NISR, NQueue, NSemaphore, NMutex\r
+ *\r
+ * A group of Macros which should be defined as an integer value of zero (0) \r
+ * or larger.\r
+ *\r
+ * This defines the capacity of the Object Property Table - the maximum number\r
+ * of objects active at any given point within each object class.\r
+ * \r
+ * NOTE: In case objects are deleted and created during runtime, this setting\r
+ * does not limit the total amount of objects, only the number of concurrently\r
+ * active objects. \r
+ *\r
+ * Using too small values will give an error message through the vTraceError\r
+ * routine, which makes the error message appear when opening the trace data\r
+ * in FreeRTOS+Trace. If you are using the recorder status monitor task,\r
+ * any error messages are displayed in console prints, assuming that the\r
+ * print macro has been defined properly (vConsolePrintMessage).\r
+ * \r
+ * NOTE 2: If you include the monitor task (USE_TRACE_PROGRESS_MONITOR_TASK)\r
+ * make sure to dimension NTask with this task accounted for.\r
+ *\r
+ * Also remember to account for all tasks created by FreeRTOS, such as the \r
+ * IDLE task, the FreeRTOS timer task, and any tasks created by other 3rd party \r
+ * software components, such as communication stacks.\r
+ * Moreover, one task slot is used to indicate "(startup)", i.e., a "task" that \r
+ * represent the time before the first task starts. NTask should thus be at \r
+ * least 2-3 slots larger than your application task count.\r
+ *\r
+ * NOTE 3: The FreeRTOS timer task creates a Queue, that should be accounted \r
+ * for in NQueue.\r
+ ******************************************************************************/\r
+#define NTask 500\r
+#define NISR 500\r
+#define NQueue 500\r
+#define NSemaphore 500\r
+#define NMutex 500\r
+\r
+/* Maximum object name length for each class (includes zero termination) */\r
+#define NameLenTask configMAX_TASK_NAME_LEN\r
+#define NameLenISR 10\r
+#define NameLenQueue 15\r
+#define NameLenSemaphore 15\r
+#define NameLenMutex 15\r
+\r
+/******************************************************************************\r
+ * TRACE_DESCRIPTION\r
+ *\r
+ * Macro which should be defined as a string.\r
+ *\r
+ * This string is stored in the trace and displayed in FreeRTOS+Trace. Can be\r
+ * used to store, e.g., system version or build date. This is also used to store\r
+ * internal error messages from the recorder, which if occurs overwrites the\r
+ * value defined here. This may be maximum 256 chars.\r
+ *****************************************************************************/\r
+#define TRACE_DESCRIPTION "FreeRTOS+Trace Demo"\r
+\r
+/******************************************************************************\r
+ * TRACE_DESCRIPTION_MAX_LENGTH\r
+ *\r
+ * The maximum length (including zero termination) for the TRACE_DESCRIPTION\r
+ * string. Since this string also is used for internal error messages from the \r
+ * recorder do not make it too short, as this may truncate the error messages.\r
+ * Default is 80. \r
+ * Maximum allowed length is 256 - the trace will fail to load if longer.\r
+ *****************************************************************************/\r
+#define TRACE_DESCRIPTION_MAX_LENGTH 80\r
+\r
+\r
+/******************************************************************************\r
+ * TRACE_DATA_ALLOCATION\r
+ *\r
+ * This defines how to allocate the recorder data structure, i.e., using a \r
+ * static declaration or using a dynamic allocation in runtime (malloc).\r
+ *\r
+ * Should be one of these two options:\r
+ * - TRACE_DATA_ALLOCATION_STATIC (default)\r
+ * - TRACE_DATA_ALLOCATION_DYNAMIC\r
+ *\r
+ * Using static allocation has the benefits of compile-time errors if the buffer \r
+ * is too large (too large constants in trcConfig.h) and no need to call the \r
+ * initialization routine (xTraceInitTraceData).\r
+ *\r
+ * Using dynamic allocation may give more flexibility in some cases.\r
+ *****************************************************************************/\r
+\r
+#define TRACE_DATA_ALLOCATION TRACE_DATA_ALLOCATION_STATIC\r
+\r
+\r
+/******************************************************************************\r
+ * CONFIGURATION REGARDING WHAT CODE/FEATURES TO INCLUDE\r
+ *****************************************************************************/\r
+\r
+/******************************************************************************\r
+ * INCLUDE_USER_EVENTS\r
+ *\r
+ * Macro which should be defined as either zero (0) or one (1). \r
+ * Default is 1.\r
+ *\r
+ * If this is zero (0) the code for creating User Events is excluded to\r
+ * reduce code size. User Events are application-generated events, like \r
+ * "printf" but for the trace log instead of console output. User Events are \r
+ * much faster than a printf and can therefore be used in timing critical code.\r
+ * See vTraceUserEvent() and vTracePrintF() in trcUser.h\r
+ * \r
+ * Note that FreeRTOS+Trace Standard Edition or Professional Edition is required\r
+ * for User Events, they are not displayed in FreeRTOS+Trace Free Edition.\r
+ *****************************************************************************/\r
+#define INCLUDE_USER_EVENTS 1\r
+\r
+/*****************************************************************************\r
+ * INCLUDE_ISR_TRACING\r
+ *\r
+ * Macro which should be defined as either zero (0) or one (1). \r
+ * Default is 1.\r
+ *\r
+ * If this is zero (0), the code for recording Interrupt Service Routines is \r
+ * excluded to reduce code size. Note, recording ISRs require that you insert\r
+ * calls to vTraceStoreISRBegin and vTraceStoreISREnd in your interrupt handlers.\r
+ * There is no automatic recording of ISRs like for task scheduling, since \r
+ * FreeRTOS does not have a central interrupt dispatcher.\r
+ *****************************************************************************/\r
+#define INCLUDE_ISR_TRACING 1\r
+\r
+/******************************************************************************\r
+ * INCLUDE_OBJECT_DELETE\r
+ * \r
+ * Macro which should be defined as either zero (0) or one (1). \r
+ * Default is 1.\r
+ *\r
+ * This must be enabled (1) if tasks, queues or other \r
+ * traced kernel objects are deleted at runtime, e.g., using vTaskDelete or \r
+ * vQueueDelete. If no deletes are made, this can be set to 0 in order to\r
+ * exclude the delete-handling code. \r
+ *****************************************************************************/\r
+#define INCLUDE_OBJECT_DELETE 1\r
+\r
+/******************************************************************************\r
+ * CONFIGURATION RELATED TO BEHAVIOR\r
+ *****************************************************************************/\r
+\r
+/******************************************************************************\r
+ * RECORDER_STORE_MODE\r
+ *\r
+ * Macro which should be defined as one of:\r
+ * - STORE_MODE_RING_BUFFER\r
+ * - STORE_MODE_STOP_WHEN_FULL\r
+ * Default is STORE_MODE_RING_BUFFER.\r
+ *\r
+ * With RECORDER_STORE_MODE set to STORE_MODE_RING_BUFFER, the events are stored\r
+ * in a ring buffer, i.e., where the oldest events are overwritten when the\r
+ * buffer becomes full. This allows you to get the last events leading up to an\r
+ * interesting state, e.g., an error, without having a large trace buffer for\r
+ * string the whole run since startup. In this mode, the recorder can run\r
+ * "forever" as the buffer never gets full, i.e., in the sense that it always\r
+ * has room for more events.\r
+ *\r
+ * To fetch the trace in mode STORE_MODE_RING_BUFFER, you need to first halt the\r
+ * system using your debugger and then do a RAM dump, or to explicitly stop the\r
+ * recorder using vTraceStop() and then store/upload the trace data using a\r
+ * FreeRTOS task that you need to provide yourself. The trace data is found in\r
+ * the struct RecorderData, initialized in trcBase.c.\r
+ *\r
+ * Note that, if you upload the trace using a RAM dump, i.e., when the system is \r
+ * halted on a breakpoint or by a debugger command, there is no need to stop the \r
+ * recorder first.\r
+ *\r
+ * When RECORDER_STORE_MODE is STORE_MODE_STOP_WHEN_FULL, the recording is\r
+ * stopped when the buffer becomes full. When the recorder stops itself this way\r
+ * vTracePortEnd() is called which allows for custom actions, such as triggering\r
+ * a task that stores the trace buffer, i.e., in case taking a RAM dump\r
+ * using an on-chip debugger is not possible. In the Windows port, vTracePortEnd\r
+ * saves the trace to file directly, but this is not recommended in a real-time\r
+ * system since the scheduler is blocked during the processing of vTracePortEnd.\r
+ *****************************************************************************/\r
+#define RECORDER_STORE_MODE STORE_MODE_RING_BUFFER\r
+/*#define RECORDER_STORE_MODE STORE_MODE_STOP_WHEN_FULL*/\r
+\r
+/******************************************************************************\r
+ * STOP_AFTER_N_EVENTS\r
+ *\r
+ * Macro which should be defined as an integer value, or not defined.\r
+ * Default is -1\r
+ *\r
+ * STOP_AFTER_N_EVENTS is intended for tests of the ring buffer mode (when\r
+ * RECORDER_STORE_MODE is STORE_MODE_RING_BUFFER). It stops the recording when\r
+ * the specified number of events has been observed. This value can be larger\r
+ * than the buffer size, to allow for test of the "wrapping around" that occurs\r
+ * in ring buffer mode . A negative value (or no definition of this macro)\r
+ * disables this feature.\r
+ *****************************************************************************/\r
+#define STOP_AFTER_N_EVENTS -1\r
+\r
+/******************************************************************************\r
+ * USE_IMPLICIT_IFE_RULES\r
+ *\r
+ * Macro which should be defined as either zero (0) or one (1). \r
+ * Default is 1.\r
+ *\r
+ * ### Instance Finish Events (IFE) ###\r
+ *\r
+ * For tasks with "infinite" main loops (non-terminating tasks), the concept\r
+ * of a task instance has no clear definition, it is an application-specific\r
+ * thing. FreeRTOS+Trace allows you to define Instance Finish Events (IFEs),\r
+ * which marks the point in a cyclic task when the "task instance" ends.\r
+ * The IFE is a blocking kernel call, typically in the main loop of a task\r
+ * which typically reads a message queue, waits for a semaphore or performs\r
+ * an explicit delay.\r
+ *\r
+ * If USE_IMPLICIT_IFE_RULES is one (1), the following FreeRTOS kernel calls\r
+ * are considered by default to be IFEs (Implicit IFEs):\r
+ * - vTaskDelay\r
+ * - vTaskDelayUntil\r
+ * - vTaskSuspend\r
+ * - xQueueReceive (blocking cases only)\r
+ * - xSemaphoreTake (blocking cases only)\r
+ *\r
+ * However, Implicit IFEs only applies to blocking kernel calls. If an\r
+ * xQueueReceive reads a message without blocking, it does not create a new\r
+ * instance since no blocking occurred.\r
+ *\r
+ * Moreover, the actual IFE might sometimes be another blocking call such as\r
+ * xQueueSend or xSemaphoreGive. We therefore allow for user-defined\r
+ * Explicit IFEs by calling\r
+ *\r
+ * vTraceTaskInstanceIsFinished()\r
+ *\r
+ * right before the kernel call considered as IFE. This does not create an\r
+ * additional event but instead stores the service code and object handle\r
+ * of the IFE call as properties of the task.\r
+ *\r
+ * If using Explicit IFEs and the task also calls an Implicit IFE like\r
+ * vTaskDelay, this may result in additional incorrect task instances.\r
+ * This is solved by disabling the Implicit IFEs for the task, by adding\r
+ * a call to\r
+ * \r
+ * vTraceTaskSkipDefaultInstanceFinishedEvents()\r
+ * \r
+ * in the very beginning of that task. This allows you to combine Explicit IFEs\r
+ * for some tasks with Implicit IFEs for the rest of the tasks, if\r
+ * USE_IMPLICIT_IFE_RULES is 1.\r
+ *\r
+ * By setting USE_IMPLICIT_IFE_RULES to zero (0), the implicit IFEs are disabled\r
+ * for all tasks. Tasks will then be considered to have a single instance only, \r
+ * covering all execution fragments, unless you define an explicit IFE in each\r
+ * task by calling vTraceTaskInstanceIsFinished before the blocking call.\r
+ *****************************************************************************/\r
+#define USE_IMPLICIT_IFE_RULES 1\r
+\r
+/******************************************************************************\r
+ * INCLUDE_SAVE_TO_FILE\r
+ *\r
+ * Macro which should be defined as either zero (0) or one (1).\r
+ * Default is 0.\r
+ *\r
+ * If enabled (1), the recorder will include code for saving the trace\r
+ * to a local file system.\r
+ ******************************************************************************/\r
+#ifdef WIN32\r
+ #define INCLUDE_SAVE_TO_FILE 1\r
+#else\r
+ #define INCLUDE_SAVE_TO_FILE 0\r
+#endif\r
+\r
+/******************************************************************************\r
+ * TRACE_PROGRESS_MONITOR_TASK_PRIORITY\r
+ *\r
+ * Macro which sets the priority of the "recorder status monitor" task.\r
+ *\r
+ * This task, vTraceMonitorTask in trcUser.c, periodically writes\r
+ * the recorder status using the vTraceConsoleMessage macro, which is to\r
+ * be mapped to your console "printf" routine. The task is named TraceMon but \r
+ * is intentionally excluded from the demo trace.\r
+ *\r
+ * Default is tskIDLE_PRIORITY + 1\r
+ * Note that if your system constantly has a high CPU load from high-priority \r
+ * tasks, this might not be get a chance to execute.\r
+ * \r
+ * See vTraceMonitorTask in trcUser.c\r
+ *****************************************************************************/\r
+#define TRACE_PROGRESS_MONITOR_TASK_PRIORITY (tskIDLE_PRIORITY + 3)\r
+\r
+/******************************************************************************\r
+ * TRACE_PROGRESS_MONITOR_TASK_STACKSIZE\r
+ *\r
+ * Macro which sets the stack size of the "recorder status monitor" task.\r
+ *\r
+ * This task, vTraceMonitorTask in trcUser.c, periodically writes\r
+ * the recorder status using the vTraceConsoleMessage macro, which is to\r
+ * be mapped to your console "printf" routine. The task is intentionally \r
+ * excluded from the demo trace.\r
+ *\r
+ * See vTraceMonitorTask in trcUser.c\r
+ *****************************************************************************/\r
+#define TRACE_PROGRESS_MONITOR_TASK_STACKSIZE 500\r
+\r
+/******************************************************************************\r
+ * TRACE_PROGRESS_MONITOR_TASK_PERIOD\r
+ *\r
+ * Macro which sets the period of the "recorder status monitor" task.\r
+ *\r
+ * This task, vTraceMonitorTask in trcUser.c, periodically writes\r
+ * the recorder status using the vTraceConsoleMessage macro, which is to\r
+ * be mapped to your console "printf" routine. The task is named TraceMon but \r
+ * is intentionally excluded from the demo trace.\r
+ *\r
+ * Default is 1000 FreeRTOS ticks (typically 1 second). On the Windows port, a \r
+ * lower value is suggested since the Windows port runs very slowly, often 20-40\r
+ * times slower than the simulated FreeRTOS time.\r
+ *\r
+ * See vTraceMonitorTask in trcUser.c\r
+ *****************************************************************************/\r
+#if WIN32\r
+ #define TRACE_PROGRESS_MONITOR_TASK_PERIOD 100\r
+#else\r
+ #define TRACE_PROGRESS_MONITOR_TASK_PERIOD 1000\r
+#endif\r
+\r
+/******************************************************************************\r
+ * TEAM_LICENSE_CODE\r
+ *\r
+ * Macro which defines a string - the team license code.\r
+ * If no team license is available, this should be an empty string "".\r
+ * This should be maximum 32 chars, including zero-termination.\r
+ *****************************************************************************/\r
+#define TEAM_LICENSE_CODE ""\r
+\r
+#endif\r
+\r
--- /dev/null
+/******************************************************************************* \r
+ * FreeRTOS+Trace v2.3.0 Recorder Library\r
+ * Percepio AB, www.percepio.com\r
+ *\r
+ * trcPort.h\r
+ *\r
+ * Contains together with trcPort.c all portability issues of the trace recorder \r
+ * library.\r
+ *\r
+ * Terms of Use\r
+ * This software is copyright Percepio AB. The recorder library is free for\r
+ * use together with Percepio products. You may distribute the recorder library\r
+ * in its original form, including modifications in trcPort.c and trcPort.h\r
+ * given that these modification are clearly marked as your own modifications\r
+ * and documented in the initial comment section of these source files. \r
+ * This software is the intellectual property of Percepio AB and may not be \r
+ * sold or in other ways commercially redistributed without explicit written \r
+ * permission by Percepio AB.\r
+ *\r
+ * Disclaimer \r
+ * The trace tool and recorder library is being delivered to you AS IS and \r
+ * Percepio AB makes no warranty as to its use or performance. Percepio AB does \r
+ * not and cannot warrant the performance or results you may obtain by using the \r
+ * software or documentation. Percepio AB make no warranties, express or \r
+ * implied, as to noninfringement of third party rights, merchantability, or \r
+ * fitness for any particular purpose. In no event will Percepio AB, its \r
+ * technology partners, or distributors be liable to you for any consequential, \r
+ * incidental or special damages, including any lost profits or lost savings, \r
+ * even if a representative of Percepio AB has been advised of the possibility \r
+ * of such damages, or for any claim by any third party. Some jurisdictions do \r
+ * not allow the exclusion or limitation of incidental, consequential or special \r
+ * damages, or the exclusion of implied warranties or limitations on how long an \r
+ * implied warranty may last, so the above limitations may not apply to you.\r
+ *\r
+ * FreeRTOS+Trace is available as Free Edition and in two premium editions.\r
+ * You may use the premium features during 30 days for evaluation.\r
+ * Download FreeRTOS+Trace at http://www.percepio.com/products/downloads/\r
+ *\r
+ * Copyright Percepio AB, 2012.\r
+ * www.percepio.com\r
+ ******************************************************************************/\r
+\r
+#ifndef TRCPORT_H\r
+#define TRCPORT_H\r
+\r
+/* If FreeRTOS Win32 port */\r
+#ifdef WIN32\r
+\r
+ #undef _WIN32_WINNT\r
+ #define _WIN32_WINNT 0x0600\r
+\r
+ /* Standard includes. */\r
+ #include <stdio.h>\r
+ #include <windows.h>\r
+ #include <direct.h>\r
+\r
+/*******************************************************************************\r
+ * The Win32 port by default saves the trace to file and then kills the\r
+ * program when the recorder is stopped, to facilitate quick, simple tests\r
+ * of the recorder.\r
+ ******************************************************************************/\r
+ #define WIN32_PORT_SAVE_WHEN_STOPPED 1\r
+ #define WIN32_PORT_EXIT_WHEN_STOPPED 1\r
+#else\r
+ #define WIN32_PORT_SAVE_WHEN_STOPPED 0\r
+ #define WIN32_PORT_EXIT_WHEN_STOPPED 0\r
+#endif\r
+\r
+#define DIRECTION_INCREMENTING 1\r
+#define DIRECTION_DECREMENTING 2\r
+\r
+/******************************************************************************\r
+ * Supported ports\r
+ * \r
+ * PORT_HWIndependent\r
+ * A hardware independent fallback option for event timestamping. Provides low \r
+ * resolution timestamps based on the OS tick.\r
+ * This may be used on the Win32 port, but may also be used on embedded hardware \r
+ * platforms. Note that this gives suboptimal display in FreeRTOS+Trace. All \r
+ * time durations will be truncated to the OS tick frequency, typically 1 KHz. \r
+ * This means that a task or ISR that executes in less than 1 ms get an exection \r
+ * time of zero. They are however still visible in FreeRTOS+Trace. \r
+ *\r
+ * PORT_Win32\r
+ * "Accurate" timestamping based on the Windows permance counter. Note that\r
+ * this gives the host machine time, not the simulated FreeRTOS time (tick \r
+ * count). The timing of the Win32 FreeRTOS build is not real-time, since it \r
+ * depends on the scheduling and tick rate of Windows, which is very slow.\r
+ *\r
+ * Officially supported hardware timer ports:\r
+ * - PORT_Atmel_AT91SAM7\r
+ * - PORT_Atmel_UC3A0\r
+ * - PORT_ARM_CortexM \r
+ * - PORT_Renesas_RX600\r
+ * - PORT_Microchip_dsPIC_AND_PIC24\r
+ *\r
+ * We also provide several "unofficial" hardware-specific ports. There have \r
+ * been developed by external contributors, and have not yet been verified \r
+ * by Percepio AB. Let us know if you have problems getting these to work.\r
+ * \r
+ * Unoffical hardware specific ports provided are:\r
+ * - PORT_TEXAS_INSTRUMENTS_TMS570\r
+ * - PORT_TEXAS_INSTRUMENTS_MSP430\r
+ * - PORT_MICROCHIP_PIC32\r
+ * - PORT_XILINX_PPC405\r
+ * - PORT_XILINX_PPC440\r
+ * - PORT_XILINX_MICROBLAZE\r
+ * - PORT_NXP_LPC210X\r
+ *\r
+ *****************************************************************************/\r
+\r
+#define PORT_NOT_SET -1\r
+\r
+/*** Officially supported hardware timer ports *******************************/\r
+#define PORT_HWIndependent 0\r
+#define PORT_Win32 1\r
+#define PORT_Atmel_AT91SAM7 2\r
+#define PORT_Atmel_UC3A0 3\r
+#define PORT_ARM_CortexM 4\r
+#define PORT_Renesas_RX600 5\r
+#define PORT_Microchip_dsPIC_AND_PIC24 6\r
+\r
+/*** Unofficial ports, provided by external developers, not yet verified *****/\r
+#define PORT_TEXAS_INSTRUMENTS_TMS570 7\r
+#define PORT_TEXAS_INSTRUMENTS_MSP430 8\r
+#define PORT_MICROCHIP_PIC32 9\r
+#define PORT_XILINX_PPC405 10\r
+#define PORT_XILINX_PPC440 11\r
+#define PORT_XILINX_MICROBLAZE 12\r
+#define PORT_NXP_LPC210X 13\r
+\r
+/*** Select your port here! **************************************************/\r
+#define SELECTED_PORT PORT_Win32\r
+/*****************************************************************************/\r
+\r
+#if (SELECTED_PORT == PORT_NOT_SET) \r
+#error "You need to define SELECTED_PORT here!"\r
+#endif\r
+\r
+/*******************************************************************************\r
+ * IRQ_PRIORITY_ORDER\r
+ *\r
+ * Macro which should be defined as an integer of 0 or 1.\r
+ *\r
+ * This should be 0 if lower irq priority values implies higher priority \r
+ * levels, such as on ARM Cortex M. If the opposite scheme is used, i.e., \r
+ * if higher irq priority values means higher priority, this should be 1.\r
+ *\r
+ * This setting is not critical. It is used only to sort and colorize the \r
+ * interrupts in priority order, in case you record interrupts using\r
+ * the vTraceStoreISRBegin and vTraceStoreISREnd routines.\r
+ *\r
+ * We provide this setting for some hardware architectures below:\r
+ * - ARM Cortex M: 0 (lower irq priority values are more significant)\r
+ * - Atmel AT91SAM7x: 1 (higher irq priority values are more significant)\r
+ * - Atmel AVR32: 1 (higher irq priority values are more significant)\r
+ * - Renesas RX600: 1 (higher irq priority values are more significant)\r
+ * - Microchip PIC24: 0 (lower irq priority values are more significant)\r
+ * - Microchip dsPIC: 0 (lower irq priority values are more significant)\r
+ * - TI TMS570: 0 (lower irq priority values are more significant)\r
+ * - Freescale HCS08: 0 (lower irq priority values are more significant)\r
+ * - Freescale HCS12: 0 (lower irq priority values are more significant)\r
+ * - PowerPC 405: 0 (lower irq priority values are more significant)\r
+ * - PowerPC 440: 0 (lower irq priority values are more significant)\r
+ * - Freescale ColdFire: 1 (higher irq priority values are more significant)\r
+ * - NXP LPC210x: 0 (lower irq priority values are more significant)\r
+ * - MicroBlaze: 0 (lower irq priority values are more significant)\r
+ *\r
+ * If your chip is not on the above list, and you perhaps know this detail by \r
+ * heart, please inform us by e-mail to support@percepio.com.\r
+ *\r
+ ******************************************************************************\r
+ *\r
+ * HWTC Macros \r
+ *\r
+ * These four HWTC macros provides a hardware isolation layer representing a \r
+ * generic hardware timer/counter used for driving the operating system tick, \r
+ * such as the SysTick feature of ARM Cortex M3/M4, or the PIT of the Atmel \r
+ * AT91SAM7X.\r
+ *\r
+ * HWTC_COUNT: The current value of the counter. This is expected to be reset \r
+ * a each tick interrupt. Thus, when the tick handler starts, the counter has \r
+ * already wrapped.\r
+ *\r
+ * HWTC_COUNT_DIRECTION: Should be one of:\r
+ * - DIRECTION_INCREMENTING - for hardware timer/counters of incrementing type\r
+ * such as the PIT on Atmel AT91SAM7X.\r
+ * When the counter value reach HWTC_PERIOD, it is reset to zero and the\r
+ * interrupt is signaled.\r
+ * - DIRECTION_DECREMENTING - for hardware timer/counters of decrementing type\r
+ * such as the SysTick on ARM Cortex M3/M4 chips.\r
+ * When the counter value reach 0, it is reset to HWTC_PERIOD and the\r
+ * interrupt is signaled.\r
+ *\r
+ * HWTC_PERIOD: The number of increments or decrements of HWTC_COUNT between\r
+ * two tick interrupts. This should preferably be mapped to the reload\r
+ * register of the hardware timer, to make it more portable between chips in the \r
+ * same family. The macro should in most cases be (reload register + 1).\r
+ *\r
+ * HWTC_DIVISOR: If the timer frequency is very high, like on the Cortex M chips\r
+ * (where the SysTick runs at the core clock frequency), the "differential \r
+ * timestamping" used in the recorder will more frequently insert extra XTS \r
+ * events to store the timestamps, which increases the event buffer usage. \r
+ * In such cases, to reduce the number of XTS events and thereby get longer \r
+ * traces, you use HWTC_DIVISOR to scale down the timestamps and frequency.\r
+ * Assuming a OS tick rate of 1 KHz, it is suggested to keep the effective timer\r
+ * frequency below 65 MHz to avoid an excessive amount of XTS events. Thus, a\r
+ * Cortex M chip running at 72 MHZ should use a HWTC_DIVISOR of 2, while a \r
+ * faster chip require a higher HWTC_DIVISOR value. \r
+ *\r
+ * The HWTC macros and uiTracePortGetTimeStamp is the main porting issue\r
+ * or the trace recorder library. Typically you should not need to change\r
+ * the code of uiTracePortGetTimeStamp if using the HWTC macros.\r
+ *\r
+ * FREE LICENSE OFFER FROM PERCEPIO\r
+ *\r
+ * For silicon companies and non-corporate FreeRTOS users (researchers, students,\r
+ * hobbyists or early-phase startups) we have the following offer: \r
+ * Provide a hardware port for our FreeRTOS recorder and get a FREE single-user\r
+ * license for FreeRTOS+Trace Professional Edition. Read more about this offer\r
+ * at www.percepio.com or contact us directly at support@percepio.com.\r
+ *\r
+ ******************************************************************************/\r
+\r
+#if (SELECTED_PORT == PORT_Win32)\r
+ \r
+ #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+ #define HWTC_COUNT (ulGetRunTimeCounterValue())\r
+ #define HWTC_PERIOD 0\r
+ #define HWTC_DIVISOR 1\r
+ \r
+ #define IRQ_PRIORITY_ORDER 1 // Please update according to your hardware...\r
+\r
+#elif (SELECTED_PORT == PORT_HWIndependent)\r
+ \r
+ #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+ #define HWTC_COUNT 0\r
+ #define HWTC_PERIOD 1\r
+ #define HWTC_DIVISOR 1\r
+\r
+ #define IRQ_PRIORITY_ORDER 1 // Please update according to your hardware...\r
+\r
+#elif (SELECTED_PORT == PORT_Atmel_AT91SAM7)\r
+\r
+ /* HWTC_PERIOD is hardcoded for AT91SAM7X256-EK Board (48 MHz)\r
+ A more generic solution is to get the period from pxPIT->PITC_PIMR */\r
+ \r
+ #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+ #define HWTC_COUNT (AT91C_BASE_PITC->PITC_PIIR & 0xFFFFF)\r
+ #define HWTC_PERIOD 2995 \r
+ #define HWTC_DIVISOR 1\r
+\r
+ #define IRQ_PRIORITY_ORDER 1 // higher irq priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_Atmel_UC3A0) \r
+ \r
+ /* For Atmel AVR32 (AT32UC3A) */\r
+ \r
+ #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+ #define HWTC_COUNT sysreg_read(AVR32_COUNT)\r
+ #define HWTC_PERIOD ( configCPU_CLOCK_HZ / configTICK_RATE_HZ )\r
+ #define HWTC_DIVISOR 1 \r
+\r
+ #define IRQ_PRIORITY_ORDER 1 // higher irq priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_ARM_CortexM)\r
+\r
+ /* For all chips using ARM Cortex M cores */\r
+\r
+ #define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING\r
+ #define HWTC_COUNT (*((uint32_t*)0xE000E018))\r
+ #define HWTC_PERIOD ((*(uint32_t*)0xE000E014) + 1)\r
+ #define HWTC_DIVISOR 2\r
+ \r
+ #define IRQ_PRIORITY_ORDER 0 // lower irq priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_Renesas_RX600) \r
+\r
+ #include "iodefine.h"\r
+\r
+ #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+ #define HWTC_COUNT (CMT0.CMCNT)\r
+ #define HWTC_PERIOD ((((configPERIPHERAL_CLOCK_HZ/configTICK_RATE_HZ)-1)/8))\r
+ #define HWTC_DIVISOR 1\r
+\r
+ #define IRQ_PRIORITY_ORDER 1 // higher irq priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_Microchip_dsPIC_AND_PIC24) \r
+\r
+ /* For Microchip PIC24 and dsPIC (16 bit) */\r
+\r
+ /* Note: The trace library was originally designed for 32-bit MCUs, and is slower\r
+ than intended on 16-bit MCUs. Storing an event on a PIC24 takes about 70 µs. \r
+ In comparison, 32-bit MCUs are often 10-20 times faster. If recording overhead \r
+ becomes a problem on PIC24, use the filters to exclude less interresting tasks \r
+ or system calls. */\r
+\r
+ #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+ #define HWTC_COUNT (TMR1)\r
+ #define HWTC_PERIOD (PR1+1)\r
+ #define HWTC_DIVISOR 1\r
+\r
+ #define IRQ_PRIORITY_ORDER 0 // lower irq priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_NXP_LPC210X)\r
+ /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
+ \r
+ /* Tested with LPC2106, but should work with most LPC21XX chips.\r
+ Assumption: prescaler is 1:1 (this setting is hardcoded in \r
+ FreeRTOS port for LPC21XX) */\r
+ \r
+ #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+ #define HWTC_COUNT *((uint32_t *)0xE0004008 )\r
+ #define HWTC_PERIOD ( configCPU_CLOCK_HZ / configTICK_RATE_HZ ) \r
+ #define HWTC_DIVISOR 1 \r
+\r
+ #define IRQ_PRIORITY_ORDER 0 // lower irq priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_TEXAS_INSTRUMENTS_TMS570)\r
+ /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
+\r
+ #define RTIFRC0 *((uint32_t *)0xFFFFFC10)\r
+ #define RTICOMP0 *((uint32_t *)0xFFFFFC50)\r
+ #define RTIUDCP0 *((uint32_t *)0xFFFFFC54)\r
+ #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+ #define HWTC_COUNT (RTIFRC0 - (RTICOMP0 - RTIUDCP0))\r
+ #define HWTC_PERIOD (RTIUDCP0)\r
+ #define HWTC_DIVISOR 1\r
+\r
+ #define IRQ_PRIORITY_ORDER 0 // lower irq priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_TEXAS_INSTRUMENTS_MSP430)\r
+ /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
+\r
+ #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+ #define HWTC_COUNT (TA0R)\r
+ #define HWTC_PERIOD configCPU_CLOCKS_PER_TICK \r
+ #define HWTC_DIVISOR 1\r
+\r
+ #define IRQ_PRIORITY_ORDER 1 // higher irq priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_MICROCHIP_PIC32)\r
+ /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
+\r
+ #define HWTC_COUNT_DIRECTION DIRECTION_INCREMENTING\r
+ #define HWTC_COUNT (ReadTimer1()) /* Should be available in BSP */\r
+ #define HWTC_PERIOD (ReadPeriod1()+1) /* Should be available in BSP */\r
+ #define HWTC_DIVISOR 1\r
+\r
+ #define IRQ_PRIORITY_ORDER 0 // lower irq priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_XILINX_PPC405) \r
+ /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
+\r
+ #define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING\r
+ #define HWTC_COUNT mfspr( 0x3db)\r
+ #define HWTC_PERIOD ( configCPU_CLOCK_HZ / configTICK_RATE_HZ )\r
+ #define HWTC_DIVISOR 1\r
+\r
+ #define IRQ_PRIORITY_ORDER 0 // lower irq priority values are more significant\r
+\r
+#elif (SELECTED_PORT == PORT_XILINX_PPC440) \r
+ /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
+\r
+ /* This should work with most PowerPC chips */\r
+ \r
+ #define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING\r
+ #define HWTC_COUNT mfspr( 0x016 )\r
+ #define HWTC_PERIOD ( configCPU_CLOCK_HZ / configTICK_RATE_HZ )\r
+ #define HWTC_DIVISOR 1 \r
+\r
+ #define IRQ_PRIORITY_ORDER 0 // lower irq priority values are more significant\r
+ \r
+#elif (SELECTED_PORT == PORT_XILINX_MICROBLAZE)\r
+ /* UNOFFICIAL PORT - NOT YET VERIFIED BY PERCEPIO */\r
+\r
+ /* This should work with most Microblaze configurations\r
+ * This port is based on the official FreeRTOS Microlaze port and example application.\r
+ * It uses the AXI Timer 0 - the tick interrupt source.\r
+ * If an AXI Timer 0 peripheral is available on your hardware platform, no modifications are required.\r
+ */\r
+ #include "xtmrctr_l.h"\r
+\r
+ #define HWTC_COUNT_DIRECTION DIRECTION_DECREMENTING\r
+ #define HWTC_COUNT XTmrCtr_GetTimerCounterReg( XPAR_TMRCTR_0_BASEADDR, 0 )\r
+ #define HWTC_PERIOD ( configCPU_CLOCK_HZ / configTICK_RATE_HZ )\r
+ #define HWTC_DIVISOR 16\r
+\r
+ #define IRQ_PRIORITY_ORDER 0 // lower irq priority values are more significant\r
+\r
+#elif (SELECTED_PORT != PORT_NOT_SET)\r
+\r
+ #error "SELECTED_PORT had unsupported value!"\r
+ #define SELECTED_PORT PORT_NOT_SET\r
+\r
+#endif\r
+\r
+#if (SELECTED_PORT != PORT_NOT_SET)\r
+ \r
+ #ifndef HWTC_COUNT_DIRECTION\r
+ #error "HWTC_COUNT_DIRECTION is not set!"\r
+ #endif \r
+ \r
+ #ifndef HWTC_COUNT\r
+ #error "HWTC_COUNT is not set!" \r
+ #endif \r
+ \r
+ #ifndef HWTC_PERIOD\r
+ #error "HWTC_PERIOD is not set!"\r
+ #endif \r
+ \r
+ #ifndef HWTC_DIVISOR\r
+ #error "HWTC_DIVISOR is not set!" \r
+ #endif \r
+ \r
+ #ifndef IRQ_PRIORITY_ORDER\r
+ #error "IRQ_PRIORITY_ORDER is not set!"\r
+ #elif (IRQ_PRIORITY_ORDER != 0) && (IRQ_PRIORITY_ORDER != 1)\r
+ #error "IRQ_PRIORITY_ORDER has bad value!"\r
+ #endif \r
+ \r
+ #if (HWTC_DIVISOR < 1)\r
+ #error "HWTC_DIVISOR must be a non-zero positive value!"\r
+ #endif \r
+\r
+#endif\r
+/*******************************************************************************\r
+ * vTraceConsoleMessage\r
+ *\r
+ * A wrapper for your system-specific console "printf" console output function.\r
+ * This needs to be correctly defined to see status reports from the trace \r
+ * status monitor task (this is defined in trcUser.c).\r
+ ******************************************************************************/ \r
+#if (SELECTED_PORT == PORT_Atmel_AT91SAM7)\r
+/* Port specific includes */\r
+#include "console.h"\r
+#endif\r
+\r
+#define vTraceConsoleMessage printf\r
+\r
+/*******************************************************************************\r
+ * uiTracePortGetTimeStamp\r
+ *\r
+ * Returns the current time based on the HWTC macros which provide a hardware\r
+ * isolation layer towards the hardware timer/counter.\r
+ *\r
+ * The HWTC macros and uiTracePortGetTimeStamp is the main porting issue\r
+ * or the trace recorder library. Typically you should not need to change\r
+ * the code of uiTracePortGetTimeStamp if using the HWTC macros.\r
+ *\r
+ * OFFER FROM PERCEPIO:\r
+ * For silicon companies and non-corporate FreeRTOS users (researchers, \r
+ * students, hobbyists or early-phase startups) we have an attractive offer: \r
+ * Provide a hardware timer port and get a FREE single-user licence for\r
+ * FreeRTOS+Trace Professional Edition. Read more about this offer at \r
+ * www.percepio.com or contact us directly at support@percepio.com.\r
+ ******************************************************************************/\r
+void uiTracePortGetTimeStamp(uint32_t *puiTimestamp);\r
+\r
+/*******************************************************************************\r
+ * vTracePortEnd\r
+ * \r
+ * This function is called when the recorder is stopped due to full buffer.\r
+ * Mainly intended to show a message in the console.\r
+ * This is used by the Win32 port to store the trace to a file. The file path is\r
+ * set using vTracePortSetFileName.\r
+ ******************************************************************************/\r
+void vTracePortEnd(void);\r
+\r
+#if (INCLUDE_SAVE_TO_FILE == 1)\r
+\r
+/*******************************************************************************\r
+ * vTracePortSetOutFile\r
+ *\r
+ * Sets the filename/path used in vTracePortSave.\r
+ * This is set in a separate function, since the Win32 port calls vTracePortSave\r
+ * in vTracePortEnd if WIN32_PORT_SAVE_WHEN_STOPPED is set.\r
+ ******************************************************************************/\r
+void vTracePortSetOutFile(char* path);\r
+\r
+/******************************************************************************\r
+ * vTracePortSave\r
+ *\r
+ * Saves the trace to a file on a target-side file system. The path is set in a \r
+ * separate function, vTracePortSetOutFile, since the Win32 port may call\r
+ * vTracePortSave in vTracePortEnd, if using WIN32_PORT_SAVE_WHEN_STOPPED.\r
+ ******************************************************************************/\r
+void vTracePortSave(void);\r
+\r
+#endif\r
+\r
+#endif\r
</Midl>\r
<ClCompile>\r
<Optimization>Disabled</Optimization>\r
- <AdditionalIncludeDirectories>..\..\Source\include;..\..\Source\portable\MSVC-MingW;..\Common\Include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
+ <AdditionalIncludeDirectories>..\..\Source\include;..\..\Source\portable\MSVC-MingW;..\Common\Include;..\..\..\FreeRTOS-Plus\FreeRTOS-Plus-Trace\Include;.\Trace_Recorder_Configuration;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\r
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
<MinimalRebuild>true</MinimalRebuild>\r
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>\r
</Bscmake>\r
</ItemDefinitionGroup>\r
<ItemGroup>\r
+ <ClCompile Include="..\..\..\FreeRTOS-Plus\FreeRTOS-Plus-Trace\trcBase.c" />\r
+ <ClCompile Include="..\..\..\FreeRTOS-Plus\FreeRTOS-Plus-Trace\trcKernel.c" />\r
+ <ClCompile Include="..\..\..\FreeRTOS-Plus\FreeRTOS-Plus-Trace\trcPort.c" />\r
+ <ClCompile Include="..\..\..\FreeRTOS-Plus\FreeRTOS-Plus-Trace\trcUser.c" />\r
<ClCompile Include="..\..\Source\portable\MemMang\heap_3.c" />\r
<ClCompile Include="..\..\Source\timers.c" />\r
<ClCompile Include="..\Common\Minimal\BlockQ.c" />\r
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>\r
</ClCompile>\r
+ <ClCompile Include="Run-time-stats-utils.c" />\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="..\..\Source\include\timers.h" />\r
<ClInclude Include="..\..\Source\include\queue.h" />\r
<ClInclude Include="..\..\Source\include\semphr.h" />\r
<ClInclude Include="..\..\Source\include\task.h" />\r
+ <ClInclude Include="Trace_Recorder_Configuration\trcConfig.h" />\r
+ <ClInclude Include="Trace_Recorder_Configuration\trcPort.h" />\r
</ItemGroup>\r
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
<ImportGroup Label="ExtensionTargets">\r
<UniqueIdentifier>{19ff1a34-36de-4c48-9d10-3fb1fa0d1fa4}</UniqueIdentifier>\r
<Extensions>h;hpp;hxx;hm;inl</Extensions>\r
</Filter>\r
+ <Filter Include="Demo App Source\FreeRTOS+Trace Recorder">\r
+ <UniqueIdentifier>{90b56567-bab6-4d92-b319-b514d378329d}</UniqueIdentifier>\r
+ </Filter>\r
</ItemGroup>\r
<ItemGroup>\r
<ClCompile Include="main.c">\r
<ClCompile Include="..\Common\Minimal\QueueSet.c">\r
<Filter>Demo App Source\Common Demo Tasks</Filter>\r
</ClCompile>\r
+ <ClCompile Include="..\..\..\FreeRTOS-Plus\FreeRTOS-Plus-Trace\trcUser.c">\r
+ <Filter>Demo App Source\FreeRTOS+Trace Recorder</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="..\..\..\FreeRTOS-Plus\FreeRTOS-Plus-Trace\trcBase.c">\r
+ <Filter>Demo App Source\FreeRTOS+Trace Recorder</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="..\..\..\FreeRTOS-Plus\FreeRTOS-Plus-Trace\trcKernel.c">\r
+ <Filter>Demo App Source\FreeRTOS+Trace Recorder</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="..\..\..\FreeRTOS-Plus\FreeRTOS-Plus-Trace\trcPort.c">\r
+ <Filter>Demo App Source\FreeRTOS+Trace Recorder</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="Run-time-stats-utils.c">\r
+ <Filter>Demo App Source</Filter>\r
+ </ClCompile>\r
</ItemGroup>\r
<ItemGroup>\r
<ClInclude Include="FreeRTOSConfig.h">\r
<ClInclude Include="..\..\Source\include\timer_test.h">\r
<Filter>FreeRTOS Source\Include</Filter>\r
</ClInclude>\r
+ <ClInclude Include="Trace_Recorder_Configuration\trcConfig.h">\r
+ <Filter>Demo App Source\FreeRTOS+Trace Recorder</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="Trace_Recorder_Configuration\trcPort.h">\r
+ <Filter>Demo App Source\FreeRTOS+Trace Recorder</Filter>\r
+ </ClInclude>\r
</ItemGroup>\r
</Project>
\ No newline at end of file
is done purely to test the use of vSemaphoreDelete(). */\r
xMutexToDelete = xSemaphoreCreateMutex();\r
\r
+ /* Start the trace recording - the recording is written to a file if\r
+ configASSERT() is called. */\r
+ vTraceStart();\r
+\r
/* Start the scheduler itself. */\r
vTaskStartScheduler();\r
\r
pcStatusMessage = "Error: Returned test task state was incorrect 3";\r
}\r
}\r
-\r
}\r
}\r
/*-----------------------------------------------------------*/\r
\r
/* Write to a queue that is in use as part of the queue set demo to \r
demonstrate using queue sets from an ISR. */\r
- vQueueSetWriteToQueueFromISR();\r
+ vQueueSetAccessQueueSetFromISR();\r
}\r
/*-----------------------------------------------------------*/\r
\r
void vAssertCalled( void )\r
{\r
taskDISABLE_INTERRUPTS();\r
+\r
+ /* Stop the trace recording. */\r
+ vTraceStop();\r
+ vTracePortSave();\r
+ \r
for( ;; );\r
}\r
+/*-----------------------------------------------------------*/\r
\r
#define uxTaskGetStackHighWaterMark MPU_uxTaskGetStackHighWaterMark\r
#define xTaskGetCurrentTaskHandle MPU_xTaskGetCurrentTaskHandle\r
#define xTaskGetSchedulerState MPU_xTaskGetSchedulerState\r
+ #define xTaskGetIdleTaskHandle MPU_xTaskGetIdleTaskHandle\r
\r
#define xQueueGenericCreate MPU_xQueueGenericCreate\r
#define xQueueCreateMutex MPU_xQueueCreateMutex\r
#define xQueueGenericReceive MPU_xQueueGenericReceive\r
#define uxQueueMessagesWaiting MPU_uxQueueMessagesWaiting\r
#define vQueueDelete MPU_vQueueDelete\r
+ #define xQueueGenericReset MPU_xQueueGenericReset\r
+ #define xQueueCreateSet MPU_xQueueCreateSet\r
+ #define xQueueSelectFromSet MPU_xQueueSelectFromSet\r
+ #define xQueueAddToSet MPU_xQueueAddToSet\r
+ #define xQueueRemoveFromSet MPU_xQueueRemoveFromSet\r
\r
#define pvPortMalloc MPU_pvPortMalloc\r
#define vPortFree MPU_vPortFree\r
\r
/**\r
* Type by which queue sets are referenced. For example, a call to\r
- * xQueueSetCreate() returns an xQueueSet variable that can then be used as a\r
- * parameter to xQueueBlockMultiple(), xQueueAddToQueueSet(), etc.\r
+ * xQueueCreateSet() returns an xQueueSet variable that can then be used as a\r
+ * parameter to xQueueSelectFromSet(), xQueueAddToSet(), etc.\r
*/\r
typedef void * xQueueSetHandle;\r
\r
* See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
* function.\r
*\r
- * A queue set must be explicitly created using a call to xQueueSetCreate()\r
+ * A queue set must be explicitly created using a call to xQueueCreateSet()\r
* before it can be used. Once created, standard FreeRTOS queues and semaphores\r
- * can be added to the set using calls to xQueueAddToQueueSet().\r
- * xQueueBlockMultiple() is then used to determine which, if any, of the queues\r
+ * can be added to the set using calls to xQueueAddToSet().\r
+ * xQueueSelectFromSet() is then used to determine which, if any, of the queues\r
* or semaphores contained in the set is in a state where a queue read or\r
* semaphore take operation would be successful.\r
*\r
* queue added to a queue set. Therefore counting semaphores with large maximum\r
* counts should not be added to queue sets.\r
*\r
+ * Note 4: A received (in the case of a queue) or take (in the case of a \r
+ * semaphore) operation must not be performed on a member of a queue set unless \r
+ * a call to xQueueSelect() has first returned a handle to that set member.\r
+ *\r
* @param uxEventQueueLength Queue sets themselves queue events that occur on\r
* the queues and semaphores contained in the set. uxEventQueueLength specifies\r
* the maximum number of events that can be queued at once. To be absolutely\r
* @return If the queue set is created successfully then a handle to the created\r
* queue set is returned. Otherwise NULL is returned.\r
*/\r
-xQueueSetHandle xQueueSetCreate( unsigned portBASE_TYPE uxEventQueueLength );\r
+xQueueSetHandle xQueueCreateSet( unsigned portBASE_TYPE uxEventQueueLength );\r
\r
/*\r
* Adds a queue or semaphore to a queue set that was previously created by a\r
- * call to xQueueSetCreate().\r
+ * call to xQueueCreateSet().\r
*\r
* See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
* function.\r
*\r
+ * Note 1: A received (in the case of a queue) or take (in the case of a \r
+ * semaphore) operation must not be performed on a member of a queue set unless \r
+ * a call to xQueueSelect() has first returned a handle to that set member.\r
+ *\r
* @param xQueueOrSemaphore The handle of the queue or semaphore being added to \r
* the queue set (cast to an xQueueSetMemberHandle type).\r
*\r
* queue set because it is already a member of a different queue set then pdFAIL \r
* is returned.\r
*/\r
-portBASE_TYPE xQueueAddToQueueSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet );\r
+portBASE_TYPE xQueueAddToSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet );\r
\r
/*\r
- * Removes a queue or semaphore from a queue set.\r
+ * Removes a queue or semaphore from a queue set. A queue can only be removed\r
+ * from a set when it is empty.\r
*\r
* See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
* function.\r
* then pdPASS is returned. If the queue was not in the queue set then pdFAIL\r
* is returned.\r
*/\r
-portBASE_TYPE xQueueRemoveFromQueueSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet );\r
+portBASE_TYPE xQueueRemoveFromSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet );\r
\r
/*\r
- * xQueueBlockMultiple() allows a task to block (pend) on a read operation on\r
- * all the queues and semaphores in a queue set simultaneously.\r
+ * xQueueSelectFromSet() selects from the members of a queue set a queue or \r
+ * semaphore that either contains data (in the case of a queue) or is available\r
+ * to take (in the case of a semaphore). xQueueSelectFromSet() effectively \r
+ * allows a task to block (pend) on a read operation on all the queues and \r
+ * semaphores in a queue set simultaneously.\r
*\r
* See FreeRTOS/Source/Demo/Common/Minimal/QueueSet.c for an example using this\r
* function.\r
* Note 2: Blocking on a queue set that contains a mutex will not cause the\r
* mutex holder to inherit the priority of the blocked task.\r
*\r
+ * Note 3: A received (in the case of a queue) or take (in the case of a \r
+ * semaphore) operation must not be performed on a member of a queue set unless \r
+ * a call to xQueueSelect() has first returned a handle to that set member.\r
+ *\r
* @param xQueueSet The queue set on which the task will (potentially) block.\r
*\r
* @param xBlockTimeTicks The maximum time, in ticks, that the calling task will\r
* of the queue set to be ready for a successful queue read or semaphore take\r
* operation.\r
*\r
- * @return xQueueBlockMultiple() will return the handle of a queue (cast to\r
+ * @return xQueueSelectFromSet() will return the handle of a queue (cast to\r
* a xQueueSetMemberHandle type) contained in the queue set that contains data, \r
* or the handle of a semaphore (cast to a xQueueSetMemberHandle type) contained\r
* in the queue set that is available, or NULL if no such queue or semaphore \r
* exists before before the specified block time expires.\r
*/\r
-xQueueSetMemberHandle xQueueBlockMultiple( xQueueSetHandle xQueueSet, portTickType xBlockTimeTicks );\r
+xQueueSetMemberHandle xQueueSelectFromSet( xQueueSetHandle xQueueSet, portTickType xBlockTimeTicks );\r
+\r
+/*\r
+ * A version of xQueueSelectFromSet() that can be used from an ISR.\r
+ */\r
+xQueueSetMemberHandle xQueueSelectFromSetFromISR( xQueueSetHandle xQueueSet );\r
\r
/* Not public API functions. */\r
void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait );\r
unsigned portBASE_TYPE MPU_uxTaskGetStackHighWaterMark( xTaskHandle xTask );\r
xTaskHandle MPU_xTaskGetCurrentTaskHandle( void );\r
portBASE_TYPE MPU_xTaskGetSchedulerState( void );\r
+xTaskHandle MPU_xTaskGetIdleTaskHandle( void );\r
xQueueHandle MPU_xQueueGenericCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize, unsigned char ucQueueType );\r
signed portBASE_TYPE MPU_xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition );\r
+portBASE_TYPE MPU_xQueueGenericReset( xQueueHandle pxQueue, portBASE_TYPE xNewQueue );\r
unsigned portBASE_TYPE MPU_uxQueueMessagesWaiting( const xQueueHandle pxQueue );\r
signed portBASE_TYPE MPU_xQueueGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking );\r
xQueueHandle MPU_xQueueCreateMutex( void );\r
void MPU_vPortFree( void *pv );\r
void MPU_vPortInitialiseBlocks( void );\r
size_t MPU_xPortGetFreeHeapSize( void );\r
+xQueueSetHandle MPU_xQueueCreateSet( unsigned portBASE_TYPE uxEventQueueLength );\r
+xQueueSetMemberHandle MPU_xQueueSelectFromSet( xQueueSetHandle xQueueSet, portTickType xBlockTimeTicks );\r
+portBASE_TYPE MPU_xQueueAddToSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet );\r
+portBASE_TYPE MPU_xQueueRemoveFromSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet );\r
\r
/*-----------------------------------------------------------*/\r
\r
#endif\r
/*-----------------------------------------------------------*/\r
\r
+#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )\r
+ xTaskHandle MPU_xTaskGetIdleTaskHandle( void )\r
+ {\r
+ xTaskHandle xReturn;\r
+ portBASE_TYPE xRunningPrivileged = prvRaisePrivilege();\r
+\r
+ xReturn = xTaskGetIdleTaskHandle();\r
+ portRESET_PRIVILEGE( xRunningPrivileged );\r
+ return eReturn;\r
+ }\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
#if ( INCLUDE_vTaskSuspend == 1 )\r
void MPU_vTaskSuspend( xTaskHandle pxTaskToSuspend )\r
{\r
}\r
/*-----------------------------------------------------------*/\r
\r
+portBASE_TYPE MPU_xQueueGenericReset( xQueueHandle pxQueue, portBASE_TYPE xNewQueue )\r
+{\r
+portBASE_TYPE xReturn;\r
+portBASE_TYPE xRunningPrivileged = prvRaisePrivilege();\r
+\r
+ xReturn = xQueueGenericReset( pxQueue, xNewQueue );\r
+ portRESET_PRIVILEGE( xRunningPrivileged );\r
+ return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
signed portBASE_TYPE MPU_xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition )\r
{\r
signed portBASE_TYPE xReturn;\r
#endif\r
/*-----------------------------------------------------------*/\r
\r
+#if ( configUSE_QUEUE_SETS == 1 )\r
+ xQueueSetHandle MPU_xQueueCreateSet( unsigned portBASE_TYPE uxEventQueueLength )\r
+ {\r
+ xQueueSetHandle xReturn;\r
+ portBASE_TYPE xRunningPrivileged = prvRaisePrivilege();\r
+\r
+ xReturn = xQueueCreateSet( uxEventQueueLength );\r
+ portRESET_PRIVILEGE( xRunningPrivileged );\r
+ return xReturn;\r
+ }\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_QUEUE_SETS == 1 )\r
+ xQueueSetMemberHandle MPU_xQueueSelectFromSet( xQueueSetHandle xQueueSet, portTickType xBlockTimeTicks )\r
+ {\r
+ xQueueSetMemberHandle xReturn;\r
+ portBASE_TYPE xRunningPrivileged = prvRaisePrivilege();\r
+\r
+ xReturn = xQueueSelectFromSet( xQueueSet, xBlockTimeTicks );\r
+ portRESET_PRIVILEGE( xRunningPrivileged );\r
+ return xReturn;\r
+ }\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_QUEUE_SETS == 1 )\r
+ portBASE_TYPE MPU_xQueueAddToSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet )\r
+ {\r
+ portBASE_TYPE xReturn;\r
+ portBASE_TYPE xRunningPrivileged = prvRaisePrivilege();\r
+\r
+ xReturn = xQueueAddToSet( xQueueOrSemaphore, xQueueSet );\r
+ portRESET_PRIVILEGE( xRunningPrivileged );\r
+ return xReturn;\r
+ }\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
+#if ( configUSE_QUEUE_SETS == 1 )\r
+ portBASE_TYPE MPU_xQueueRemoveFromSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet )\r
+ {\r
+ portBASE_TYPE xReturn;\r
+ portBASE_TYPE xRunningPrivileged = prvRaisePrivilege();\r
+\r
+ xReturn = xQueueRemoveFromSet( xQueueOrSemaphore, xQueueSet );\r
+ portRESET_PRIVILEGE( xRunningPrivileged );\r
+ return xReturn;\r
+ }\r
+#endif\r
+/*-----------------------------------------------------------*/\r
+\r
#if configUSE_ALTERNATIVE_API == 1\r
signed portBASE_TYPE MPU_xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition )\r
{\r
#define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( 2U )\r
#define queueQUEUE_TYPE_BINARY_SEMAPHORE ( 3U )\r
#define queueQUEUE_TYPE_RECURSIVE_MUTEX ( 4U )\r
-#define queueQUEUE_TYPE_SET ( 5U )\r
+#define queueQUEUE_TYPE_SET ( 0U )\r
\r
/*\r
* Definition of the queue used by the scheduler.\r
unsigned char ucQueueGetQueueType( xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;\r
portBASE_TYPE xQueueGenericReset( xQueueHandle pxQueue, portBASE_TYPE xNewQueue ) PRIVILEGED_FUNCTION;\r
xTaskHandle xQueueGetMutexHolder( xQueueHandle xSemaphore ) PRIVILEGED_FUNCTION;\r
-xQueueSetHandle xQueueSetCreate( unsigned portBASE_TYPE uxEventQueueLength ) PRIVILEGED_FUNCTION;\r
-xQueueSetMemberHandle xQueueBlockMultiple( xQueueSetHandle xQueueSet, portTickType xBlockTimeTicks ) PRIVILEGED_FUNCTION;\r
-portBASE_TYPE xQueueAddToQueueSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet ) PRIVILEGED_FUNCTION;\r
-portBASE_TYPE xQueueRemoveFromQueueSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet ) PRIVILEGED_FUNCTION;\r
+xQueueSetHandle xQueueCreateSet( unsigned portBASE_TYPE uxEventQueueLength ) PRIVILEGED_FUNCTION;\r
+xQueueSetMemberHandle xQueueSelectFromSet( xQueueSetHandle xQueueSet, portTickType xBlockTimeTicks ) PRIVILEGED_FUNCTION;\r
+portBASE_TYPE xQueueAddToSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet ) PRIVILEGED_FUNCTION;\r
+portBASE_TYPE xQueueRemoveFromSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet ) PRIVILEGED_FUNCTION;\r
\r
/*\r
* Co-routine queue functions differ from task queue functions. Co-routines are\r
traceQUEUE_SEND( pxQueue );\r
prvCopyDataToQueue( pxQueue, pvItemToQueue, xCopyPosition );\r
\r
- /* If there was a task waiting for data to arrive on the\r
- queue then unblock it now. */\r
- if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+ #if ( configUSE_QUEUE_SETS == 1 )\r
{\r
- if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE )\r
+ if( pxQueue->pxQueueSetContainer != NULL )\r
{\r
- /* The unblocked task has a priority higher than\r
- our own so yield immediately. Yes it is ok to do\r
- this from within the critical section - the kernel\r
- takes care of that. */\r
- portYIELD_WITHIN_API();\r
+ if( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) == pdTRUE )\r
+ {\r
+ /* The queue is a member of a queue set, and posting\r
+ to the queue set caused a higher priority task to\r
+ unblock. A context switch is required. */\r
+ portYIELD_WITHIN_API();\r
+ }\r
}\r
- }\r
- else\r
- {\r
- #if ( configUSE_QUEUE_SETS == 1 )\r
+ else\r
{\r
- if( pxQueue->pxQueueSetContainer != NULL )\r
+ /* If there was a task waiting for data to arrive on the\r
+ queue then unblock it now. */\r
+ if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
{\r
- if( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) == pdTRUE )\r
+ if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE )\r
{\r
- /* The queue is a member of a queue set, and posting to\r
- the queue set caused a higher priority task to unblock.\r
- A context switch is required. */\r
+ /* The unblocked task has a priority higher than\r
+ our own so yield immediately. Yes it is ok to\r
+ do this from within the critical section - the\r
+ kernel takes care of that. */\r
portYIELD_WITHIN_API();\r
}\r
}\r
}\r
- #endif /* configUSE_QUEUE_SETS */\r
}\r
+ #else /* configUSE_QUEUE_SETS */\r
+ {\r
+ /* If there was a task waiting for data to arrive on the\r
+ queue then unblock it now. */\r
+ if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+ {\r
+ if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) == pdTRUE )\r
+ {\r
+ /* The unblocked task has a priority higher than\r
+ our own so yield immediately. Yes it is ok to do\r
+ this from within the critical section - the kernel\r
+ takes care of that. */\r
+ portYIELD_WITHIN_API();\r
+ }\r
+ }\r
+ }\r
+ #endif /* configUSE_QUEUE_SETS */\r
\r
taskEXIT_CRITICAL();\r
\r
be done when the queue is unlocked later. */\r
if( pxQueue->xTxLock == queueUNLOCKED )\r
{\r
- if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+ #if ( configUSE_QUEUE_SETS == 1 )\r
{\r
- if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
+ if( pxQueue->pxQueueSetContainer != NULL )\r
{\r
- /* The task waiting has a higher priority so record that a\r
- context switch is required. */\r
- if( pxHigherPriorityTaskWoken != NULL )\r
+ if( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) == pdTRUE )\r
{\r
- *pxHigherPriorityTaskWoken = pdTRUE;\r
+ /* The queue is a member of a queue set, and posting\r
+ to the queue set caused a higher priority task to\r
+ unblock. A context switch is required. */\r
+ if( pxHigherPriorityTaskWoken != NULL )\r
+ {\r
+ *pxHigherPriorityTaskWoken = pdTRUE;\r
+ }\r
}\r
}\r
- }\r
- else\r
- {\r
- #if ( configUSE_QUEUE_SETS == 1 )\r
+ else\r
{\r
- if( pxQueue->pxQueueSetContainer != NULL )\r
+ if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
{\r
- if( prvNotifyQueueSetContainer( pxQueue, xCopyPosition ) == pdTRUE )\r
+ if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
{\r
- /* The queue is a member of a queue set, and posting\r
- to the queue set caused a higher priority task to\r
- unblock. A context switch is required. */\r
+ /* The task waiting has a higher priority so record that a\r
+ context switch is required. */\r
if( pxHigherPriorityTaskWoken != NULL )\r
{\r
*pxHigherPriorityTaskWoken = pdTRUE;\r
}\r
}\r
}\r
- #endif /* configUSE_QUEUE_SETS */\r
}\r
+ #else /* configUSE_QUEUE_SETS */\r
+ {\r
+ if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+ {\r
+ if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
+ {\r
+ /* The task waiting has a higher priority so record that a\r
+ context switch is required. */\r
+ if( pxHigherPriorityTaskWoken != NULL )\r
+ {\r
+ *pxHigherPriorityTaskWoken = pdTRUE;\r
+ }\r
+ }\r
+ }\r
+ }\r
+ #endif /* configUSE_QUEUE_SETS */\r
}\r
else\r
{\r
{\r
/* Data was posted while the queue was locked. Are any tasks\r
blocked waiting for data to become available? */\r
- if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+ #if ( configUSE_QUEUE_SETS == 1 )\r
{\r
- /* Tasks that are removed from the event list will get added to\r
- the pending ready list as the scheduler is still suspended. */\r
- if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
+ if( pxQueue->pxQueueSetContainer != NULL )\r
{\r
- /* The task waiting has a higher priority so record that a\r
- context switch is required. */\r
- vTaskMissedYield();\r
+ if( prvNotifyQueueSetContainer( pxQueue, queueSEND_TO_BACK ) == pdTRUE )\r
+ {\r
+ /* The queue is a member of a queue set, and posting to\r
+ the queue set caused a higher priority task to unblock.\r
+ A context switch is required. */\r
+ vTaskMissedYield();\r
+ }\r
}\r
else\r
{\r
- #if ( configUSE_QUEUE_SETS == 1 )\r
+ /* Tasks that are removed from the event list will get added to\r
+ the pending ready list as the scheduler is still suspended. */\r
+ if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
{\r
- /* It is highly unlikely that this code will ever run,\r
- for the following reason:\r
- + A task will only lock a queue that is part of a\r
- queue set when it is blocking on a write to the\r
- queue.\r
- + An interrupt can only add something to a queue\r
- while the queue is locked (resulting in the\r
- following code executing when the queue is unlocked)\r
- if the queue is not full, meaning a task will never\r
- have blocked on a write in the first place.\r
- The code could execute if an interrupt is also removing\r
- items from a queue. */\r
- if( pxQueue->pxQueueSetContainer != NULL )\r
+ if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
{\r
- if( prvNotifyQueueSetContainer( pxQueue, queueSEND_TO_BACK ) == pdTRUE )\r
- {\r
- /* The queue is a member of a queue set, and posting to\r
- the queue set caused a higher priority task to unblock.\r
- A context switch is required. */\r
- vTaskMissedYield();\r
- }\r
+ /* The task waiting has a higher priority so record that a\r
+ context switch is required. */\r
+ vTaskMissedYield();\r
}\r
}\r
- #endif /* configUSE_QUEUE_SETS */\r
+ else\r
+ {\r
+ break;\r
+ }\r
}\r
-\r
- --( pxQueue->xTxLock );\r
}\r
- else\r
+ #else /* configUSE_QUEUE_SETS */\r
{\r
- break;\r
+ /* Tasks that are removed from the event list will get added to\r
+ the pending ready list as the scheduler is still suspended. */\r
+ if( listLIST_IS_EMPTY( &( pxQueue->xTasksWaitingToReceive ) ) == pdFALSE )\r
+ {\r
+ if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )\r
+ {\r
+ /* The task waiting has a higher priority so record that a\r
+ context switch is required. */\r
+ vTaskMissedYield();\r
+ }\r
+ }\r
+ else\r
+ {\r
+ break;\r
+ }\r
}\r
+ #endif /* configUSE_QUEUE_SETS */\r
+\r
+ --( pxQueue->xTxLock );\r
}\r
\r
pxQueue->xTxLock = queueUNLOCKED;\r
\r
#if ( configUSE_QUEUE_SETS == 1 )\r
\r
- xQueueSetHandle xQueueSetCreate( unsigned portBASE_TYPE uxEventQueueLength )\r
+ xQueueSetHandle xQueueCreateSet( unsigned portBASE_TYPE uxEventQueueLength )\r
{\r
xQUEUE *pxQueue;\r
\r
\r
#if ( configUSE_QUEUE_SETS == 1 )\r
\r
- portBASE_TYPE xQueueAddToQueueSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet )\r
+ portBASE_TYPE xQueueAddToSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet )\r
{\r
portBASE_TYPE xReturn;\r
\r
\r
#if ( configUSE_QUEUE_SETS == 1 )\r
\r
- portBASE_TYPE xQueueRemoveFromQueueSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet )\r
+ portBASE_TYPE xQueueRemoveFromSet( xQueueSetMemberHandle xQueueOrSemaphore, xQueueSetHandle xQueueSet )\r
{\r
portBASE_TYPE xReturn;\r
\r
if( xQueueOrSemaphore->pxQueueSetContainer != xQueueSet )\r
{\r
+ /* The queue was not a member of the set. */\r
+ xReturn = pdFAIL;\r
+ }\r
+ else if( xQueueOrSemaphore->uxMessagesWaiting != 0 )\r
+ {\r
+ /* It is dangerous to remove a queue from a set when the queue is\r
+ not empty because the queue set will still hold pending events for\r
+ the queue. */\r
xReturn = pdFAIL;\r
}\r
else\r
{\r
taskENTER_CRITICAL();\r
{\r
+ /* The queue is no longer contained in the set. */\r
xQueueOrSemaphore->pxQueueSetContainer = NULL;\r
}\r
taskEXIT_CRITICAL();\r
\r
#if ( configUSE_QUEUE_SETS == 1 )\r
\r
- xQueueSetMemberHandle xQueueBlockMultiple( xQueueSetHandle xQueueSet, portTickType xBlockTimeTicks )\r
+ xQueueSetMemberHandle xQueueSelectFromSet( xQueueSetHandle xQueueSet, portTickType xBlockTimeTicks )\r
{\r
xQueueSetMemberHandle xReturn = NULL;\r
\r
#endif /* configUSE_QUEUE_SETS */\r
/*-----------------------------------------------------------*/\r
\r
+#if ( configUSE_QUEUE_SETS == 1 )\r
+\r
+ xQueueSetMemberHandle xQueueSelectFromSetFromISR( xQueueSetHandle xQueueSet )\r
+ {\r
+ xQueueSetMemberHandle xReturn = NULL;\r
+\r
+ xQueueReceiveFromISR( ( xQueueHandle ) xQueueSet, &xReturn, NULL );\r
+ return xReturn;\r
+ }\r
+\r
+#endif /* configUSE_QUEUE_SETS */\r
+/*-----------------------------------------------------------*/\r
+\r
#if ( configUSE_QUEUE_SETS == 1 )\r
\r
static portBASE_TYPE prvNotifyQueueSetContainer( xQUEUE *pxQueue, portBASE_TYPE xCopyPosition )\r
\r
if( pxQueueSetContainer->uxMessagesWaiting < pxQueueSetContainer->uxLength )\r
{\r
+ traceQUEUE_SEND( pxQueueSetContainer );\r
+ /* The data copies is the handle of the queue that contains data. */\r
prvCopyDataToQueue( pxQueueSetContainer, &pxQueue, xCopyPosition );\r
if( listLIST_IS_EMPTY( &( pxQueueSetContainer->xTasksWaitingToReceive ) ) == pdFALSE )\r
{\r
/* Remember the ready list the task might be referenced from\r
before its uxPriority member is changed so the\r
taskRESET_READY_PRIORITY() macro can function correctly. */\r
- uxPriorityUsedOnEntry = pxTCB->uxPriority;\r
+ #if ( configUSE_PORT_OPTIMISED_TASK_SELECTION != 0 )\r
+ {\r
+ uxPriorityUsedOnEntry = pxTCB->uxPriority;\r
+ }\r
+ #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */\r
\r
#if ( configUSE_MUTEXES == 1 )\r
{\r
/* Should only reach here if a task calls xTaskEndScheduler(). */\r
}\r
}\r
-\r
- /* This line will only be reached if the kernel could not be started, or\r
- vTaskEndScheduler() was called (vTaskEndScheduler() is not implemented for\r
- most ports). */\r
- configASSERT( xReturn );\r
+ else\r
+ {\r
+ /* This line will only be reached if the kernel could not be started, \r
+ because there was not enough FreeRTOS heap to create the idle task\r
+ or the timer task. */\r
+ configASSERT( xReturn );\r
+ }\r
}\r
/*-----------------------------------------------------------*/\r
\r