Revert "Remove coroutines (#874)" (#1019)

* Revert "Remove coroutines (#874)"

This reverts commit 569c78fd8c.

* Update freertos Kernel submodule to latest head

* Remove temporary files

* Fix MingW demos and spell check

* Fix manifest version; fix headers

* Add ignore files and paths to core-checker.py

* Fix copyright in remaining files

* Fix PR check build failure

1. Remove defining `inline` in Makefile. This was causing build
   warnings.
2. Ensure that the linker removed unused functions from various
   compilation units.
3. Update the linker script so that all the functions are correctly
   placed in FLASH section.

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>

---------

Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
Co-authored-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
Aniruddha Kanhere 2023-06-09 15:25:48 -07:00 committed by GitHub
parent 9ccae851e7
commit 1277ba1661
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
605 changed files with 11240 additions and 3628 deletions

View file

@ -306,7 +306,6 @@ FREERTOS_IGNORED_FILES = [
'interrupt_vector.s',
'reg_test.S',
'gdbinit',
]
FREERTOS_HEADER = [
@ -358,4 +357,3 @@ def main():
if __name__ == '__main__':
exit(main())

View file

@ -59,6 +59,9 @@
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -55,6 +55,9 @@
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -56,6 +56,9 @@
#define configIDLE_SHOULD_YIELD 1
#define configQUEUE_REGISTRY_SIZE 0
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -57,6 +57,9 @@
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -56,6 +56,9 @@
#define configQUEUE_REGISTRY_SIZE 0
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -69,6 +69,9 @@ the CPU frequency. */
#define configUSE_RECURSIVE_MUTEXES 1
#define configCHECK_FOR_STACK_OVERFLOW 2
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -53,6 +53,9 @@
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -55,6 +55,9 @@
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -53,6 +53,9 @@
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -52,6 +52,7 @@
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 0
#define configUSE_MUTEXES 1
#define configCHECK_FOR_STACK_OVERFLOW 0
#define configUSE_RECURSIVE_MUTEXES 1
@ -59,6 +60,7 @@
#define configUSE_COUNTING_SEMAPHORES 1
#define configMAX_PRIORITIES ( 6 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -73,6 +73,9 @@
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 0 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -56,6 +56,10 @@
#define configUSE_16_BIT_TICKS 1
#define configIDLE_SHOULD_YIELD 1
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 1
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -71,6 +71,10 @@ Changes from V2.2.0
Changes from V2.6.1
+ The IAR and WinAVR AVR ports are now maintained separately.
Changes from V4.0.5
+ Modified to demonstrate the use of co-routines.
*/
#include <stdlib.h>
@ -84,12 +88,14 @@ Changes from V2.6.1
/* Scheduler include files. */
#include "FreeRTOS.h"
#include "task.h"
#include "croutine.h"
/* Demo file headers. */
#include "PollQ.h"
#include "integer.h"
#include "serial.h"
#include "comtest.h"
#include "crflash.h"
#include "print.h"
#include "partest.h"
#include "regtest.h"
@ -121,6 +127,9 @@ again. */
the demo application is not unexpectedly resetting. */
#define mainRESET_COUNT_ADDRESS ( ( void * ) 0x50 )
/* The number of coroutines to create. */
#define mainNUM_FLASH_COROUTINES ( 3 )
/*
* The task function for the "Check" task.
*/
@ -139,7 +148,7 @@ static void prvCheckOtherTasksAreStillRunning( void );
static void prvIncrementResetCount( void );
/*
* Idle hook (empty)
* Idle hook is used to scheduler co-routines.
*/
void vApplicationIdleHook( void );
@ -159,6 +168,9 @@ short main( void )
/* Create the tasks defined within this file. */
xTaskCreate( vErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
/* Create the co-routines that flash the LED's. */
vStartFlashCoRoutines( mainNUM_FLASH_COROUTINES );
/* In this port, to use preemptive scheduler define configUSE_PREEMPTION
as 1 in portmacro.h. To use the cooperative scheduler define
configUSE_PREEMPTION as 0. */
@ -256,5 +268,6 @@ const unsigned char ucWrite2 = ( unsigned char ) 0x02;
void vApplicationIdleHook( void )
{
vCoRoutineSchedule();
}

View file

@ -971,6 +971,9 @@
<file>
<name>$PROJ_DIR$\..\Common\Minimal\comtest.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\Minimal\crflash.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\portable\MemMang\heap_1.c</name>
</file>
@ -995,6 +998,9 @@
</group>
<group>
<name>Kernel Source</name>
<file>
<name>$PROJ_DIR$\..\..\Source\croutine.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\list.c</name>
</file>
@ -1012,3 +1018,5 @@
</file>
</group>
</project>

View file

@ -55,6 +55,10 @@
#define configIDLE_SHOULD_YIELD 1
#define configQUEUE_REGISTRY_SIZE 0
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 1
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -39,7 +39,6 @@ Changes from V2.6.0
#include "FreeRTOS.h"
#include "task.h"
#include "partest.h"
#include <avr/io.h>
/*-----------------------------------------------------------
* Simple parallel port IO routines.

View file

@ -68,6 +68,10 @@ Changes from V2.6.1
+ The IAR and WinAVR AVR ports are now maintained separately.
Changes from V4.0.5
+ Modified to demonstrate the use of co-routines.
*/
#include <stdlib.h>
@ -81,12 +85,14 @@ Changes from V2.6.1
/* Scheduler include files. */
#include "FreeRTOS.h"
#include "task.h"
#include "croutine.h"
/* Demo file headers. */
#include "PollQ.h"
#include "integer.h"
#include "serial.h"
#include "comtest.h"
#include "crflash.h"
#include "print.h"
#include "partest.h"
#include "regtest.h"
@ -118,6 +124,9 @@ again. */
the demo application is not unexpectedly resetting. */
#define mainRESET_COUNT_ADDRESS ( ( void * ) 0x50 )
/* The number of coroutines to create. */
#define mainNUM_FLASH_COROUTINES ( 3 )
/*
* The task function for the "Check" task.
*/
@ -136,7 +145,7 @@ static void prvCheckOtherTasksAreStillRunning( void );
static void prvIncrementResetCount( void );
/*
* The idle hook is unused.
* The idle hook is used to scheduler co-routines.
*/
void vApplicationIdleHook( void );
@ -158,6 +167,9 @@ short main( void )
/* Create the tasks defined within this file. */
xTaskCreate( vErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
/* Create the co-routines that flash the LED's. */
vStartFlashCoRoutines( mainNUM_FLASH_COROUTINES );
/* In this port, to use preemptive scheduler define configUSE_PREEMPTION
as 1 in portmacro.h. To use the cooperative scheduler define
configUSE_PREEMPTION as 0. */
@ -235,5 +247,6 @@ unsigned char ucCount;
void vApplicationIdleHook( void )
{
vCoRoutineSchedule();
}

View file

@ -1,4 +1,4 @@
# WinAVR Sample makefile written by Eric B. Weddington, J<EFBFBD>rg Wunsch, et al.
# WinAVR Sample makefile written by Eric B. Weddington, Jörg Wunsch, et al.
# Released to the Public Domain
# Please read the make user manual!
#
@ -57,8 +57,10 @@ regtest.c \
$(SOURCE_DIR)/tasks.c \
$(SOURCE_DIR)/queue.c \
$(SOURCE_DIR)/list.c \
$(SOURCE_DIR)/croutine.c \
$(SOURCE_DIR)/portable/MemMang/heap_1.c \
$(PORT_DIR)/port.c \
$(DEMO_DIR)/crflash.c \
$(DEMO_DIR)/integer.c \
$(DEMO_DIR)/PollQ.c \
$(DEMO_DIR)/comtest.c

View file

@ -89,6 +89,10 @@ For other frequency values, update clock_config.h with your own settings. */
#define configUSE_TRACE_FACILITY 0
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
/* Co-routine related definitions. */
#define configUSE_CO_ROUTINES 1
#define configMAX_CO_ROUTINE_PRIORITIES 2
/* Software timer related definitions. */
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )

View file

@ -155,6 +155,10 @@
<Compile Include="main.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="..\..\..\Source\croutine.c">
<SubType>compile</SubType>
<Link>Source\croutine.c</Link>
</Compile>
<Compile Include="..\..\..\Source\event_groups.c">
<SubType>compile</SubType>
<Link>Source\event_groups.c</Link>
@ -199,6 +203,10 @@
<SubType>compile</SubType>
<Link>Source\include\atomic.h</Link>
</Compile>
<Compile Include="..\..\..\Source\include\croutine.h">
<SubType>compile</SubType>
<Link>Source\include\croutine.h</Link>
</Compile>
<Compile Include="..\..\..\Source\include\deprecated_definitions.h">
<SubType>compile</SubType>
<Link>Source\include\deprecated_definitions.h</Link>
@ -304,6 +312,14 @@
<SubType>compile</SubType>
<Link>Common\Minimal\PollQ.c</Link>
</Compile>
<Compile Include="..\..\..\Demo\Common\include\crflash.h">
<SubType>compile</SubType>
<Link>Common\include\crflash.h</Link>
</Compile>
<Compile Include="..\..\..\Demo\Common\Minimal\crflash.c">
<SubType>compile</SubType>
<Link>Common\Minimal\crflash.c</Link>
</Compile>
<Compile Include="..\..\..\Demo\Common\include\recmutex.h">
<SubType>compile</SubType>
<Link>Common\include\recmutex.h</Link>

View file

@ -28,10 +28,12 @@
#include "FreeRTOS.h"
#include "task.h"
#include "croutine.h"
#include "PollQ.h"
#include "integer.h"
#include "serial.h"
#include "comtest.h"
#include "crflash.h"
#include "partest.h"
#include "regtest.h"
@ -61,6 +63,9 @@ again. */
the demo application is not unexpectedly resetting. */
#define mainRESET_COUNT_ADDRESS ( 0x1400 )
/* The number of coroutines to create. */
#define mainNUM_FLASH_COROUTINES ( 3 )
/*
* The task function for the "Check" task.
*/
@ -91,6 +96,9 @@ void main_minimal( void )
/* Create the tasks defined within this file. */
xTaskCreate( vErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
/* Create the co-routines that flash the LED's. */
vStartFlashCoRoutines( mainNUM_FLASH_COROUTINES );
/* In this port, to use preemptive scheduler define configUSE_PREEMPTION
as 1 in portmacro.h. To use the cooperative scheduler define
configUSE_PREEMPTION as 0. */
@ -174,4 +182,5 @@ unsigned char ucResetCount;
void vApplicationIdleHook( void )
{
vCoRoutineSchedule();
}

View file

@ -91,6 +91,10 @@ For other frequency values, update clock_config.h with your own settings. */
#define configUSE_TRACE_FACILITY 0
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
/* Co-routine related definitions. */
#define configUSE_CO_ROUTINES 1
#define configMAX_CO_ROUTINE_PRIORITIES 2
/* Software timer related definitions. */
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )

View file

@ -2121,6 +2121,9 @@
<file>
<name>$PROJ_DIR$\..\Common\include\comtest.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\include\crflash.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\include\integer.h</name>
</file>
@ -2145,6 +2148,9 @@
<file>
<name>$PROJ_DIR$\..\Common\Minimal\comtest.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\Minimal\crflash.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\Minimal\integer.c</name>
</file>
@ -2193,6 +2199,9 @@
<file>
<name>$PROJ_DIR$\..\..\Source\include\atomic.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\include\croutine.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\include\deprecated_definitions.h</name>
</file>
@ -2269,6 +2278,9 @@
</file>
</group>
</group>
<file>
<name>$PROJ_DIR$\..\..\Source\croutine.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\event_groups.c</name>
</file>

View file

@ -2169,6 +2169,9 @@
<file>
<name>$PROJ_DIR$\..\Common\include\comtest.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\include\crflash.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\include\integer.h</name>
</file>
@ -2193,6 +2196,9 @@
<file>
<name>$PROJ_DIR$\..\Common\Minimal\comtest.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\Minimal\crflash.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\Minimal\integer.c</name>
</file>
@ -2241,6 +2247,9 @@
<file>
<name>$PROJ_DIR$\..\..\Source\include\atomic.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\include\croutine.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\include\deprecated_definitions.h</name>
</file>
@ -2317,6 +2326,9 @@
</file>
</group>
</group>
<file>
<name>$PROJ_DIR$\..\..\Source\croutine.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\event_groups.c</name>
</file>

View file

@ -26,11 +26,13 @@
#include "FreeRTOS.h"
#include "task.h"
#include "croutine.h"
#include "PollQ.h"
#include "integer.h"
#include "serial.h"
#include "comtest.h"
#include "crflash.h"
#include "partest.h"
#include "regtest.h"
@ -60,6 +62,9 @@ again. */
the demo application is not unexpectedly resetting. */
#define mainRESET_COUNT_ADDRESS ( 0x1400 )
/* The number of coroutines to create. */
#define mainNUM_FLASH_COROUTINES ( 3 )
/*
* The task function for the "Check" task.
*/
@ -90,6 +95,9 @@ void main_minimal( void )
/* Create the tasks defined within this file. */
xTaskCreate( vErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
/* Create the co-routines that flash the LED's. */
vStartFlashCoRoutines( mainNUM_FLASH_COROUTINES );
/* In this port, to use preemptive scheduler define configUSE_PREEMPTION
as 1 in portmacro.h. To use the cooperative scheduler define
configUSE_PREEMPTION as 0. */
@ -171,4 +179,5 @@ static unsigned char __eeprom ucResetCount @ mainRESET_COUNT_ADDRESS;
void vApplicationIdleHook( void )
{
vCoRoutineSchedule();
}

View file

@ -89,6 +89,10 @@ For other frequency values, update clock_config.h with your own settings. */
#define configUSE_TRACE_FACILITY 0
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
/* Co-routine related definitions. */
#define configUSE_CO_ROUTINES 1
#define configMAX_CO_ROUTINE_PRIORITIES 2
/* Software timer related definitions. */
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )

View file

@ -28,10 +28,12 @@
#include "FreeRTOS.h"
#include "task.h"
#include "croutine.h"
#include "PollQ.h"
#include "integer.h"
#include "serial.h"
#include "comtest.h"
#include "crflash.h"
#include "partest.h"
#include "regtest.h"
@ -61,6 +63,9 @@ again. */
the demo application is not unexpectedly resetting. */
#define mainRESET_COUNT_ADDRESS ( 0x1400 )
/* The number of coroutines to create. */
#define mainNUM_FLASH_COROUTINES ( 3 )
/*
* The task function for the "Check" task.
*/
@ -91,6 +96,9 @@ void main_minimal( void )
/* Create the tasks defined within this file. */
xTaskCreate( vErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
/* Create the co-routines that flash the LED's. */
vStartFlashCoRoutines( mainNUM_FLASH_COROUTINES );
/* In this port, to use preemptive scheduler define configUSE_PREEMPTION
as 1 in portmacro.h. To use the cooperative scheduler define
configUSE_PREEMPTION as 0. */
@ -174,4 +182,5 @@ unsigned char ucResetCount;
void vApplicationIdleHook( void )
{
vCoRoutineSchedule();
}

View file

@ -30,6 +30,8 @@
<itemPath>../Common/include/comtest2.h</itemPath>
<itemPath>../Common/include/comtest_strings.h</itemPath>
<itemPath>../Common/include/countsem.h</itemPath>
<itemPath>../Common/include/crflash.h</itemPath>
<itemPath>../Common/include/crhook.h</itemPath>
<itemPath>../Common/include/death.h</itemPath>
<itemPath>../Common/include/dynamic.h</itemPath>
<itemPath>../Common/include/fileIO.h</itemPath>
@ -48,6 +50,7 @@
<itemPath>../Common/Minimal/PollQ.c</itemPath>
<itemPath>../Common/Minimal/TaskNotify.c</itemPath>
<itemPath>../Common/Minimal/comtest.c</itemPath>
<itemPath>../Common/Minimal/crflash.c</itemPath>
<itemPath>../Common/Minimal/integer.c</itemPath>
<itemPath>../Common/Minimal/recmutex.c</itemPath>
</logicalFolder>
@ -57,6 +60,7 @@
<itemPath>../../Source/include/FreeRTOS.h</itemPath>
<itemPath>../../Source/include/StackMacros.h</itemPath>
<itemPath>../../Source/include/atomic.h</itemPath>
<itemPath>../../Source/include/croutine.h</itemPath>
<itemPath>../../Source/include/deprecated_definitions.h</itemPath>
<itemPath>../../Source/include/event_groups.h</itemPath>
<itemPath>../../Source/include/list.h</itemPath>
@ -85,6 +89,7 @@
<itemPath>../../Source/portable/MemMang/heap_1.c</itemPath>
</logicalFolder>
</logicalFolder>
<itemPath>../../Source/croutine.c</itemPath>
<itemPath>../../Source/event_groups.c</itemPath>
<itemPath>../../Source/list.c</itemPath>
<itemPath>../../Source/queue.c</itemPath>

View file

@ -204,6 +204,10 @@
</ToolchainSettings>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\..\Source\croutine.c">
<SubType>compile</SubType>
<Link>FreeRTOS\croutine.c</Link>
</Compile>
<Compile Include="..\..\..\Source\event_groups.c">
<SubType>compile</SubType>
<Link>FreeRTOS\event_groups.c</Link>
@ -212,6 +216,10 @@
<SubType>compile</SubType>
<Link>FreeRTOS\include\atomic.h</Link>
</Compile>
<Compile Include="..\..\..\Source\include\croutine.h">
<SubType>compile</SubType>
<Link>FreeRTOS\include\croutine.h</Link>
</Compile>
<Compile Include="..\..\..\Source\include\deprecated_definitions.h">
<SubType>compile</SubType>
<Link>FreeRTOS\include\deprecated_definitions.h</Link>

View file

@ -91,6 +91,10 @@ For other frequency values, update clock_config.h with your own settings */
#define configUSE_TRACE_FACILITY 0
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
/* Co-routine related definitions. */
#define configUSE_CO_ROUTINES 1
#define configMAX_CO_ROUTINE_PRIORITIES 2
/* Software timer related definitions. */
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )

View file

@ -152,6 +152,10 @@
<Compile Include="FreeRTOSConfig.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="..\..\..\Source\croutine.c">
<SubType>compile</SubType>
<Link>freeRTOS\croutine.c</Link>
</Compile>
<Compile Include="..\..\..\Source\event_groups.c">
<SubType>compile</SubType>
<Link>freeRTOS\event_groups.c</Link>
@ -196,6 +200,10 @@
<SubType>compile</SubType>
<Link>freeRTOS\include\atomic.h</Link>
</Compile>
<Compile Include="..\..\..\Source\include\croutine.h">
<SubType>compile</SubType>
<Link>freeRTOS\include\croutine.h</Link>
</Compile>
<Compile Include="..\..\..\Source\include\deprecated_definitions.h">
<SubType>compile</SubType>
<Link>freeRTOS\include\deprecated_definitions.h</Link>
@ -308,6 +316,14 @@
<SubType>compile</SubType>
<Link>Common\Minimal\PollQ.c</Link>
</Compile>
<Compile Include="..\..\..\Demo\Common\include\crflash.h">
<SubType>compile</SubType>
<Link>Common\include\crflash.h</Link>
</Compile>
<Compile Include="..\..\..\Demo\Common\Minimal\crflash.c">
<SubType>compile</SubType>
<Link>Common\Minimal\crflash.c</Link>
</Compile>
<Compile Include="..\..\..\Demo\Common\include\serial.h">
<SubType>compile</SubType>
<Link>Common\include\serial.h</Link>

View file

@ -27,10 +27,12 @@
#include "FreeRTOS.h"
#include "task.h"
#include "croutine.h"
#include "PollQ.h"
#include "integer.h"
#include "serial.h"
#include "comtest.h"
#include "crflash.h"
#include "partest.h"
#include "regtest.h"
@ -60,6 +62,9 @@ again. */
the demo application is not unexpectedly resetting. */
#define mainRESET_COUNT_ADDRESS ( 0x1400 )
/* The number of coroutines to create. */
#define mainNUM_FLASH_COROUTINES ( 3 )
/*
* The task function for the "Check" task.
*/
@ -90,6 +95,9 @@ void main_minimal( void )
/* Create the tasks defined within this file. */
xTaskCreate( vErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
/* Create the co-routines that flash the LED's. */
vStartFlashCoRoutines( mainNUM_FLASH_COROUTINES );
/* In this port, to use preemptive scheduler define configUSE_PREEMPTION
as 1 in portmacro.h. To use the cooperative scheduler define
configUSE_PREEMPTION as 0. */
@ -173,4 +181,5 @@ unsigned char ucResetCount;
void vApplicationIdleHook( void )
{
vCoRoutineSchedule();
}

View file

@ -93,6 +93,10 @@ For other frequency values, update clock_config.h with your own settings */
#define configUSE_TRACE_FACILITY 0
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
/* Co-routine related definitions. */
#define configUSE_CO_ROUTINES 1
#define configMAX_CO_ROUTINE_PRIORITIES 2
/* Software timer related definitions. */
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )

View file

@ -2126,6 +2126,9 @@
<file>
<name>$PROJ_DIR$\..\Common\include\comtest.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\include\crflash.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\include\integer.h</name>
</file>
@ -2156,6 +2159,9 @@
<file>
<name>$PROJ_DIR$\..\Common\Minimal\comtest.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\Minimal\crflash.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\Minimal\integer.c</name>
</file>
@ -2177,6 +2183,9 @@
<file>
<name>$PROJ_DIR$\..\..\Source\include\atomic.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\include\croutine.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\include\deprecated_definitions.h</name>
</file>
@ -2253,6 +2262,9 @@
</file>
</group>
</group>
<file>
<name>$PROJ_DIR$\..\..\Source\croutine.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\event_groups.c</name>
</file>

View file

@ -2169,6 +2169,9 @@
<file>
<name>$PROJ_DIR$\..\Common\include\comtest.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\include\crflash.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\include\integer.h</name>
</file>
@ -2199,6 +2202,9 @@
<file>
<name>$PROJ_DIR$\..\Common\Minimal\comtest.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\Minimal\crflash.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\Minimal\integer.c</name>
</file>
@ -2220,6 +2226,9 @@
<file>
<name>$PROJ_DIR$\..\..\Source\include\atomic.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\include\croutine.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\include\deprecated_definitions.h</name>
</file>
@ -2296,6 +2305,9 @@
</file>
</group>
</group>
<file>
<name>$PROJ_DIR$\..\..\Source\croutine.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\event_groups.c</name>
</file>

View file

@ -26,11 +26,13 @@
#include "FreeRTOS.h"
#include "task.h"
#include "croutine.h"
#include "PollQ.h"
#include "integer.h"
#include "serial.h"
#include "comtest.h"
#include "crflash.h"
#include "partest.h"
#include "regtest.h"
@ -60,6 +62,9 @@ again. */
the demo application is not unexpectedly resetting. */
#define mainRESET_COUNT_ADDRESS ( 0x1400 )
/* The number of coroutines to create. */
#define mainNUM_FLASH_COROUTINES ( 3 )
/*
* The task function for the "Check" task.
*/
@ -90,6 +95,9 @@ void main_minimal( void )
/* Create the tasks defined within this file. */
xTaskCreate( vErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
/* Create the co-routines that flash the LED's. */
vStartFlashCoRoutines( mainNUM_FLASH_COROUTINES );
/* In this port, to use preemptive scheduler define configUSE_PREEMPTION
as 1 in portmacro.h. To use the cooperative scheduler define
configUSE_PREEMPTION as 0. */
@ -171,4 +179,5 @@ static unsigned char __eeprom ucResetCount @ mainRESET_COUNT_ADDRESS;
void vApplicationIdleHook( void )
{
vCoRoutineSchedule();
}

View file

@ -91,6 +91,10 @@ For other frequency values, update clock_config.h with your own settings */
#define configUSE_TRACE_FACILITY 0
#define configUSE_STATS_FORMATTING_FUNCTIONS 0
/* Co-routine related definitions. */
#define configUSE_CO_ROUTINES 1
#define configMAX_CO_ROUTINE_PRIORITIES 2
/* Software timer related definitions. */
#define configUSE_TIMERS 1
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )

View file

@ -27,10 +27,12 @@
#include "FreeRTOS.h"
#include "task.h"
#include "croutine.h"
#include "PollQ.h"
#include "integer.h"
#include "serial.h"
#include "comtest.h"
#include "crflash.h"
#include "partest.h"
#include "regtest.h"
@ -60,6 +62,9 @@ again. */
the demo application is not unexpectedly resetting. */
#define mainRESET_COUNT_ADDRESS ( 0x1400 )
/* The number of coroutines to create. */
#define mainNUM_FLASH_COROUTINES ( 3 )
/*
* The task function for the "Check" task.
*/
@ -90,6 +95,9 @@ void main_minimal( void )
/* Create the tasks defined within this file. */
xTaskCreate( vErrorChecks, "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
/* Create the co-routines that flash the LED's. */
vStartFlashCoRoutines( mainNUM_FLASH_COROUTINES );
/* In this port, to use preemptive scheduler define configUSE_PREEMPTION
as 1 in portmacro.h. To use the cooperative scheduler define
configUSE_PREEMPTION as 0. */
@ -173,4 +181,5 @@ unsigned char ucResetCount;
void vApplicationIdleHook( void )
{
vCoRoutineSchedule();
}

View file

@ -10,6 +10,7 @@
<itemPath>../Common/include/PollQ.h</itemPath>
<itemPath>../Common/include/TaskNotify.h</itemPath>
<itemPath>../Common/include/comtest.h</itemPath>
<itemPath>../Common/include/crflash.h</itemPath>
<itemPath>../Common/include/integer.h</itemPath>
<itemPath>../Common/include/partest.h</itemPath>
<itemPath>../Common/include/print.h</itemPath>
@ -21,6 +22,7 @@
<itemPath>../Common/Minimal/PollQ.c</itemPath>
<itemPath>../Common/Minimal/TaskNotify.c</itemPath>
<itemPath>../Common/Minimal/comtest.c</itemPath>
<itemPath>../Common/Minimal/crflash.c</itemPath>
<itemPath>../Common/Minimal/integer.c</itemPath>
<itemPath>../Common/Minimal/recmutex.c</itemPath>
</logicalFolder>
@ -30,6 +32,7 @@
<itemPath>../../Source/include/FreeRTOS.h</itemPath>
<itemPath>../../Source/include/StackMacros.h</itemPath>
<itemPath>../../Source/include/atomic.h</itemPath>
<itemPath>../../Source/include/croutine.h</itemPath>
<itemPath>../../Source/include/deprecated_definitions.h</itemPath>
<itemPath>../../Source/include/event_groups.h</itemPath>
<itemPath>../../Source/include/list.h</itemPath>
@ -57,6 +60,7 @@
<itemPath>../../Source/portable/MemMang/heap_1.c</itemPath>
</logicalFolder>
</logicalFolder>
<itemPath>../../Source/croutine.c</itemPath>
<itemPath>../../Source/event_groups.c</itemPath>
<itemPath>../../Source/list.c</itemPath>
<itemPath>../../Source/queue.c</itemPath>

View file

@ -93,6 +93,9 @@
#define configSUPPORT_STATIC_ALLOCATION 1
#define configSUPPORT_DYNAMIC_ALLOCATION 1 /* Defaults to 1 anyway. */
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Software timer definitions. */
#define configUSE_TIMERS 1

View file

@ -61,6 +61,9 @@
#define configUSE_APPLICATION_TASK_TAG 0
#define configUSE_COUNTING_SEMAPHORES 1
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Software timer definitions. */
#define configUSE_TIMERS 1

View file

@ -61,6 +61,9 @@
#define configUSE_APPLICATION_TASK_TAG 0
#define configUSE_COUNTING_SEMAPHORES 1
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Software timer definitions. */
#define configUSE_TIMERS 1

View file

@ -61,6 +61,9 @@
#define configUSE_APPLICATION_TASK_TAG 0
#define configUSE_COUNTING_SEMAPHORES 1
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Software timer definitions. */
#define configUSE_TIMERS 1

View file

@ -108,6 +108,9 @@ uint8_t ucHeap[ configTOTAL_HEAP_SIZE ];
#define configUSE_TICK_HOOK 1
#define configUSE_DAEMON_TASK_STARTUP_HOOK 1
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Software timer definitions. */
#define configUSE_TIMERS 1

View file

@ -95,6 +95,9 @@
/* Include the query-heap CLI command to query the free heap space. */
#define configINCLUDE_QUERY_HEAP_COMMAND 1
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Software timer definitions. */
#define configUSE_TIMERS 1

View file

@ -102,6 +102,9 @@ LEDs are not visible in QEMU. */
/* Include the query-heap CLI command to query the free heap space. */
#define configINCLUDE_QUERY_HEAP_COMMAND 1
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Software timer definitions. */
#define configUSE_TIMERS 1

View file

@ -50,11 +50,13 @@
#define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 0
#define configUSE_MUTEXES 1
#define configUSE_RECURSIVE_MUTEXES 1
#define configCHECK_FOR_STACK_OVERFLOW 2
#define configMAX_PRIORITIES ( 5 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
#define configQUEUE_REGISTRY_SIZE 10
/* Set the following definitions to 1 to include the API function, or zero

View file

@ -354,6 +354,9 @@
</ToolchainSettings>
</PropertyGroup>
<ItemGroup>
<Compile Include="src\asf\thirdparty\FreeRTOS\include\croutine.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="src\asf\thirdparty\FreeRTOS\include\FreeRTOS.h">
<SubType>compile</SubType>
</Compile>

View file

@ -71,6 +71,9 @@ extern uint32_t SystemCoreClock;
#define configUSE_COUNTING_SEMAPHORES 1
#define configGENERATE_RUN_TIME_STATS 0
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Software timer definitions. */
#define configUSE_TIMERS 1

View file

@ -442,6 +442,9 @@
<Compile Include="src\asf\sam\utils\cmsis\sam3x\source\templates\system_sam3x.c">
<SubType>compile</SubType>
</Compile>
<Compile Include="src\asf\thirdparty\FreeRTOS\include\croutine.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="src\asf\thirdparty\FreeRTOS\include\FreeRTOS.h">
<SubType>compile</SubType>
</Compile>
@ -547,6 +550,12 @@
<Compile Include="src\Common-Demo-Source\include\countsem.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="src\Common-Demo-Source\include\crflash.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="src\Common-Demo-Source\include\crhook.h">
<SubType>compile</SubType>
</Compile>
<Compile Include="src\Common-Demo-Source\include\death.h">
<SubType>compile</SubType>
</Compile>

View file

@ -71,6 +71,9 @@ extern uint32_t SystemCoreClock;
#define configUSE_COUNTING_SEMAPHORES 1
#define configGENERATE_RUN_TIME_STATS 0
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Software timer definitions. */
#define configUSE_TIMERS 1

View file

@ -51,8 +51,10 @@
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 0
#define configUSE_MUTEXES 1
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_ALTERNATIVE_API 0

View file

@ -63,6 +63,13 @@
<PropertyDeltas />
</CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b>
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="crhook.h" persistent="../../Common/include/crhook.h">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<build_action v="NONE" />
<PropertyDeltas />
</CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b>
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="death.h" persistent="../../Common/include/death.h">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
@ -173,6 +180,13 @@
<CyGuid_0820c2e7-528d-4137-9a08-97257b946089 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItemList" version="2">
<dependencies>
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="croutine.h" persistent="../../../Source/include/croutine.h">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<build_action v="NONE" />
<PropertyDeltas />
</CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b>
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="FreeRTOS.h" persistent="../../../Source/include/FreeRTOS.h">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
@ -400,6 +414,13 @@
<CyGuid_0820c2e7-528d-4137-9a08-97257b946089 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItemList" version="2">
<dependencies>
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="croutine.c" persistent="../../../Source/croutine.c">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<build_action v="C_FILE" />
<PropertyDeltas />
</CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b>
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="heap_2.c" persistent="../../../Source/portable/MemMang/heap_2.c">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>

View file

@ -51,8 +51,10 @@
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 0
#define configUSE_MUTEXES 1
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_ALTERNATIVE_API 0

View file

@ -173,6 +173,20 @@
<CyGuid_0820c2e7-528d-4137-9a08-97257b946089 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItemList" version="2">
<dependencies>
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="croutine.h" persistent="../../../Source/include/croutine.h">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<build_action v="NONE" />
<PropertyDeltas />
</CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b>
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="FreeRTOS.h" persistent="../../../Source/include/FreeRTOS.h">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<build_action v="NONE" />
<PropertyDeltas />
</CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b>
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="list.h" persistent="../../../Source/include/list.h">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
@ -393,6 +407,13 @@
<CyGuid_0820c2e7-528d-4137-9a08-97257b946089 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItemList" version="2">
<dependencies>
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="croutine.c" persistent="../../../Source/croutine.c">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<build_action v="C_FILE" />
<PropertyDeltas />
</CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b>
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="heap_2.c" persistent="../../../Source/portable/MemMang/heap_2.c">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>

View file

@ -51,8 +51,10 @@
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 0
#define configUSE_MUTEXES 1
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
#define configUSE_COUNTING_SEMAPHORES 1
#define configUSE_ALTERNATIVE_API 0

View file

@ -173,6 +173,13 @@
<CyGuid_0820c2e7-528d-4137-9a08-97257b946089 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItemList" version="2">
<dependencies>
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="croutine.h" persistent="../../../Source/include/croutine.h">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<build_action v="NONE" />
<PropertyDeltas />
</CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b>
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="FreeRTOS.h" persistent="../../../Source/include/FreeRTOS.h">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
@ -400,6 +407,13 @@
<CyGuid_0820c2e7-528d-4137-9a08-97257b946089 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItemList" version="2">
<dependencies>
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="croutine.c" persistent="../../../Source/croutine.c">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>
<build_action v="C_FILE" />
<PropertyDeltas />
</CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b>
<CyGuid_8b8ab257-35d3-4473-b57b-36315200b38b type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtFile" version="3">
<CyGuid_31768f72-0253-412b-af77-e7dba74d1330 type_name="CyDesigner.Common.ProjMgmt.Model.CyPrjMgmtItem" version="2" name="heap_2.c" persistent="../../../Source/portable/MemMang/heap_2.c">
<Hidden v="False" />
</CyGuid_31768f72-0253-412b-af77-e7dba74d1330>

View file

@ -42,6 +42,15 @@
</link>
</linkedResources>
<filteredResources>
<filter>
<id>1456936861071</id>
<name>FreeRTOS_Source</name>
<type>6</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-croutine.c</arguments>
</matcher>
</filter>
<filter>
<id>1456936886134</id>
<name>FreeRTOS_Source/portable</name>

View file

@ -145,6 +145,10 @@ extern "C" {
/* Run time stats gathering related definitions. */
#define configGENERATE_RUN_TIME_STATS ( 0 )
/* Co-routine related definitions. */
#define configUSE_CO_ROUTINES ( 0 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 1 )
/* Software timer related definitions. */
#define configUSE_TIMERS ( 1 )
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) /* Highest priority */

View file

@ -122,6 +122,10 @@ extern "C" {
/* Run time stats gathering related definitions. */
#define configGENERATE_RUN_TIME_STATS ( 0 )
/* Co-routine related definitions. */
#define configUSE_CO_ROUTINES ( 0 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 1 )
/* Software timer related definitions. */
#define configUSE_TIMERS ( 1 )
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) /* Highest priority */

View file

@ -0,0 +1,2 @@
# Build Artifacts.
gcc/

View file

@ -40,7 +40,7 @@
*----------------------------------------------------------*/
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 0
#define configUSE_IDLE_HOOK 1
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( ( unsigned long ) 20000000 )
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
@ -50,8 +50,10 @@
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 1
#define configMAX_PRIORITIES ( 2 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
@ -64,4 +66,7 @@ to exclude the API function. */
#define INCLUDE_vTaskDelayUntil 0
#define INCLUDE_vTaskDelay 1
#endif /* FREERTOS_CONFIG_H */

View file

@ -25,13 +25,24 @@
*/
/*
* This demo application creates two tasks (three including
* the idle task).
* This demo application creates six co-routines and two tasks (three including
* the idle task). The co-routines execute as part of the idle task hook.
*
* Five of the created co-routines are the standard 'co-routine flash'
* co-routines contained within the Demo/Common/Minimal/crflash.c file and
* documented on the FreeRTOS.org WEB site.
*
* The 'LCD Task' rotates a string on the LCD, delaying between each character
* as necessitated by the slow interface, and delaying between each string just
* long enough to enable the text to be read.
*
* The sixth co-routine and final task control the transmission and reception
* of a string to UART 0. The co-routine periodically sends the first
* character of the string to the UART, with the UART's TxEnd interrupt being
* used to transmit the remaining characters. The UART's RxEnd interrupt
* receives the characters and places them on a queue to be processed by the
* 'COMs Rx' task. An error is latched should an unexpected character be
* received, or any character be received out of sequence.
*
* A loopback connector is required to ensure that each character transmitted
* on the UART is also received on the same UART. For test purposes the UART
@ -40,6 +51,10 @@
* order that the resultant interrupts are more randomly distributed and
* therefore more likely to highlight any problems.
*
* The flash co-routines control LED's zero to four. LED five is toggled each
* time the string is transmitted on the UART. LED six is toggled each time
* the string is CORRECTLY received on the UART. LED seven is latched on should
* an error be detected in any task or co-routine.
*
* In addition the idle task makes repetitive calls to
* prvSetAndCheckRegisters(). This simply loads the general purpose registers
@ -55,9 +70,11 @@
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "croutine.h"
/* Demo application include files. */
#include "partest.h"
#include "crflash.h"
/* Library include files. */
#include "DriverLib.h"
@ -68,10 +85,20 @@
/* The time to delay between writing each string to the LCD. */
#define mainSTRING_WRITE_DELAY ( 400 / portTICK_PERIOD_MS )
/* The number of flash co-routines to create. */
#define mainNUM_FLASH_CO_ROUTINES ( 5 )
/* The length of the queue used to pass received characters to the Comms Rx
task. */
#define mainRX_QUEUE_LEN ( 5 )
/* The priority of the co-routine used to initiate the transmission of the
string on UART 0. */
#define mainTX_CO_ROUTINE_PRIORITY ( 1 )
/* Only one co-routine is created so its index is not important. */
#define mainTX_CO_ROUTINE_INDEX ( 0 )
/* The time between transmissions of the string on UART 0. This is pseudo
random in order to generate a bit or randomness to when the interrupts occur.*/
#define mainMIN_TX_DELAY ( 40 / portTICK_PERIOD_MS )
@ -93,7 +120,7 @@ the timing of the transmission. */
#define mainCOMMS_RX_LED ( 6 )
#define mainCOMMS_TX_LED ( 5 )
/* The baud rate used by the UART comms tasks. */
/* The baud rate used by the UART comms tasks/co-routine. */
#define mainBAUD_RATE ( 57600 )
/* FIFO setting for the UART. The FIFO is not used to create a better test. */
@ -129,6 +156,12 @@ static void vLCDTask( void * pvParameters );
*/
static void vCommsRxTask( void * pvParameters );
/*
* The co-routine that periodically initiates the transmission of the string on
* the UART.
*/
static void vSerialTxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex );
/*
* Writes a string the the LCD.
*/
@ -163,7 +196,7 @@ static void prvSetupHardware( void );
/*-----------------------------------------------------------*/
/* Error flag set to pdFAIL if an error is encountered in the tasks
/* Error flag set to pdFAIL if an error is encountered in the tasks/co-routines
defined within this file. */
unsigned portBASE_TYPE uxErrorStatus = pdPASS;
@ -185,11 +218,18 @@ void Main( void )
/* Setup the ports used by the demo and the clock. */
prvSetupHardware();
/* Create the co-routines that flash the LED's. */
vStartFlashCoRoutines( mainNUM_FLASH_CO_ROUTINES );
/* Create the co-routine that initiates the transmission of characters
on the UART. */
xCoRoutineCreate( vSerialTxCoRoutine, mainTX_CO_ROUTINE_PRIORITY, mainTX_CO_ROUTINE_INDEX );
/* Create the LCD and Comms Rx tasks. */
xTaskCreate( vLCDTask, "LCD", configMINIMAL_STACK_SIZE, NULL, mainLCD_TASK_PRIORITY, NULL );
xTaskCreate( vCommsRxTask, "CMS", configMINIMAL_STACK_SIZE, NULL, mainCOMMS_RX_TASK_PRIORITY, NULL );
/* Start the scheduler running the tasks just created. */
/* Start the scheduler running the tasks and co-routines just created. */
vTaskStartScheduler();
/* Should not get here unless we did not have enough memory to start the
@ -208,7 +248,21 @@ static void prvSetupHardware( void )
vParTestInitialise();
vSerialInit();
}
/*-----------------------------------------------------------*/
void vApplicationIdleHook( void )
{
/* The co-routines are executed in the idle task using the idle task
hook. */
for( ;; )
{
/* Schedule the co-routines. */
vCoRoutineSchedule();
/* Run the register check function between each co-routine. */
prvSetAndCheckRegisters();
}
}
/*-----------------------------------------------------------*/
static void prvWriteString( const char *pcString )
@ -333,7 +387,71 @@ static char cRxedChar, cExpectedChar;
}
}
}
/*-----------------------------------------------------------*/
static void vSerialTxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex )
{
TickType_t xDelayPeriod;
static unsigned long *pulRandomBytes = mainFIRST_PROGRAM_BYTES;
/* Co-routine MUST start with a call to crSTART. */
crSTART( xHandle );
for(;;)
{
/* Was the previously transmitted string received correctly? */
if( uxErrorStatus != pdPASS )
{
/* An error was encountered so set the error LED. */
vSetErrorLED();
}
/* The next character to Tx is the first in the string. */
cNextChar = mainFIRST_TX_CHAR;
UARTIntDisable( UART0_BASE, UART_INT_TX );
{
/* Send the first character. */
if( !( HWREG( UART0_BASE + UART_O_FR ) & UART_FR_TXFF ) )
{
HWREG( UART0_BASE + UART_O_DR ) = cNextChar;
}
/* Move the variable to the char to Tx on so the ISR transmits
the next character in the string once this one has completed. */
cNextChar++;
}
UARTIntEnable(UART0_BASE, UART_INT_TX);
/* Toggle the LED to show a new string is being transmitted. */
vParTestToggleLED( mainCOMMS_TX_LED );
/* Delay before we start the string off again. A pseudo-random delay
is used as this will provide a better test. */
xDelayPeriod = xTaskGetTickCount() + ( *pulRandomBytes );
pulRandomBytes++;
if( pulRandomBytes > mainTOTAL_PROGRAM_MEMORY )
{
pulRandomBytes = mainFIRST_PROGRAM_BYTES;
}
/* Make sure we don't wait too long... */
xDelayPeriod &= mainMAX_TX_DELAY;
/* ...but we do want to wait. */
if( xDelayPeriod < mainMIN_TX_DELAY )
{
xDelayPeriod = mainMIN_TX_DELAY;
}
/* Block for the random(ish) time. */
crDELAY( xHandle, xDelayPeriod );
}
/* Co-routine MUST end with a call to crEND. */
crEND();
}
/*-----------------------------------------------------------*/
static void vSerialInit( void )

View file

@ -0,0 +1,72 @@
/*
* FreeRTOS V202212.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
*/
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
* Application specific definitions.
*
* These definitions should be adjusted for your particular hardware and
* application requirements.
*
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
*
* See http://www.freertos.org/a00110.html
*----------------------------------------------------------*/
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 1
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( ( unsigned long ) 20000000 )
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 59 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 1240 ) )
#define configMAX_TASK_NAME_LEN ( 3 )
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 1
#define configMAX_PRIORITIES ( 2 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 3 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet 0
#define INCLUDE_uxTaskPriorityGet 0
#define INCLUDE_vTaskDelete 0
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 0
#define INCLUDE_vTaskDelayUntil 0
#define INCLUDE_vTaskDelay 1
#endif /* FREERTOS_CONFIG_H */

View file

@ -0,0 +1,594 @@
/*
* FreeRTOS V202212.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
*/
/*
* This demo application creates seven co-routines and one task (two including
* the idle task). The co-routines execute as part of the idle task hook.
*
* Five of the created co-routines are the standard 'co-routine flash'
* co-routines contained within the Demo/Common/Minimal/crflash.c file and
* documented on the FreeRTOS.org WEB site.
*
* The 'LCD Task' rotates a string on the LCD, delaying between each character
* as necessitated by the slow interface, and delaying between each string just
* long enough to enable the text to be read.
*
* The sixth co-routine controls the transmission of a string to UART 0. The
* co-routine periodically sends the first character of the string to the UART,
* with the UART's TxEnd interrupt being used to transmit the remaining
* characters. The UART's RxEnd interrupt receives the characters and places
* them on a queue to be processed by the seventh and final co-routine. An
* error is latched should an unexpected character be received, or any
* character be received out of sequence.
*
* A loopback connector is required to ensure that each character transmitted
* on the UART is also received on the same UART. For test purposes the UART
* FIFO's are not utalised in order to maximise the interrupt overhead. Also
* a pseudo random interval is used between the start of each transmission in
* order that the resultant interrupts are more randomly distributed and
* therefore more likely to highlight any problems.
*
* The flash co-routines control LED's zero to four. LED five is toggled each
* time the string is transmitted on the UART. LED six is toggled each time
* the string is CORRECTLY received on the UART. LED seven is latched on should
* an error be detected in any task or co-routine.
*
* In addition the idle task makes repetitive calls to
* prvSetAndCheckRegisters(). This simply loads the general purpose registers
* with a known value, then checks each register to ensure the held value is
* still correct. As a low priority task this checking routine is likely to
* get repeatedly swapped in and out. A register being found to contain an
* incorrect value is therefore indicative of an error in the task switching
* mechansim.
*
*/
/* Scheduler include files. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "croutine.h"
/* Demo application include files. */
#include "partest.h"
#include "crflash.h"
/* Library include files. */
#include "DriverLib.h"
/* The time to delay between writing each character to the LCD. */
#define mainCHAR_WRITE_DELAY ( 2 / portTICK_PERIOD_MS )
/* The time to delay between writing each string to the LCD. */
#define mainSTRING_WRITE_DELAY ( 400 / portTICK_PERIOD_MS )
/* The number of flash co-routines to create. */
#define mainNUM_FLASH_CO_ROUTINES ( 5 )
/* The length of the queue used to pass received characters to the Comms Rx
task. */
#define mainRX_QUEUE_LEN ( 5 )
/* The priority of the co-routine used to initiate the transmission of the
string on UART 0. */
#define mainTX_CO_ROUTINE_PRIORITY ( 1 )
/* The priority of the co-routine used to receive characters from the UART. */
#define mainRX_CO_ROUTINE_PRIORITY ( 2 )
/* Only one co-routine is created so its index is not important. */
#define mainTX_CO_ROUTINE_INDEX ( 0 )
#define mainRX_CO_ROUTINE_INDEX ( 0 )
/* The time between transmissions of the string on UART 0. This is pseudo
random in order to generate a bit or randomness to when the interrupts occur.*/
#define mainMIN_TX_DELAY ( 40 / portTICK_PERIOD_MS )
#define mainMAX_TX_DELAY ( ( TickType_t ) 0x7f )
#define mainOFFSET_TIME ( ( TickType_t ) 3 )
/* The time the Comms Rx task should wait to receive a character. This should
be slightly longer than the time between transmissions. If we do not receive
a character after this time then there must be an error in the transmission or
the timing of the transmission. */
#define mainCOMMS_RX_DELAY ( mainMAX_TX_DELAY + 20 )
/* The task priorities. */
#define mainLCD_TASK_PRIORITY ( tskIDLE_PRIORITY )
#define mainCOMMS_RX_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
/* The LED's toggled by the various tasks. */
#define mainCOMMS_FAIL_LED ( 7 )
#define mainCOMMS_RX_LED ( 6 )
#define mainCOMMS_TX_LED ( 5 )
/* The baud rate used by the UART comms tasks/co-routine. */
#define mainBAUD_RATE ( 57600 )
/* FIFO setting for the UART. The FIFO is not used to create a better test. */
#define mainFIFO_SET ( 0x10 )
/* The string that is transmitted on the UART contains sequentially the
characters from mainFIRST_TX_CHAR to mainLAST_TX_CHAR. */
#define mainFIRST_TX_CHAR '0'
#define mainLAST_TX_CHAR 'z'
/* Just used to walk through the program memory in order that some random data
can be generated. */
#define mainTOTAL_PROGRAM_MEMORY ( ( unsigned long * ) ( 8 * 1024 ) )
#define mainFIRST_PROGRAM_BYTES ( ( unsigned long * ) 4 )
/* The error routine that is called if the driver library encounters an error. */
#ifdef DEBUG
void
__error__(char *pcFilename, unsigned long ulLine)
{
}
#endif
/*-----------------------------------------------------------*/
/*
* The task that rotates text on the LCD.
*/
static void vLCDTask( void * pvParameters );
/*
* The task that receives the characters from UART 0.
*/
static void vCommsRxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex );
/*
* The co-routine that periodically initiates the transmission of the string on
* the UART.
*/
static void vSerialTxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex );
/*
* Writes a string the the LCD.
*/
static void prvWriteString( const char *pcString );
/*
* Initialisation routine for the UART.
*/
static void vSerialInit( void );
/*
* Thread safe write to the PDC.
*/
static void prvPDCWrite( char cAddress, char cData );
/*
* Function to simply set a known value into the general purpose registers
* then read them back to ensure they remain set correctly. An incorrect value
* being indicative of an error in the task switching mechanism.
*/
void prvSetAndCheckRegisters( void );
/*
* Latch the LED that indicates that an error has occurred.
*/
void vSetErrorLED( void );
/*
* Sets up the PLL and ports used by the demo.
*/
static void prvSetupHardware( void );
/*-----------------------------------------------------------*/
/* Error flag set to pdFAIL if an error is encountered in the tasks/co-routines
defined within this file. */
unsigned portBASE_TYPE uxErrorStatus = pdPASS;
/* The next character to transmit. */
static char cNextChar;
/* The queue used to transmit characters from the interrupt to the Comms Rx
task. */
static QueueHandle_t xCommsQueue;
/*-----------------------------------------------------------*/
void Main( void )
{
/* Create the queue used to communicate between the UART ISR and the Comms
Rx task. */
xCommsQueue = xQueueCreate( mainRX_QUEUE_LEN, sizeof( char ) );
/* Setup the ports used by the demo and the clock. */
prvSetupHardware();
/* Create the co-routines that flash the LED's. */
vStartFlashCoRoutines( mainNUM_FLASH_CO_ROUTINES );
/* Create the co-routine that initiates the transmission of characters
on the UART. */
xCoRoutineCreate( vSerialTxCoRoutine, mainTX_CO_ROUTINE_PRIORITY, mainTX_CO_ROUTINE_INDEX );
/* Create the co-routine that receives characters from the UART. */
xCoRoutineCreate( vCommsRxCoRoutine, mainRX_CO_ROUTINE_PRIORITY, mainRX_CO_ROUTINE_INDEX );
/* Create the LCD task. */
xTaskCreate( vLCDTask, "LCD", configMINIMAL_STACK_SIZE, NULL, mainLCD_TASK_PRIORITY, NULL );
/* Start the scheduler running the tasks and co-routines just created. */
vTaskStartScheduler();
/* Should not get here unless we did not have enough memory to start the
scheduler. */
for( ;; );
}
/*-----------------------------------------------------------*/
static void prvSetupHardware( void )
{
/* Setup the PLL. */
SysCtlClockSet( SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ );
/* Initialise the hardware used to talk to the LCD, LED's and UART. */
PDCInit();
vParTestInitialise();
vSerialInit();
}
/*-----------------------------------------------------------*/
void vApplicationIdleHook( void )
{
/* The co-routines are executed in the idle task using the idle task
hook. */
for( ;; )
{
/* Schedule the co-routines. */
vCoRoutineSchedule();
/* Run the register check function between each co-routine. */
prvSetAndCheckRegisters();
}
}
/*-----------------------------------------------------------*/
static void prvWriteString( const char *pcString )
{
/* Write pcString to the LED, pausing between each character. */
prvPDCWrite(PDC_LCD_CSR, LCD_CLEAR);
while( *pcString )
{
vTaskDelay( mainCHAR_WRITE_DELAY );
prvPDCWrite( PDC_LCD_RAM, *pcString );
pcString++;
}
}
/*-----------------------------------------------------------*/
void vLCDTask( void * pvParameters )
{
unsigned portBASE_TYPE uxIndex;
const unsigned char ucCFGData[] = {
0x30, /* Set data bus to 8-bits. */
0x30,
0x30,
0x3C, /* Number of lines/font. */
0x08, /* Display off. */
0x01, /* Display clear. */
0x06, /* Entry mode [cursor dir][shift]. */
0x0C /* Display on [display on][curson on][blinking on]. */
};
/* The strings that are written to the LCD. */
const char *pcStringsToDisplay[] = {
"Stellaris",
"Demo",
"Two",
"www.FreeRTOS.org",
""
};
/* Configure the LCD. */
uxIndex = 0;
while( uxIndex < sizeof( ucCFGData ) )
{
prvPDCWrite( PDC_LCD_CSR, ucCFGData[ uxIndex ] );
uxIndex++;
vTaskDelay( mainCHAR_WRITE_DELAY );
}
/* Turn the LCD Backlight on. */
prvPDCWrite( PDC_CSR, 0x01 );
/* Clear display. */
vTaskDelay( mainCHAR_WRITE_DELAY );
prvPDCWrite( PDC_LCD_CSR, LCD_CLEAR );
uxIndex = 0;
for( ;; )
{
/* Display the string on the LCD. */
prvWriteString( pcStringsToDisplay[ uxIndex ] );
/* Move on to the next string - wrapping if necessary. */
uxIndex++;
if( *( pcStringsToDisplay[ uxIndex ] ) == 0x00 )
{
uxIndex = 0;
/* Longer pause on the last string to be sent. */
vTaskDelay( mainSTRING_WRITE_DELAY * 2 );
}
/* Wait until it is time to move onto the next string. */
vTaskDelay( mainSTRING_WRITE_DELAY );
}
}
/*-----------------------------------------------------------*/
static void vCommsRxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex )
{
static char cRxedChar, cExpectedChar = mainFIRST_TX_CHAR;
portBASE_TYPE xResult;
crSTART( xHandle );
for( ;; )
{
/* Wait for a character to be received. */
crQUEUE_RECEIVE( xHandle, xCommsQueue, ( void * ) &cRxedChar, mainCOMMS_RX_DELAY, &xResult );
/* Was the character received (if any) the expected character. */
if( ( cRxedChar != cExpectedChar ) || ( xResult != pdPASS ) )
{
/* Got an unexpected character. This can sometimes occur when
reseting the system using the debugger leaving characters already
in the UART registers. */
uxErrorStatus = pdFAIL;
/* Resync by waiting for the end of the current string. */
while( cRxedChar != mainLAST_TX_CHAR )
{
crQUEUE_RECEIVE( xHandle, xCommsQueue, ( void * ) &cRxedChar, mainCOMMS_RX_DELAY, &xResult );
}
/* The next expected character is the start of the string again. */
cExpectedChar = mainFIRST_TX_CHAR;
}
else
{
if( cExpectedChar == mainLAST_TX_CHAR )
{
/* We have reached the end of the string - we now expect to
receive the first character in the string again. The LED is
toggled to indicate that the entire string was received without
error. */
vParTestToggleLED( mainCOMMS_RX_LED );
cExpectedChar = mainFIRST_TX_CHAR;
}
else
{
/* We got the expected character, we now expect to receive the
next character in the string. */
cExpectedChar++;
}
}
}
crEND();
}
/*-----------------------------------------------------------*/
static void vSerialTxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex )
{
TickType_t xDelayPeriod;
static unsigned long *pulRandomBytes = mainFIRST_PROGRAM_BYTES;
/* Co-routine MUST start with a call to crSTART. */
crSTART( xHandle );
for(;;)
{
/* Was the previously transmitted string received correctly? */
if( uxErrorStatus != pdPASS )
{
/* An error was encountered so set the error LED. */
vSetErrorLED();
}
/* The next character to Tx is the first in the string. */
cNextChar = mainFIRST_TX_CHAR;
UARTIntDisable( UART0_BASE, UART_INT_TX );
{
/* Send the first character. */
if( !( HWREG( UART0_BASE + UART_O_FR ) & UART_FR_TXFF ) )
{
HWREG( UART0_BASE + UART_O_DR ) = cNextChar;
}
/* Move the variable to the char to Tx on so the ISR transmits
the next character in the string once this one has completed. */
cNextChar++;
}
UARTIntEnable(UART0_BASE, UART_INT_TX);
/* Toggle the LED to show a new string is being transmitted. */
vParTestToggleLED( mainCOMMS_TX_LED );
/* Delay before we start the string off again. A pseudo-random delay
is used as this will provide a better test. */
xDelayPeriod = xTaskGetTickCount() + ( *pulRandomBytes );
pulRandomBytes++;
if( pulRandomBytes > mainTOTAL_PROGRAM_MEMORY )
{
pulRandomBytes = mainFIRST_PROGRAM_BYTES;
}
/* Make sure we don't wait too long... */
xDelayPeriod &= mainMAX_TX_DELAY;
/* ...but we do want to wait. */
if( xDelayPeriod < mainMIN_TX_DELAY )
{
xDelayPeriod = mainMIN_TX_DELAY;
}
/* Block for the random(ish) time. */
crDELAY( xHandle, xDelayPeriod );
}
/* Co-routine MUST end with a call to crEND. */
crEND();
}
/*-----------------------------------------------------------*/
static void vSerialInit( void )
{
/* Enable the UART. GPIOA has already been initialised. */
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
/* Set GPIO A0 and A1 as peripheral function. They are used to output the
UART signals. */
GPIODirModeSet( GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1, GPIO_DIR_MODE_HW );
/* Configure the UART for 8-N-1 operation. */
UARTConfigSet( UART0_BASE, mainBAUD_RATE, UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE );
/* We dont want to use the fifo. This is for test purposes to generate
as many interrupts as possible. */
HWREG( UART0_BASE + UART_O_LCR_H ) &= ~mainFIFO_SET;
/* Enable both Rx and Tx interrupts. */
HWREG( UART0_BASE + UART_O_IM ) |= ( UART_INT_TX | UART_INT_RX );
IntEnable( INT_UART0 );
}
/*-----------------------------------------------------------*/
void vUART_ISR(void)
{
unsigned long ulStatus;
char cRxedChar;
portBASE_TYPE xTaskWokenByPost = pdFALSE;
/* What caused the interrupt. */
ulStatus = UARTIntStatus( UART0_BASE, pdTRUE );
/* Clear the interrupt. */
UARTIntClear( UART0_BASE, ulStatus );
/* Was an Rx interrupt pending? */
if( ulStatus & UART_INT_RX )
{
if( ( HWREG(UART0_BASE + UART_O_FR ) & UART_FR_RXFF ) )
{
/* Get the char from the buffer and post it onto the queue of
Rxed chars. Posting the character should wake the task that is
blocked on the queue waiting for characters. */
cRxedChar = ( char ) HWREG( UART0_BASE + UART_O_DR );
xTaskWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsQueue, &cRxedChar, xTaskWokenByPost );
}
}
/* Was a Tx interrupt pending? */
if( ulStatus & UART_INT_TX )
{
/* Send the next character in the string. We are not using the FIFO. */
if( cNextChar <= mainLAST_TX_CHAR )
{
if( !( HWREG( UART0_BASE + UART_O_FR ) & UART_FR_TXFF ) )
{
HWREG( UART0_BASE + UART_O_DR ) = cNextChar;
}
cNextChar++;
}
}
if( xTaskWokenByPost )
{
/* We are posting to a co-routine rather than a task so don't bother
causing a task switch. */
}
}
/*-----------------------------------------------------------*/
static void prvPDCWrite( char cAddress, char cData )
{
vTaskSuspendAll();
{
PDCWrite( cAddress, cData );
}
xTaskResumeAll();
}
/*-----------------------------------------------------------*/
void vSetErrorLED( void )
{
vParTestSetLED( mainCOMMS_FAIL_LED, pdTRUE );
}
/*-----------------------------------------------------------*/
void prvSetAndCheckRegisters( void )
{
/* Fill the general purpose registers with known values. */
__asm volatile( " mov r11, #10\n"
" add r0, r11, #1\n"
" add r1, r11, #2\n"
" add r2, r11, #3\n"
" add r3, r11, #4\n"
" add r4, r11, #5\n"
" add r5, r11, #6\n"
" add r6, r11, #7\n"
" add r7, r11, #8\n"
" add r12, r11, #12" );
/* Check the values are as expected. */
__asm volatile( " cmp r11, #10\n"
" bne set_error_led\n"
" cmp r0, #11\n"
" bne set_error_led\n"
" cmp r1, #12\n"
" bne set_error_led\n"
" cmp r2, #13\n"
" bne set_error_led\n"
" cmp r3, #14\n"
" bne set_error_led\n"
" cmp r4, #15\n"
" bne set_error_led\n"
" cmp r5, #16\n"
" bne set_error_led\n"
" cmp r6, #17\n"
" bne set_error_led\n"
" cmp r7, #18\n"
" bne set_error_led\n"
" cmp r12, #22\n"
" bne set_error_led\n"
" bx lr" );
__asm volatile( "set_error_led:\n"
" push {r14}\n"
" ldr r1, =vSetErrorLED\n"
" blx r1\n"
" pop {r14}\n"
" bx lr" );
}
/*-----------------------------------------------------------*/

View file

@ -0,0 +1,3 @@
Move these two fines into the Demo/CORTEX_LM3S102_GCC directory to run Demo 2.
See the port documentation on the www.FreeRTOS.org site for more information.

View file

@ -50,8 +50,10 @@
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 1
#define configMAX_PRIORITIES ( 2 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -29,8 +29,10 @@ RTOS_SOURCE_DIR=../../Source
DEMO_SOURCE_DIR=../Common/Minimal
CFLAGS+=-I hw_include -I . -I ${RTOS_SOURCE_DIR}/include -I ${RTOS_SOURCE_DIR}/portable/GCC/ARM_CM3 -I ../Common/include -D GCC_ARMCM3_LM3S102
VPATH=${RTOS_SOURCE_DIR}:${RTOS_SOURCE_DIR}/portable/MemMang:${RTOS_SOURCE_DIR}/portable/GCC/ARM_CM3:${DEMO_SOURCE_DIR}:init:ParTest:hw_include
OBJS= ${COMPILER}/main.o \
${COMPILER}/pdc.o \
${COMPILER}/list.o \
@ -38,12 +40,16 @@ OBJS= ${COMPILER}/main.o \
${COMPILER}/tasks.o \
${COMPILER}/port.o \
${COMPILER}/heap_1.o \
${COMPILER}/ParTest.o
${COMPILER}/ParTest.o \
${COMPILER}/crflash.o \
${COMPILER}/croutine.o
# ${COMPILER}/pendsv_handler.o
INIT_OBJS= ${COMPILER}/startup.o
LIBS= hw_include/libdriver.a
#
# The default rule, which causes init to be built.
#
@ -53,6 +59,7 @@ all: ${COMPILER} \
#
# The rule to clean out all the build products
#
clean:
@rm -rf ${COMPILER} ${wildcard *.bin} RTOSDemo.axf
@ -71,3 +78,9 @@ ENTRY_RTOSDemo=ResetISR
# Include the automatically generated dependency files.
#
-include ${wildcard ${COMPILER}/*.d} __dummy__

View file

@ -25,13 +25,25 @@
*/
/*
* This demo application creates two tasks (three including
* the idle task).
* This demo application creates six co-routines and two tasks (three including
* the idle task). The co-routines execute as part of the idle task hook.
*
* Five of the created co-routines are the standard 'co-routine flash'
* co-routines contained within the Demo/Common/Minimal/crflash.c file and
* documented on the FreeRTOS.org WEB site.
*
* The 'LCD Task' rotates a string on the LCD, delaying between each character
* as necessitated by the slow interface, and delaying between each string just
* long enough to enable the text to be read.
*
* The sixth co-routine and final task control the transmission and reception
* of a string to UART 0. The co-routine periodically sends the first
* character of the string to the UART, with the UART's TxEnd interrupt being
* used to transmit the remaining characters. The UART's RxEnd interrupt
* receives the characters and places them on a queue to be processed by the
* 'COMs Rx' task. An error is latched should an unexpected character be
* received, or any character be received out of sequence.
*
* A loopback connector is required to ensure that each character transmitted
* on the UART is also received on the same UART. For test purposes the UART
* FIFO's are not utalised in order to maximise the interrupt overhead. Also
@ -39,6 +51,11 @@
* order that the resultant interrupts are more randomly distributed and
* therefore more likely to highlight any problems.
*
* The flash co-routines control LED's zero to four. LED five is toggled each
* time the string is transmitted on the UART. LED six is toggled each time
* the string is CORRECTLY received on the UART. LED seven is latched on should
* an error be detected in any task or co-routine.
*
* In addition the idle task makes repetitive calls to
* prvSetAndCheckRegisters(). This simply loads the general purpose registers
* with a known value, then checks each register to ensure the held value is
@ -53,9 +70,11 @@
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "croutine.h"
/* Demo application include files. */
#include "partest.h"
#include "crflash.h"
/* Library include files. */
#include "DriverLib.h"
@ -66,10 +85,20 @@
/* The time to delay between writing each string to the LCD. */
#define mainSTRING_WRITE_DELAY ( 400 / portTICK_PERIOD_MS )
/* The number of flash co-routines to create. */
#define mainNUM_FLASH_CO_ROUTINES ( 5 )
/* The length of the queue used to pass received characters to the Comms Rx
task. */
#define mainRX_QUEUE_LEN ( 5 )
/* The priority of the co-routine used to initiate the transmission of the
string on UART 0. */
#define mainTX_CO_ROUTINE_PRIORITY ( 1 )
/* Only one co-routine is created so its index is not important. */
#define mainTX_CO_ROUTINE_INDEX ( 0 )
/* The time between transmissions of the string on UART 0. This is pseudo
random in order to generate a bit or randomness to when the interrupts occur.*/
#define mainMIN_TX_DELAY ( 40 / portTICK_PERIOD_MS )
@ -91,7 +120,7 @@ the timing of the transmission. */
#define mainCOMMS_RX_LED ( 6 )
#define mainCOMMS_TX_LED ( 5 )
/* The baud rate used by the UART comms tasks. */
/* The baud rate used by the UART comms tasks/co-routine. */
#define mainBAUD_RATE ( 57600 )
/* FIFO setting for the UART. The FIFO is not used to create a better test. */
@ -127,6 +156,12 @@ static void vLCDTask( void * pvParameters );
*/
static void vCommsRxTask( void * pvParameters );
/*
* The co-routine that periodically initiates the transmission of the string on
* the UART.
*/
static void vSerialTxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex );
/*
* Writes a string the the LCD.
*/
@ -161,7 +196,7 @@ static void prvSetupHardware( void );
/*-----------------------------------------------------------*/
/* Error flag set to pdFAIL if an error is encountered in the tasks.
/* Error flag set to pdFAIL if an error is encountered in the tasks/co-routines
defined within this file. */
unsigned portBASE_TYPE uxErrorStatus = pdPASS;
@ -183,11 +218,18 @@ void Main( void )
/* Setup the ports used by the demo and the clock. */
prvSetupHardware();
/* Create the co-routines that flash the LED's. */
vStartFlashCoRoutines( mainNUM_FLASH_CO_ROUTINES );
/* Create the co-routine that initiates the transmission of characters
on the UART. */
xCoRoutineCreate( vSerialTxCoRoutine, mainTX_CO_ROUTINE_PRIORITY, mainTX_CO_ROUTINE_INDEX );
/* Create the LCD and Comms Rx tasks. */
xTaskCreate( vLCDTask, "LCD", configMINIMAL_STACK_SIZE, NULL, mainLCD_TASK_PRIORITY, NULL );
xTaskCreate( vCommsRxTask, "CMS", configMINIMAL_STACK_SIZE, NULL, mainCOMMS_RX_TASK_PRIORITY, NULL );
/* Start the scheduler running the tasks just created. */
/* Start the scheduler running the tasks and co-routines just created. */
vTaskStartScheduler();
/* Should not get here unless we did not have enough memory to start the
@ -210,6 +252,16 @@ static void prvSetupHardware( void )
void vApplicationIdleHook( void )
{
/* The co-routines are executed in the idle task using the idle task
hook. */
for( ;; )
{
/* Schedule the co-routines. */
vCoRoutineSchedule();
/* Run the register check function between each co-routine. */
prvSetAndCheckRegisters();
}
}
/*-----------------------------------------------------------*/
@ -337,6 +389,71 @@ static char cRxedChar, cExpectedChar;
}
/*-----------------------------------------------------------*/
static void vSerialTxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex )
{
TickType_t xDelayPeriod;
static unsigned long *pulRandomBytes = mainFIRST_PROGRAM_BYTES;
/* Co-routine MUST start with a call to crSTART. */
crSTART( xHandle );
for(;;)
{
/* Was the previously transmitted string received correctly? */
if( uxErrorStatus != pdPASS )
{
/* An error was encountered so set the error LED. */
vSetErrorLED();
}
/* The next character to Tx is the first in the string. */
cNextChar = mainFIRST_TX_CHAR;
UARTIntDisable( UART0_BASE, UART_INT_TX );
{
/* Send the first character. */
if( !( HWREG( UART0_BASE + UART_O_FR ) & UART_FR_TXFF ) )
{
HWREG( UART0_BASE + UART_O_DR ) = cNextChar;
}
/* Move the variable to the char to Tx on so the ISR transmits
the next character in the string once this one has completed. */
cNextChar++;
}
UARTIntEnable(UART0_BASE, UART_INT_TX);
/* Toggle the LED to show a new string is being transmitted. */
vParTestToggleLED( mainCOMMS_TX_LED );
/* Delay before we start the string off again. A pseudo-random delay
is used as this will provide a better test. */
xDelayPeriod = xTaskGetTickCount() + ( *pulRandomBytes );
pulRandomBytes++;
if( pulRandomBytes > mainTOTAL_PROGRAM_MEMORY )
{
pulRandomBytes = mainFIRST_PROGRAM_BYTES;
}
/* Make sure we don't wait too long... */
xDelayPeriod &= mainMAX_TX_DELAY;
/* ...but we do want to wait. */
if( xDelayPeriod < mainMIN_TX_DELAY )
{
xDelayPeriod = mainMIN_TX_DELAY;
}
/* Block for the random(ish) time. */
crDELAY( xHandle, xDelayPeriod );
}
/* Co-routine MUST end with a call to crEND. */
crEND();
}
/*-----------------------------------------------------------*/
static void vSerialInit( void )
{
/* Enable the UART. GPIOA has already been initialised. */

View file

@ -65,9 +65,10 @@ AFLAGS=-mthumb \
#
CFLAGS=-mthumb \
-mcpu=cortex-m3 \
-fdata-sections -ffunction-sections \
-MD \
-g
-O2 \
-fdata-sections \
-ffunction-sections \
-MD
#
# The command for calling the library archiver.

View file

@ -35,7 +35,7 @@ SECTIONS
.text :
{
*(vectors)
*(.text)
*(.text*)
*(.rodata*)
*(.constdata*)
_etext = .;

View file

@ -50,8 +50,10 @@
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 1
#define configMAX_PRIORITIES ( 2 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -25,13 +25,24 @@
*/
/*
* This demo application creates two tasks (three including
* the idle task).
* This demo application creates six co-routines and two tasks (three including
* the idle task). The co-routines execute as part of the idle task hook.
*
* Five of the created co-routines are the standard 'co-routine flash'
* co-routines contained within the Demo/Common/Minimal/crflash.c file and
* documented on the FreeRTOS.org WEB site.
*
* The 'LCD Task' rotates a string on the LCD, delaying between each character
* as necessitated by the slow interface, and delaying between each string just
* long enough to enable the text to be read.
*
* The sixth co-routine and final task control the transmission and reception
* of a string to UART 0. The co-routine periodically sends the first
* character of the string to the UART, with the UART's TxEnd interrupt being
* used to transmit the remaining characters. The UART's RxEnd interrupt
* receives the characters and places them on a queue to be processed by the
* 'COMs Rx' task. An error is latched should an unexpected character be
* received, or any character be received out of sequence.
*
* A loopback connector is required to ensure that each character transmitted
* on the UART is also received on the same UART. For test purposes the UART
@ -40,6 +51,11 @@
* order that the resultant interrupts are more randomly distributed and
* therefore more likely to highlight any problems.
*
* The flash co-routines control LED's zero to four. LED five is toggled each
* time the string is transmitted on the UART. LED six is toggled each time
* the string is CORRECTLY received on the UART. LED seven is latched on should
* an error be detected in any task or co-routine.
*
* In addition the idle task makes repetitive calls to
* prvSetAndCheckRegisters(). This simply loads the general purpose registers
* with a known value, then checks each register to ensure the held value is
@ -54,9 +70,11 @@
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "croutine.h"
/* Demo application include files. */
#include "partest.h"
#include "crflash.h"
/* Library include files. */
#include "DriverLib.h"
@ -67,10 +85,20 @@
/* The time to delay between writing each string to the LCD. */
#define mainSTRING_WRITE_DELAY ( 400 / portTICK_PERIOD_MS )
/* The number of flash co-routines to create. */
#define mainNUM_FLASH_CO_ROUTINES ( 5 )
/* The length of the queue used to pass received characters to the Comms Rx
task. */
#define mainRX_QUEUE_LEN ( 5 )
/* The priority of the co-routine used to initiate the transmission of the
string on UART 0. */
#define mainTX_CO_ROUTINE_PRIORITY ( 1 )
/* Only one co-routine is created so its index is not important. */
#define mainTX_CO_ROUTINE_INDEX ( 0 )
/* The time between transmissions of the string on UART 0. This is pseudo
random in order to generate a bit or randomness to when the interrupts occur.*/
#define mainMIN_TX_DELAY ( 40 / portTICK_PERIOD_MS )
@ -92,7 +120,7 @@ the timing of the transmission. */
#define mainCOMMS_RX_LED ( 6 )
#define mainCOMMS_TX_LED ( 5 )
/* The baud rate used by the UART comms tasks. */
/* The baud rate used by the UART comms tasks/co-routine. */
#define mainBAUD_RATE ( 57600 )
/* FIFO setting for the UART. The FIFO is not used to create a better test. */
@ -128,6 +156,12 @@ static void vLCDTask( void * pvParameters );
*/
static void vCommsRxTask( void * pvParameters );
/*
* The co-routine that periodically initiates the transmission of the string on
* the UART.
*/
static void vSerialTxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex );
/*
* Writes a string the the LCD.
*/
@ -162,7 +196,7 @@ static void prvSetupHardware( void );
/*-----------------------------------------------------------*/
/* Error flag set to pdFAIL if an error is encountered in the tasks
/* Error flag set to pdFAIL if an error is encountered in the tasks/co-routines
defined within this file. */
unsigned portBASE_TYPE uxErrorStatus = pdPASS;
@ -184,11 +218,18 @@ int main( void )
/* Setup the ports used by the demo and the clock. */
prvSetupHardware();
/* Create the co-routines that flash the LED's. */
vStartFlashCoRoutines( mainNUM_FLASH_CO_ROUTINES );
/* Create the co-routine that initiates the transmission of characters
on the UART. */
xCoRoutineCreate( vSerialTxCoRoutine, mainTX_CO_ROUTINE_PRIORITY, mainTX_CO_ROUTINE_INDEX );
/* Create the LCD and Comms Rx tasks. */
xTaskCreate( vLCDTask, "LCD", configMINIMAL_STACK_SIZE, NULL, mainLCD_TASK_PRIORITY, NULL );
xTaskCreate( vCommsRxTask, "CMS", configMINIMAL_STACK_SIZE, NULL, mainCOMMS_RX_TASK_PRIORITY, NULL );
/* Start the scheduler running the tasks just created. */
/* Start the scheduler running the tasks and co-routines just created. */
vTaskStartScheduler();
/* Should not get here unless we did not have enough memory to start the
@ -212,9 +253,14 @@ static void prvSetupHardware( void )
void vApplicationIdleHook( void )
{
/* The co-routines are executed in the idle task using the idle task
hook. */
for( ;; )
{
/* Run the register check function */
/* Schedule the co-routines. */
vCoRoutineSchedule();
/* Run the register check function between each co-routine. */
prvSetAndCheckRegisters();
}
}
@ -344,6 +390,71 @@ static char cRxedChar, cExpectedChar;
}
/*-----------------------------------------------------------*/
static void vSerialTxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex )
{
TickType_t xDelayPeriod;
static unsigned long *pulRandomBytes = mainFIRST_PROGRAM_BYTES;
/* Co-routine MUST start with a call to crSTART. */
crSTART( xHandle );
for(;;)
{
/* Was the previously transmitted string received correctly? */
if( uxErrorStatus != pdPASS )
{
/* An error was encountered so set the error LED. */
vSetErrorLED();
}
/* The next character to Tx is the first in the string. */
cNextChar = mainFIRST_TX_CHAR;
UARTIntDisable( UART0_BASE, UART_INT_TX );
{
/* Send the first character. */
if( !( HWREG( UART0_BASE + UART_O_FR ) & UART_FR_TXFF ) )
{
HWREG( UART0_BASE + UART_O_DR ) = cNextChar;
}
/* Move the variable to the char to Tx on so the ISR transmits
the next character in the string once this one has completed. */
cNextChar++;
}
UARTIntEnable(UART0_BASE, UART_INT_TX);
/* Toggle the LED to show a new string is being transmitted. */
vParTestToggleLED( mainCOMMS_TX_LED );
/* Delay before we start the string off again. A pseudo-random delay
is used as this will provide a better test. */
xDelayPeriod = xTaskGetTickCount() + ( *pulRandomBytes );
pulRandomBytes++;
if( pulRandomBytes > mainTOTAL_PROGRAM_MEMORY )
{
pulRandomBytes = mainFIRST_PROGRAM_BYTES;
}
/* Make sure we don't wait too long... */
xDelayPeriod &= mainMAX_TX_DELAY;
/* ...but we do want to wait. */
if( xDelayPeriod < mainMIN_TX_DELAY )
{
xDelayPeriod = mainMIN_TX_DELAY;
}
/* Block for the random(ish) time. */
crDELAY( xHandle, xDelayPeriod );
}
/* Co-routine MUST end with a call to crEND. */
crEND();
}
/*-----------------------------------------------------------*/
static void vSerialInit( void )
{
/* Enable the UART. GPIOA has already been initialised. */

View file

@ -0,0 +1,76 @@
/*
* FreeRTOS V202212.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
*/
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
* Application specific definitions.
*
* These definitions should be adjusted for your particular hardware and
* application requirements.
*
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
*
* See http://www.freertos.org/a00110.html
*----------------------------------------------------------*/
#define configUSE_PREEMPTION 1
#define configUSE_IDLE_HOOK 1
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( ( unsigned long ) 20000000 )
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 59 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 1240 ) )
#define configMAX_TASK_NAME_LEN ( 3 )
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 1
#define configMAX_PRIORITIES ( 2 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 3 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet 0
#define INCLUDE_uxTaskPriorityGet 0
#define INCLUDE_vTaskDelete 0
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 0
#define INCLUDE_vTaskDelayUntil 0
#define INCLUDE_vTaskDelay 1
#define configKERNEL_INTERRUPT_PRIORITY 255
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xa0, or priority 5. */
#endif /* FREERTOS_CONFIG_H */

View file

@ -0,0 +1,106 @@
/*
* FreeRTOS V202212.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
*/
/*-----------------------------------------------------------
* Simple parallel port IO routines.
*-----------------------------------------------------------*/
/*
*/
#include "FreeRTOS.h"
#include "task.h"
#include "partest.h"
#include "pdc.h"
#define partstPINS (GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 Z | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7)
#define partstALL_OUTPUTS_OFF ( ( unsigned char ) 0x00 )
#define partstMAX_OUTPUT_LED ( ( unsigned char ) 8 )
static volatile unsigned char ucOutputValue = partstALL_OUTPUTS_OFF;
void vParTestInitialise( void )
{
PDCInit();
PDCWrite( PDC_LED, ucOutputValue );
}
/*-----------------------------------------------------------*/
void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
{
unsigned char ucBit = ( unsigned char ) 1;
vTaskSuspendAll();
{
if( uxLED < partstMAX_OUTPUT_LED )
{
ucBit = ( ( unsigned char ) 1 ) << uxLED;
if( xValue == pdFALSE )
{
ucBit ^= ( unsigned char ) 0xff;
ucOutputValue &= ucBit;
}
else
{
ucOutputValue |= ucBit;
}
PDCWrite( PDC_LED, ucOutputValue );
}
}
xTaskResumeAll();
}
/*-----------------------------------------------------------*/
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
{
unsigned char ucBit;
vTaskSuspendAll();
{
if( uxLED < partstMAX_OUTPUT_LED )
{
ucBit = ( ( unsigned char ) 1 ) << uxLED;
if( ucOutputValue & ucBit )
{
ucOutputValue &= ~ucBit;
}
else
{
ucOutputValue |= ucBit;
}
PDCWrite( PDC_LED, ucOutputValue );
}
}
xTaskResumeAll();
}

View file

@ -0,0 +1,616 @@
/*
* FreeRTOS V202212.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
*/
/*
* This demo application creates seven co-routines and one task (two including
* the idle task). The co-routines execute as part of the idle task hook.
*
* Five of the created co-routines are the standard 'co-routine flash'
* co-routines contained within the Demo/Common/Minimal/crflash.c file and
* documented on the FreeRTOS.org WEB site.
*
* The 'LCD Task' rotates a string on the LCD, delaying between each character
* as necessitated by the slow interface, and delaying between each string just
* long enough to enable the text to be read.
*
* The sixth co-routine controls the transmission of a string to UART 0. The
* co-routine periodically sends the first character of the string to the UART,
* with the UART's TxEnd interrupt being used to transmit the remaining
* characters. The UART's RxEnd interrupt receives the characters and places
* them on a queue to be processed by the seventh and final co-routine. An
* error is latched should an unexpected character be received, or any
* character be received out of sequence.
*
* A loopback connector is required to ensure that each character transmitted
* on the UART is also received on the same UART. For test purposes the UART
* FIFO's are not utalised in order to maximise the interrupt overhead. Also
* a pseudo random interval is used between the start of each transmission in
* order that the resultant interrupts are more randomly distributed and
* therefore more likely to highlight any problems.
*
* The flash co-routines control LED's zero to four. LED five is toggled each
* time the string is transmitted on the UART. LED six is toggled each time
* the string is CORRECTLY received on the UART. LED seven is latched on should
* an error be detected in any task or co-routine.
*
* In addition the idle task makes repetitive calls to
* prvSetAndCheckRegisters(). This simply loads the general purpose registers
* with a known value, then checks each register to ensure the held value is
* still correct. As a low priority task this checking routine is likely to
* get repeatedly swapped in and out. A register being found to contain an
* incorrect value is therefore indicative of an error in the task switching
* mechansim.
*
*/
/* Scheduler include files. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "croutine.h"
/* Demo application include files. */
#include "partest.h"
#include "crflash.h"
/* Library include files. */
#include "DriverLib.h"
/* The time to delay between writing each character to the LCD. */
#define mainCHAR_WRITE_DELAY ( 2 / portTICK_PERIOD_MS )
/* The time to delay between writing each string to the LCD. */
#define mainSTRING_WRITE_DELAY ( 400 / portTICK_PERIOD_MS )
/* The number of flash co-routines to create. */
#define mainNUM_FLASH_CO_ROUTINES ( 5 )
/* The length of the queue used to pass received characters to the Comms Rx
task. */
#define mainRX_QUEUE_LEN ( 5 )
/* The priority of the co-routine used to initiate the transmission of the
string on UART 0. */
#define mainTX_CO_ROUTINE_PRIORITY ( 1 )
/* The priority of the co-routine used to receive characters from the UART. */
#define mainRX_CO_ROUTINE_PRIORITY ( 2 )
/* Only one co-routine is created so its index is not important. */
#define mainTX_CO_ROUTINE_INDEX ( 0 )
#define mainRX_CO_ROUTINE_INDEX ( 0 )
/* The time between transmissions of the string on UART 0. This is pseudo
random in order to generate a bit or randomness to when the interrupts occur.*/
#define mainMIN_TX_DELAY ( 40 / portTICK_PERIOD_MS )
#define mainMAX_TX_DELAY ( ( TickType_t ) 0x7f )
#define mainOFFSET_TIME ( ( TickType_t ) 3 )
/* The time the Comms Rx task should wait to receive a character. This should
be slightly longer than the time between transmissions. If we do not receive
a character after this time then there must be an error in the transmission or
the timing of the transmission. */
#define mainCOMMS_RX_DELAY ( mainMAX_TX_DELAY + 20 )
/* The task priorities. */
#define mainLCD_TASK_PRIORITY ( tskIDLE_PRIORITY )
#define mainCOMMS_RX_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
/* The LED's toggled by the various tasks. */
#define mainCOMMS_FAIL_LED ( 7 )
#define mainCOMMS_RX_LED ( 6 )
#define mainCOMMS_TX_LED ( 5 )
/* The baud rate used by the UART comms tasks/co-routine. */
#define mainBAUD_RATE ( 57600 )
/* FIFO setting for the UART. The FIFO is not used to create a better test. */
#define mainFIFO_SET ( 0x10 )
/* The string that is transmitted on the UART contains sequentially the
characters from mainFIRST_TX_CHAR to mainLAST_TX_CHAR. */
#define mainFIRST_TX_CHAR '0'
#define mainLAST_TX_CHAR 'z'
/* Just used to walk through the program memory in order that some random data
can be generated. */
#define mainTOTAL_PROGRAM_MEMORY ( ( unsigned long * ) ( 8 * 1024 ) )
#define mainFIRST_PROGRAM_BYTES ( ( unsigned long * ) 4 )
/* The error routine that is called if the driver library encounters an error. */
#ifdef DEBUG
void
__error__(char *pcFilename, unsigned long ulLine)
{
}
#endif
/*-----------------------------------------------------------*/
/*
* The task that rotates text on the LCD.
*/
static void vLCDTask( void * pvParameters );
/*
* The task that receives the characters from UART 0.
*/
static void vCommsRxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex );
/*
* The co-routine that periodically initiates the transmission of the string on
* the UART.
*/
static void vSerialTxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex );
/*
* Writes a string the the LCD.
*/
static void prvWriteString( const char *pcString );
/*
* Initialisation routine for the UART.
*/
static void vSerialInit( void );
/*
* Thread safe write to the PDC.
*/
static void prvPDCWrite( char cAddress, char cData );
/*
* Function to simply set a known value into the general purpose registers
* then read them back to ensure they remain set correctly. An incorrect value
* being indicative of an error in the task switching mechanism.
*/
void prvSetAndCheckRegisters( void );
/*
* Latch the LED that indicates that an error has occurred.
*/
void vSetErrorLED( void );
/*
* Sets up the PLL and ports used by the demo.
*/
static void prvSetupHardware( void );
/*-----------------------------------------------------------*/
/* Error flag set to pdFAIL if an error is encountered in the tasks/co-routines
defined within this file. */
unsigned portBASE_TYPE uxErrorStatus = pdPASS;
/* The next character to transmit. */
static char cNextChar;
/* The queue used to transmit characters from the interrupt to the Comms Rx
task. */
static QueueHandle_t xCommsQueue;
/*-----------------------------------------------------------*/
int main( void )
{
/* Create the queue used to communicate between the UART ISR and the Comms
Rx task. */
xCommsQueue = xQueueCreate( mainRX_QUEUE_LEN, sizeof( char ) );
/* Setup the ports used by the demo and the clock. */
prvSetupHardware();
/* Create the co-routines that flash the LED's. */
vStartFlashCoRoutines( mainNUM_FLASH_CO_ROUTINES );
/* Create the co-routine that initiates the transmission of characters
on the UART. */
xCoRoutineCreate( vSerialTxCoRoutine, mainTX_CO_ROUTINE_PRIORITY, mainTX_CO_ROUTINE_INDEX );
/* Create the co-routine that receives characters from the UART. */
xCoRoutineCreate( vCommsRxCoRoutine, mainRX_CO_ROUTINE_PRIORITY, mainRX_CO_ROUTINE_INDEX );
/* Create the LCD task. */
xTaskCreate( vLCDTask, "LCD", configMINIMAL_STACK_SIZE, NULL, mainLCD_TASK_PRIORITY, NULL );
/* Start the scheduler running the tasks and co-routines just created. */
vTaskStartScheduler();
/* Should not get here unless we did not have enough memory to start the
scheduler. */
for( ;; );
return 0;
}
/*-----------------------------------------------------------*/
static void prvSetupHardware( void )
{
/* Setup the PLL. */
SysCtlClockSet( SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ );
/* Initialise the hardware used to talk to the LCD, LED's and UART. */
PDCInit();
vParTestInitialise();
vSerialInit();
}
/*-----------------------------------------------------------*/
void vApplicationIdleHook( void )
{
/* The co-routines are executed in the idle task using the idle task
hook. */
for( ;; )
{
/* Schedule the co-routines. */
vCoRoutineSchedule();
/* Run the register check function between each co-routine. */
prvSetAndCheckRegisters();
}
}
/*-----------------------------------------------------------*/
static void prvWriteString( const char *pcString )
{
/* Write pcString to the LED, pausing between each character. */
prvPDCWrite(PDC_LCD_CSR, LCD_CLEAR);
while( *pcString )
{
vTaskDelay( mainCHAR_WRITE_DELAY );
prvPDCWrite( PDC_LCD_RAM, *pcString );
pcString++;
}
}
/*-----------------------------------------------------------*/
void vLCDTask( void * pvParameters )
{
unsigned portBASE_TYPE uxIndex;
const unsigned char ucCFGData[] = {
0x30, /* Set data bus to 8-bits. */
0x30,
0x30,
0x3C, /* Number of lines/font. */
0x08, /* Display off. */
0x01, /* Display clear. */
0x06, /* Entry mode [cursor dir][shift]. */
0x0C /* Display on [display on][curson on][blinking on]. */
};
/* The strings that are written to the LCD. */
const char *pcStringsToDisplay[] = {
"Stellaris",
"Demo",
"Two",
"www.FreeRTOS.org",
""
};
/* Configure the LCD. */
uxIndex = 0;
while( uxIndex < sizeof( ucCFGData ) )
{
prvPDCWrite( PDC_LCD_CSR, ucCFGData[ uxIndex ] );
uxIndex++;
vTaskDelay( mainCHAR_WRITE_DELAY );
}
/* Turn the LCD Backlight on. */
prvPDCWrite( PDC_CSR, 0x01 );
/* Clear display. */
vTaskDelay( mainCHAR_WRITE_DELAY );
prvPDCWrite( PDC_LCD_CSR, LCD_CLEAR );
uxIndex = 0;
for( ;; )
{
/* Display the string on the LCD. */
prvWriteString( pcStringsToDisplay[ uxIndex ] );
/* Move on to the next string - wrapping if necessary. */
uxIndex++;
if( *( pcStringsToDisplay[ uxIndex ] ) == 0x00 )
{
uxIndex = 0;
/* Longer pause on the last string to be sent. */
vTaskDelay( mainSTRING_WRITE_DELAY * 2 );
}
/* Wait until it is time to move onto the next string. */
vTaskDelay( mainSTRING_WRITE_DELAY );
}
}
/*-----------------------------------------------------------*/
static void vCommsRxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex )
{
static char cRxedChar, cExpectedChar = mainFIRST_TX_CHAR;
portBASE_TYPE xResult;
crSTART( xHandle );
for( ;; )
{
/* Wait for a character to be received. */
crQUEUE_RECEIVE( xHandle, xCommsQueue, ( void * ) &cRxedChar, mainCOMMS_RX_DELAY, &xResult );
/* Was the character received (if any) the expected character. */
if( ( cRxedChar != cExpectedChar ) || ( xResult != pdPASS ) )
{
/* Got an unexpected character. This can sometimes occur when
reseting the system using the debugger leaving characters already
in the UART registers. */
uxErrorStatus = pdFAIL;
/* Resync by waiting for the end of the current string. */
while( cRxedChar != mainLAST_TX_CHAR )
{
crQUEUE_RECEIVE( xHandle, xCommsQueue, ( void * ) &cRxedChar, mainCOMMS_RX_DELAY, &xResult );
}
/* The next expected character is the start of the string again. */
cExpectedChar = mainFIRST_TX_CHAR;
}
else
{
if( cExpectedChar == mainLAST_TX_CHAR )
{
/* We have reached the end of the string - we now expect to
receive the first character in the string again. The LED is
toggled to indicate that the entire string was received without
error. */
vParTestToggleLED( mainCOMMS_RX_LED );
cExpectedChar = mainFIRST_TX_CHAR;
}
else
{
/* We got the expected character, we now expect to receive the
next character in the string. */
cExpectedChar++;
}
}
}
crEND();
}
/*-----------------------------------------------------------*/
static void vSerialTxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex )
{
TickType_t xDelayPeriod;
static unsigned long *pulRandomBytes = mainFIRST_PROGRAM_BYTES;
/* Co-routine MUST start with a call to crSTART. */
crSTART( xHandle );
for(;;)
{
/* Was the previously transmitted string received correctly? */
if( uxErrorStatus != pdPASS )
{
/* An error was encountered so set the error LED. */
vSetErrorLED();
}
/* The next character to Tx is the first in the string. */
cNextChar = mainFIRST_TX_CHAR;
UARTIntDisable( UART0_BASE, UART_INT_TX );
{
/* Send the first character. */
if( !( HWREG( UART0_BASE + UART_O_FR ) & UART_FR_TXFF ) )
{
HWREG( UART0_BASE + UART_O_DR ) = cNextChar;
}
/* Move the variable to the char to Tx on so the ISR transmits
the next character in the string once this one has completed. */
cNextChar++;
}
UARTIntEnable(UART0_BASE, UART_INT_TX);
/* Toggle the LED to show a new string is being transmitted. */
vParTestToggleLED( mainCOMMS_TX_LED );
/* Delay before we start the string off again. A pseudo-random delay
is used as this will provide a better test. */
xDelayPeriod = xTaskGetTickCount() + ( *pulRandomBytes );
pulRandomBytes++;
if( pulRandomBytes > mainTOTAL_PROGRAM_MEMORY )
{
pulRandomBytes = mainFIRST_PROGRAM_BYTES;
}
/* Make sure we don't wait too long... */
xDelayPeriod &= mainMAX_TX_DELAY;
/* ...but we do want to wait. */
if( xDelayPeriod < mainMIN_TX_DELAY )
{
xDelayPeriod = mainMIN_TX_DELAY;
}
/* Block for the random(ish) time. */
crDELAY( xHandle, xDelayPeriod );
}
/* Co-routine MUST end with a call to crEND. */
crEND();
}
/*-----------------------------------------------------------*/
static void vSerialInit( void )
{
/* Enable the UART. GPIOA has already been initialised. */
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
/* Set GPIO A0 and A1 as peripheral function. They are used to output the
UART signals. */
GPIODirModeSet( GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1, GPIO_DIR_MODE_HW );
/* Configure the UART for 8-N-1 operation. */
UARTConfigSet( UART0_BASE, mainBAUD_RATE, UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE );
/* We dont want to use the fifo. This is for test purposes to generate
as many interrupts as possible. */
HWREG( UART0_BASE + UART_O_LCR_H ) &= ~mainFIFO_SET;
/* Enable both Rx and Tx interrupts. */
HWREG( UART0_BASE + UART_O_IM ) |= ( UART_INT_TX | UART_INT_RX );
IntEnable( INT_UART0 );
}
/*-----------------------------------------------------------*/
void vUART_ISR(void)
{
unsigned long ulStatus;
char cRxedChar;
portBASE_TYPE xTaskWokenByPost = pdFALSE;
/* What caused the interrupt. */
ulStatus = UARTIntStatus( UART0_BASE, pdTRUE );
/* Clear the interrupt. */
UARTIntClear( UART0_BASE, ulStatus );
/* Was an Rx interrupt pending? */
if( ulStatus & UART_INT_RX )
{
if( ( HWREG(UART0_BASE + UART_O_FR ) & UART_FR_RXFF ) )
{
/* Get the char from the buffer and post it onto the queue of
Rxed chars. Posting the character should wake the task that is
blocked on the queue waiting for characters. */
cRxedChar = ( char ) HWREG( UART0_BASE + UART_O_DR );
xTaskWokenByPost = crQUEUE_SEND_FROM_ISR( xCommsQueue, &cRxedChar, xTaskWokenByPost );
}
}
/* Was a Tx interrupt pending? */
if( ulStatus & UART_INT_TX )
{
/* Send the next character in the string. We are not using the FIFO. */
if( cNextChar <= mainLAST_TX_CHAR )
{
if( !( HWREG( UART0_BASE + UART_O_FR ) & UART_FR_TXFF ) )
{
HWREG( UART0_BASE + UART_O_DR ) = cNextChar;
}
cNextChar++;
}
}
if( xTaskWokenByPost )
{
/* We are posting to a co-routine rather than a task so don't bother
causing a task switch. */
}
}
/*-----------------------------------------------------------*/
static void prvPDCWrite( char cAddress, char cData )
{
vTaskSuspendAll();
{
PDCWrite( cAddress, cData );
}
xTaskResumeAll();
}
/*-----------------------------------------------------------*/
void vSetErrorLED( void )
{
vParTestSetLED( mainCOMMS_FAIL_LED, pdTRUE );
}
/*-----------------------------------------------------------*/
void prvSetAndCheckRegisters( void )
{
/* Fill the general purpose registers with known values. */
__asm volatile
(
" mov r11, #10 \n"
" add r0, r11, #1 \n"
" add r1, r11, #2 \n"
" add r2, r11, #3 \n"
" add r3, r11, #4 \n"
" add r4, r11, #5 \n"
" add r5, r11, #6 \n"
" add r6, r11, #7 \n"
" add r7, r11, #8 \n"
" add r8, r11, #9 \n"
" add r9, r11, #10 \n"
" add r10, r11, #11 \n"
" add r12, r11, #12"
);
/* Check the values are as expected. */
__asm volatile
(
" cmp r11, #10 \n"
" bne set_error_led \n"
" cmp r0, #11 \n"
" bne set_error_led \n"
" cmp r1, #12 \n"
" bne set_error_led \n"
" cmp r2, #13 \n"
" bne set_error_led \n"
" cmp r3, #14 \n"
" bne set_error_led \n"
" cmp r4, #15 \n"
" bne set_error_led \n"
" cmp r5, #16 \n"
" bne set_error_led \n"
" cmp r6, #17 \n"
" bne set_error_led \n"
" cmp r7, #18 \n"
" bne set_error_led \n"
" cmp r8, #19 \n"
" bne set_error_led \n"
" cmp r9, #20 \n"
" bne set_error_led \n"
" cmp r10, #21 \n"
" bne set_error_led \n"
" cmp r12, #22 \n"
" bne set_error_led \n"
" bx lr"
);
__asm volatile
(
"set_error_led: \n"
" push {r14} \n"
" ldr r1, vSetErrorLEDConst\n"
" blx r1 \n"
" pop {r14} \n"
" bx lr \n"
" \n"
" .align 2 \n"
"vSetErrorLEDConst: .word vSetErrorLED"
);
}
/*-----------------------------------------------------------*/

View file

@ -0,0 +1,120 @@
/*****************************************************************************
* Copyright (c) 2006 Rowley Associates Limited. *
* *
* This file may be distributed under the terms of the License Agreement *
* provided with this software. *
* *
* THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE *
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *
*****************************************************************************/
.section .vectors, "ax"
.code 16
.align 0
.global _vectors
.extern xPortPendSVHandler
.extern xPortSysTickHandler
.extern vUART_ISR
.extern vPortSVCHandler
.macro DEFAULT_ISR_HANDLER name=
.thumb_func
.weak \name
\name:
1: b 1b /* endless loop */
.endm
_vectors:
.word __stack_end__
#ifdef STARTUP_FROM_RESET
.word _start
#else
.word reset_wait
#endif /* STARTUP_FROM_RESET */
.word NmiISR
.word FaultISR
.word 0 // Populate if using MemManage (MPU)
.word 0 // Populate if using Bus fault
.word 0 // Populate if using Usage fault
.word 0 // Reserved
.word 0 // Reserved
.word 0 // Reserved
.word 0 // Reserved
.word vPortSVCHandler
.word 0 // Populate if using a debug monitor
.word 0 // Reserved
.word xPortPendSVHandler // Populate if using pendable service request
.word xPortSysTickHandler
// External interrupts start her
.word GPIO_Port_A_ISR
.word GPIO_Port_B_ISR
.word GPIO_Port_C_ISR
.word GPIO_Port_D_ISR
.word GPIO_Port_E_ISR
.word vUART_ISR
.word UART1_ISR
.word SSI_ISR
.word I2C_ISR
.word PWM_Fault_ISR
.word PWM_Generator_0_ISR
.word PWM_Generator_1_ISR
.word PWM_Generator_2_ISR
.word QEI_ISR
.word ADC_Sequence_0_ISR
.word ADC_Sequence_1_ISR
.word ADC_Sequence_2_ISR
.word ADC_Sequence_3_ISR
.word Watchdog_timer_ISR
.word Timer0a_ISR
.word Timer0b_ISR
.word Timer1a_ISR
.word Timer1b_ISR
.word Timer2a_ISR
.word Timer2b_ISR
.word Analog_Comparator_0_ISR
.word Analog_Comparator_1_ISR
.word Analog_Comparator_2_ISR
.word System_Control_ISR
.word FLASH_Control_ISR
.section .init, "ax"
.thumb_func
DEFAULT_ISR_HANDLER NmiISR
DEFAULT_ISR_HANDLER FaultISR
DEFAULT_ISR_HANDLER SVCallISR
DEFAULT_ISR_HANDLER SysTickISR
DEFAULT_ISR_HANDLER GPIO_Port_A_ISR
DEFAULT_ISR_HANDLER GPIO_Port_B_ISR
DEFAULT_ISR_HANDLER GPIO_Port_C_ISR
DEFAULT_ISR_HANDLER GPIO_Port_D_ISR
DEFAULT_ISR_HANDLER GPIO_Port_E_ISR
DEFAULT_ISR_HANDLER UART0_ISR
DEFAULT_ISR_HANDLER UART1_ISR
DEFAULT_ISR_HANDLER SSI_ISR
DEFAULT_ISR_HANDLER I2C_ISR
DEFAULT_ISR_HANDLER PWM_Fault_ISR
DEFAULT_ISR_HANDLER PWM_Generator_0_ISR
DEFAULT_ISR_HANDLER PWM_Generator_1_ISR
DEFAULT_ISR_HANDLER PWM_Generator_2_ISR
DEFAULT_ISR_HANDLER QEI_ISR
DEFAULT_ISR_HANDLER ADC_Sequence_0_ISR
DEFAULT_ISR_HANDLER ADC_Sequence_1_ISR
DEFAULT_ISR_HANDLER ADC_Sequence_2_ISR
DEFAULT_ISR_HANDLER ADC_Sequence_3_ISR
DEFAULT_ISR_HANDLER Watchdog_timer_ISR
DEFAULT_ISR_HANDLER Timer0a_ISR
DEFAULT_ISR_HANDLER Timer0b_ISR
DEFAULT_ISR_HANDLER Timer1a_ISR
DEFAULT_ISR_HANDLER Timer1b_ISR
DEFAULT_ISR_HANDLER Timer2a_ISR
DEFAULT_ISR_HANDLER Timer2b_ISR
DEFAULT_ISR_HANDLER Analog_Comparator_0_ISR
DEFAULT_ISR_HANDLER Analog_Comparator_1_ISR
DEFAULT_ISR_HANDLER Analog_Comparator_2_ISR
DEFAULT_ISR_HANDLER System_Control_ISR
DEFAULT_ISR_HANDLER FLASH_Control_ISR
#ifndef STARTUP_FROM_RESET
DEFAULT_ISR_HANDLER reset_wait
#endif /* STARTUP_FROM_RESET */

View file

@ -0,0 +1,76 @@
/*
* FreeRTOS V202212.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
*/
#ifndef FREERTOS_CONFIG_H
#define FREERTOS_CONFIG_H
/*-----------------------------------------------------------
* Application specific definitions.
*
* These definitions should be adjusted for your particular hardware and
* application requirements.
*
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
*
* See http://www.freertos.org/a00110.html
*----------------------------------------------------------*/
#define configUSE_PREEMPTION 0
#define configUSE_IDLE_HOOK 1
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( ( unsigned long ) 20000000 )
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 59 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 1240 ) )
#define configMAX_TASK_NAME_LEN ( 3 )
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 1
#define configMAX_PRIORITIES ( 2 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
#define INCLUDE_vTaskPrioritySet 0
#define INCLUDE_uxTaskPriorityGet 0
#define INCLUDE_vTaskDelete 0
#define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 0
#define INCLUDE_vTaskDelayUntil 0
#define INCLUDE_vTaskDelay 0
#define configKERNEL_INTERRUPT_PRIORITY 255
/* !!!! configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to zero !!!!
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xa0, or priority 5. */
#endif /* FREERTOS_CONFIG_H */

View file

@ -0,0 +1,106 @@
/*
* FreeRTOS V202212.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
*/
/*-----------------------------------------------------------
* Simple parallel port IO routines.
*-----------------------------------------------------------*/
/*
*/
/* Kernel include files. */
#include "FreeRTOS.h"
#include "task.h"
#include "partest.h"
/* Hardware specific include files. */
#include "DriverLib.h"
static const unsigned long ulLEDs[] =
{
GPIO_PIN_6, GPIO_PIN_1, GPIO_PIN_0
};
#define partstLED_PINS ( GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_6 )
#define partstMAX_OUTPUT_LED ( ( unsigned char ) 3 )
/*-----------------------------------------------------------*/
void vParTestInitialise( void )
{
portBASE_TYPE xLED;
/* The LED's are on port B. */
GPIODirModeSet( GPIO_PORTB_BASE, partstLED_PINS, GPIO_DIR_MODE_OUT );
for( xLED = 0; xLED < partstMAX_OUTPUT_LED; xLED++ )
{
vParTestSetLED( xLED, pdFALSE );
}
}
/*-----------------------------------------------------------*/
void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
{
vTaskSuspendAll();
{
if( uxLED < partstMAX_OUTPUT_LED )
{
if( xValue == pdFALSE )
{
GPIOPinWrite( GPIO_PORTB_BASE, ulLEDs[ uxLED ], ulLEDs[ uxLED ] );
}
else
{
GPIOPinWrite( GPIO_PORTB_BASE, ulLEDs[ uxLED ], ~ulLEDs[ uxLED ] );
}
}
}
xTaskResumeAll();
}
/*-----------------------------------------------------------*/
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
{
portBASE_TYPE xCurrentValue;
vTaskSuspendAll();
{
if( uxLED < partstMAX_OUTPUT_LED )
{
xCurrentValue = GPIOPinRead( GPIO_PORTB_BASE, ulLEDs[ uxLED ] );
if( xCurrentValue )
{
GPIOPinWrite( GPIO_PORTB_BASE, ulLEDs[ uxLED ], ~ulLEDs[ uxLED ] );
}
else
{
GPIOPinWrite( GPIO_PORTB_BASE, ulLEDs[ uxLED ], ulLEDs[ uxLED ] );
}
}
}
xTaskResumeAll();
}

View file

@ -0,0 +1,284 @@
/*
* FreeRTOS V202212.00
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* https://www.FreeRTOS.org
* https://github.com/FreeRTOS
*
*/
/*
* This is a mini co-routine demo for the Rowley CrossFire LM3S102 development
* board. It makes use of the boards tri-colour LED and analogue input.
*
* Four co-routines are created - an 'I2C' co-routine and three 'flash'
* co-routines.
*
* The I2C co-routine triggers an ADC conversion then blocks on a queue to
* wait for the conversion result - which it receives on the queue directly
* from the I2C interrupt service routine. The conversion result is then
* scalled to a delay period. The I2C interrupt then wakes each of the
* flash co-routines before itself delaying for the calculated period and
* then repeating the whole process.
*
* When woken by the I2C co-routine the flash co-routines each block for
* a given period, illuminate an LED for a fixed period, then go back to
* sleep to wait for the next cycle. The uxIndex parameter of the flash
* co-routines is used to ensure that each flashes a different LED, and that
* the delay periods are such that the LED's get flashed in sequence.
*/
/* Scheduler include files. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "croutine.h"
/* Demo application include files. */
#include "partest.h"
/* Library include files. */
#include "DriverLib.h"
/* States of the I2C master interface. */
#define mainI2C_IDLE 0
#define mainI2C_READ_1 1
#define mainI2C_READ_2 2
#define mainI2C_READ_DONE 3
#define mainZERO_LENGTH 0
/* Address of the A2D IC on the CrossFire board. */
#define mainI2CAddress 0x4D
/* The queue used to send data from the I2C ISR to the co-routine should never
contain more than one item as the same co-routine is used to trigger the I2C
activity. */
#define mainQUEUE_LENGTH 1
/* The CrossFire board contains a tri-colour LED. */
#define mainNUM_LEDs 3
/* The I2C co-routine has a higher priority than the flash co-routines. This
is not really necessary as when the I2C co-routine is active the other
co-routines are delaying. */
#define mainI2c_CO_ROUTINE_PRIORITY 1
/* The current state of the I2C master. */
static volatile unsigned portBASE_TYPE uxState = mainI2C_IDLE;
/* The delay period derived from the A2D value. */
static volatile portBASE_TYPE uxDelay = 250;
/* The queue used to communicate between the I2C interrupt and the I2C
co-routine. */
static QueueHandle_t xADCQueue;
/* The queue used to synchronise the flash co-routines. */
static QueueHandle_t xDelayQueue;
/*
* Sets up the PLL, I2C and GPIO used by the demo.
*/
static void prvSetupHardware( void );
/* The co-routines as described at the top of the file. */
static void vI2CCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex );
static void vFlashCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex );
/*-----------------------------------------------------------*/
int main( void )
{
unsigned portBASE_TYPE uxCoRoutine;
/* Setup all the hardware used by this demo. */
prvSetupHardware();
/* Create the queue used to communicate between the ISR and I2C co-routine.
This can only ever contain one value. */
xADCQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( TickType_t ) );
/* Create the queue used to synchronise the flash co-routines. The queue
is used to trigger three tasks, but is for synchronisation only and does
not pass any data. It therefore has three position each of zero length. */
xDelayQueue = xQueueCreate( mainNUM_LEDs, mainZERO_LENGTH );
/* Create the co-routine that initiates the i2c. */
xCoRoutineCreate( vI2CCoRoutine, mainI2c_CO_ROUTINE_PRIORITY, 0 );
/* Create the flash co-routines. */
for( uxCoRoutine = 0; uxCoRoutine < mainNUM_LEDs; uxCoRoutine++ )
{
xCoRoutineCreate( vFlashCoRoutine, tskIDLE_PRIORITY, uxCoRoutine );
}
/* Start the scheduler. From this point on the co-routines should
execute. */
vTaskStartScheduler();
/* Should not get here unless we did not have enough memory to start the
scheduler. */
for( ;; );
return 0;
}
/*-----------------------------------------------------------*/
static void prvSetupHardware( void )
{
/* Setup the PLL. */
SysCtlClockSet( SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ );
/* Enable the I2C used to read the pot. */
SysCtlPeripheralEnable( SYSCTL_PERIPH_I2C );
SysCtlPeripheralEnable( SYSCTL_PERIPH_GPIOB );
GPIOPinTypeI2C( GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_3 );
/* Initialize the I2C master. */
I2CMasterInit( I2C_MASTER_BASE, pdFALSE );
/* Enable the I2C master interrupt. */
I2CMasterIntEnable( I2C_MASTER_BASE );
IntEnable( INT_I2C );
/* Initialise the hardware used to talk to the LED's. */
vParTestInitialise();
}
/*-----------------------------------------------------------*/
static void vI2CCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex )
{
TickType_t xADCResult;
static portBASE_TYPE xResult = 0, xMilliSecs, xLED;
crSTART( xHandle );
for( ;; )
{
/* Start the I2C off to read the ADC. */
uxState = mainI2C_READ_1;
I2CMasterSlaveAddrSet( I2C_MASTER_BASE, mainI2CAddress, pdTRUE );
I2CMasterControl( I2C_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START );
/* Wait to receive the conversion result. */
crQUEUE_RECEIVE( xHandle, xADCQueue, &xADCResult, portMAX_DELAY, &xResult );
/* Scale the result to give a useful range of values for a visual
demo. */
xADCResult >>= 2;
xMilliSecs = xADCResult / portTICK_PERIOD_MS;
/* The delay is split between the four co-routines so they remain in
synch. */
uxDelay = xMilliSecs / ( mainNUM_LEDs + 1 );
/* Trigger each of the flash co-routines. */
for( xLED = 0; xLED < mainNUM_LEDs; xLED++ )
{
crQUEUE_SEND( xHandle, xDelayQueue, &xLED, 0, &xResult );
}
/* Wait for the full delay time then start again. This delay is long
enough to ensure the flash co-routines have done their thing and gone
back to sleep. */
crDELAY( xHandle, xMilliSecs );
}
crEND();
}
/*-----------------------------------------------------------*/
static void vFlashCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex )
{
portBASE_TYPE xResult, xNothing;
crSTART( xHandle );
for( ;; )
{
/* Wait for start of next round. */
crQUEUE_RECEIVE( xHandle, xDelayQueue, &xNothing, portMAX_DELAY, &xResult );
/* Wait until it is this co-routines turn to flash. */
crDELAY( xHandle, uxDelay * uxIndex );
/* Turn on the LED for a fixed period. */
vParTestSetLED( uxIndex, pdTRUE );
crDELAY( xHandle, uxDelay );
vParTestSetLED( uxIndex, pdFALSE );
/* Go back and wait for the next round. */
}
crEND();
}
/*-----------------------------------------------------------*/
void vI2C_ISR(void)
{
static TickType_t xReading;
/* Clear the interrupt. */
I2CMasterIntClear( I2C_MASTER_BASE );
/* Determine what to do based on the current uxState. */
switch (uxState)
{
case mainI2C_IDLE: break;
case mainI2C_READ_1: /* Read ADC result high byte. */
xReading = I2CMasterDataGet( I2C_MASTER_BASE );
xReading <<= 8;
/* Continue the burst read. */
I2CMasterControl( I2C_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT );
uxState = mainI2C_READ_2;
break;
case mainI2C_READ_2: /* Read ADC result low byte. */
xReading |= I2CMasterDataGet( I2C_MASTER_BASE );
/* Finish the burst read. */
I2CMasterControl( I2C_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH );
uxState = mainI2C_READ_DONE;
break;
case mainI2C_READ_DONE: /* Complete. */
I2CMasterDataGet( I2C_MASTER_BASE );
uxState = mainI2C_IDLE;
/* Send the result to the co-routine. */
crQUEUE_SEND_FROM_ISR( xADCQueue, &xReading, pdFALSE );
break;
}
}
/*-----------------------------------------------------------*/
void vApplicationIdleHook( void )
{
for( ;; )
{
vCoRoutineSchedule();
}
}

View file

@ -0,0 +1,121 @@
/*****************************************************************************
* Copyright (c) 2006 Rowley Associates Limited. *
* *
* This file may be distributed under the terms of the License Agreement *
* provided with this software. *
* *
* THIS FILE IS PROVIDED AS IS WITH NO WARRANTY OF ANY KIND, INCLUDING THE *
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. *
*****************************************************************************/
.section .vectors, "ax"
.code 16
.align 0
.global _vectors
.extern xPortPendSVHandler
.extern xPortSysTickHandler
.extern vI2C_ISR
.extern faultisr
.extern vPortSVCHandler
.macro DEFAULT_ISR_HANDLER name=
.thumb_func
.weak \name
\name:
1: b 1b /* endless loop */
.endm
_vectors:
.word __stack_end__
#ifdef STARTUP_FROM_RESET
.word _start
#else
.word reset_wait
#endif /* STARTUP_FROM_RESET */
.word NmiISR
.word FaultISR
.word 0 // Populate if using MemManage (MPU)
.word 0 // Populate if using Bus fault
.word 0 // Populate if using Usage fault
.word 0 // Reserved
.word 0 // Reserved
.word 0 // Reserved
.word 0 // Reserved
.word vPortSVCHandler
.word 0 // Populate if using a debug monitor
.word 0 // Reserved
.word xPortPendSVHandler // Populate if using pendable service request
.word xPortSysTickHandler
// External interrupts start her
.word GPIO_Port_A_ISR
.word GPIO_Port_B_ISR
.word GPIO_Port_C_ISR
.word GPIO_Port_D_ISR
.word GPIO_Port_E_ISR
.word UART0_ISR
.word UART1_ISR
.word SSI_ISR
.word vI2C_ISR
.word PWM_Fault_ISR
.word PWM_Generator_0_ISR
.word PWM_Generator_1_ISR
.word PWM_Generator_2_ISR
.word QEI_ISR
.word ADC_Sequence_0_ISR
.word ADC_Sequence_1_ISR
.word ADC_Sequence_2_ISR
.word ADC_Sequence_3_ISR
.word Watchdog_timer_ISR
.word Timer0a_ISR
.word Timer0b_ISR
.word Timer1a_ISR
.word Timer1b_ISR
.word Timer2a_ISR
.word Timer2b_ISR
.word Analog_Comparator_0_ISR
.word Analog_Comparator_1_ISR
.word Analog_Comparator_2_ISR
.word System_Control_ISR
.word FLASH_Control_ISR
.section .init, "ax"
.thumb_func
DEFAULT_ISR_HANDLER NmiISR
DEFAULT_ISR_HANDLER FaultISR
DEFAULT_ISR_HANDLER SVCallISR
DEFAULT_ISR_HANDLER SysTickISR
DEFAULT_ISR_HANDLER GPIO_Port_A_ISR
DEFAULT_ISR_HANDLER GPIO_Port_B_ISR
DEFAULT_ISR_HANDLER GPIO_Port_C_ISR
DEFAULT_ISR_HANDLER GPIO_Port_D_ISR
DEFAULT_ISR_HANDLER GPIO_Port_E_ISR
DEFAULT_ISR_HANDLER UART0_ISR
DEFAULT_ISR_HANDLER UART1_ISR
DEFAULT_ISR_HANDLER SSI_ISR
DEFAULT_ISR_HANDLER I2C_ISR
DEFAULT_ISR_HANDLER PWM_Fault_ISR
DEFAULT_ISR_HANDLER PWM_Generator_0_ISR
DEFAULT_ISR_HANDLER PWM_Generator_1_ISR
DEFAULT_ISR_HANDLER PWM_Generator_2_ISR
DEFAULT_ISR_HANDLER QEI_ISR
DEFAULT_ISR_HANDLER ADC_Sequence_0_ISR
DEFAULT_ISR_HANDLER ADC_Sequence_1_ISR
DEFAULT_ISR_HANDLER ADC_Sequence_2_ISR
DEFAULT_ISR_HANDLER ADC_Sequence_3_ISR
DEFAULT_ISR_HANDLER Watchdog_timer_ISR
DEFAULT_ISR_HANDLER Timer0a_ISR
DEFAULT_ISR_HANDLER Timer0b_ISR
DEFAULT_ISR_HANDLER Timer1a_ISR
DEFAULT_ISR_HANDLER Timer1b_ISR
DEFAULT_ISR_HANDLER Timer2a_ISR
DEFAULT_ISR_HANDLER Timer2b_ISR
DEFAULT_ISR_HANDLER Analog_Comparator_0_ISR
DEFAULT_ISR_HANDLER Analog_Comparator_1_ISR
DEFAULT_ISR_HANDLER Analog_Comparator_2_ISR
DEFAULT_ISR_HANDLER System_Control_ISR
DEFAULT_ISR_HANDLER FLASH_Control_ISR
#ifndef STARTUP_FROM_RESET
DEFAULT_ISR_HANDLER reset_wait
#endif /* STARTUP_FROM_RESET */

View file

@ -7,11 +7,13 @@
<folder Name="Source Files" >
<configuration filter="c;cpp;cxx;cc;h;s;asm;inc" Name="Common" />
<folder Name="Demo Source" >
<file file_name="../Common/Minimal/crflash.c" Name="crflash.c" />
<file file_name="Demo1/main.c" Name="main.c" />
<file file_name="Demo1/ParTest.c" Name="ParTest.c" />
</folder>
<folder Name="RTOS Source" >
<file file_name="../../Source/tasks.c" Name="tasks.c" />
<file file_name="../../Source/croutine.c" Name="croutine.c" />
<file file_name="../../Source/list.c" Name="list.c" />
<file file_name="../../Source/queue.c" Name="queue.c" />
<file file_name="../../Source/portable/GCC/ARM_CM3/port.c" Name="port.c" >
@ -43,11 +45,13 @@
<folder Name="Source Files" >
<configuration filter="c;cpp;cxx;cc;h;s;asm;inc" Name="Common" />
<folder Name="Demo Source" >
<file file_name="../Common/Minimal/crflash.c" Name="crflash.c" />
<file file_name="Demo2/main.c" Name="main.c" />
<file file_name="Demo2/ParTest.c" Name="ParTest.c" />
</folder>
<folder Name="RTOS Source" >
<file file_name="../../Source/tasks.c" Name="tasks.c" />
<file file_name="../../Source/croutine.c" Name="croutine.c" />
<file file_name="../../Source/list.c" Name="list.c" />
<file file_name="../../Source/queue.c" Name="queue.c" />
<file file_name="../../Source/portable/GCC/ARM_CM3/port.c" Name="port.c" >
@ -81,6 +85,7 @@
</folder>
<folder Name="RTOS Source" >
<file file_name="../../Source/tasks.c" Name="tasks.c" />
<file file_name="../../Source/croutine.c" Name="croutine.c" />
<file file_name="../../Source/list.c" Name="list.c" />
<file file_name="../../Source/queue.c" Name="queue.c" />
<file file_name="../../Source/portable/GCC/ARM_CM3/port.c" Name="port.c" >

View file

@ -50,8 +50,10 @@
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 1
#define configMAX_PRIORITIES ( 2 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */
@ -69,4 +71,6 @@ to exclude the API function. */
See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configMAX_SYSCALL_INTERRUPT_PRIORITY 191 /* equivalent to 0xa0, or priority 5. */
#endif /* FREERTOS_CONFIG_H */

View file

@ -907,6 +907,9 @@
<file>
<name>$PROJ_DIR$\commstest.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\Common\Minimal\crflash.c</name>
</file>
<file>
<name>$PROJ_DIR$\main.c</name>
</file>
@ -919,6 +922,9 @@
</group>
<group>
<name>FreeRTOS Source</name>
<file>
<name>$PROJ_DIR$\..\..\Source\croutine.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\portable\MemMang\heap_1.c</name>
</file>
@ -951,3 +957,5 @@
</file>
</group>
</project>

View file

@ -25,7 +25,7 @@
*/
/*
* The comms test Rx and Tx task. See the comments at the top
* The comms test Rx and Tx task and co-routine. See the comments at the top
* of main.c for full information.
*/
@ -34,6 +34,7 @@
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "croutine.h"
/* Demo application include files. */
#include "partest.h"
@ -50,7 +51,7 @@
task. */
#define commsRX_QUEUE_LEN ( 5 )
/* The baud rate used by the UART comms tasks. */
/* The baud rate used by the UART comms tasks/co-routine. */
#define commsBAUD_RATE ( 57600 )
/* FIFO setting for the UART. The FIFO is not used to create a better test. */
@ -116,6 +117,71 @@ void vSerialInit( void )
}
/*-----------------------------------------------------------*/
void vSerialTxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex )
{
TickType_t xDelayPeriod;
static unsigned long *pulRandomBytes = commsFIRST_PROGRAM_BYTES;
/* Co-routine MUST start with a call to crSTART. */
crSTART( xHandle );
for(;;)
{
/* Was the previously transmitted string received correctly? */
if( uxCommsErrorStatus != pdPASS )
{
/* An error was encountered so set the error LED. */
vParTestSetLED( commsFAIL_LED, pdTRUE );
}
/* The next character to Tx is the first in the string. */
cNextChar = commsFIRST_TX_CHAR;
UARTIntDisable( UART0_BASE, UART_INT_TX );
{
/* Send the first character. */
if( !( HWREG( UART0_BASE + UART_O_FR ) & UART_FR_TXFF ) )
{
HWREG( UART0_BASE + UART_O_DR ) = cNextChar;
}
/* Move the variable to the char to Tx on so the ISR transmits
the next character in the string once this one has completed. */
cNextChar++;
}
UARTIntEnable(UART0_BASE, UART_INT_TX);
/* Toggle the LED to show a new string is being transmitted. */
vParTestToggleLED( commsTX_LED );
/* Delay before we start the string off again. A pseudo-random delay
is used as this will provide a better test. */
xDelayPeriod = xTaskGetTickCount() + ( *pulRandomBytes );
pulRandomBytes++;
if( pulRandomBytes > commsTOTAL_PROGRAM_MEMORY )
{
pulRandomBytes = commsFIRST_PROGRAM_BYTES;
}
/* Make sure we don't wait too long... */
xDelayPeriod &= commsMAX_TX_DELAY;
/* ...but we do want to wait. */
if( xDelayPeriod < commsMIN_TX_DELAY )
{
xDelayPeriod = commsMIN_TX_DELAY;
}
/* Block for the random(ish) time. */
crDELAY( xHandle, xDelayPeriod );
}
/* Co-routine MUST end with a call to crEND. */
crEND();
}
/*-----------------------------------------------------------*/
void vUART_ISR( void )
{
unsigned long ulStatus;

View file

@ -37,6 +37,12 @@ void vSerialInit( void );
*/
void vCommsRxTask( void * pvParameters );
/*
* The co-routine that periodically initiates the transmission of the string on
* the UART.
*/
void vSerialTxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex );
unsigned portBASE_TYPE uxGetCommsStatus( void );
#endif

View file

@ -25,10 +25,15 @@
*/
/*
* This demo application creates four tasks (five including the idle task).
* The application is limited in size to allow its compilation using
* This demo application creates eight co-routines and four tasks (five
* including the idle task). The co-routines execute as part of the idle task
* hook. The application is limited in size to allow its compilation using
* the KickStart version of the IAR compiler.
*
* Six of the created co-routines are the standard 'co-routine flash'
* co-routines contained within the Demo/Common/Minimal/crflash.c file and
* documented on the FreeRTOS.org WEB site.
*
* The 'LCD Task' waits on a message queue for messages informing it what and
* where to display text. This is the only task that accesses the LCD
* so mutual exclusion is guaranteed.
@ -37,6 +42,19 @@
* the message queue. The strings are rotated to form a short message and
* are written to the top row of the LCD.
*
* The 'ADC Co-routine' periodically reads the ADC input that is connected to
* the light sensor, forms a short message from the value, and then sends this
* message to the LCD Task using the same message queue. The ADC readings are
* displayed on the bottom row of the LCD.
*
* The eighth co-routine and final task control the transmission and reception
* of a string to UART 0. The co-routine periodically sends the first
* character of the string to the UART, with the UART's TxEnd interrupt being
* used to transmit the remaining characters. The UART's RxEnd interrupt
* receives the characters and places them on a queue to be processed by the
* 'COMs Rx' task. An error is latched should an unexpected character be
* received, or any character be received out of sequence.
*
* A loopback connector is required to ensure that each character transmitted
* on the UART is also received on the same UART. For test purposes the UART
* FIFO's are not utalised in order to maximise the interrupt overhead. Also
@ -44,6 +62,11 @@
* order that the resultant interrupts are more randomly distributed and
* therefore more likely to highlight any problems.
*
* The flash co-routines control LED's zero to four. LED five is toggled each
* time the string is transmitted on the UART. LED six is toggled each time
* the string is CORRECTLY received on the UART. LED seven is latched on
* should an error be detected in any task or co-routine.
*
* In addition the idle task makes repetitive calls to
* vSetAndCheckRegisters(). This simply loads the general purpose registers
* with a known value, then checks each register to ensure the held value is
@ -61,9 +84,11 @@
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include "croutine.h"
/* Demo application include files. */
#include "partest.h"
#include "crflash.h"
#include "commstest.h"
/* Library include files. */
@ -77,9 +102,21 @@
#define mainADC_DELAY ( 200 / portTICK_PERIOD_MS )
/* The number of flash co-routines to create. */
#define mainNUM_FLASH_CO_ROUTINES ( 5 )
/* The length of the queue used to send messages to the LCD task. */
#define mainLCD_QUEUE_LEN ( 3 )
/* The priority of the co-routine used to initiate the transmission of the
string on UART 0. */
#define mainTX_CO_ROUTINE_PRIORITY ( 1 )
#define mainADC_CO_ROUTINE_PRIORITY ( 2 )
/* Only one of each co-routine is created so its index is not important. */
#define mainTX_CO_ROUTINE_INDEX ( 0 )
#define mainADC_CO_ROUTINE_INDEX ( 0 )
/* The task priorities. */
#define mainLCD_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define mainMSG_TASK_PRIORITY ( mainLCD_TASK_PRIORITY - 1 )
@ -92,7 +129,8 @@
/* Dimension for the buffer into which the ADC value string is written. */
#define mainMAX_ADC_STRING_LEN 20
/* The LED that is lit should an error be detected in any of the tasks */
/* The LED that is lit should an error be detected in any of the tasks or
co-routines. */
#define mainFAIL_LED ( 7 )
/*-----------------------------------------------------------*/
@ -107,6 +145,12 @@ static void prvLCDTask( void * pvParameters );
*/
static void prvLCDMessageTask( void * pvParameters );
/*
* The co-routine that reads the ADC and sends messages for display on the
* bottom row of the LCD.
*/
static void prvADCCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex );
/*
* Function to simply set a known value into the general purpose registers
* then read them back to ensure they remain set correctly. An incorrect value
@ -139,7 +183,7 @@ typedef struct
portBASE_TYPE xRow; /*<< The row on which the message should be displayed. */
} xLCDMessage;
/* Error flag set to pdFAIL if an error is encountered in the tasks
/* Error flag set to pdFAIL if an error is encountered in the tasks/co-routines
defined within this file. */
unsigned portBASE_TYPE uxErrorStatus = pdPASS;
@ -149,7 +193,7 @@ static QueueHandle_t xLCDQueue;
/*-----------------------------------------------------------*/
/*
* Setup the hardware, create the tasks, then start the scheduler.
* Setup the hardware, create the tasks/co-routines, then start the scheduler.
*/
void main( void )
{
@ -159,15 +203,23 @@ void main( void )
/* Setup the ports used by the demo and the clock. */
prvSetupHardware();
/* Create the co-routines that flash the LED's. */
vStartFlashCoRoutines( mainNUM_FLASH_CO_ROUTINES );
/* Create the co-routine that initiates the transmission of characters
on the UART and the task that receives them, as described at the top of
this file. */
xCoRoutineCreate( vSerialTxCoRoutine, mainTX_CO_ROUTINE_PRIORITY, mainTX_CO_ROUTINE_INDEX );
xTaskCreate( vCommsRxTask, "CMS", configMINIMAL_STACK_SIZE, NULL, mainCOMMS_RX_TASK_PRIORITY, NULL );
/* Create the task that waits for messages to display on the LCD, plus the
task that sends messages for display (as described at the top
task and co-routine that send messages for display (as described at the top
of this file. */
xTaskCreate( prvLCDTask, "LCD", configMINIMAL_STACK_SIZE, ( void * ) &xLCDQueue, mainLCD_TASK_PRIORITY, NULL );
xTaskCreate( prvLCDMessageTask, "MSG", configMINIMAL_STACK_SIZE, ( void * ) &xLCDQueue, mainMSG_TASK_PRIORITY, NULL );
xCoRoutineCreate( prvADCCoRoutine, mainADC_CO_ROUTINE_PRIORITY, mainADC_CO_ROUTINE_INDEX );
/* Start the scheduler running the tasks just created. */
/* Start the scheduler running the tasks and co-routines just created. */
vTaskStartScheduler();
/* Should not get here unless we did not have enough memory to start the
@ -285,7 +337,48 @@ const unsigned char ucCFGData[] = {
}
}
}
/*-----------------------------------------------------------*/
static void prvADCCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex )
{
static unsigned long ulADCValue;
static char cMessageBuffer[ mainMAX_ADC_STRING_LEN ];
static char *pcMessage;
static xLCDMessage xMessageToSend;
/* Co-routines MUST start with a call to crSTART(). */
crSTART( xHandle );
for( ;; )
{
/* Start an ADC conversion. */
ADCProcessorTrigger( ADC_BASE, 0 );
/* Simply delay - when we unblock the result should be available */
crDELAY( xHandle, mainADC_DELAY );
/* Get the ADC result. */
ADCSequenceDataGet( ADC_BASE, 0, &ulADCValue );
/* Create a string with the result. */
sprintf( cMessageBuffer, "ADC = %d ", ulADCValue );
pcMessage = cMessageBuffer;
/* Configure the message we are going to send for display. */
xMessageToSend.ppcMessageToDisplay = ( char** ) &pcMessage;
xMessageToSend.xRow = mainBOTTOM_ROW;
/* Send the string to the LCD task for display. We are sending
on a task queue so do not have the option to block. */
if( !xQueueSend( xLCDQueue, ( void * ) &xMessageToSend, 0 ) )
{
uxErrorStatus = pdFAIL;
}
}
/* Co-routines MUST end with a call to crEND(). */
crEND();
}
/*-----------------------------------------------------------*/
static void prvSetupHardware( void )
@ -325,11 +418,17 @@ void vSetErrorLED( void )
void vApplicationIdleHook( void )
{
/* The co-routines are executed in the idle task using the idle task
hook. */
for( ;; )
{
/* Schedule the co-routines. */
vCoRoutineSchedule();
/* Run the register check function between each co-routine. */
vSetAndCheckRegisters();
/* See if the comms task has found any errors. */
/* See if the comms task and co-routine has found any errors. */
if( uxGetCommsStatus() != pdPASS )
{
vParTestSetLED( mainFAIL_LED, pdTRUE );

View file

@ -50,6 +50,7 @@
#define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 0
#define configUSE_MUTEXES 1
#define configUSE_RECURSIVE_MUTEXES 1
#define configCHECK_FOR_STACK_OVERFLOW 2
@ -57,6 +58,7 @@
#define configUSE_COUNTING_SEMAPHORES 1
#define configMAX_PRIORITIES ( 6UL )
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
#define configQUEUE_REGISTRY_SIZE 10
#define configSUPPORT_STATIC_ALLOCATION 1

View file

@ -50,8 +50,10 @@
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 0
#define configMAX_PRIORITIES ( 5 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -50,8 +50,10 @@
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 1
#define configMAX_PRIORITIES ( 5 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -50,8 +50,10 @@
#define configUSE_TRACE_FACILITY 0
#define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 0
#define configUSE_CO_ROUTINES 0
#define configMAX_PRIORITIES ( 2 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Set the following definitions to 1 to include the API function, or zero
to exclude the API function. */

View file

@ -70,6 +70,9 @@ unsigned long ulMainGetRunTimeCounterValue( void );
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vMainConfigureTimerForRunTimeStats()
#define portGET_RUN_TIME_COUNTER_VALUE() ulMainGetRunTimeCounterValue()
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Software timer definitions. */
#define configUSE_TIMERS 1

View file

@ -55,6 +55,11 @@
<type>1</type>
<locationURI>PARENT-1-PROJECT_LOC/Common/Minimal/recmutex.c</locationURI>
</link>
<link>
<name>FreeRTOS_source/croutine.c</name>
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/Source/croutine.c</locationURI>
</link>
<link>
<name>FreeRTOS_source/event_groups.c</name>
<type>1</type>
@ -110,6 +115,11 @@
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/Source/include/atomic.h</locationURI>
</link>
<link>
<name>FreeRTOS_source/include/croutine.h</name>
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/Source/include/croutine.h</locationURI>
</link>
<link>
<name>FreeRTOS_source/include/deprecated_definitions.h</name>
<type>1</type>

View file

@ -2318,6 +2318,9 @@
<file>
<name>$PROJ_DIR$\..\..\Source\include\atomic.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\include\croutine.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\include\deprecated_definitions.h</name>
</file>
@ -2388,6 +2391,9 @@
</file>
</group>
</group>
<file>
<name>$PROJ_DIR$\..\..\Source\croutine.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\event_groups.c</name>
</file>

View file

@ -2573,6 +2573,9 @@
<file>
<name>$PROJ_DIR$\..\..\Source\include\atomic.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\include\croutine.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\include\deprecated_definitions.h</name>
</file>
@ -2643,6 +2646,9 @@
</file>
</group>
</group>
<file>
<name>$PROJ_DIR$\..\..\Source\croutine.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\Source\event_groups.c</name>
</file>

View file

@ -1074,6 +1074,18 @@
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>11</GroupNumber>
<FileNumber>66</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\Source\croutine.c</PathWithFileName>
<FilenameWithoutPath>croutine.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>11</GroupNumber>
<FileNumber>67</FileNumber>
@ -1158,6 +1170,18 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>11</GroupNumber>
<FileNumber>74</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\Source\include\croutine.h</PathWithFileName>
<FilenameWithoutPath>croutine.h</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>11</GroupNumber>
<FileNumber>75</FileNumber>

View file

@ -757,6 +757,11 @@
<Group>
<GroupName>FreeRTOS_Source</GroupName>
<Files>
<File>
<FileName>croutine.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\Source\croutine.c</FilePath>
</File>
<File>
<FileName>event_groups.c</FileName>
<FileType>1</FileType>
@ -792,6 +797,11 @@
<FileType>5</FileType>
<FilePath>..\..\Source\include\atomic.h</FilePath>
</File>
<File>
<FileName>croutine.h</FileName>
<FileType>5</FileType>
<FilePath>..\..\Source\include\croutine.h</FilePath>
</File>
<File>
<FileName>deprecated_definitions.h</FileName>
<FileType>5</FileType>

View file

@ -70,6 +70,9 @@
#define configTASK_NOTIFICATION_ARRAY_ENTRIES 3
#define configMESSAGE_BUFFER_LENGTH_TYPE size_t
/* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Software timer definitions. */
#define configUSE_TIMERS 1

View file

@ -84,6 +84,15 @@
<arguments>1.0-name-matches-false-false-comtest_strings.c</arguments>
</matcher>
</filter>
<filter>
<id>1649345202745</id>
<name>Demo/Standard_Demos</name>
<type>6</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-crhook.c</arguments>
</matcher>
</filter>
<filter>
<id>1649345202750</id>
<name>Demo/Standard_Demos</name>
@ -93,6 +102,15 @@
<arguments>1.0-name-matches-false-false-comtest.c</arguments>
</matcher>
</filter>
<filter>
<id>1649345202755</id>
<name>Demo/Standard_Demos</name>
<type>6</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-crflash.c</arguments>
</matcher>
</filter>
<filter>
<id>1649345202759</id>
<name>Demo/Standard_Demos</name>

Some files were not shown because too many files have changed in this diff Show more