/*\r
- FreeRTOS V9.0.0rc1 - Copyright (C) 2016 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
- 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
-\r
- ***************************************************************************\r
- >>! NOTE: The modification to the GPL is included to allow you to !<<\r
- >>! distribute a combined work that includes FreeRTOS without being !<<\r
- >>! obliged to provide the source code for proprietary components !<<\r
- >>! outside of the FreeRTOS kernel. !<<\r
- ***************************************************************************\r
-\r
- FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
- FOR A PARTICULAR PURPOSE. Full license text is available on the following\r
- link: http://www.freertos.org/a00114.html\r
-\r
- ***************************************************************************\r
- * *\r
- * FreeRTOS provides completely free yet professionally developed, *\r
- * robust, strictly quality controlled, supported, and cross *\r
- * platform software that is more than just the market leader, it *\r
- * is the industry's de facto standard. *\r
- * *\r
- * Help yourself get started quickly while simultaneously helping *\r
- * to support the FreeRTOS project by purchasing a FreeRTOS *\r
- * tutorial book, reference manual, or both: *\r
- * http://www.FreeRTOS.org/Documentation *\r
- * *\r
- ***************************************************************************\r
-\r
- http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading\r
- the FAQ page "My application does not run, what could be wrong?". Have you\r
- defined configASSERT()?\r
-\r
- http://www.FreeRTOS.org/support - In return for receiving this top quality\r
- embedded software for free we request you assist our global community by\r
- participating in the support forum.\r
-\r
- http://www.FreeRTOS.org/training - Investing in training allows your team to\r
- be as productive as possible as early as possible. Now you can receive\r
- FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers\r
- Ltd, and the world's leading authority on the world's leading RTOS.\r
-\r
- http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
- including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
- compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
-\r
- http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.\r
- Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.\r
-\r
- http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High\r
- Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS\r
- licenses offer ticketed support, indemnification and commercial middleware.\r
-\r
- http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
- engineered and independently SIL3 certified version for use in safety and\r
- mission critical applications that require provable dependability.\r
-\r
- 1 tab == 4 spaces!\r
-*/\r
+ * FreeRTOS Kernel V10.2.1\r
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
+ * this software and associated documentation files (the "Software"), to deal in\r
+ * the Software without restriction, including without limitation the rights to\r
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
+ * the Software, and to permit persons to whom the Software is furnished to do so,\r
+ * subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included in all\r
+ * copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ *\r
+ * http://www.FreeRTOS.org\r
+ * http://aws.amazon.com/freertos\r
+ *\r
+ * 1 tab == 4 spaces!\r
+ */\r
\r
/*\r
*******************************************************************************\r
- * NOTE: Windows will not be running the FreeRTOS demo threads continuously, so\r
- * do not expect to get real time behaviour from the FreeRTOS Windows port, or\r
- * this demo application. Also, the timing information in the FreeRTOS+Trace\r
- * logs have no meaningful units. See the documentation page for the Windows\r
- * port for further information:\r
+ * NOTE 1: The Win32 port is a simulation (or is that emulation?) only! Do not\r
+ * expect to get real time behaviour from the Win32 port or this demo\r
+ * application. It is provided as a convenient development and demonstration\r
+ * test bed only.\r
+ *\r
+ * Windows will not be running the FreeRTOS simulator threads continuously, so\r
+ * the timing information in the FreeRTOS+Trace logs have no meaningful units.\r
+ * See the documentation page for the Windows simulator for an explanation of\r
+ * the slow timing:\r
* http://www.freertos.org/FreeRTOS-Windows-Simulator-Emulator-for-Visual-Studio-and-Eclipse-MingW.html\r
+ * - READ THE WEB DOCUMENTATION FOR THIS PORT FOR MORE INFORMATION ON USING IT -\r
*\r
* NOTE 2: This project provides two demo applications. A simple blinky style\r
* project, and a more comprehensive test and demo application. The\r
* in main.c. This file implements the comprehensive test and demo version.\r
*\r
* NOTE 3: This file only contains the source code that is specific to the\r
- * basic demo. Generic functions, such FreeRTOS hook functions, are defined in\r
+ * full demo. Generic functions, such FreeRTOS hook functions, are defined in\r
* main.c.\r
*******************************************************************************\r
*\r
* "Check" task - This only executes every five seconds but has a high priority\r
* to ensure it gets processor time. Its main function is to check that all the\r
* standard demo tasks are still operational. While no errors have been\r
- * discovered the check task will print out "No Errors" along with some system\r
- * status information. If an error is discovered in the execution of a task\r
- * then the check task will print out an appropriate error message.\r
+ * discovered the check task will print out "OK" and the current simulated tick\r
+ * time. If an error is discovered in the execution of a task then the check\r
+ * task will print out an appropriate error message.\r
*\r
*/\r
\r
#include "StaticAllocation.h"\r
#include "blocktim.h"\r
#include "AbortDelay.h"\r
+#include "MessageBufferDemo.h"\r
+#include "StreamBufferDemo.h"\r
+#include "StreamBufferInterrupt.h"\r
+#include "MessageBufferAMP.h"\r
\r
/* Priorities at which the tasks are created. */\r
#define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 2 )\r
static void prvDemonstratePendingFunctionCall( void );\r
\r
/*\r
-* The function that is pended by prvDemonstratePendingFunctionCall().\r
-*/\r
+ * The function that is pended by prvDemonstratePendingFunctionCall().\r
+ */\r
static void prvPendedFunction( void *pvParameter1, uint32_t ulParameter2 );\r
\r
/*\r
vStartRecursiveMutexTasks();\r
vStartCountingSemaphoreTasks();\r
vStartDynamicPriorityTasks();\r
- vStartQueueSetTasks();\r
vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY );\r
vStartEventGroupTasks();\r
vStartInterruptSemaphoreTasks();\r
- vStartQueueSetPollingTask();\r
vCreateBlockTimeTasks();\r
vCreateAbortDelayTasks();\r
xTaskCreate( prvDemoQueueSpaceFunctions, "QSpace", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
xTaskCreate( prvPermanentlyBlockingSemaphoreTask, "BlockSem", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
xTaskCreate( prvPermanentlyBlockingNotificationTask, "BlockNoti", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
\r
+ vStartMessageBufferTasks( configMINIMAL_STACK_SIZE );\r
+ vStartStreamBufferTasks();\r
+ vStartStreamBufferInterruptDemo();\r
+ vStartMessageBufferAMPTasks( configMINIMAL_STACK_SIZE );\r
+\r
+ #if( configUSE_QUEUE_SETS == 1 )\r
+ {\r
+ vStartQueueSetTasks();\r
+ vStartQueueSetPollingTask();\r
+ }\r
+ #endif\r
+\r
#if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
{\r
vStartStaticallyAllocatedTasks();\r
static void prvCheckTask( void *pvParameters )\r
{\r
TickType_t xNextWakeTime;\r
-const TickType_t xCycleFrequency = pdMS_TO_TICKS( 2500UL );\r
+const TickType_t xCycleFrequency = pdMS_TO_TICKS( 5000UL );\r
+HeapStats_t xHeapStats;\r
\r
/* Just to remove compiler warning. */\r
( void ) pvParameters;\r
}\r
#endif\r
\r
- if( xAreTaskNotificationTasksStillRunning() != pdTRUE )\r
+ if( xAreStreamBufferTasksStillRunning() != pdTRUE )\r
+ {\r
+ pcStatusMessage = "Error: StreamBuffer";\r
+ }\r
+ else if( xAreMessageBufferTasksStillRunning() != pdTRUE )\r
+ {\r
+ pcStatusMessage = "Error: MessageBuffer";\r
+ }\r
+ else if( xAreTaskNotificationTasksStillRunning() != pdTRUE )\r
{\r
pcStatusMessage = "Error: Notification";\r
}\r
-\r
- if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )\r
+ else if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE )\r
{\r
pcStatusMessage = "Error: IntSem";\r
}\r
{\r
pcStatusMessage = "Error: EventGroup";\r
}\r
- else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
- {\r
+ else if( xAreIntegerMathsTaskStillRunning() != pdTRUE )\r
+ {\r
pcStatusMessage = "Error: IntMath";\r
- }\r
+ }\r
else if( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
{\r
pcStatusMessage = "Error: GenQueue";\r
{\r
pcStatusMessage = "Error: BlockQueue";\r
}\r
- else if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
- {\r
+ else if( xAreSemaphoreTasksStillRunning() != pdTRUE )\r
+ {\r
pcStatusMessage = "Error: SemTest";\r
- }\r
- else if( xArePollingQueuesStillRunning() != pdTRUE )\r
- {\r
+ }\r
+ else if( xArePollingQueuesStillRunning() != pdTRUE )\r
+ {\r
pcStatusMessage = "Error: PollQueue";\r
- }\r
+ }\r
else if( xAreMathsTaskStillRunning() != pdPASS )\r
{\r
pcStatusMessage = "Error: Flop";\r
}\r
- else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
- {\r
+ else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
+ {\r
pcStatusMessage = "Error: RecMutex";\r
}\r
else if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE )\r
{\r
pcStatusMessage = "Error: Dynamic";\r
}\r
- else if( xAreQueueSetTasksStillRunning() != pdPASS )\r
- {\r
- pcStatusMessage = "Error: Queue set";\r
- }\r
else if( xIsQueueOverwriteTaskStillRunning() != pdPASS )\r
{\r
pcStatusMessage = "Error: Queue overwrite";\r
}\r
- else if( xAreQueueSetPollTasksStillRunning() != pdPASS )\r
- {\r
- pcStatusMessage = "Error: Queue set polling";\r
- }\r
else if( xAreBlockTimeTestTasksStillRunning() != pdPASS )\r
{\r
pcStatusMessage = "Error: Block time";\r
{\r
pcStatusMessage = "Error: Abort delay";\r
}\r
+ else if( xIsInterruptStreamBufferDemoStillRunning() != pdPASS )\r
+ {\r
+ pcStatusMessage = "Error: Stream buffer interrupt";\r
+ }\r
+ else if( xAreMessageBufferAMPTasksStillRunning() != pdPASS )\r
+ {\r
+ pcStatusMessage = "Error: Message buffer AMP";\r
+ }\r
+\r
+ #if( configUSE_QUEUE_SETS == 1 )\r
+ else if( xAreQueueSetTasksStillRunning() != pdPASS )\r
+ {\r
+ pcStatusMessage = "Error: Queue set";\r
+ }\r
+ else if( xAreQueueSetPollTasksStillRunning() != pdPASS )\r
+ {\r
+ pcStatusMessage = "Error: Queue set polling";\r
+ }\r
+ #endif\r
\r
#if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
else if( xAreStaticAllocationTasksStillRunning() != pdPASS )\r
\r
/* This is the only task that uses stdout so its ok to call printf()\r
directly. */\r
- printf( "%s - tick count %d - free heap %d - min free heap %d\r\n", pcStatusMessage,\r
- xTaskGetTickCount(),\r
- xPortGetFreeHeapSize(),\r
- xPortGetMinimumEverFreeHeapSize() );\r
+ vPortGetHeapStats( &xHeapStats );\r
+\r
+ configASSERT( xHeapStats.xAvailableHeapSpaceInBytes == xPortGetFreeHeapSize() );\r
+ configASSERT( xHeapStats.xMinimumEverFreeBytesRemaining == xPortGetMinimumEverFreeHeapSize() );\r
+\r
+ printf( "%s - tick count %zu - free heap %zu - min free heap %zu - largest free block %zu \r\n",\r
+ pcStatusMessage,\r
+ xTaskGetTickCount(),\r
+ xHeapStats.xAvailableHeapSpaceInBytes,\r
+ xHeapStats.xMinimumEverFreeBytesRemaining,\r
+ xHeapStats.xSizeOfLargestFreeBlockInBytes );\r
}\r
}\r
/*-----------------------------------------------------------*/\r
/* Call the periodic queue overwrite from ISR demo. */\r
vQueueOverwritePeriodicISRDemo();\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
- vQueueSetAccessQueueSetFromISR();\r
- vQueueSetPollingInterruptAccess();\r
+ #if( configUSE_QUEUE_SETS == 1 ) /* Remove the tests if queue sets are not defined. */\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
+ vQueueSetAccessQueueSetFromISR();\r
+ vQueueSetPollingInterruptAccess();\r
+ }\r
+ #endif\r
\r
/* Exercise event groups from interrupts. */\r
vPeriodicEventGroupsProcessing();\r
/* Exercise using task notifications from an interrupt. */\r
xNotifyTaskFromISR();\r
\r
+ /* Writes to stream buffer byte by byte to test the stream buffer trigger\r
+ level functionality. */\r
+ vPeriodicStreamBufferProcessing();\r
+\r
+ /* Writes a string to a string buffer four bytes at a time to demonstrate\r
+ a stream being sent from an interrupt to a task. */\r
+ vBasicStreamBufferSendFromISR();\r
+\r
/* For code coverage purposes. */\r
xTimerTask = xTimerGetTimerDaemonTaskHandle();\r
configASSERT( uxTaskPriorityGetFromISR( xTimerTask ) == configTIMER_TASK_PRIORITY );\r
\r
/* Check the same handle is obtained using the idle task's name. First try\r
with the wrong name, then the right name. */\r
- if( xTaskGetTaskHandle( "Idle" ) == xIdleTaskHandle )\r
+ if( xTaskGetHandle( "Idle" ) == xIdleTaskHandle )\r
{\r
pcStatusMessage = "Error: Returned handle for name Idle was incorrect";\r
}\r
\r
- if( xTaskGetTaskHandle( "IDLE" ) != xIdleTaskHandle )\r
+ if( xTaskGetHandle( "IDLE" ) != xIdleTaskHandle )\r
{\r
pcStatusMessage = "Error: Returned handle for name Idle was incorrect";\r
}\r
pcStatusMessage = "Error: Returned timer task handle was incorrect";\r
}\r
\r
- if( xTaskGetTaskHandle( "Tmr Svc" ) != xTimerTaskHandle )\r
+ if( xTaskGetHandle( "Tmr Svc" ) != xTimerTaskHandle )\r
{\r
pcStatusMessage = "Error: Returned handle for name Tmr Svc was incorrect";\r
}\r
pcStatusMessage = "Error: Returned timer task state was incorrect";\r
}\r
\r
- /* Also with the vTaskGetTaskInfo() function. */\r
- vTaskGetTaskInfo( xTimerTaskHandle, /* The task being queried. */\r
+ /* Also with the vTaskGetInfo() function. */\r
+ vTaskGetInfo( xTimerTaskHandle, /* The task being queried. */\r
&xTaskInfo, /* The structure into which information on the task will be written. */\r
pdTRUE, /* Include the task's high watermark in the structure. */\r
eInvalid ); /* Include the task state in the structure. */\r
\r
- /* Check the information returned by vTaskGetTaskInfo() is as expected. */\r
+ /* Check the information returned by vTaskGetInfo() is as expected. */\r
if( ( xTaskInfo.eCurrentState != eBlocked ) ||\r
( strcmp( xTaskInfo.pcTaskName, "Tmr Svc" ) != 0 ) ||\r
( xTaskInfo.uxCurrentPriority != configTIMER_TASK_PRIORITY ) ||\r
( xTaskInfo.pxStackBase != uxTimerTaskStack ) ||\r
( xTaskInfo.xHandle != xTimerTaskHandle ) )\r
{\r
- pcStatusMessage = "Error: vTaskGetTaskInfo() returned incorrect information about the timer task";\r
+ pcStatusMessage = "Error: vTaskGetInfo() returned incorrect information about the timer task";\r
}\r
\r
/* Other tests that should only be performed once follow. The test task\r