<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1632260763" name="GNU RISC-V Cross C Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler">\r
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths.1464742435" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath">\r
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/FreeRTOS_Source/include}""/>\r
+ <listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/full_demo/common_demo_tasks/include}""/>\r
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/freedom-e-sdk/drivers}""/>\r
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}}""/>\r
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/FreeRTOS_Source/portable/GCC/RISC-V-RV32}""/>\r
<listOptionValue builtIn="false" value="DONT_USE_PLIC"/>\r
<listOptionValue builtIn="false" value="DONT_USE_M_TIME"/>\r
</option>\r
- <option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.other.953712529" name="Other compiler flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.other" useByScannerDiscovery="true" value="-include sys/cdefs.h -fno-builtin-printf -c" valueType="string"/>\r
+ <option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.other.953712529" name="Other compiler flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.other" useByScannerDiscovery="true" value="-ffunction-sections -fdata-sections -include sys/cdefs.h -fno-builtin-printf -c" valueType="string"/>\r
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.1963706020" name="Language standard" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.default" valueType="enumerated"/>\r
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otheroptimizations.1382786252" name="Other optimization flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otheroptimizations" useByScannerDiscovery="true" value="" valueType="string"/>\r
+ <option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otherwarnings.1264446812" name="Other warning flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.otherwarnings" useByScannerDiscovery="true" value="-Wall -Wextra" valueType="string"/>\r
<inputType id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input.517786622" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.input"/>\r
</tool>\r
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler.890064572" name="GNU RISC-V Cross C++ Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.cpp.compiler"/>\r
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker.1118992651" name="GNU RISC-V Cross C Linker" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.linker">\r
- <option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.gcsections.303446425" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.gcsections" useByScannerDiscovery="false" value="false" valueType="boolean"/>\r
+ <option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.gcsections.303446425" name="Remove unused sections (-Xlinker --gc-sections)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.gcsections" useByScannerDiscovery="false" value="true" valueType="boolean"/>\r
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nostart.2092172057" name="Do not use standard start files (-nostartfiles)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.nostart" useByScannerDiscovery="false" value="true" valueType="boolean"/>\r
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs.1930877742" name="Libraries (-l)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.libs" useByScannerDiscovery="false" valueType="libs">\r
<listOptionValue builtIn="false" value="c"/>\r
</option>\r
- <option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.other.724386459" name="Other linker flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.other" useByScannerDiscovery="false" value="-Wl,--start-group -Wl,--end-group -Wl,--wrap=malloc -Wl,--wrap=free -Wl,--wrap=open -Wl,--wrap=lseek -Wl,--wrap=read -Wl,--wrap=write -Wl,--wrap=fstat -Wl,--wrap=stat -Wl,--wrap=close -Wl,--wrap=link -Wl,--wrap=unlink -Wl,--wrap=execve -Wl,--wrap=fork -Wl,--wrap=getpid -Wl,--wrap=kill -Wl,--wrap=wait -Wl,--wrap=isatty -Wl,--wrap=times -Wl,--wrap=sbrk -Wl,--wrap=_exit -Wl,--wrap=puts -Wl,--wrap=_malloc -Wl,--wrap=_free -Wl,--wrap=_open -Wl,--wrap=_lseek -Wl,--wrap=_read -Wl,--wrap=_write -Wl,--wrap=_fstat -Wl,--wrap=_stat -Wl,--wrap=_close -Wl,--wrap=_link -Wl,--wrap=_unlink -Wl,--wrap=_execve -Wl,--wrap=_fork -Wl,--wrap=_getpid -Wl,--wrap=_kill -Wl,--wrap=_wait -Wl,--wrap=_isatty -Wl,--wrap=_times -Wl,--wrap=_sbrk -Wl,--wrap=__exit -Wl,--wrap=_puts" valueType="string"/>\r
+ <option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.other.724386459" name="Other linker flags" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.other" useByScannerDiscovery="false" value="-Xlinker --defsym=__stack_size=1K -Wl,--start-group -Wl,--end-group -Wl,--wrap=malloc -Wl,--wrap=free -Wl,--wrap=open -Wl,--wrap=lseek -Wl,--wrap=read -Wl,--wrap=write -Wl,--wrap=fstat -Wl,--wrap=stat -Wl,--wrap=close -Wl,--wrap=link -Wl,--wrap=unlink -Wl,--wrap=execve -Wl,--wrap=fork -Wl,--wrap=getpid -Wl,--wrap=kill -Wl,--wrap=wait -Wl,--wrap=isatty -Wl,--wrap=times -Wl,--wrap=sbrk -Wl,--wrap=_exit -Wl,--wrap=puts -Wl,--wrap=_malloc -Wl,--wrap=_free -Wl,--wrap=_open -Wl,--wrap=_lseek -Wl,--wrap=_read -Wl,--wrap=_write -Wl,--wrap=_fstat -Wl,--wrap=_stat -Wl,--wrap=_close -Wl,--wrap=_link -Wl,--wrap=_unlink -Wl,--wrap=_execve -Wl,--wrap=_fork -Wl,--wrap=_getpid -Wl,--wrap=_kill -Wl,--wrap=_wait -Wl,--wrap=_isatty -Wl,--wrap=_times -Wl,--wrap=_sbrk -Wl,--wrap=__exit -Wl,--wrap=_puts" valueType="string"/>\r
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.paths.1340277823" name="Library search path (-L)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.linker.paths" useByScannerDiscovery="false" valueType="libPaths">\r
<listOptionValue builtIn="false" value="../"/>\r
</option>\r
<link>\r
<name>FreeRTOS_Source/event_groups.c</name>\r
<type>1</type>\r
- <locationURI>FREERTOS_ROUTE/FreeRTOS/Source/event_groups.c</locationURI>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Source/event_groups.c</locationURI>\r
</link>\r
<link>\r
<name>FreeRTOS_Source/include</name>\r
<type>2</type>\r
- <locationURI>FREERTOS_ROUTE/FreeRTOS/Source/include</locationURI>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Source/include</locationURI>\r
</link>\r
<link>\r
<name>FreeRTOS_Source/list.c</name>\r
<type>1</type>\r
- <locationURI>FREERTOS_ROUTE/FreeRTOS/Source/list.c</locationURI>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Source/list.c</locationURI>\r
</link>\r
<link>\r
<name>FreeRTOS_Source/portable</name>\r
<link>\r
<name>FreeRTOS_Source/queue.c</name>\r
<type>1</type>\r
- <locationURI>FREERTOS_ROUTE/FreeRTOS/Source/queue.c</locationURI>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Source/queue.c</locationURI>\r
</link>\r
<link>\r
<name>FreeRTOS_Source/stream_buffer.c</name>\r
<type>1</type>\r
- <locationURI>FREERTOS_ROUTE/FreeRTOS/Source/stream_buffer.c</locationURI>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Source/stream_buffer.c</locationURI>\r
</link>\r
<link>\r
<name>FreeRTOS_Source/tasks.c</name>\r
<type>1</type>\r
- <locationURI>FREERTOS_ROUTE/FreeRTOS/Source/tasks.c</locationURI>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Source/tasks.c</locationURI>\r
</link>\r
<link>\r
<name>FreeRTOS_Source/timers.c</name>\r
<type>1</type>\r
- <locationURI>FREERTOS_ROUTE/FreeRTOS/Source/timers.c</locationURI>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Source/timers.c</locationURI>\r
+ </link>\r
+ <link>\r
+ <name>full_demo/common_demo_tasks</name>\r
+ <type>2</type>\r
+ <locationURI>virtual:/virtual</locationURI>\r
</link>\r
<link>\r
<name>FreeRTOS_Source/portable/GCC</name>\r
<type>2</type>\r
<locationURI>virtual:/virtual</locationURI>\r
</link>\r
+ <link>\r
+ <name>full_demo/common_demo_tasks/EventGroupsDemo.c</name>\r
+ <type>1</type>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Demo/Common/Minimal/EventGroupsDemo.c</locationURI>\r
+ </link>\r
+ <link>\r
+ <name>full_demo/common_demo_tasks/GenQTest.c</name>\r
+ <type>1</type>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Demo/Common/Minimal/GenQTest.c</locationURI>\r
+ </link>\r
+ <link>\r
+ <name>full_demo/common_demo_tasks/TaskNotify.c</name>\r
+ <type>1</type>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Demo/Common/Minimal/TaskNotify.c</locationURI>\r
+ </link>\r
+ <link>\r
+ <name>full_demo/common_demo_tasks/TimerDemo.c</name>\r
+ <type>1</type>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Demo/Common/Minimal/TimerDemo.c</locationURI>\r
+ </link>\r
+ <link>\r
+ <name>full_demo/common_demo_tasks/blocktim.c</name>\r
+ <type>1</type>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Demo/Common/Minimal/blocktim.c</locationURI>\r
+ </link>\r
+ <link>\r
+ <name>full_demo/common_demo_tasks/dynamic.c</name>\r
+ <type>1</type>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Demo/Common/Minimal/dynamic.c</locationURI>\r
+ </link>\r
+ <link>\r
+ <name>full_demo/common_demo_tasks/include</name>\r
+ <type>2</type>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Demo/Common/include</locationURI>\r
+ </link>\r
+ <link>\r
+ <name>full_demo/common_demo_tasks/recmutex.c</name>\r
+ <type>1</type>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Demo/Common/Minimal/recmutex.c</locationURI>\r
+ </link>\r
<link>\r
<name>FreeRTOS_Source/portable/GCC/RISC-V-RV32</name>\r
<type>2</type>\r
- <locationURI>FREERTOS_ROUTE/FreeRTOS/Source/portable/GCC/RISC-V-RV32</locationURI>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Source/portable/GCC/RISC-V-RV32</locationURI>\r
</link>\r
<link>\r
<name>FreeRTOS_Source/portable/MemMang/heap_4.c</name>\r
<type>1</type>\r
- <locationURI>FREERTOS_ROUTE/FreeRTOS/Source/portable/MemMang/heap_4.c</locationURI>\r
+ <locationURI>FREERTOS_ROOT/FreeRTOS/Source/portable/MemMang/heap_4.c</locationURI>\r
</link>\r
</linkedResources>\r
<variableList>\r
<variable>\r
- <name>FREERTOS_ROUTE</name>\r
+ <name>FREERTOS_ROOT</name>\r
<value>$%7BPARENT-3-PROJECT_LOC%7D</value>\r
</variable>\r
</variableList>\r
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>\r
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>\r
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>\r
- <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1967898482140670668" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">\r
+ <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-1662098508467853022" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">\r
<language-scope id="org.eclipse.cdt.core.gcc"/>\r
<language-scope id="org.eclipse.cdt.core.g++"/>\r
</provider>\r
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>\r
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>\r
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>\r
- <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1935790922815146096" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">\r
+ <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-1671468065510502376" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">\r
<language-scope id="org.eclipse.cdt.core.gcc"/>\r
<language-scope id="org.eclipse.cdt.core.g++"/>\r
</provider>\r
#define configCLINT_BASE_ADDRESS CLINT_CTRL_ADDR\r
#define configUSE_PREEMPTION 1\r
#define configUSE_IDLE_HOOK 0\r
-#define configUSE_TICK_HOOK 0\r
+#define configUSE_TICK_HOOK 1\r
#define configCPU_CLOCK_HZ ( 10000000 ) /*QEMU*/\r
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )\r
#define configMAX_PRIORITIES ( 5 )\r
-#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 512 )\r
-#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 8 * 1024 ) )\r
+#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 85 )\r
+#define configTOTAL_HEAP_SIZE ( ( size_t ) 14300 )\r
#define configMAX_TASK_NAME_LEN ( 16 )\r
-#define configUSE_TRACE_FACILITY 1\r
+#define configUSE_TRACE_FACILITY 0\r
#define configUSE_16_BIT_TICKS 0\r
#define configIDLE_SHOULD_YIELD 0\r
#define configUSE_MUTEXES 1\r
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )\r
\r
/* Software timer definitions. */\r
-#define configUSE_TIMERS 0\r
-#define configTIMER_TASK_PRIORITY ( 2 )\r
-#define configTIMER_QUEUE_LENGTH 2\r
-#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE )\r
+#define configUSE_TIMERS 1\r
+#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )\r
+#define configTIMER_QUEUE_LENGTH 7\r
+#define configTIMER_TASK_STACK_DEPTH ( 120 )\r
\r
/* Task priorities. Allow these to be overridden. */\r
#ifndef uartPRIMARY_PRIORITY\r
#define INCLUDE_vTaskDelayUntil 1\r
#define INCLUDE_vTaskDelay 1\r
#define INCLUDE_eTaskGetState 1\r
+#define INCLUDE_xTimerPendFunctionCall 1\r
\r
/* Normal assert() semantics without relying on the provision of an assert.h\r
header file. */\r
-#define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); for( ;; ); }\r
-\r
-/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS\r
-standard names - or at least those used in the unmodified vector table. */\r
-//#define vPortSVCHandler SVCall_Handler\r
-//#define xPortPendSVHandler PendSV_Handler\r
-//#define vPortSysTickHandler SysTick_Handler\r
-\r
-extern void vApplicationMallocFailedHook();\r
-\r
-\r
-extern void vUARTWriteString( const char * const pcString );\r
+void vAssertCalled( void );\r
+#define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled()\r
+\r
+/* Overwrite some of the stack sizes allocated to various test and demo tasks.\r
+Like all task stack sizes, the value is the number of words, not bytes. */\r
+#define configTIMER_TEST_TASK_STACK_SIZE 150\r
+#define configNOTIFIED_TEST_TASK_STACK_SIZE 120\r
+#define configEVENT_GROUP_SET_BIT_TEST_TASK_STACK_SIZE 110\r
+#define configEVENT_GROUP_RENDEZVOUS_TASK_STACK_SIZE 100\r
+#define configRECURSIVE_MUTEX_TASK_STACK_SIZE 100\r
+\r
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0\r
\r
#endif /* FREERTOS_CONFIG_H */\r
--- /dev/null
+/*\r
+ * FreeRTOS Kernel V10.1.1\r
+ * Copyright (C) 2018 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
+ * NOTE 1: This project provides two demo applications. A simple blinky\r
+ * style project, and a more comprehensive test and demo application. The\r
+ * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select\r
+ * between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY\r
+ * in main.c. This file implements the simply blinky style version.\r
+ *\r
+ * NOTE 2: This file only contains the source code that is specific to the\r
+ * basic demo. Generic functions, such FreeRTOS hook functions, and functions\r
+ * required to configure the hardware are defined in main.c.\r
+ ******************************************************************************\r
+ *\r
+ * main_blinky() creates one queue, and two tasks. It then starts the\r
+ * scheduler.\r
+ *\r
+ * The Queue Send Task:\r
+ * The queue send task is implemented by the prvQueueSendTask() function in\r
+ * this file. prvQueueSendTask() sits in a loop that causes it to repeatedly\r
+ * block for 1000 milliseconds, before sending the value 100 to the queue that\r
+ * was created within main_blinky(). Once the value is sent, the task loops\r
+ * back around to block for another 1000 milliseconds...and so on.\r
+ *\r
+ * The Queue Receive Task:\r
+ * The queue receive task is implemented by the prvQueueReceiveTask() function\r
+ * in this file. prvQueueReceiveTask() sits in a loop where it repeatedly\r
+ * blocks on attempts to read data from the queue that was created within\r
+ * main_blinky(). When data is received, the task checks the value of the\r
+ * data, and if the value equals the expected 100, writes 'Blink' to the UART\r
+ * (the UART is used in place of the LED to allow easy execution in QEMU). The\r
+ * 'block time' parameter passed to the queue receive function specifies that\r
+ * the task should be held in the Blocked state indefinitely to wait for data to\r
+ * be available on the queue. The queue receive task will only leave the\r
+ * Blocked state when the queue send task writes to the queue. As the queue\r
+ * send task writes to the queue every 1000 milliseconds, the queue receive\r
+ * task leaves the Blocked state every 1000 milliseconds, and therefore toggles\r
+ * the LED every 200 milliseconds.\r
+ */\r
+\r
+/* Standard includes. */\r
+#include <stdio.h>\r
+#include <string.h>\r
+#include <unistd.h>\r
+\r
+/* Kernel includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+#include "queue.h"\r
+\r
+/* Priorities used by the tasks. */\r
+#define mainQUEUE_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )\r
+#define mainQUEUE_SEND_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )\r
+\r
+/* The rate at which data is sent to the queue. The 200ms value is converted\r
+to ticks using the pdMS_TO_TICKS() macro. */\r
+#define mainQUEUE_SEND_FREQUENCY_MS pdMS_TO_TICKS( 1000 )\r
+\r
+/* The maximum number items the queue can hold. The priority of the receiving\r
+task is above the priority of the sending task, so the receiving task will\r
+preempt the sending task and remove the queue items each time the sending task\r
+writes to the queue. Therefore the queue will never have more than one item in\r
+it at any time, and even with a queue length of 1, the sending task will never\r
+find the queue full. */\r
+#define mainQUEUE_LENGTH ( 1 )\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Called by main when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1 in\r
+ * main.c.\r
+ */\r
+void main_blinky( void );\r
+\r
+/*\r
+ * The tasks as described in the comments at the top of this file.\r
+ */\r
+static void prvQueueReceiveTask( void *pvParameters );\r
+static void prvQueueSendTask( void *pvParameters );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* The queue used by both tasks. */\r
+static QueueHandle_t xQueue = NULL;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void main_blinky( void )\r
+{\r
+ /* Create the queue. */\r
+ xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( uint32_t ) );\r
+\r
+ if( xQueue != NULL )\r
+ {\r
+ /* Start the two tasks as described in the comments at the top of this\r
+ file. */\r
+ xTaskCreate( prvQueueReceiveTask, /* The function that implements the task. */\r
+ "Rx", /* The text name assigned to the task - for debug only as it is not used by the kernel. */\r
+ configMINIMAL_STACK_SIZE * 2U, /* The size of the stack to allocate to the task. */\r
+ NULL, /* The parameter passed to the task - not used in this case. */\r
+ mainQUEUE_RECEIVE_TASK_PRIORITY, /* The priority assigned to the task. */\r
+ NULL ); /* The task handle is not required, so NULL is passed. */\r
+\r
+ xTaskCreate( prvQueueSendTask, "TX", configMINIMAL_STACK_SIZE * 2U, NULL, mainQUEUE_SEND_TASK_PRIORITY, NULL );\r
+\r
+ /* Start the tasks and timer running. */\r
+ vTaskStartScheduler();\r
+ }\r
+\r
+ /* If all is well, the scheduler will now be running, and the following\r
+ line will never be reached. If the following line does execute, then\r
+ there was insufficient FreeRTOS heap memory available for the Idle and/or\r
+ timer tasks to be created. See the memory management section on the\r
+ FreeRTOS web site for more details on the FreeRTOS heap\r
+ http://www.freertos.org/a00111.html. */\r
+ for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvQueueSendTask( void *pvParameters )\r
+{\r
+TickType_t xNextWakeTime;\r
+const unsigned long ulValueToSend = 100UL;\r
+BaseType_t xReturned;\r
+\r
+ /* Remove compiler warning about unused parameter. */\r
+ ( void ) pvParameters;\r
+\r
+ /* Initialise xNextWakeTime - this only needs to be done once. */\r
+ xNextWakeTime = xTaskGetTickCount();\r
+\r
+ for( ;; )\r
+ {\r
+ /* Place this task in the blocked state until it is time to run again. */\r
+ vTaskDelayUntil( &xNextWakeTime, mainQUEUE_SEND_FREQUENCY_MS );\r
+\r
+ /* Send to the queue - causing the queue receive task to unblock and\r
+ toggle the LED. 0 is used as the block time so the sending operation\r
+ will not block - it shouldn't need to block as the queue should always\r
+ be empty at this point in the code. */\r
+ xReturned = xQueueSend( xQueue, &ulValueToSend, 0U );\r
+ configASSERT( xReturned == pdPASS );\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvQueueReceiveTask( void *pvParameters )\r
+{\r
+unsigned long ulReceivedValue;\r
+const unsigned long ulExpectedValue = 100UL;\r
+const char * const pcPassMessage = "Blink\r\n";\r
+const char * const pcFailMessage = "Unexpected value received\r\n";\r
+\r
+ /* Remove compiler warning about unused parameter. */\r
+ ( void ) pvParameters;\r
+\r
+ for( ;; )\r
+ {\r
+ /* Wait until something arrives in the queue - this task will block\r
+ indefinitely provided INCLUDE_vTaskSuspend is set to 1 in\r
+ FreeRTOSConfig.h. */\r
+ xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );\r
+\r
+ /* To get here something must have been received from the queue, but\r
+ is it the expected value? If it is, toggle the LED. */\r
+ if( ulReceivedValue == ulExpectedValue )\r
+ {\r
+ write( STDOUT_FILENO, pcPassMessage, strlen( pcPassMessage ) );\r
+ ulReceivedValue = 0U;\r
+ }\r
+ else\r
+ {\r
+ write( STDOUT_FILENO, pcFailMessage, strlen( pcFailMessage ) );\r
+ }\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
.extern ulRegTest1LoopCounter\r
.extern ulRegTest2LoopCounter\r
\r
- .global vRegTest1Task\r
- .global vRegTest2Task\r
+ .global vRegTest1Implementation\r
+ .global vRegTest2Implementation\r
\r
/*-----------------------------------------------------------*/\r
\r
-vRegTest1Task:\r
+/*\r
+ * The register check tasks are described in the comments at the top of\r
+ * main_full.c.\r
+ */\r
+\r
+vRegTest1Implementation:\r
\r
/* Fill the core registers with known values. */\r
li x5, 0x5\r
\r
reg1_loop:\r
\r
- /* Check each register still contains the expected known value.\r
- vRegTest1Implementation uses x31 as the temporary, vRegTest2Implementation\r
- uses x5 as the temporary. */\r
+ /* Check each register still contains the expected known value.\r
+ vRegTest1Implementation uses x31 as the temporary, vRegTest2Implementation\r
+ uses x5 as the temporary. */\r
li x31, 0x5\r
bne x31, x5, reg1_error_loop\r
li x31, 0x6\r
li x31, 0x1e\r
bne x31, x30, reg1_error_loop\r
\r
- /* Everything passed, increment the loop counter. */\r
+ /* Everything passed, increment the loop counter. */\r
lw x31, ulRegTest1LoopCounterConst\r
lw x30, 0(x31)\r
addi x30, x30, 1\r
sw x30, 0(x31)\r
\r
- /* Restore clobbered register reading for next loop. */\r
- li x30, 0x1e\r
+ /* Restore clobbered register reading for next loop. */\r
+ li x30, 0x1e\r
\r
- /* Yield to increase code coverage. */\r
- ecall\r
+ /* Yield to increase code coverage. */\r
+ ecall\r
\r
- /* Start again. */\r
- jal reg1_loop\r
+ /* Start again. */\r
+ jal reg1_loop\r
\r
reg1_error_loop:\r
- /* Jump here if a register contains an uxpected value. This stops the loop\r
- counter being incremented so the check task knows an error was found. */\r
+ /* Jump here if a register contains an uxpected value. This stops the loop\r
+ counter being incremented so the check task knows an error was found. */\r
+// ebreak\r
jal reg1_error_loop\r
\r
ulRegTest1LoopCounterConst: .word ulRegTest1LoopCounter\r
\r
/*-----------------------------------------------------------*/\r
\r
-vRegTest2Task:\r
-\r
- /* Fill the core registers with known values. */\r
- li x6, 0x61\r
- li x7, 0x71\r
- li x8, 0x81\r
- li x9, 0x91\r
- li x10, 0xa1\r
- li x11, 0xb1\r
- li x12, 0xc1\r
- li x13, 0xd1\r
- li x14, 0xe1\r
- li x15, 0xf1\r
- li x16, 0x20\r
- li x17, 0x21\r
- li x18, 0x22\r
- li x19, 0x23\r
- li x20, 0x24\r
- li x21, 0x25\r
- li x22, 0x26\r
- li x23, 0x27\r
- li x24, 0x28\r
- li x25, 0x29\r
- li x26, 0x2a\r
- li x27, 0x2b\r
- li x28, 0x2c\r
- li x29, 0x2d\r
- li x30, 0x2e\r
- li x31, 0x2f\r
+vRegTest2Implementation:\r
+\r
+ /* Fill the core registers with known values. */\r
+ li x6, 0x61\r
+ li x7, 0x71\r
+ li x8, 0x81\r
+ li x9, 0x91\r
+ li x10, 0xa1\r
+ li x11, 0xb1\r
+ li x12, 0xc1\r
+ li x13, 0xd1\r
+ li x14, 0xe1\r
+ li x15, 0xf1\r
+ li x16, 0x20\r
+ li x17, 0x21\r
+ li x18, 0x22\r
+ li x19, 0x23\r
+ li x20, 0x24\r
+ li x21, 0x25\r
+ li x22, 0x26\r
+ li x23, 0x27\r
+ li x24, 0x28\r
+ li x25, 0x29\r
+ li x26, 0x2a\r
+ li x27, 0x2b\r
+ li x28, 0x2c\r
+ li x29, 0x2d\r
+ li x30, 0x2e\r
+ li x31, 0x2f\r
\r
Reg2_loop:\r
\r
- /* Check each register still contains the expected known value.\r
- vRegTest2Implementation uses x5 as the temporary, vRegTest1Implementation\r
- uses x31 as the temporary. */\r
- li x5, 0x61\r
- bne x5, x6, reg2_error_loop\r
- li x5, 0x71\r
- bne x5, x7, reg2_error_loop\r
- li x5, 0x81\r
- bne x5, x8, reg2_error_loop\r
- li x5, 0x91\r
- bne x5, x9, reg2_error_loop\r
- li x5, 0xa1\r
- bne x5, x10, reg2_error_loop\r
- li x5, 0xb1\r
- bne x5, x11, reg2_error_loop\r
- li x5, 0xc1\r
- bne x5, x12, reg2_error_loop\r
- li x5, 0xd1\r
- bne x5, x13, reg2_error_loop\r
- li x5, 0xe1\r
- bne x5, x14, reg2_error_loop\r
- li x5, 0xf1\r
- bne x5, x15, reg2_error_loop\r
- li x5, 0x20\r
- bne x5, x16, reg2_error_loop\r
- li x5, 0x21\r
- bne x5, x17, reg2_error_loop\r
- li x5, 0x22\r
- bne x5, x18, reg2_error_loop\r
- li x5, 0x23\r
- bne x5, x19, reg2_error_loop\r
- li x5, 0x24\r
- bne x5, x20, reg2_error_loop\r
- li x5, 0x25\r
- bne x5, x21, reg2_error_loop\r
- li x5, 0x26\r
- bne x5, x22, reg2_error_loop\r
- li x5, 0x27\r
- bne x5, x23, reg2_error_loop\r
- li x5, 0x28\r
- bne x5, x24, reg2_error_loop\r
- li x5, 0x29\r
- bne x5, x25, reg2_error_loop\r
- li x5, 0x2a\r
- bne x5, x26, reg2_error_loop\r
- li x5, 0x2b\r
- bne x5, x27, reg2_error_loop\r
- li x5, 0x2c\r
- bne x5, x28, reg2_error_loop\r
- li x5, 0x2d\r
- bne x5, x29, reg2_error_loop\r
- li x5, 0x2e\r
- bne x5, x30, reg2_error_loop\r
- li x5, 0x2f\r
- bne x5, x31, reg2_error_loop\r
-\r
- /* Everything passed, increment the loop counter. */\r
- lw x5, ulRegTest2LoopCounterConst\r
- lw x6, 0(x5)\r
- addi x6, x6, 1\r
- sw x6, 0(x5)\r
-\r
- /* Restore clobbered register reading for next loop. */\r
- li x6, 0x61\r
-\r
- /* Start again. */\r
- jal Reg2_loop\r
+ /* Check each register still contains the expected known value.\r
+ vRegTest2Implementation uses x5 as the temporary, vRegTest1Implementation\r
+ uses x31 as the temporary. */\r
+ li x5, 0x61\r
+ bne x5, x6, reg2_error_loop\r
+ li x5, 0x71\r
+ bne x5, x7, reg2_error_loop\r
+ li x5, 0x81\r
+ bne x5, x8, reg2_error_loop\r
+ li x5, 0x91\r
+ bne x5, x9, reg2_error_loop\r
+ li x5, 0xa1\r
+ bne x5, x10, reg2_error_loop\r
+ li x5, 0xb1\r
+ bne x5, x11, reg2_error_loop\r
+ li x5, 0xc1\r
+ bne x5, x12, reg2_error_loop\r
+ li x5, 0xd1\r
+ bne x5, x13, reg2_error_loop\r
+ li x5, 0xe1\r
+ bne x5, x14, reg2_error_loop\r
+ li x5, 0xf1\r
+ bne x5, x15, reg2_error_loop\r
+ li x5, 0x20\r
+ bne x5, x16, reg2_error_loop\r
+ li x5, 0x21\r
+ bne x5, x17, reg2_error_loop\r
+ li x5, 0x22\r
+ bne x5, x18, reg2_error_loop\r
+ li x5, 0x23\r
+ bne x5, x19, reg2_error_loop\r
+ li x5, 0x24\r
+ bne x5, x20, reg2_error_loop\r
+ li x5, 0x25\r
+ bne x5, x21, reg2_error_loop\r
+ li x5, 0x26\r
+ bne x5, x22, reg2_error_loop\r
+ li x5, 0x27\r
+ bne x5, x23, reg2_error_loop\r
+ li x5, 0x28\r
+ bne x5, x24, reg2_error_loop\r
+ li x5, 0x29\r
+ bne x5, x25, reg2_error_loop\r
+ li x5, 0x2a\r
+ bne x5, x26, reg2_error_loop\r
+ li x5, 0x2b\r
+ bne x5, x27, reg2_error_loop\r
+ li x5, 0x2c\r
+ bne x5, x28, reg2_error_loop\r
+ li x5, 0x2d\r
+ bne x5, x29, reg2_error_loop\r
+ li x5, 0x2e\r
+ bne x5, x30, reg2_error_loop\r
+ li x5, 0x2f\r
+ bne x5, x31, reg2_error_loop\r
+\r
+ /* Everything passed, increment the loop counter. */\r
+ lw x5, ulRegTest2LoopCounterConst\r
+ lw x6, 0(x5)\r
+ addi x6, x6, 1\r
+ sw x6, 0(x5)\r
+\r
+ /* Restore clobbered register reading for next loop. */\r
+ li x6, 0x61\r
+\r
+ /* Start again. */\r
+ jal Reg2_loop\r
\r
reg2_error_loop:\r
- /* Jump here if a register contains an uxpected value. This stops the loop\r
- counter being incremented so the check task knows an error was found. */\r
- jal reg2_error_loop\r
+ /* Jump here if a register contains an uxpected value. This stops the loop\r
+ counter being incremented so the check task knows an error was found. */\r
+// ebreak\r
+ jal reg2_error_loop\r
\r
ulRegTest2LoopCounterConst: .word ulRegTest2LoopCounter\r
\r
--- /dev/null
+/*\r
+ * FreeRTOS Kernel V10.1.1\r
+ * Copyright (C) 2018 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
+ * NOTE 1: This project provides two demo applications. A simple blinky style\r
+ * project, and a more comprehensive test and demo application. The\r
+ * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select\r
+ * between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY\r
+ * in main.c. This file implements the comprehensive test and demo version.\r
+ *\r
+ * NOTE 2: This file only contains the source code that is specific to the\r
+ * full demo. Generic functions, such FreeRTOS hook functions, and functions\r
+ * required to configure the hardware, are defined in main.c.\r
+ *\r
+ ******************************************************************************\r
+ *\r
+ * main_full() creates all the demo application tasks and software timers, then\r
+ * starts the scheduler. The web documentation provides more details of the\r
+ * standard demo application tasks, which provide no particular functionality,\r
+ * but do provide a good example of how to use the FreeRTOS API.\r
+ *\r
+ * In addition to the standard demo tasks, the following tasks and tests are\r
+ * defined and/or created within this file:\r
+ *\r
+ * "Reg test" tasks - These fill both the core registers with known values, then\r
+ * check that each register maintains its expected value for the lifetime of the\r
+ * task. Each task uses a different set of values. The reg test tasks execute\r
+ * with a very low priority, so get preempted very frequently. A register\r
+ * containing an unexpected value is indicative of an error in the context\r
+ * switching mechanism.\r
+ *\r
+ * "Check" task - The check executes every five seconds. It checks that all\r
+ * the standard demo tasks, and the register check tasks, are not only still\r
+ * executing, but are executing without reporting any errors. If the check task\r
+ * discovers that a task has either stalled, or reported an error, then it\r
+ * prints an error message to the UART, otherwise it prints "Pass.".\r
+ */\r
+\r
+/* Standard includes. */\r
+#include <stdio.h>\r
+#include <string.h>\r
+\r
+/* Kernel includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+#include "timers.h"\r
+#include "semphr.h"\r
+\r
+/* Standard demo application includes. */\r
+#include "dynamic.h"\r
+#include "blocktim.h"\r
+#include "GenQTest.h"\r
+#include "recmutex.h"\r
+#include "TimerDemo.h"\r
+#include "EventGroupsDemo.h"\r
+#include "TaskNotify.h"\r
+\r
+/* SiFive includes. */\r
+#include "platform.h"\r
+#include "encoding.h"\r
+#include "unistd.h"\r
+\r
+/* Priorities for the demo application tasks. */\r
+#define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )\r
+\r
+/* The period of the check task, in ms, converted to ticks using the\r
+pdMS_TO_TICKS() macro. */\r
+#define mainNO_ERROR_CHECK_TASK_PERIOD pdMS_TO_TICKS( 3000UL )\r
+\r
+/* Parameters that are passed into the register check tasks solely for the\r
+purpose of ensuring parameters are passed into tasks correctl5. */\r
+#define mainREG_TEST_TASK_1_PARAMETER ( ( void * ) 0x12345678 )\r
+#define mainREG_TEST_TASK_2_PARAMETER ( ( void * ) 0x87654321 )\r
+\r
+/* The base period used by the timer test tasks. */\r
+#define mainTIMER_TEST_PERIOD ( 50 )\r
+\r
+/* The size of the stack allocated to the check task (as described in the\r
+comments at the top of this file. */\r
+#define mainCHECK_TASK_STACK_SIZE_WORDS 100\r
+\r
+/* Size of the stacks to allocated for the register check tasks. */\r
+#define mainREG_TEST_STACK_SIZE_WORDS 60\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Called by main() to run the full demo (as opposed to the blinky demo) when\r
+ * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.\r
+ */\r
+void main_full( void );\r
+\r
+/*\r
+ * The check task, as described at the top of this file.\r
+ */\r
+static void prvCheckTask( void *pvParameters );\r
+\r
+/*\r
+ * Register check tasks as described at the top of this file. The nature of\r
+ * these files necessitates that they are written in an assembly file, but the\r
+ * entry points are kept in the C file for the convenience of checking the task\r
+ * parameter.\r
+ */\r
+static void prvRegTestTaskEntry1( void *pvParameters );\r
+extern void vRegTest1Implementation( void );\r
+static void prvRegTestTaskEntry2( void *pvParameters );\r
+extern void vRegTest2Implementation( void );\r
+\r
+/*\r
+ * Tick hook used by the full demo, which includes code that interacts with\r
+ * some of the tests.\r
+ */\r
+void vFullDemoTickHook( void );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* The following two variables are used to communicate the status of the\r
+register check tasks to the check task. If the variables keep incrementing,\r
+then the register check tasks have not discovered any errors. If a variable\r
+stops incrementing, then an error has been found. */\r
+volatile uint32_t ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void main_full( void )\r
+{\r
+ /* Start all the other standard demo/test tasks. They have no particular\r
+ functionality, but do demonstrate how to use the FreeRTOS API and test the\r
+ kernel port. */\r
+ vStartDynamicPriorityTasks();\r
+ vCreateBlockTimeTasks();\r
+ vStartGenericQueueTasks( tskIDLE_PRIORITY );\r
+ vStartRecursiveMutexTasks();\r
+ vStartTimerDemoTask( mainTIMER_TEST_PERIOD );\r
+ vStartEventGroupTasks();\r
+ vStartTaskNotifyTask();\r
+\r
+ /* Create the register check tasks, as described at the top of this file.\r
+ Use xTaskCreateStatic() to create a task using only statically allocated\r
+ memory. */\r
+ xTaskCreate( prvRegTestTaskEntry1, /* The function that implements the task. */\r
+ "Reg1", /* The name of the task. */\r
+ mainREG_TEST_STACK_SIZE_WORDS, /* Size of stack to allocate for the task - in words not bytes!. */\r
+ mainREG_TEST_TASK_1_PARAMETER, /* Parameter passed into the task. */\r
+ tskIDLE_PRIORITY, /* Priority of the task. */\r
+ NULL ); /* Can be used to pass out a handle to the created task. */\r
+ xTaskCreate( prvRegTestTaskEntry2, "Reg2", mainREG_TEST_STACK_SIZE_WORDS, mainREG_TEST_TASK_2_PARAMETER, tskIDLE_PRIORITY, NULL );\r
+\r
+ /* Create the task that performs the 'check' functionality, as described at\r
+ the top of this file. */\r
+// xTaskCreate( prvCheckTask, "Check", mainCHECK_TASK_STACK_SIZE_WORDS, NULL, mainCHECK_TASK_PRIORITY, NULL );\r
+ xTaskCreate( prvCheckTask, "Check", mainCHECK_TASK_STACK_SIZE_WORDS, NULL, tskIDLE_PRIORITY, NULL );\r
+\r
+ /* Start the scheduler. */\r
+ vTaskStartScheduler();\r
+\r
+ /* If all is well, the scheduler will now be running, and the following\r
+ line will never be reached. If the following line does execute, then\r
+ there was insufficient FreeRTOS heap memory available for the Idle and/or\r
+ timer tasks to be created. See the memory management section on the\r
+ FreeRTOS web site for more details on the FreeRTOS heap\r
+ http://www.freertos.org/a00111.html. */\r
+ for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvCheckTask( void *pvParameters )\r
+{\r
+const TickType_t xDelayPeriod = mainNO_ERROR_CHECK_TASK_PERIOD;\r
+TickType_t xLastExecutionTime;\r
+static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;\r
+const char * const pcPassMessage = "Pass.\r\n";\r
+char * pcStatusMessage = pcPassMessage;\r
+\r
+ /* Just to stop compiler warnings. */\r
+ ( void ) pvParameters;\r
+\r
+ /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil()\r
+ works correctly. */\r
+ xLastExecutionTime = xTaskGetTickCount();\r
+\r
+ /* Cycle for ever, delaying then checking all the other tasks are still\r
+ operating without error. The onboard LED is toggled on each iteration.\r
+ If an error is detected then the delay period is decreased from\r
+ mainNO_ERROR_CHECK_TASK_PERIOD to mainERROR_CHECK_TASK_PERIOD. This has the\r
+ effect of increasing the rate at which the onboard LED toggles, and in so\r
+ doing gives visual feedback of the system status. */\r
+ for( ;; )\r
+ {\r
+ /* Delay until it is time to execute again. */\r
+ vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod );\r
+\r
+ /* Check all the demo tasks (other than the flash tasks) to ensure\r
+ that they are all still running, and that none have detected an error. */\r
+ if( xAreDynamicPriorityTasksStillRunning() != pdTRUE )\r
+ {\r
+ pcStatusMessage = "ERROR: Dynamic priority demo/tests.\r\n";\r
+ }\r
+\r
+ if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE )\r
+ {\r
+ pcStatusMessage = "ERROR: Block time demo/tests.\r\n";\r
+ }\r
+\r
+ if ( xAreGenericQueueTasksStillRunning() != pdTRUE )\r
+ {\r
+ pcStatusMessage = "ERROR: Generic queue demo/tests.\r\n";\r
+ }\r
+\r
+ if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE )\r
+ {\r
+ pcStatusMessage = "ERROR: Recursive mutex demo/tests.\r\n";\r
+ }\r
+\r
+ if( xAreTimerDemoTasksStillRunning( ( TickType_t ) xDelayPeriod ) != pdPASS )\r
+ {\r
+// pcStatusMessage = "ERROR: Timer demo/tests.\r\n";\r
+ }\r
+\r
+ if( xAreEventGroupTasksStillRunning() != pdPASS )\r
+ {\r
+ pcStatusMessage = "ERROR: Event group demo/tests.\r\n";\r
+ }\r
+\r
+ if( xAreTaskNotificationTasksStillRunning() != pdPASS )\r
+ {\r
+ pcStatusMessage = "ERROR: Task notification demo/tests.\r\n";\r
+ }\r
+\r
+ /* Check that the register test 1 task is still running. */\r
+ if( ulLastRegTest1Value == ulRegTest1LoopCounter )\r
+ {\r
+ pcStatusMessage = "ERROR: Register test 1.\r\n";\r
+ }\r
+ ulLastRegTest1Value = ulRegTest1LoopCounter;\r
+\r
+ /* Check that the register test 2 task is still running. */\r
+ if( ulLastRegTest2Value == ulRegTest2LoopCounter )\r
+ {\r
+ pcStatusMessage = "ERROR: Register test 2.\r\n";\r
+ }\r
+ ulLastRegTest2Value = ulRegTest2LoopCounter;\r
+\r
+ /* Write the status message to the UART. */\r
+ write( STDOUT_FILENO, pcStatusMessage, strlen( pcStatusMessage ) );\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvRegTestTaskEntry1( void *pvParameters )\r
+{\r
+ /* Although the regtest task is written in assembler, its entry point is\r
+ written in C for convenience of checking the task parameter is being passed\r
+ in correctly. */\r
+ if( pvParameters == mainREG_TEST_TASK_1_PARAMETER )\r
+ {\r
+ /* Start the part of the test that is written in assembler. */\r
+ vRegTest1Implementation();\r
+ }\r
+\r
+ /* The following line will only execute if the task parameter is found to\r
+ be incorrect. The check task will detect that the regtest loop counter is\r
+ not being incremented and flag an error. */\r
+ vTaskDelete( NULL );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvRegTestTaskEntry2( void *pvParameters )\r
+{\r
+ /* Although the regtest task is written in assembler, its entry point is\r
+ written in C for convenience of checking the task parameter is being passed\r
+ in correctly. */\r
+ if( pvParameters == mainREG_TEST_TASK_2_PARAMETER )\r
+ {\r
+ /* Start the part of the test that is written in assembler. */\r
+ vRegTest2Implementation();\r
+ }\r
+\r
+ /* The following line will only execute if the task parameter is found to\r
+ be incorrect. The check task will detect that the regtest loop counter is\r
+ not being incremented and flag an error. */\r
+ vTaskDelete( NULL );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vFullDemoTickHook( void )\r
+{\r
+ /* Called from vApplicationTickHook() when the project is configured to\r
+ build the full demo. */\r
+// vTimerPeriodicISRTests();\r
+ vPeriodicEventGroupsProcessing();\r
+ xNotifyTaskFromISR();\r
+}\r
-// See LICENSE for license details.\r
+/*\r
+ * FreeRTOS Kernel V10.1.1\r
+ * Copyright (C) 2018 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
+/* FreeRTOS kernel includes. */\r
#include <FreeRTOS.h>\r
#include <task.h>\r
\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include "platform.h"\r
-#include <string.h>\r
-#include "plic/plic_driver.h"\r
-#include "encoding.h"\r
-#include <unistd.h>\r
-#include "stdatomic.h"\r
-\r
+/******************************************************************************\r
+ * This project provides two demo applications. A simple blinky style project,\r
+ * and a more comprehensive test and demo application. The\r
+ * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this file) is used to\r
+ * select between the two. The simply blinky demo is implemented and described\r
+ * in main_blinky.c. The more comprehensive test and demo application is\r
+ * implemented and described in main_full.c.\r
+ *\r
+ * This file implements the code that is not demo specific, including the\r
+ * hardware setup and standard FreeRTOS hook functions.\r
+ *\r
+ * ENSURE TO READ THE DOCUMENTATION PAGE FOR THIS PORT AND DEMO APPLICATION ON\r
+ * THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO\r
+ * APPLICATION, AND ITS ASSOCIATE FreeRTOS ARCHITECTURE PORT!\r
+ *\r
+ */\r
\r
+/* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,\r
+or 0 to run the more comprehensive test and demo application. */\r
+#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY 0\r
\r
/*\r
- * FreeRTOS hook for when malloc fails, enable in FreeRTOSConfig.\r
+ * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.\r
+ * main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.\r
*/\r
+#if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1\r
+ extern void main_blinky( void );\r
+#else\r
+ extern void main_full( void );\r
+#endif /* #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 */\r
+\r
+/* Prototypes for the standard FreeRTOS callback/hook functions implemented\r
+within this file. See https://www.freertos.org/a00016.html */\r
void vApplicationMallocFailedHook( void );\r
-\r
-/*\r
- * FreeRTOS hook for when FreeRtos is idling, enable in FreeRTOSConfig.\r
- */\r
void vApplicationIdleHook( void );\r
-\r
-/*\r
- * FreeRTOS hook for when a stack overflow occurs, enable in FreeRTOSConfig.\r
- */\r
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );\r
+void vApplicationTickHook( void );\r
\r
-\r
-\r
-void vRegTest1Task( void *pvParameters );\r
-void vRegTest2Task( void *pvParameters );\r
-\r
-\r
-const char * const pcStartMessage = "FreeRTOS demo\r\n";\r
-volatile uint32_t ulRegTest1LoopCounter = 0, ulRegTest2LoopCounter = 0;\r
-static void prvCheckTask( void *pvParameters );\r
-plic_instance_t g_plic;\r
-uint32_t bitbang_mask = 0;\r
+/*-----------------------------------------------------------*/\r
\r
int main( void )\r
{\r
- #ifdef HAS_BOARD_BUTTONS\r
- GPIO_REG(GPIO_OUTPUT_EN) &= ~((0x1 << BUTTON_0_OFFSET) | (0x1 << BUTTON_1_OFFSET) | (0x1 << BUTTON_2_OFFSET));\r
- GPIO_REG(GPIO_PULLUP_EN) &= ~((0x1 << BUTTON_0_OFFSET) | (0x1 << BUTTON_1_OFFSET) | (0x1 << BUTTON_2_OFFSET));\r
- GPIO_REG(GPIO_INPUT_EN) |= ((0x1 << BUTTON_0_OFFSET) | (0x1 << BUTTON_1_OFFSET) | (0x1 << BUTTON_2_OFFSET));\r
- #endif\r
-\r
- GPIO_REG(GPIO_INPUT_EN) &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;\r
- GPIO_REG(GPIO_OUTPUT_EN) |= ((0x1<< RED_LED_OFFSET)| (0x1<< GREEN_LED_OFFSET) | (0x1 << BLUE_LED_OFFSET)) ;\r
- GPIO_REG(GPIO_OUTPUT_VAL) |= (0x1 << BLUE_LED_OFFSET) ;\r
- GPIO_REG(GPIO_OUTPUT_VAL) &= ~((0x1<< RED_LED_OFFSET) | (0x1<< GREEN_LED_OFFSET)) ;\r
-\r
- /* For Bit-banging with Atomics demo. */\r
- #ifdef _SIFIVE_HIFIVE1_H\r
- bitbang_mask = (1 << PIN_19_OFFSET);\r
+ /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top\r
+ of this file. */\r
+ #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )\r
+ {\r
+ main_blinky();\r
+ }\r
#else\r
- #ifdef _SIFIVE_COREPLEXIP_ARTY_H\r
- bitbang_mask = (0x1 << JA_0_OFFSET);\r
- #endif\r
- #endif\r
-\r
- GPIO_REG(GPIO_OUTPUT_EN) |= bitbang_mask;\r
-\r
-// xTaskCreate( vRegTest1Task, "RegTest1", 1000, NULL, tskIDLE_PRIORITY, NULL );\r
-// xTaskCreate( vRegTest2Task, "RegTest2", 1000, NULL, tskIDLE_PRIORITY, NULL );\r
- xTaskCreate( prvCheckTask, "Check", 1000, NULL, configMAX_PRIORITIES - 1, NULL );\r
-\r
- vTaskStartScheduler();\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-static void prvCheckTask( void *pvParameters )\r
-{\r
-const char *pcMessage = "PASS\r\n";\r
-const TickType_t xCheckPeriod = pdMS_TO_TICKS( 3000UL );\r
-uint32_t ulLastRegTest1LoopCounter = 0, ulLastRegTest2LoopCounter = 0;\r
-volatile uintptr_t mstatus;\r
-\r
-volatile uint32_t ulx;\r
-__asm volatile ("csrr %0, mstatus" : "=r"(mstatus));\r
-portENABLE_INTERRUPTS();\r
-__asm volatile ("csrr %0, mstatus" : "=r"(mstatus));\r
-for( ;; )\r
-{\r
-// for( ulx = 0; ulx < 0xffff; ulx++ ) __asm volatile( "NOP" );\r
-// vPortSetupTimerInterrupt();\r
- vTaskDelay( xCheckPeriod );\r
- write( STDOUT_FILENO, "Blip\r\n", strlen( "Blip\r\n" ) );\r
-}\r
-#if 0\r
- for( ;; )\r
{\r
- vTaskDelay( xCheckPeriod );\r
-\r
- if( ulLastRegTest1LoopCounter == ulRegTest1LoopCounter )\r
- {\r
- /* The RegTest1 loop counter is no longer incrementing, indicating\r
- the task failed its self check. */\r
- pcMessage = "FAIL: RegTest1\r\n";\r
- }\r
- else\r
- {\r
- ulLastRegTest1LoopCounter = ulRegTest1LoopCounter;\r
- }\r
-\r
- if( ulLastRegTest2LoopCounter == ulRegTest2LoopCounter )\r
- {\r
- /* The RegTest1 loop counter is no longer incrementing, indicating\r
- the task failed its self check. */\r
- pcMessage = "FAIL: RegTest2\r\n";\r
- }\r
- else\r
- {\r
- ulLastRegTest2LoopCounter = ulRegTest2LoopCounter;\r
- }\r
-\r
- vUARTWriteString( pcMessage );\r
+ main_full();\r
}\r
-#endif\r
+ #endif\r
}\r
/*-----------------------------------------------------------*/\r
\r
to query the size of free heap space that remains (although it does not\r
provide information on how the remaining heap might be fragmented). */\r
taskDISABLE_INTERRUPTS();\r
+// __asm volatile( "ebreak" );\r
for( ;; );\r
}\r
/*-----------------------------------------------------------*/\r
configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2. This hook\r
function is called if a stack overflow is detected. */\r
taskDISABLE_INTERRUPTS();\r
+// __asm volatile( "ebreak" );\r
for( ;; );\r
}\r
/*-----------------------------------------------------------*/\r
\r
-#define mainINTERRUPT_BIT_SET 0x80000000UL\r
-#define mainENVIRONMENT_CALL 11UL\r
-#define mainEXTERNAL_INTERRRUPT ( mainINTERRUPT_BIT_SET | 11UL )\r
-#define mainTIMER_INTERRUPT ( mainINTERRUPT_BIT_SET | 7UL )\r
-#define mainSOFTWARE_INTERRUPT ( mainINTERRUPT_BIT_SET | 3UL )\r
-\r
-extern void Timer_IRQHandler( void );\r
-\r
-uint32_t ulPortTrapHandler( uint32_t mcause, uint32_t mepc )\r
+void vApplicationTickHook( void )\r
{\r
- if( mcause == mainENVIRONMENT_CALL )\r
+ /* The tests in the full demo expect some interaction with interrupts. */\r
+ #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY != 1 )\r
{\r
- vTaskSwitchContext();\r
-\r
- /* Ensure not to return to the instruction that generated the exception. */\r
- mepc += 4;\r
- }\r
- else if( mcause == mainEXTERNAL_INTERRRUPT )\r
- {\r
- for( ;; );\r
- }\r
- else if( mcause == mainTIMER_INTERRUPT )\r
- {\r
- Timer_IRQHandler();\r
- }\r
- else if( mcause == mainSOFTWARE_INTERRUPT )\r
- {\r
- for( ;; );\r
+ extern void vFullDemoTickHook( void );\r
+ vFullDemoTickHook();\r
}\r
+ #endif\r
+}\r
+/*-----------------------------------------------------------*/\r
\r
- return mepc;\r
+void vAssertCalled( void )\r
+{\r
+ taskDISABLE_INTERRUPTS();\r
+// __asm volatile( "ebreak" );\r
+ for( ;; );\r
}\r