*/\r
#define configMAX_API_CALL_INTERRUPT_PRIORITY 18\r
\r
-\r
#define configCPU_CLOCK_HZ 100000000UL\r
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1\r
#define configUSE_TICKLESS_IDLE 0\r
#include "QueueOverwrite.h"\r
#include "IntQueue.h"\r
#include "EventGroupsDemo.h"\r
+#include "TaskNotify.h"\r
+#include "IntSemTest.h"\r
\r
/* Priorities for the demo application tasks. */\r
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1UL )\r
vStartTimerDemoTask( mainTIMER_TEST_PERIOD );\r
vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );\r
vStartEventGroupTasks();\r
+ vStartTaskNotifyTask();\r
+ vStartInterruptSemaphoreTasks();\r
+\r
\r
/* Start the tasks that implements the command console on the UART, as\r
described above. */\r
that they are all still running, and that none have detected an error. */\r
if( xAreIntQueueTasksStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 0UL;\r
}\r
\r
if( xAreMathsTaskStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 1UL;\r
}\r
\r
if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 2UL;\r
}\r
\r
if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 3UL;\r
}\r
\r
if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 4UL;\r
}\r
\r
if ( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 5UL;\r
}\r
\r
if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 6UL;\r
}\r
\r
if( xIsCreateTaskStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 7UL;\r
}\r
\r
if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 8UL;\r
}\r
\r
if( xAreTimerDemoTasksStillRunning( ( TickType_t ) mainNO_ERROR_CHECK_TASK_PERIOD ) != pdPASS )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 9UL;\r
}\r
\r
if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 10UL;\r
}\r
\r
if( xIsQueueOverwriteTaskStillRunning() != pdPASS )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 11UL;\r
}\r
\r
if( xAreEventGroupTasksStillRunning() != pdPASS )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 12UL;\r
+ }\r
+\r
+ if( xAreTaskNotificationTasksStillRunning() != pdTRUE )\r
+ {\r
+ ulErrorFound |= 1UL << 13UL;\r
+ }\r
+\r
+ if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )\r
+ {\r
+ ulErrorFound |= 1UL << 14UL;\r
}\r
\r
/* Check that the register test 1 task is still running. */\r
if( ulLastRegTest1Value == ulRegTest1LoopCounter )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 15UL;\r
}\r
ulLastRegTest1Value = ulRegTest1LoopCounter;\r
\r
/* Check that the register test 2 task is still running. */\r
if( ulLastRegTest2Value == ulRegTest2LoopCounter )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 16UL;\r
}\r
ulLastRegTest2Value = ulRegTest2LoopCounter;\r
\r
#include "TimerDemo.h"\r
#include "QueueOverwrite.h"\r
#include "EventGroupsDemo.h"\r
+#include "TaskNotify.h"\r
+#include "IntSemTest.h"\r
\r
/* Xilinx includes. */\r
#include "platform.h"\r
\r
/* Call the periodic event group from ISR demo. */\r
vPeriodicEventGroupsProcessing();\r
+\r
+ /* Use task notifications from an interrupt. */\r
+ xNotifyTaskFromISR();\r
+\r
+ /* Use mutexes from interrupts. */\r
+ vInterruptSemaphorePeriodicTest();\r
}\r
#endif\r
}\r
copy %FREERTOS_SOURCE%\queue.c src\asf\thirdparty\FreeRTOS\r
copy %FREERTOS_SOURCE%\list.c src\asf\thirdparty\FreeRTOS\r
copy %FREERTOS_SOURCE%\timers.c src\asf\thirdparty\FreeRTOS\r
+ copy %FREERTOS_SOURCE%\event_groups.c src\asf\thirdparty\FreeRTOS\r
\r
REM Copy the common header files into the project directory\r
copy %FREERTOS_SOURCE%\include\*.* src\asf\thirdparty\FreeRTOS\include\r
copy %COMMON_SOURCE%\integer.c src\Common-Demo-Source\r
copy %COMMON_SOURCE%\QueueSet.c src\Common-Demo-Source\r
COPY %COMMON_SOURCE%\IntQueue.c src\Common-Demo-Source\r
+ COPY %COMMON_SOURCE%\TaskNotify.c src\Common-Demo-Source\r
+ COPY %COMMON_SOURCE%\TimerDemo.c src\Common-Demo-Source\r
+ COPY %COMMON_SOURCE%\EventGroupsDemo.c src\Common-Demo-Source\r
+ COPY %COMMON_SOURCE%\IntSemTest.c src\Common-Demo-Source\r
\r
REM Copy the common demo file headers.\r
copy %COMMON_INCLUDE%\*.h src\Common-Demo-Source\include\r
<documentation help="" />\r
<offline-documentation help="" />\r
<dependencies>\r
- <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.6.0" />\r
+ <content-extension eid="atmel.asf" uuidref="Atmel.ASF" version="3.10.1" />\r
</dependencies>\r
</framework-data>\r
</AsfFrameworkConfig>\r
</armgcc.linker.libraries.LibrarySearchPaths>\r
<armgcc.linker.optimization.GarbageCollectUnusedSections>True</armgcc.linker.optimization.GarbageCollectUnusedSections>\r
<armgcc.linker.miscellaneous.LinkerFlags>-T../src/asf/sam/utils/linker_scripts/sam4s/sam4s16/gcc/flash.ld -Wl,--cref -Wl,--entry=Reset_Handler -mthumb</armgcc.linker.miscellaneous.LinkerFlags>\r
- <armgcc.assembler.general.IncludePaths>\r
- <ListValues>\r
- <Value>../src/ASF/sam/drivers/tc</Value>\r
- </ListValues>\r
- </armgcc.assembler.general.IncludePaths>\r
<armgcc.preprocessingassembler.general.AssemblerFlags>-DARM_MATH_CM4=true -DBOARD=SAM4S_EK -D__SAM4S16C__</armgcc.preprocessingassembler.general.AssemblerFlags>\r
<armgcc.preprocessingassembler.general.IncludePaths>\r
<ListValues>\r
</ListValues>\r
</armgcc.linker.libraries.LibrarySearchPaths>\r
<armgcc.linker.optimization.GarbageCollectUnusedSections>True</armgcc.linker.optimization.GarbageCollectUnusedSections>\r
+ <armgcc.linker.memorysettings.ExternalRAM />\r
<armgcc.linker.miscellaneous.LinkerFlags>-T../src/asf/sam/utils/linker_scripts/sam4s/sam4s16/gcc/flash.ld -Wl,--cref -Wl,--entry=Reset_Handler -mthumb</armgcc.linker.miscellaneous.LinkerFlags>\r
- <armgcc.assembler.general.IncludePaths>\r
- <ListValues>\r
- <Value>../src/ASF/sam/drivers/tc</Value>\r
- </ListValues>\r
- </armgcc.assembler.general.IncludePaths>\r
<armgcc.preprocessingassembler.general.AssemblerFlags>-DARM_MATH_CM4=true -DBOARD=SAM4S_EK -D__SAM4S16C__</armgcc.preprocessingassembler.general.AssemblerFlags>\r
<armgcc.preprocessingassembler.general.IncludePaths>\r
<ListValues>\r
<None Include="src\asf\sam\drivers\usart\usart.h">\r
<SubType>compile</SubType>\r
</None>\r
+ <Compile Include="src\asf\thirdparty\FreeRTOS\event_groups.c">\r
+ <SubType>compile</SubType>\r
+ </Compile>\r
<Compile Include="src\asf\thirdparty\FreeRTOS\portable\MemMang\heap_4.c">\r
<SubType>compile</SubType>\r
</Compile>\r
+ <Compile Include="src\Common-Demo-Source\EventGroupsDemo.c">\r
+ <SubType>compile</SubType>\r
+ </Compile>\r
<Compile Include="src\Common-Demo-Source\include\demo_serial.h">\r
<SubType>compile</SubType>\r
</Compile>\r
+ <Compile Include="src\Common-Demo-Source\include\TaskNotify.h">\r
+ <SubType>compile</SubType>\r
+ </Compile>\r
<Compile Include="src\Common-Demo-Source\IntQueue.c">\r
<SubType>compile</SubType>\r
</Compile>\r
+ <Compile Include="src\Common-Demo-Source\IntSemTest.c">\r
+ <SubType>compile</SubType>\r
+ </Compile>\r
<Compile Include="src\Common-Demo-Source\QueueSet.c">\r
<SubType>compile</SubType>\r
</Compile>\r
+ <Compile Include="src\Common-Demo-Source\TaskNotify.c">\r
+ <SubType>compile</SubType>\r
+ </Compile>\r
+ <Compile Include="src\Common-Demo-Source\TimerDemo.c">\r
+ <SubType>compile</SubType>\r
+ </Compile>\r
<Compile Include="src\IntQueueTimer.c">\r
<SubType>compile</SubType>\r
</Compile>\r
\r
#define configUSE_PREEMPTION 1\r
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 1\r
-#define configUSE_IDLE_HOOK 0\r
+#define configUSE_IDLE_HOOK 1\r
#define configUSE_TICK_HOOK 1\r
#define configCPU_CLOCK_HZ ( SystemCoreClock )\r
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )\r
#define INCLUDE_vTaskDelayUntil 1\r
#define INCLUDE_vTaskDelay 1\r
#define INCLUDE_eTaskGetState 1\r
+#define INCLUDE_xTimerPendFunctionCall 1\r
\r
/* Cortex-M specific definitions. */\r
#ifdef __NVIC_PRIO_BITS\r
\r
/* Standard demo includes. */\r
#include "partest.h"\r
-#include "QueueSet.h"\r
\r
/* Atmel library includes. */\r
#include <asf.h>\r
important that vApplicationIdleHook() is permitted to return to its calling\r
function, because it is the responsibility of the idle task to clean up\r
memory allocated by the kernel to any task that has since been deleted. */\r
+ \r
+ #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )\r
+ {\r
+ extern void vFullDemoIdleHook( void );\r
+ \r
+ vFullDemoIdleHook();\r
+ }\r
+ #endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */\r
}\r
/*-----------------------------------------------------------*/\r
\r
\r
#if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 )\r
{\r
- /* In this case the tick hook is used as part of the queue set test. */\r
- vQueueSetAccessQueueSetFromISR();\r
+ extern void vFullDemoTickHook( void );\r
+ \r
+ vFullDemoTickHook();\r
}\r
#endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */\r
}\r
#include "comtest2.h"\r
#include "QueueSet.h"\r
#include "IntQueue.h"\r
+#include "TaskNotify.h"\r
+#include "TimerDemo.h"\r
+#include "EventGroupsDemo.h"\r
+#include "IntSemTest.h"\r
\r
/* Atmel library includes. */\r
#include "asf.h"\r
/* The period after which the check timer will expire, in ms, provided no errors\r
have been reported by any of the standard demo tasks. ms are converted to the\r
equivalent in ticks using the portTICK_PERIOD_MS constant. */\r
-#define mainCHECK_TIMER_PERIOD_MS ( 3000UL / portTICK_PERIOD_MS )\r
+#define mainCHECK_TIMER_PERIOD_MS ( pdMS_TO_TICKS( 3000UL ) )\r
\r
/* The period at which the check timer will expire, in ms, if an error has been\r
reported in one of the standard demo tasks. ms are converted to the equivalent\r
in ticks using the portTICK_PERIOD_MS constant. */\r
-#define mainERROR_CHECK_TIMER_PERIOD_MS ( 200UL / portTICK_PERIOD_MS )\r
+#define mainERROR_CHECK_TIMER_PERIOD_MS ( pdMS_TO_TICKS( 200UL ) )\r
\r
/* The standard demo flash timers can be used to flash any number of LEDs. In\r
this case, because only three LEDs are available, and one is in use by the\r
for the comtest, so the LED number is deliberately out of range. */\r
#define mainCOM_TEST_LED ( 3 )\r
\r
+/* Used by the standard demo timer tasks. */\r
+#define mainTIMER_TEST_PERIOD ( 50 )\r
+\r
/*-----------------------------------------------------------*/\r
\r
+/*\r
+ * Called by the idle hook function when the project is configured to run the\r
+ * full (as opposed to the blinky) demo.\r
+ */\r
+void vFullDemoIdleHook( void );\r
+\r
+/*\r
+ * Called by the tick hook function when the project is configured to run the\r
+ * full (as opposed to the blinky) demo.\r
+ */\r
+void vFullDemoTickHook( void );\r
+\r
/*\r
* The check timer callback function, as described at the top of this file.\r
*/\r
\r
void main_full( void )\r
{\r
-TimerHandle_t xCheckTimer = NULL;\r
-\r
/* Start all the other standard demo/test tasks. The have not particular\r
functionality, but do demonstrate how to use the FreeRTOS API and test the\r
kernel port. */\r
vStartRecursiveMutexTasks();\r
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );\r
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );\r
- vStartLEDFlashTimers( mainNUMBER_OF_FLASH_TIMERS_LEDS );\r
vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );\r
vStartQueueSetTasks();\r
-\r
- /* Create the software timer that performs the 'check' functionality,\r
- as described at the top of this file. */\r
- xCheckTimer = xTimerCreate( "CheckTimer", /* A text name, purely to help debugging. */\r
- ( mainCHECK_TIMER_PERIOD_MS ), /* The timer period, in this case 3000ms (3s). */\r
- pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */\r
- ( void * ) 0, /* The ID is not used, so can be set to anything. */\r
- prvCheckTimerCallback /* The callback function that inspects the status of all the other tasks. */\r
- );\r
-\r
- if( xCheckTimer != NULL )\r
- {\r
- xTimerStart( xCheckTimer, mainDONT_BLOCK );\r
- }\r
+ vStartTaskNotifyTask();\r
+ vStartTimerDemoTask( mainTIMER_TEST_PERIOD );\r
+ vStartEventGroupTasks();\r
+ vStartInterruptSemaphoreTasks();\r
\r
/* The set of tasks created by the following function call have to be\r
created last as they keep account of the number of tasks they expect to see\r
\r
if( xAreIntQueueTasksStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 0UL;\r
}\r
\r
if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 1UL;\r
}\r
\r
if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 2UL;\r
}\r
\r
if( xAreBlockingQueuesStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 3UL;\r
}\r
\r
if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 4UL;\r
}\r
\r
if ( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 5UL;\r
}\r
\r
if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 6UL;\r
}\r
\r
if( xIsCreateTaskStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 7UL;\r
}\r
\r
if( xArePollingQueuesStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 8UL;\r
}\r
\r
if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 9UL;\r
}\r
\r
if( xAreComTestTasksStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 10UL;\r
}\r
\r
- if( xAreQueueSetTasksStillRunning() != pdPASS )\r
+ if( xAreQueueSetTasksStillRunning() != pdTRUE )\r
+ {\r
+ ulErrorFound |= 1UL << 11UL;\r
+ }\r
+ \r
+ if( xAreTaskNotificationTasksStillRunning() != pdTRUE )\r
+ {\r
+ ulErrorFound |= 1UL << 12UL;\r
+ }\r
+ \r
+ if( xAreTimerDemoTasksStillRunning( mainCHECK_TIMER_PERIOD_MS ) != pdTRUE )\r
+ {\r
+ ulErrorFound |= 1UL << 13UL;\r
+ }\r
+ \r
+ if( xAreEventGroupTasksStillRunning() != pdTRUE )\r
+ {\r
+ ulErrorFound |= 1UL << 14UL;\r
+ }\r
+ \r
+ if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )\r
{\r
- ulErrorFound = pdTRUE;\r
+ ulErrorFound |= 1UL << 15UL;\r
}\r
+ \r
\r
/* Toggle the check LED to give an indication of the system status. If\r
the LED toggles every mainCHECK_TIMER_PERIOD_MS milliseconds then\r
}\r
/*-----------------------------------------------------------*/\r
\r
+void vFullDemoIdleHook( void )\r
+{\r
+static TimerHandle_t xCheckTimer = NULL;\r
+ \r
+ if( xCheckTimer == NULL )\r
+ {\r
+ /* Create the software timer that performs the 'check' \r
+ functionality, in the full demo. This is not done before the\r
+ scheduler is started as to do so would prevent the standard demo\r
+ timer tasks from passing their tests (they expect the timer\r
+ command queue to be empty. */\r
+ xCheckTimer = xTimerCreate( "CheckTimer", /* A text name, purely to help debugging. */\r
+ mainCHECK_TIMER_PERIOD_MS, /* The timer period, in this case 3000ms (3s). */\r
+ pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */\r
+ ( void * ) 0, /* The ID is not used, so can be set to anything. */\r
+ prvCheckTimerCallback /* The callback function that inspects the status of all the other tasks. */\r
+ );\r
+\r
+ if( xCheckTimer != NULL )\r
+ {\r
+ xTimerStart( xCheckTimer, mainDONT_BLOCK );\r
+ }\r
+ \r
+ /* Also start some timers that just flash LEDs. */\r
+ vStartLEDFlashTimers( mainNUMBER_OF_FLASH_TIMERS_LEDS );\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vFullDemoTickHook( void )\r
+{\r
+ /* In this case the tick hook is used as part of the queue set test. */\r
+ vQueueSetAccessQueueSetFromISR();\r
+ \r
+ /* Use task notifications from an interrupt. */\r
+ xNotifyTaskFromISR();\r
+ \r
+ /* Use timers from an interrupt. */\r
+ vTimerPeriodicISRTests();\r
+ \r
+ /* Use event groups from an interrupt. */\r
+ vPeriodicEventGroupsProcessing();\r
+ \r
+ /* Use mutexes from interrupts. */\r
+ vInterruptSemaphorePeriodicTest();\r
+}\r
#define configUSE_TICK_HOOK 1\r
#define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */\r
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 50 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */\r
-#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 23 * 1024 ) )\r
+#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 24 * 1024 ) )\r
#define configMAX_TASK_NAME_LEN ( 12 )\r
#define configUSE_TRACE_FACILITY 1\r
#define configUSE_16_BIT_TICKS 0\r
being used as this demo could easily create one large heap region instead of\r
multiple smaller heap regions - in which case heap_4.c would be the more\r
appropriate choice. */\r
-#define mainREGION_1_SIZE 3001\r
+#define mainREGION_1_SIZE 4001\r
#define mainREGION_2_SIZE 18105\r
-#define mainREGION_3_SIZE 1407\r
+#define mainREGION_3_SIZE 1807\r
\r
/*\r
* main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.\r
function, because it is the responsibility of the idle task to clean up\r
memory allocated by the kernel to any task that has since been deleted. */\r
\r
- /* Uncomment the following code to allow the trace to be stopped with any \r
+ /* Uncomment the following code to allow the trace to be stopped with any\r
key press. The code is commented out by default as the kbhit() function\r
interferes with the run time behaviour. */\r
- /* \r
+ /*\r
if( _kbhit() != pdFALSE )\r
{\r
if( xTraceRunning == pdTRUE )\r
array. */\r
configASSERT( ( ulAdditionalOffset + mainREGION_1_SIZE + mainREGION_2_SIZE + mainREGION_3_SIZE ) < configTOTAL_HEAP_SIZE );\r
\r
+ /* Prevent compiler warnings when configASSERT() is not defined. */\r
+ ( void ) ulAdditionalOffset;\r
+\r
vPortDefineHeapRegions( xHeapRegions );\r
}\r
/*-----------------------------------------------------------*/\r
* \ingroup FreeRTOSIntro\r
*/\r
\r
+#ifndef INC_FREERTOS_H\r
+ #error FreeRTOS.h must be included before list.h\r
+#endif\r
\r
#ifndef LIST_H\r
#define LIST_H\r
#ifdef __cplusplus\r
extern "C" {\r
#endif\r
+\r
+/* Macros that can be used to place known values within the list structures,\r
+then check that the known values do not get corrupted during the execution of\r
+the application. These may catch the list data structures being overwritten in\r
+memory. They will not catch data errors caused by incorrect configuration or\r
+use of FreeRTOS.*/\r
+#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 )\r
+ /* Define the macros to do nothing. */\r
+ #define listLIST_ITEM_INTEGRITY_CHECK_VALUE_1\r
+ #define listLIST_ITEM_INTEGRITY_CHECK_VALUE_2\r
+ #define listLIST_INTEGRITY_CHECK_VALUE_1\r
+ #define listLIST_INTEGRITY_CHECK_VALUE_2\r
+ #define listSET_LIST_ITEM_INTEGRITY_CHECK_1_VALUE( pxItem )\r
+ #define listSET_LIST_ITEM_INTEGRITY_CHECK_2_VALUE( pxItem )\r
+ #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList )\r
+ #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList )\r
+ #define listTEST_LIST_ITEM_INTEGRITY( pxItem )\r
+ #define listTEST_LIST_INTEGRITY( pxList )\r
+#else\r
+ /* Define macros that add new members into the list structures. */\r
+ #define listLIST_ITEM_INTEGRITY_CHECK_VALUE_1 TickType_t xListItemIntegrityValue1;\r
+ #define listLIST_ITEM_INTEGRITY_CHECK_VALUE_2 TickType_t xListItemIntegrityValue2;\r
+ #define listLIST_INTEGRITY_CHECK_VALUE_1 TickType_t xListIntegrityValue1;\r
+ #define listLIST_INTEGRITY_CHECK_VALUE_2 TickType_t xListIntegrityValue2;\r
+\r
+ /* Define macros that set the new structure members to known values. */\r
+ #define listSET_LIST_ITEM_INTEGRITY_CHECK_1_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE\r
+ #define listSET_LIST_ITEM_INTEGRITY_CHECK_2_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE\r
+ #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) ( pxList )->xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE\r
+ #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) ( pxList )->xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE\r
+\r
+ /* Define macros that will assert if one of the structure members does not\r
+ contain its expected value. */\r
+ #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) configASSERT( ( ( pxItem )->xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxItem )->xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) )\r
+ #define listTEST_LIST_INTEGRITY( pxList ) configASSERT( ( ( pxList )->xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxList )->xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) )\r
+#endif /* configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES */\r
+\r
+\r
/*\r
* Definition of the only type of object that a list can contain.\r
*/\r
struct xLIST_ITEM\r
{\r
+ listLIST_ITEM_INTEGRITY_CHECK_VALUE_1 /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */\r
configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */\r
struct xLIST_ITEM * configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */\r
struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */\r
void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */\r
void * configLIST_VOLATILE pvContainer; /*< Pointer to the list in which this list item is placed (if any). */\r
+ listLIST_ITEM_INTEGRITY_CHECK_VALUE_2 /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */\r
};\r
typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */\r
\r
struct xMINI_LIST_ITEM\r
{\r
+ listLIST_ITEM_INTEGRITY_CHECK_VALUE_1 /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */\r
configLIST_VOLATILE TickType_t xItemValue;\r
struct xLIST_ITEM * configLIST_VOLATILE pxNext;\r
struct xLIST_ITEM * configLIST_VOLATILE pxPrevious;\r
*/\r
typedef struct xLIST\r
{\r
+ listLIST_INTEGRITY_CHECK_VALUE_1 /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */\r
configLIST_VOLATILE UBaseType_t uxNumberOfItems;\r
ListItem_t * configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */\r
MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */\r
+ listLIST_INTEGRITY_CHECK_VALUE_2 /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */\r
} List_t;\r
\r
/*\r
#define errQUEUE_BLOCKED ( -4 )\r
#define errQUEUE_YIELD ( -5 )\r
\r
+/* Macros used for basic data corruption checks. */\r
+#ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES\r
+ #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0\r
+#endif\r
+\r
+#if( configUSE_16_BIT_TICKS == 1 )\r
+ #define pdINTEGRITY_CHECK_VALUE 0x5a5a\r
+#else\r
+ #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL\r
+#endif\r
+\r
#endif /* PROJDEFS_H */\r
\r
\r
pxList->xListEnd.pxPrevious = ( ListItem_t * ) &( pxList->xListEnd );/*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */\r
\r
pxList->uxNumberOfItems = ( UBaseType_t ) 0U;\r
+\r
+ /* Write known values into the list if\r
+ configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */\r
+ listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList );\r
+ listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList );\r
}\r
/*-----------------------------------------------------------*/\r
\r
{\r
/* Make sure the list item is not recorded as being on a list. */\r
pxItem->pvContainer = NULL;\r
+\r
+ /* Write known values into the list item if\r
+ configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */\r
+ listSET_LIST_ITEM_INTEGRITY_CHECK_1_VALUE( pxItem );\r
+ listSET_LIST_ITEM_INTEGRITY_CHECK_2_VALUE( pxItem );\r
}\r
/*-----------------------------------------------------------*/\r
\r
{\r
ListItem_t * const pxIndex = pxList->pxIndex;\r
\r
+ /* Only effective when configASSERT() is also defined, these tests may catch\r
+ the list data structures being overwritten in memory. They will not catch\r
+ data errors caused by incorrect configuration or use of FreeRTOS. */\r
+ listTEST_LIST_INTEGRITY( pxList );\r
+ listTEST_LIST_ITEM_INTEGRITY( pxNewListItem );\r
+\r
/* Insert a new list item into pxList, but rather than sort the list,\r
makes the new list item the last item to be removed by a call to\r
listGET_OWNER_OF_NEXT_ENTRY(). */\r
ListItem_t *pxIterator;\r
const TickType_t xValueOfInsertion = pxNewListItem->xItemValue;\r
\r
+ /* Only effective when configASSERT() is also defined, these tests may catch\r
+ the list data structures being overwritten in memory. They will not catch\r
+ data errors caused by incorrect configuration or use of FreeRTOS. */\r
+ listTEST_LIST_INTEGRITY( pxList );\r
+ listTEST_LIST_ITEM_INTEGRITY( pxNewListItem );\r
+\r
/* Insert the new list item into the list, sorted in xItemValue order.\r
\r
If the list already contains a list item with the same item value then the\r
*pxTopOfStack = ( StackType_t ) 0x00000000;\r
pxTopOfStack--;\r
\r
- #if XPAR_MICROBLAZE_0_USE_FPU == 1\r
+ #if XPAR_MICROBLAZE_0_USE_FPU != 0\r
/* The FSR value placed in the initial task context is just 0. */\r
*pxTopOfStack = portINITIAL_FSR;\r
pxTopOfStack--;\r
/*\r
- FreeRTOS V8.1.2 - Copyright (C) 2014 Real Time Engineers Ltd. \r
+ FreeRTOS V8.1.2 - Copyright (C) 2014 Real Time Engineers Ltd.\r
All rights reserved\r
\r
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
\r
/*-----------------------------------------------------------*/\r
\r
-/* vApplicationExceptionRegisterDump() is a callback function that the \r
+/* vApplicationExceptionRegisterDump() is a callback function that the\r
application can optionally define to receive a populated xPortRegisterDump\r
-structure. If the application chooses not to define a version of \r
-vApplicationExceptionRegisterDump() then this weekly defined default \r
+structure. If the application chooses not to define a version of\r
+vApplicationExceptionRegisterDump() then this weekly defined default\r
implementation will be called instead. */\r
extern void vApplicationExceptionRegisterDump( xPortRegisterDump *xRegisterDump ) __attribute__((weak));\r
void vApplicationExceptionRegisterDump( xPortRegisterDump *xRegisterDump )\r
\r
/* Fill an xPortRegisterDump structure with the MicroBlaze context as it\r
was immediately before the exception occurrence. */\r
- \r
- /* First fill in the name and handle of the task that was in the Running \r
+\r
+ /* First fill in the name and handle of the task that was in the Running\r
state when the exception occurred. */\r
xRegisterDump.xCurrentTaskHandle = pxCurrentTCB;\r
xRegisterDump.pcCurrentTaskName = pcTaskGetTaskName( NULL );\r
xRegisterDump.ulR18 = pulStackPointerOnFunctionEntry[ portexR18_STACK_OFFSET ];\r
xRegisterDump.ulR19 = pulStackPointerOnFunctionEntry[ portexR19_STACK_OFFSET ];\r
xRegisterDump.ulMSR = pulStackPointerOnFunctionEntry[ portexMSR_STACK_OFFSET ];\r
- \r
+\r
/* Obtain the value of all other registers. */\r
xRegisterDump.ulR2_small_data_area = mfgpr( R2 );\r
xRegisterDump.ulR13_read_write_small_data_area = mfgpr( R13 );\r
xRegisterDump.ulEAR = mfear();\r
xRegisterDump.ulESR = mfesr();\r
xRegisterDump.ulEDR = mfedr();\r
- \r
+\r
/* Move the saved program counter back to the instruction that was executed\r
when the exception occurred. This is only valid for certain types of\r
exception. */\r
xRegisterDump.ulPC = xRegisterDump.ulR17_return_address_from_exceptions - portexINSTRUCTION_SIZE;\r
\r
- #if XPAR_MICROBLAZE_0_USE_FPU == 1\r
+ #if XPAR_MICROBLAZE_0_USE_FPU != 0\r
{\r
xRegisterDump.ulFSR = mffsr();\r
}\r
xRegisterDump.pcExceptionCause = ( int8_t * const ) "XEXC_ID_STACK_VIOLATION or XEXC_ID_MMU";\r
break;\r
\r
- #if XPAR_MICROBLAZE_0_USE_FPU == 1\r
+ #if XPAR_MICROBLAZE_0_USE_FPU != 0\r
\r
case XEXC_ID_FPU :\r
xRegisterDump.pcExceptionCause = ( int8_t * const ) "XEXC_ID_FPU see ulFSR value";\r
#endif /* XPAR_MICROBLAZE_0_USE_FPU */\r
}\r
\r
- /* vApplicationExceptionRegisterDump() is a callback function that the \r
+ /* vApplicationExceptionRegisterDump() is a callback function that the\r
application can optionally define to receive the populated xPortRegisterDump\r
- structure. If the application chooses not to define a version of \r
- vApplicationExceptionRegisterDump() then the weekly defined default \r
+ structure. If the application chooses not to define a version of\r
+ vApplicationExceptionRegisterDump() then the weekly defined default\r
implementation within this file will be called instead. */\r
vApplicationExceptionRegisterDump( &xRegisterDump );\r
\r
}\r
\r
/* Exclude the entire file if the MicroBlaze is not configured to handle\r
-exceptions, or the application defined configuration item \r
+exceptions, or the application defined configuration item\r
configINSTALL_EXCEPTION_HANDLERS is not set to 1. */\r
#endif /* ( MICROBLAZE_EXCEPTIONS_ENABLED == 1 ) && ( configINSTALL_EXCEPTION_HANDLERS == 1 ) */\r
\r
/*\r
- FreeRTOS V8.1.2 - Copyright (C) 2014 Real Time Engineers Ltd. \r
+ FreeRTOS V8.1.2 - Copyright (C) 2014 Real Time Engineers Ltd.\r
All rights reserved\r
\r
VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
\r
/* The context is oversized to allow functions called from the ISR to write\r
back into the caller stack. */\r
-#if XPAR_MICROBLAZE_0_USE_FPU == 1\r
+#if XPAR_MICROBLAZE_0_USE_FPU != 0\r
#define portCONTEXT_SIZE 136\r
#define portMINUS_CONTEXT_SIZE -136\r
#else\r
mfs r18, rmsr\r
swi r18, r1, portMSR_OFFSET\r
\r
- #if XPAR_MICROBLAZE_0_USE_FPU == 1\r
+ #if XPAR_MICROBLAZE_0_USE_FPU != 0\r
/* Stack FSR. */\r
mfs r18, rfsr\r
swi r18, r1, portFSR_OFFSET\r
/* Save the top of stack value to the TCB. */\r
lwi r3, r0, pxCurrentTCB\r
sw r1, r0, r3\r
- \r
+\r
.endm\r
\r
.macro portRESTORE_CONTEXT\r
lwi r18, r1, portMSR_OFFSET\r
mts rmsr, r18\r
\r
- #if XPAR_MICROBLAZE_0_USE_FPU == 1\r
+ #if XPAR_MICROBLAZE_0_USE_FPU != 0\r
/* Reload the FSR from the stack. */\r
lwi r18, r1, portFSR_OFFSET\r
mts rfsr, r18\r
vPortStartFirstTask:\r
\r
portRESTORE_CONTEXT\r
- \r
+\r
\r
\r
#if MICROBLAZE_EXCEPTIONS_ENABLED == 1\r
- \r
+\r
.text\r
.align 2\r
vPortExceptionHandlerEntry:\r
\r
#if ( portUSING_MPU_WRAPPERS == 1 )\r
xMPU_SETTINGS xMPUSettings; /*< The MPU settings are defined as part of the port layer. THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT. */\r
+ BaseType_t xUsingStaticallyAllocatedStack; /* Set to pdTRUE if the stack is a statically allocated array, and pdFALSE if the stack is dynamically allocated. */\r
#endif\r
\r
ListItem_t xGenericListItem; /*< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */\r
{\r
BaseType_t xReturn;\r
TCB_t * pxNewTCB;\r
+StackType_t *pxTopOfStack;\r
\r
configASSERT( pxTaskCode );\r
configASSERT( ( ( uxPriority & ( ~portPRIVILEGE_BIT ) ) < configMAX_PRIORITIES ) );\r
\r
if( pxNewTCB != NULL )\r
{\r
- StackType_t *pxTopOfStack;\r
-\r
#if( portUSING_MPU_WRAPPERS == 1 )\r
/* Should the task be created in privileged mode? */\r
BaseType_t xRunPrivileged;\r
xRunPrivileged = pdFALSE;\r
}\r
uxPriority &= ~portPRIVILEGE_BIT;\r
+\r
+ if( puxStackBuffer != NULL )\r
+ {\r
+ /* The application provided its own stack. Note this so no\r
+ attempt is made to delete the stack should that task be\r
+ deleted. */\r
+ pxNewTCB->xUsingStaticallyAllocatedStack = pdTRUE;\r
+ }\r
+ else\r
+ {\r
+ /* The stack was allocated dynamically. Note this so it can be\r
+ deleted again if the task is deleted. */\r
+ pxNewTCB->xUsingStaticallyAllocatedStack = pdFALSE;\r
+ }\r
#endif /* portUSING_MPU_WRAPPERS == 1 */\r
\r
/* Calculate the top of stack address. This depends on whether the\r
_reclaim_reent( &( pxTCB->xNewLib_reent ) );\r
}\r
#endif /* configUSE_NEWLIB_REENTRANT */\r
- vPortFreeAligned( pxTCB->pxStack );\r
+\r
+ #if( portUSING_MPU_WRAPPERS == 1 )\r
+ {\r
+ /* Only free the stack if it was allocated dynamically in the first\r
+ place. */\r
+ if( pxTCB->xUsingStaticallyAllocatedStack == pdFALSE )\r
+ {\r
+ vPortFreeAligned( pxTCB->pxStack );\r
+ }\r
+ }\r
+ #else\r
+ {\r
+ vPortFreeAligned( pxTCB->pxStack );\r
+ }\r
+ #endif\r
+\r
vPortFree( pxTCB );\r
}\r
\r
pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName );\r
\r
/* Write the rest of the string. */\r
- sprintf( pcWriteBuffer, "\t\t%c\t%u\t%u\t%u\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber );\r
+ sprintf( pcWriteBuffer, "\t%c\t%u\t%u\t%u\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber );\r
pcWriteBuffer += strlen( pcWriteBuffer );\r
}\r
\r
{\r
#ifdef portLU_PRINTF_SPECIFIER_REQUIRED\r
{\r
- sprintf( pcWriteBuffer, "\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );\r
+ sprintf( pcWriteBuffer, "\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage );\r
}\r
#else\r
{\r
/* sizeof( int ) == sizeof( long ) so a smaller\r
printf() library can be used. */\r
- sprintf( pcWriteBuffer, "\t\t%u\t\t%u%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage );\r
+ sprintf( pcWriteBuffer, "\t%u\t\t%u%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage );\r
}\r
#endif\r
}\r
consumed less than 1% of the total run time. */\r
#ifdef portLU_PRINTF_SPECIFIER_REQUIRED\r
{\r
- sprintf( pcWriteBuffer, "\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter );\r
+ sprintf( pcWriteBuffer, "\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter );\r
}\r
#else\r
{\r
/* sizeof( int ) == sizeof( long ) so a smaller\r
printf() library can be used. */\r
- sprintf( pcWriteBuffer, "\t\t%u\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter );\r
+ sprintf( pcWriteBuffer, "\t%u\t\t<1%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter );\r
}\r
#endif\r
}\r