summaryrefslogtreecommitdiff
path: root/FreeRTOS/Demo/AVR_ATMega323_WinAVR
diff options
context:
space:
mode:
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2012-08-11 21:34:11 +0000
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2012-08-11 21:34:11 +0000
commitf279ebee719fa6bda3f91061819e6b42051c7395 (patch)
treec2ef3f908508343c26551949d5f947009cda3291 /FreeRTOS/Demo/AVR_ATMega323_WinAVR
parent24ce9d9c87e6b7b23f0915e1a91fb4a5bd2f7c3d (diff)
downloadfreertos-f279ebee719fa6bda3f91061819e6b42051c7395.tar.gz
Add FreeRTOS-Plus directory.
git-svn-id: http://svn.code.sf.net/p/freertos/code/trunk@1765 1d2547de-c912-0410-9cb9-b8ca96c0e9e2
Diffstat (limited to 'FreeRTOS/Demo/AVR_ATMega323_WinAVR')
-rw-r--r--FreeRTOS/Demo/AVR_ATMega323_WinAVR/FreeRTOSConfig.h114
-rw-r--r--FreeRTOS/Demo/AVR_ATMega323_WinAVR/ParTest/ParTest.c157
-rw-r--r--FreeRTOS/Demo/AVR_ATMega323_WinAVR/main.c292
-rw-r--r--FreeRTOS/Demo/AVR_ATMega323_WinAVR/makefile428
-rw-r--r--FreeRTOS/Demo/AVR_ATMega323_WinAVR/regtest.c396
-rw-r--r--FreeRTOS/Demo/AVR_ATMega323_WinAVR/regtest.h74
-rw-r--r--FreeRTOS/Demo/AVR_ATMega323_WinAVR/serial/serial.c261
7 files changed, 1722 insertions, 0 deletions
diff --git a/FreeRTOS/Demo/AVR_ATMega323_WinAVR/FreeRTOSConfig.h b/FreeRTOS/Demo/AVR_ATMega323_WinAVR/FreeRTOSConfig.h
new file mode 100644
index 000000000..b6be018a7
--- /dev/null
+++ b/FreeRTOS/Demo/AVR_ATMega323_WinAVR/FreeRTOSConfig.h
@@ -0,0 +1,114 @@
+/*
+ FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.
+
+
+ ***************************************************************************
+ * *
+ * FreeRTOS tutorial books are available in pdf and paperback. *
+ * Complete, revised, and edited pdf reference manuals are also *
+ * available. *
+ * *
+ * Purchasing FreeRTOS documentation will not only help you, by *
+ * ensuring you get running as quickly as possible and with an *
+ * in-depth knowledge of how to use FreeRTOS, it will also help *
+ * the FreeRTOS project to continue with its mission of providing *
+ * professional grade, cross platform, de facto standard solutions *
+ * for microcontrollers - completely free of charge! *
+ * *
+ * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
+ * *
+ * Thank you for using FreeRTOS, and thank you for your support! *
+ * *
+ ***************************************************************************
+
+
+ This file is part of the FreeRTOS distribution.
+
+ FreeRTOS is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License (version 2) as published by the
+ Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
+ >>>NOTE<<< The modification to the GPL is included to allow you to
+ distribute a combined work that includes FreeRTOS without being obliged to
+ provide the source code for proprietary components outside of the FreeRTOS
+ kernel. FreeRTOS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details. You should have received a copy of the GNU General Public
+ License and the FreeRTOS license exception along with FreeRTOS; if not it
+ can be viewed here: http://www.freertos.org/a00114.html and also obtained
+ by writing to Richard Barry, contact details for whom are available on the
+ FreeRTOS WEB site.
+
+ 1 tab == 4 spaces!
+
+ ***************************************************************************
+ * *
+ * Having a problem? Start by reading the FAQ "My application does *
+ * not run, what could be wrong? *
+ * *
+ * http://www.FreeRTOS.org/FAQHelp.html *
+ * *
+ ***************************************************************************
+
+
+ http://www.FreeRTOS.org - Documentation, training, latest information,
+ license and contact details.
+
+ http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
+ including FreeRTOS+Trace - an indispensable productivity tool.
+
+ Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
+ the code with commercial support, indemnification, and middleware, under
+ the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
+ provide a safety engineered and independently SIL3 certified version under
+ the SafeRTOS brand: http://www.SafeRTOS.com.
+*/
+
+#ifndef FREERTOS_CONFIG_H
+#define FREERTOS_CONFIG_H
+
+#include <avr/io.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 ) 8000000 )
+#define configTICK_RATE_HZ ( ( portTickType ) 1000 )
+#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 4 )
+#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 85 )
+#define configTOTAL_HEAP_SIZE ( (size_t ) ( 1500 ) )
+#define configMAX_TASK_NAME_LEN ( 8 )
+#define configUSE_TRACE_FACILITY 0
+#define configUSE_16_BIT_TICKS 1
+#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. */
+
+#define INCLUDE_vTaskPrioritySet 0
+#define INCLUDE_uxTaskPriorityGet 0
+#define INCLUDE_vTaskDelete 1
+#define INCLUDE_vTaskCleanUpResources 0
+#define INCLUDE_vTaskSuspend 0
+#define INCLUDE_vTaskDelayUntil 1
+#define INCLUDE_vTaskDelay 1
+
+
+#endif /* FREERTOS_CONFIG_H */
diff --git a/FreeRTOS/Demo/AVR_ATMega323_WinAVR/ParTest/ParTest.c b/FreeRTOS/Demo/AVR_ATMega323_WinAVR/ParTest/ParTest.c
new file mode 100644
index 000000000..e17e377ff
--- /dev/null
+++ b/FreeRTOS/Demo/AVR_ATMega323_WinAVR/ParTest/ParTest.c
@@ -0,0 +1,157 @@
+/*
+ FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.
+
+
+ ***************************************************************************
+ * *
+ * FreeRTOS tutorial books are available in pdf and paperback. *
+ * Complete, revised, and edited pdf reference manuals are also *
+ * available. *
+ * *
+ * Purchasing FreeRTOS documentation will not only help you, by *
+ * ensuring you get running as quickly as possible and with an *
+ * in-depth knowledge of how to use FreeRTOS, it will also help *
+ * the FreeRTOS project to continue with its mission of providing *
+ * professional grade, cross platform, de facto standard solutions *
+ * for microcontrollers - completely free of charge! *
+ * *
+ * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
+ * *
+ * Thank you for using FreeRTOS, and thank you for your support! *
+ * *
+ ***************************************************************************
+
+
+ This file is part of the FreeRTOS distribution.
+
+ FreeRTOS is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License (version 2) as published by the
+ Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
+ >>>NOTE<<< The modification to the GPL is included to allow you to
+ distribute a combined work that includes FreeRTOS without being obliged to
+ provide the source code for proprietary components outside of the FreeRTOS
+ kernel. FreeRTOS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details. You should have received a copy of the GNU General Public
+ License and the FreeRTOS license exception along with FreeRTOS; if not it
+ can be viewed here: http://www.freertos.org/a00114.html and also obtained
+ by writing to Richard Barry, contact details for whom are available on the
+ FreeRTOS WEB site.
+
+ 1 tab == 4 spaces!
+
+ ***************************************************************************
+ * *
+ * Having a problem? Start by reading the FAQ "My application does *
+ * not run, what could be wrong? *
+ * *
+ * http://www.FreeRTOS.org/FAQHelp.html *
+ * *
+ ***************************************************************************
+
+
+ http://www.FreeRTOS.org - Documentation, training, latest information,
+ license and contact details.
+
+ http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
+ including FreeRTOS+Trace - an indispensable productivity tool.
+
+ Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
+ the code with commercial support, indemnification, and middleware, under
+ the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
+ provide a safety engineered and independently SIL3 certified version under
+ the SafeRTOS brand: http://www.SafeRTOS.com.
+*/
+
+/*
+Changes from V2.0.0
+
+ + Use scheduler suspends in place of critical sections.
+
+Changes from V2.6.0
+
+ + Replaced the inb() and outb() functions with direct memory
+ access. This allows the port to be built with the 20050414 build of
+ WinAVR.
+*/
+
+#include "FreeRTOS.h"
+#include "task.h"
+#include "partest.h"
+
+/*-----------------------------------------------------------
+ * Simple parallel port IO routines.
+ *-----------------------------------------------------------*/
+
+#define partstALL_BITS_OUTPUT ( ( unsigned char ) 0xff )
+#define partstALL_OUTPUTS_OFF ( ( unsigned char ) 0xff )
+#define partstMAX_OUTPUT_LED ( ( unsigned char ) 7 )
+
+static volatile unsigned char ucCurrentOutputValue = partstALL_OUTPUTS_OFF; /*lint !e956 File scope parameters okay here. */
+
+/*-----------------------------------------------------------*/
+
+void vParTestInitialise( void )
+{
+ ucCurrentOutputValue = partstALL_OUTPUTS_OFF;
+
+ /* Set port B direction to outputs. Start with all output off. */
+ DDRB = partstALL_BITS_OUTPUT;
+ PORTB = ucCurrentOutputValue;
+}
+/*-----------------------------------------------------------*/
+
+void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
+{
+unsigned char ucBit = ( unsigned char ) 1;
+
+ if( uxLED <= partstMAX_OUTPUT_LED )
+ {
+ ucBit <<= uxLED;
+
+ vTaskSuspendAll();
+ {
+ if( xValue == pdTRUE )
+ {
+ ucBit ^= ( unsigned char ) 0xff;
+ ucCurrentOutputValue &= ucBit;
+ }
+ else
+ {
+ ucCurrentOutputValue |= ucBit;
+ }
+
+ PORTB = ucCurrentOutputValue;
+ }
+ xTaskResumeAll();
+ }
+}
+/*-----------------------------------------------------------*/
+
+void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
+{
+unsigned char ucBit;
+
+ if( uxLED <= partstMAX_OUTPUT_LED )
+ {
+ ucBit = ( ( unsigned char ) 1 ) << uxLED;
+
+ vTaskSuspendAll();
+ {
+ if( ucCurrentOutputValue & ucBit )
+ {
+ ucCurrentOutputValue &= ~ucBit;
+ }
+ else
+ {
+ ucCurrentOutputValue |= ucBit;
+ }
+
+ PORTB = ucCurrentOutputValue;
+ }
+ xTaskResumeAll();
+ }
+}
+
+
diff --git a/FreeRTOS/Demo/AVR_ATMega323_WinAVR/main.c b/FreeRTOS/Demo/AVR_ATMega323_WinAVR/main.c
new file mode 100644
index 000000000..8763fa938
--- /dev/null
+++ b/FreeRTOS/Demo/AVR_ATMega323_WinAVR/main.c
@@ -0,0 +1,292 @@
+/*
+ FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.
+
+
+ ***************************************************************************
+ * *
+ * FreeRTOS tutorial books are available in pdf and paperback. *
+ * Complete, revised, and edited pdf reference manuals are also *
+ * available. *
+ * *
+ * Purchasing FreeRTOS documentation will not only help you, by *
+ * ensuring you get running as quickly as possible and with an *
+ * in-depth knowledge of how to use FreeRTOS, it will also help *
+ * the FreeRTOS project to continue with its mission of providing *
+ * professional grade, cross platform, de facto standard solutions *
+ * for microcontrollers - completely free of charge! *
+ * *
+ * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
+ * *
+ * Thank you for using FreeRTOS, and thank you for your support! *
+ * *
+ ***************************************************************************
+
+
+ This file is part of the FreeRTOS distribution.
+
+ FreeRTOS is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License (version 2) as published by the
+ Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
+ >>>NOTE<<< The modification to the GPL is included to allow you to
+ distribute a combined work that includes FreeRTOS without being obliged to
+ provide the source code for proprietary components outside of the FreeRTOS
+ kernel. FreeRTOS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details. You should have received a copy of the GNU General Public
+ License and the FreeRTOS license exception along with FreeRTOS; if not it
+ can be viewed here: http://www.freertos.org/a00114.html and also obtained
+ by writing to Richard Barry, contact details for whom are available on the
+ FreeRTOS WEB site.
+
+ 1 tab == 4 spaces!
+
+ ***************************************************************************
+ * *
+ * Having a problem? Start by reading the FAQ "My application does *
+ * not run, what could be wrong? *
+ * *
+ * http://www.FreeRTOS.org/FAQHelp.html *
+ * *
+ ***************************************************************************
+
+
+ http://www.FreeRTOS.org - Documentation, training, latest information,
+ license and contact details.
+
+ http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
+ including FreeRTOS+Trace - an indispensable productivity tool.
+
+ Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
+ the code with commercial support, indemnification, and middleware, under
+ the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
+ provide a safety engineered and independently SIL3 certified version under
+ the SafeRTOS brand: http://www.SafeRTOS.com.
+*/
+
+/*
+ * Creates all the demo application tasks, then starts the scheduler. The WEB
+ * documentation provides more details of the demo application tasks.
+ *
+ * Main. c also creates a task called "Check". This only executes every three
+ * seconds but has the highest priority so is guaranteed to get processor time.
+ * Its main function is to check that all the other tasks are still operational.
+ * Each task that does not flash an LED maintains a unique count that is
+ * incremented each time the task successfully completes its function. Should
+ * any error occur within such a task the count is permanently halted. The
+ * check task inspects the count of each task to ensure it has changed since
+ * the last time the check task executed. If all the count variables have
+ * changed all the tasks are still executing error free, and the check task
+ * toggles an LED. Should any task contain an error at any time the LED toggle
+ * will stop.
+ *
+ * The LED flash and communications test tasks do not maintain a count.
+ */
+
+/*
+Changes from V1.2.0
+
+ + Changed the baud rate for the serial test from 19200 to 57600.
+
+Changes from V1.2.3
+
+ + The integer and comtest tasks are now used when the cooperative scheduler
+ is being used. Previously they were only used with the preemptive
+ scheduler.
+
+Changes from V1.2.5
+
+ + Set the baud rate to 38400. This has a smaller error percentage with an
+ 8MHz clock (according to the manual).
+
+Changes from V2.0.0
+
+ + Delay periods are now specified using variables and constants of
+ portTickType rather than unsigned long.
+
+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>
+#include <string.h>
+
+#ifdef GCC_MEGA_AVR
+ /* EEPROM routines used only with the WinAVR compiler. */
+ #include <avr/eeprom.h>
+#endif
+
+/* 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"
+
+/* Priority definitions for most of the tasks in the demo application. Some
+tasks just use the idle priority. */
+#define mainLED_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
+#define mainCOM_TEST_PRIORITY ( tskIDLE_PRIORITY + 2 )
+#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 2 )
+#define mainCHECK_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
+
+/* Baud rate used by the serial port tasks. */
+#define mainCOM_TEST_BAUD_RATE ( ( unsigned long ) 38400 )
+
+/* LED used by the serial port tasks. This is toggled on each character Tx,
+and mainCOM_TEST_LED + 1 is toggles on each character Rx. */
+#define mainCOM_TEST_LED ( 4 )
+
+/* LED that is toggled by the check task. The check task periodically checks
+that all the other tasks are operating without error. If no errors are found
+the LED is toggled. If an error is found at any time the LED is never toggles
+again. */
+#define mainCHECK_TASK_LED ( 7 )
+
+/* The period between executions of the check task. */
+#define mainCHECK_PERIOD ( ( portTickType ) 3000 / portTICK_RATE_MS )
+
+/* An address in the EEPROM used to count resets. This is used to check that
+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.
+ */
+static void vErrorChecks( void *pvParameters );
+
+/*
+ * Checks the unique counts of other tasks to ensure they are still operational.
+ * Flashes an LED if everything is okay.
+ */
+static void prvCheckOtherTasksAreStillRunning( void );
+
+/*
+ * Called on boot to increment a count stored in the EEPROM. This is used to
+ * ensure the CPU does not reset unexpectedly.
+ */
+static void prvIncrementResetCount( void );
+
+/*
+ * The idle hook is used to scheduler co-routines.
+ */
+void vApplicationIdleHook( void );
+
+/*-----------------------------------------------------------*/
+
+short main( void )
+{
+ prvIncrementResetCount();
+
+ /* Setup the LED's for output. */
+ vParTestInitialise();
+
+ /* Create the standard demo tasks. */
+ vStartIntegerMathTasks( tskIDLE_PRIORITY );
+ vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED );
+ vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
+ vStartRegTestTasks();
+
+ /* Create the tasks defined within this file. */
+ xTaskCreate( vErrorChecks, ( signed char * ) "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. */
+ vTaskStartScheduler();
+
+ return 0;
+}
+/*-----------------------------------------------------------*/
+
+static void vErrorChecks( void *pvParameters )
+{
+static volatile unsigned long ulDummyVariable = 3UL;
+
+ /* The parameters are not used. */
+ ( void ) pvParameters;
+
+ /* Cycle for ever, delaying then checking all the other tasks are still
+ operating without error. */
+ for( ;; )
+ {
+ vTaskDelay( mainCHECK_PERIOD );
+
+ /* Perform a bit of 32bit maths to ensure the registers used by the
+ integer tasks get some exercise. The result here is not important -
+ see the demo application documentation for more info. */
+ ulDummyVariable *= 3;
+
+ prvCheckOtherTasksAreStillRunning();
+ }
+}
+/*-----------------------------------------------------------*/
+
+static void prvCheckOtherTasksAreStillRunning( void )
+{
+static portBASE_TYPE xErrorHasOccurred = pdFALSE;
+
+ if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
+ {
+ xErrorHasOccurred = pdTRUE;
+ }
+
+ if( xAreComTestTasksStillRunning() != pdTRUE )
+ {
+ xErrorHasOccurred = pdTRUE;
+ }
+
+ if( xArePollingQueuesStillRunning() != pdTRUE )
+ {
+ xErrorHasOccurred = pdTRUE;
+ }
+
+ if( xAreRegTestTasksStillRunning() != pdTRUE )
+ {
+ xErrorHasOccurred = pdTRUE;
+ }
+
+ if( xErrorHasOccurred == pdFALSE )
+ {
+ /* Toggle the LED if everything is okay so we know if an error occurs even if not
+ using console IO. */
+ vParTestToggleLED( mainCHECK_TASK_LED );
+ }
+}
+/*-----------------------------------------------------------*/
+
+static void prvIncrementResetCount( void )
+{
+unsigned char ucCount;
+
+ eeprom_read_block( &ucCount, mainRESET_COUNT_ADDRESS, sizeof( ucCount ) );
+ ucCount++;
+ eeprom_write_byte( mainRESET_COUNT_ADDRESS, ucCount );
+}
+/*-----------------------------------------------------------*/
+
+void vApplicationIdleHook( void )
+{
+ vCoRoutineSchedule();
+}
+
diff --git a/FreeRTOS/Demo/AVR_ATMega323_WinAVR/makefile b/FreeRTOS/Demo/AVR_ATMega323_WinAVR/makefile
new file mode 100644
index 000000000..9bd557d1b
--- /dev/null
+++ b/FreeRTOS/Demo/AVR_ATMega323_WinAVR/makefile
@@ -0,0 +1,428 @@
+# WinAVR Sample makefile written by Eric B. Weddington, Jörg Wunsch, et al.
+# Released to the Public Domain
+# Please read the make user manual!
+#
+# Additional material for this makefile was submitted by:
+# Tim Henigan
+# Peter Fleury
+# Reiner Patommel
+# Sander Pool
+# Frederik Rouleau
+# Markus Pfaff
+#
+# On command line:
+#
+# make all = Make software.
+#
+# make clean = Clean out built project files.
+#
+# make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB).
+#
+# make extcoff = Convert ELF to AVR Extended COFF (for use with AVR Studio
+# 4.07 or greater).
+#
+# make program = Download the hex file to the device, using avrdude. Please
+# customize the avrdude settings below first!
+#
+# make filename.s = Just compile filename.c into the assembler code only
+#
+# To rebuild project do "make clean" then "make all".
+#
+
+
+# MCU name
+MCU = atmega323
+
+# Output format. (can be srec, ihex, binary)
+FORMAT = ihex
+
+# Target file name (without extension).
+TARGET = rtosdemo
+
+# Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization.
+# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
+OPT = s
+
+
+# List C source files here. (C dependencies are automatically generated.)
+DEMO_DIR = ../Common/Minimal
+SOURCE_DIR = ../../Source
+PORT_DIR = ../../Source/portable/GCC/ATMega323
+
+SRC = \
+main.c \
+ParTest/ParTest.c \
+serial/serial.c \
+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
+
+
+# If there is more than one source file, append them above, or modify and
+# uncomment the following:
+#SRC += foo.c bar.c
+
+# You can also wrap lines by appending a backslash to the end of the line:
+#SRC += baz.c \
+#xyzzy.c
+
+
+
+# List Assembler source files here.
+# Make them always end in a capital .S. Files ending in a lowercase .s
+# will not be considered source files but generated files (assembler
+# output from the compiler), and will be deleted upon "make clean"!
+# Even though the DOS/Win* filesystem matches both .s and .S the same,
+# it will preserve the spelling of the filenames, and gcc itself does
+# care about how the name is spelled on its command-line.
+ASRC =
+
+
+# List any extra directories to look for include files here.
+# Each directory must be seperated by a space.
+EXTRAINCDIRS =
+
+
+# Optional compiler flags.
+# -g: generate debugging information (for GDB, or for COFF conversion)
+# -O*: optimization level
+# -f...: tuning, see gcc manual and avr-libc documentation
+# -Wall...: warning level
+# -Wa,...: tell GCC to pass this to the assembler.
+# -ahlms: create assembler listing
+
+DEBUG_LEVEL=-g
+WARNINGS=-Wall -Wextra -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wsign-compare \
+ -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wunused
+
+CFLAGS = -D GCC_MEGA_AVR -I. -I../../Source/include -I../Common/include \
+$(DEBUG_LEVEL) -O$(OPT) \
+-fsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \
+$(WARNINGS) \
+-Wa,-adhlns=$(<:.c=.lst) \
+$(patsubst %,-I%,$(EXTRAINCDIRS))
+
+
+# Set a "language standard" compiler flag.
+# Unremark just one line below to set the language standard to use.
+# gnu99 = C99 + GNU extensions. See GCC manual for more information.
+#CFLAGS += -std=c89
+#CFLAGS += -std=gnu89
+#CFLAGS += -std=c99
+CFLAGS += -std=gnu99
+
+
+
+# Optional assembler flags.
+# -Wa,...: tell GCC to pass this to the assembler.
+# -ahlms: create listing
+# -gstabs: have the assembler create line number information; note that
+# for use in COFF files, additional information about filenames
+# and function names needs to be present in the assembler source
+# files -- see avr-libc docs [FIXME: not yet described there]
+ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
+
+
+
+# Optional linker flags.
+# -Wl,...: tell GCC to pass this to linker.
+# -Map: create map file
+# --cref: add cross reference to map file
+LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
+
+
+
+# Additional libraries
+
+# Minimalistic printf version
+#LDFLAGS += -Wl,-u,vfprintf -lprintf_min
+
+# Floating point printf version (requires -lm below)
+#LDFLAGS += -Wl,-u,vfprintf -lprintf_flt
+
+# -lm = math library
+LDFLAGS += -lm
+
+
+
+
+# Programming support using avrdude. Settings and variables.
+
+# Programming hardware: alf avr910 avrisp bascom bsd
+# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
+#
+# Type: avrdude -c ?
+# to get a full listing.
+#
+AVRDUDE_PROGRAMMER = stk500
+
+
+AVRDUDE_PORT = com1 # programmer connected to serial device
+#AVRDUDE_PORT = lpt1 # programmer connected to parallel port
+
+AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
+#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
+
+AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)
+
+# Uncomment the following if you want avrdude's erase cycle counter.
+# Note that this counter needs to be initialized first using -Yn,
+# see avrdude manual.
+#AVRDUDE_ERASE += -y
+
+# Uncomment the following if you do /not/ wish a verification to be
+# performed after programming the device.
+#AVRDUDE_FLAGS += -V
+
+# Increase verbosity level. Please use this when submitting bug
+# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
+# to submit bug reports.
+#AVRDUDE_FLAGS += -v -v
+
+
+
+
+# ---------------------------------------------------------------------------
+
+# Define directories, if needed.
+DIRAVR = c:/winavr
+DIRAVRBIN = $(DIRAVR)/bin
+DIRAVRUTILS = $(DIRAVR)/utils/bin
+DIRINC = .
+DIRLIB = $(DIRAVR)/avr/lib
+
+
+# Define programs and commands.
+SHELL = sh
+
+CC = avr-gcc
+
+OBJCOPY = avr-objcopy
+OBJDUMP = avr-objdump
+SIZE = avr-size
+
+
+# Programming support using avrdude.
+AVRDUDE = avrdude
+
+
+REMOVE = rm -f
+COPY = cp
+
+HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
+ELFSIZE = $(SIZE) -A $(TARGET).elf
+
+
+
+# Define Messages
+# English
+MSG_ERRORS_NONE = Errors: none
+MSG_BEGIN = -------- begin --------
+MSG_END = -------- end --------
+MSG_SIZE_BEFORE = Size before:
+MSG_SIZE_AFTER = Size after:
+MSG_COFF = Converting to AVR COFF:
+MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
+MSG_FLASH = Creating load file for Flash:
+MSG_EEPROM = Creating load file for EEPROM:
+MSG_EXTENDED_LISTING = Creating Extended Listing:
+MSG_SYMBOL_TABLE = Creating Symbol Table:
+MSG_LINKING = Linking:
+MSG_COMPILING = Compiling:
+MSG_ASSEMBLING = Assembling:
+MSG_CLEANING = Cleaning project:
+
+
+
+
+# Define all object files.
+OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)
+
+# Define all listing files.
+LST = $(ASRC:.S=.lst) $(SRC:.c=.lst)
+
+# Combine all necessary flags and optional flags.
+# Add target processor to flags.
+ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS)
+ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
+
+
+
+# Default target.
+all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \
+ $(TARGET).lss $(TARGET).sym sizeafter finished end
+
+
+# Eye candy.
+# AVR Studio 3.x does not check make's exit code but relies on
+# the following magic strings to be generated by the compile job.
+begin:
+ @echo
+ @echo $(MSG_BEGIN)
+
+finished:
+ @echo $(MSG_ERRORS_NONE)
+
+end:
+ @echo $(MSG_END)
+ @echo
+
+
+# Display size of file.
+sizebefore:
+ @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi
+
+sizeafter:
+ @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi
+
+
+
+# Display compiler version information.
+gccversion :
+ @$(CC) --version
+
+
+
+
+# Convert ELF to COFF for use in debugging / simulating in
+# AVR Studio or VMLAB.
+COFFCONVERT=$(OBJCOPY) --debugging \
+ --change-section-address .data-0x800000 \
+ --change-section-address .bss-0x800000 \
+ --change-section-address .noinit-0x800000 \
+ --change-section-address .eeprom-0x810000
+
+
+coff: $(TARGET).elf
+ @echo
+ @echo $(MSG_COFF) $(TARGET).cof
+ $(COFFCONVERT) -O coff-avr $< $(TARGET).cof
+
+
+extcoff: $(TARGET).elf
+ @echo
+ @echo $(MSG_EXTENDED_COFF) $(TARGET).cof
+ $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof
+
+
+
+
+# Program the device.
+program: $(TARGET).hex $(TARGET).eep
+ $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
+
+
+
+
+# Create final output files (.hex, .eep) from ELF output file.
+%.hex: %.elf
+ @echo
+ @echo $(MSG_FLASH) $@
+ $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+
+%.eep: %.elf
+ @echo
+ @echo $(MSG_EEPROM) $@
+ -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \
+ --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
+
+# Create extended listing file from ELF output file.
+%.lss: %.elf
+ @echo
+ @echo $(MSG_EXTENDED_LISTING) $@
+ $(OBJDUMP) -h -S $< > $@
+
+# Create a symbol table from ELF output file.
+%.sym: %.elf
+ @echo
+ @echo $(MSG_SYMBOL_TABLE) $@
+ avr-nm -n $< > $@
+
+
+
+# Link: create ELF output file from object files.
+.SECONDARY : $(TARGET).elf
+.PRECIOUS : $(OBJ)
+%.elf: $(OBJ)
+ @echo
+ @echo $(MSG_LINKING) $@
+ $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS)
+
+
+# Compile: create object files from C source files.
+%.o : %.c
+ @echo
+ @echo $(MSG_COMPILING) $<
+ $(CC) -c $(ALL_CFLAGS) $< -o $@
+
+
+# Compile: create assembler files from C source files.
+%.s : %.c
+ $(CC) -S $(ALL_CFLAGS) $< -o $@
+
+
+# Assemble: create object files from assembler source files.
+%.o : %.S
+ @echo
+ @echo $(MSG_ASSEMBLING) $<
+ $(CC) -c $(ALL_ASFLAGS) $< -o $@
+
+
+
+
+
+
+# Target: clean project.
+clean: begin clean_list finished end
+
+clean_list :
+ @echo
+ @echo $(MSG_CLEANING)
+ $(REMOVE) $(TARGET).hex
+ $(REMOVE) $(TARGET).eep
+ $(REMOVE) $(TARGET).obj
+ $(REMOVE) $(TARGET).cof
+ $(REMOVE) $(TARGET).elf
+ $(REMOVE) $(TARGET).map
+ $(REMOVE) $(TARGET).obj
+ $(REMOVE) $(TARGET).a90
+ $(REMOVE) $(TARGET).sym
+ $(REMOVE) $(TARGET).lnk
+ $(REMOVE) $(TARGET).lss
+ $(REMOVE) $(OBJ)
+ $(REMOVE) $(LST)
+ $(REMOVE) $(SRC:.c=.s)
+ $(REMOVE) $(SRC:.c=.d)
+
+
+# Automatically generate C source code dependencies.
+# (Code originally taken from the GNU make user manual and modified
+# (See README.txt Credits).)
+#
+# Note that this will work with sh (bash) and sed that is shipped with WinAVR
+# (see the SHELL variable defined above).
+# This may not work with other shells or other seds.
+#
+%.d: %.c
+ set -e; $(CC) -MM $(ALL_CFLAGS) $< \
+ | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \
+ [ -s $@ ] || rm -f $@
+
+
+# Remove the '-' if you want to see the dependency files generated.
+-include $(SRC:.c=.d)
+
+
+
+# Listing of phony targets.
+.PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \
+ clean clean_list program
+
diff --git a/FreeRTOS/Demo/AVR_ATMega323_WinAVR/regtest.c b/FreeRTOS/Demo/AVR_ATMega323_WinAVR/regtest.c
new file mode 100644
index 000000000..e1639c4bd
--- /dev/null
+++ b/FreeRTOS/Demo/AVR_ATMega323_WinAVR/regtest.c
@@ -0,0 +1,396 @@
+/*
+ FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.
+
+
+ ***************************************************************************
+ * *
+ * FreeRTOS tutorial books are available in pdf and paperback. *
+ * Complete, revised, and edited pdf reference manuals are also *
+ * available. *
+ * *
+ * Purchasing FreeRTOS documentation will not only help you, by *
+ * ensuring you get running as quickly as possible and with an *
+ * in-depth knowledge of how to use FreeRTOS, it will also help *
+ * the FreeRTOS project to continue with its mission of providing *
+ * professional grade, cross platform, de facto standard solutions *
+ * for microcontrollers - completely free of charge! *
+ * *
+ * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
+ * *
+ * Thank you for using FreeRTOS, and thank you for your support! *
+ * *
+ ***************************************************************************
+
+
+ This file is part of the FreeRTOS distribution.
+
+ FreeRTOS is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License (version 2) as published by the
+ Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
+ >>>NOTE<<< The modification to the GPL is included to allow you to
+ distribute a combined work that includes FreeRTOS without being obliged to
+ provide the source code for proprietary components outside of the FreeRTOS
+ kernel. FreeRTOS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details. You should have received a copy of the GNU General Public
+ License and the FreeRTOS license exception along with FreeRTOS; if not it
+ can be viewed here: http://www.freertos.org/a00114.html and also obtained
+ by writing to Richard Barry, contact details for whom are available on the
+ FreeRTOS WEB site.
+
+ 1 tab == 4 spaces!
+
+ ***************************************************************************
+ * *
+ * Having a problem? Start by reading the FAQ "My application does *
+ * not run, what could be wrong? *
+ * *
+ * http://www.FreeRTOS.org/FAQHelp.html *
+ * *
+ ***************************************************************************
+
+
+ http://www.FreeRTOS.org - Documentation, training, latest information,
+ license and contact details.
+
+ http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
+ including FreeRTOS+Trace - an indispensable productivity tool.
+
+ Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
+ the code with commercial support, indemnification, and middleware, under
+ the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
+ provide a safety engineered and independently SIL3 certified version under
+ the SafeRTOS brand: http://www.SafeRTOS.com.
+*/
+
+/* Scheduler include files. */
+#include "FreeRTOS.h"
+#include "task.h"
+
+/* Demo file headers. */
+#include "regtest.h"
+
+/*
+ * Test tasks that sets registers to known values, then checks to ensure the
+ * values remain as expected. Test 1 and test 2 use different values.
+ */
+static void prvRegisterCheck1( void *pvParameters );
+static void prvRegisterCheck2( void *pvParameters );
+
+/* Set to a non zero value should an error be found. */
+portBASE_TYPE xRegTestError = pdFALSE;
+
+/*-----------------------------------------------------------*/
+
+void vStartRegTestTasks( void )
+{
+ xTaskCreate( prvRegisterCheck1, ( signed char * ) "Reg1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
+ xTaskCreate( prvRegisterCheck2, ( signed char * ) "Reg2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
+}
+/*-----------------------------------------------------------*/
+
+portBASE_TYPE xAreRegTestTasksStillRunning( void )
+{
+portBASE_TYPE xReturn;
+
+ /* If a register was found to contain an unexpected value then the
+ xRegTestError variable would have been set to a non zero value. */
+ if( xRegTestError == pdFALSE )
+ {
+ xReturn = pdTRUE;
+ }
+ else
+ {
+ xReturn = pdFALSE;
+ }
+
+ return xReturn;
+}
+/*-----------------------------------------------------------*/
+
+static void prvRegisterCheck1( void *pvParameters )
+{
+ ( void ) pvParameters;
+
+ for( ;; )
+ {
+ asm( "LDI r31, 5" );
+ asm( "MOV r0, r31" );
+ asm( "LDI r31, 6" );
+ asm( "MOV r1, r31" );
+ asm( "LDI r31, 7" );
+ asm( "MOV r2, r31" );
+ asm( "LDI r31, 8" );
+ asm( "MOV r3, r31" );
+ asm( "LDI r31, 9" );
+ asm( "MOV r4, r31" );
+ asm( "LDI r31, 10" );
+ asm( "MOV r5, r31" );
+ asm( "LDI r31, 11" );
+ asm( "MOV r6, r31" );
+ asm( "LDI r31, 12" );
+ asm( "MOV r7, r31" );
+ asm( "LDI r31, 13" );
+ asm( "MOV r8, r31" );
+ asm( "LDI r31, 14" );
+ asm( "MOV r9, r31" );
+ asm( "LDI r31, 15" );
+ asm( "MOV r10, r31" );
+ asm( "LDI r31, 16" );
+ asm( "MOV r11, r31" );
+ asm( "LDI r31, 17" );
+ asm( "MOV r12, r31" );
+ asm( "LDI r31, 18" );
+ asm( "MOV r13, r31" );
+ asm( "LDI r31, 19" );
+ asm( "MOV r14, r31" );
+ asm( "LDI r31, 20" );
+ asm( "MOV r15, r31" );
+ asm( "LDI r16, 21" );
+ asm( "LDI r17, 22" );
+ asm( "LDI r18, 23" );
+ asm( "LDI r19, 24" );
+ asm( "LDI r20, 25" );
+ asm( "LDI r21, 26" );
+ asm( "LDI r22, 27" );
+ asm( "LDI r23, 28" );
+ asm( "LDI r24, 29" );
+ asm( "LDI r25, 30" );
+ asm( "LDI r26, 31" );
+ asm( "LDI r27, 32" );
+ asm( "LDI r30, 33" );
+
+ asm( "LDI r31, 5" );
+ asm( "CPSE r31, r0" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 6" );
+ asm( "CPSE r31, r1" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 7" );
+ asm( "CPSE r31, r2" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 8" );
+ asm( "CPSE r31, r3" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 9" );
+ asm( "CPSE r31, r4" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 10" );
+ asm( "CPSE r31, r5" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 11" );
+ asm( "CPSE r31, r6" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 12" );
+ asm( "CPSE r31, r7" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 13" );
+ asm( "CPSE r31, r8" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 14" );
+ asm( "CPSE r31, r9" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 15" );
+ asm( "CPSE r31, r10" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 16" );
+ asm( "CPSE r31, r11" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 17" );
+ asm( "CPSE r31, r12" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 18" );
+ asm( "CPSE r31, r13" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 19" );
+ asm( "CPSE r31, r14" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 20" );
+ asm( "CPSE r31, r15" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 21" );
+ asm( "CPSE r31, r16" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 22" );
+ asm( "CPSE r31, r17" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 23" );
+ asm( "CPSE r31, r18" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 24" );
+ asm( "CPSE r31, r19" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 25" );
+ asm( "CPSE r31, r20" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 26" );
+ asm( "CPSE r31, r21" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 27" );
+ asm( "CPSE r31, r22" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 28" );
+ asm( "CPSE r31, r23" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 29" );
+ asm( "CPSE r31, r24" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 30" );
+ asm( "CPSE r31, r25" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 31" );
+ asm( "CPSE r31, r26" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 32" );
+ asm( "CPSE r31, r27" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 33" );
+ asm( "CPSE r31, r30" );
+ asm( "STS xRegTestError, r0" );
+ }
+}
+/*-----------------------------------------------------------*/
+
+static void prvRegisterCheck2( void *pvParameters )
+{
+ ( void ) pvParameters;
+
+ for( ;; )
+ {
+ asm( "LDI r31, 1" );
+ asm( "MOV r0, r31" );
+ asm( "LDI r31, 2" );
+ asm( "MOV r1, r31" );
+ asm( "LDI r31, 3" );
+ asm( "MOV r2, r31" );
+ asm( "LDI r31, 4" );
+ asm( "MOV r3, r31" );
+ asm( "LDI r31, 5" );
+ asm( "MOV r4, r31" );
+ asm( "LDI r31, 6" );
+ asm( "MOV r5, r31" );
+ asm( "LDI r31, 7" );
+ asm( "MOV r6, r31" );
+ asm( "LDI r31, 8" );
+ asm( "MOV r7, r31" );
+ asm( "LDI r31, 9" );
+ asm( "MOV r8, r31" );
+ asm( "LDI r31, 10" );
+ asm( "MOV r9, r31" );
+ asm( "LDI r31, 11" );
+ asm( "MOV r10, r31" );
+ asm( "LDI r31, 12" );
+ asm( "MOV r11, r31" );
+ asm( "LDI r31, 13" );
+ asm( "MOV r12, r31" );
+ asm( "LDI r31, 14" );
+ asm( "MOV r13, r31" );
+ asm( "LDI r31, 15" );
+ asm( "MOV r14, r31" );
+ asm( "LDI r31, 16" );
+ asm( "MOV r15, r31" );
+ asm( "LDI r16, 17" );
+ asm( "LDI r17, 18" );
+ asm( "LDI r18, 19" );
+ asm( "LDI r19, 20" );
+ asm( "LDI r20, 21" );
+ asm( "LDI r21, 22" );
+ asm( "LDI r22, 23" );
+ asm( "LDI r23, 24" );
+ asm( "LDI r24, 25" );
+ asm( "LDI r25, 26" );
+ asm( "LDI r26, 27" );
+ asm( "LDI r27, 28" );
+ asm( "LDI r30, 29" );
+
+ asm( "LDI r31, 1" );
+ asm( "CPSE r31, r0" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 2" );
+ asm( "CPSE r31, r1" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 3" );
+ asm( "CPSE r31, r2" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 4" );
+ asm( "CPSE r31, r3" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 5" );
+ asm( "CPSE r31, r4" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 6" );
+ asm( "CPSE r31, r5" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 7" );
+ asm( "CPSE r31, r6" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 8" );
+ asm( "CPSE r31, r7" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 9" );
+ asm( "CPSE r31, r8" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 10" );
+ asm( "CPSE r31, r9" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 11" );
+ asm( "CPSE r31, r10" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 12" );
+ asm( "CPSE r31, r11" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 13" );
+ asm( "CPSE r31, r12" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 14" );
+ asm( "CPSE r31, r13" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 15" );
+ asm( "CPSE r31, r14" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 16" );
+ asm( "CPSE r31, r15" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 17" );
+ asm( "CPSE r31, r16" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 18" );
+ asm( "CPSE r31, r17" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 19" );
+ asm( "CPSE r31, r18" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 20" );
+ asm( "CPSE r31, r19" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 21" );
+ asm( "CPSE r31, r20" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 22" );
+ asm( "CPSE r31, r21" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 23" );
+ asm( "CPSE r31, r22" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 24" );
+ asm( "CPSE r31, r23" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 25" );
+ asm( "CPSE r31, r24" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 26" );
+ asm( "CPSE r31, r25" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 27" );
+ asm( "CPSE r31, r26" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 28" );
+ asm( "CPSE r31, r27" );
+ asm( "STS xRegTestError, r0" );
+ asm( "LDI r31, 29" );
+ asm( "CPSE r31, r30" );
+ asm( "STS xRegTestError, r0" );
+ }
+}
+
diff --git a/FreeRTOS/Demo/AVR_ATMega323_WinAVR/regtest.h b/FreeRTOS/Demo/AVR_ATMega323_WinAVR/regtest.h
new file mode 100644
index 000000000..17df9f0ca
--- /dev/null
+++ b/FreeRTOS/Demo/AVR_ATMega323_WinAVR/regtest.h
@@ -0,0 +1,74 @@
+/*
+ FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.
+
+
+ ***************************************************************************
+ * *
+ * FreeRTOS tutorial books are available in pdf and paperback. *
+ * Complete, revised, and edited pdf reference manuals are also *
+ * available. *
+ * *
+ * Purchasing FreeRTOS documentation will not only help you, by *
+ * ensuring you get running as quickly as possible and with an *
+ * in-depth knowledge of how to use FreeRTOS, it will also help *
+ * the FreeRTOS project to continue with its mission of providing *
+ * professional grade, cross platform, de facto standard solutions *
+ * for microcontrollers - completely free of charge! *
+ * *
+ * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
+ * *
+ * Thank you for using FreeRTOS, and thank you for your support! *
+ * *
+ ***************************************************************************
+
+
+ This file is part of the FreeRTOS distribution.
+
+ FreeRTOS is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License (version 2) as published by the
+ Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
+ >>>NOTE<<< The modification to the GPL is included to allow you to
+ distribute a combined work that includes FreeRTOS without being obliged to
+ provide the source code for proprietary components outside of the FreeRTOS
+ kernel. FreeRTOS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details. You should have received a copy of the GNU General Public
+ License and the FreeRTOS license exception along with FreeRTOS; if not it
+ can be viewed here: http://www.freertos.org/a00114.html and also obtained
+ by writing to Richard Barry, contact details for whom are available on the
+ FreeRTOS WEB site.
+
+ 1 tab == 4 spaces!
+
+ ***************************************************************************
+ * *
+ * Having a problem? Start by reading the FAQ "My application does *
+ * not run, what could be wrong? *
+ * *
+ * http://www.FreeRTOS.org/FAQHelp.html *
+ * *
+ ***************************************************************************
+
+
+ http://www.FreeRTOS.org - Documentation, training, latest information,
+ license and contact details.
+
+ http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
+ including FreeRTOS+Trace - an indispensable productivity tool.
+
+ Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
+ the code with commercial support, indemnification, and middleware, under
+ the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
+ provide a safety engineered and independently SIL3 certified version under
+ the SafeRTOS brand: http://www.SafeRTOS.com.
+*/
+
+#ifndef REG_TEST_H
+#define REG_TEST_H
+
+void vStartRegTestTasks( void );
+portBASE_TYPE xAreRegTestTasksStillRunning( void );
+
+#endif
+
diff --git a/FreeRTOS/Demo/AVR_ATMega323_WinAVR/serial/serial.c b/FreeRTOS/Demo/AVR_ATMega323_WinAVR/serial/serial.c
new file mode 100644
index 000000000..ff1b01414
--- /dev/null
+++ b/FreeRTOS/Demo/AVR_ATMega323_WinAVR/serial/serial.c
@@ -0,0 +1,261 @@
+/*
+ FreeRTOS V7.1.1 - Copyright (C) 2012 Real Time Engineers Ltd.
+
+
+ ***************************************************************************
+ * *
+ * FreeRTOS tutorial books are available in pdf and paperback. *
+ * Complete, revised, and edited pdf reference manuals are also *
+ * available. *
+ * *
+ * Purchasing FreeRTOS documentation will not only help you, by *
+ * ensuring you get running as quickly as possible and with an *
+ * in-depth knowledge of how to use FreeRTOS, it will also help *
+ * the FreeRTOS project to continue with its mission of providing *
+ * professional grade, cross platform, de facto standard solutions *
+ * for microcontrollers - completely free of charge! *
+ * *
+ * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
+ * *
+ * Thank you for using FreeRTOS, and thank you for your support! *
+ * *
+ ***************************************************************************
+
+
+ This file is part of the FreeRTOS distribution.
+
+ FreeRTOS is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License (version 2) as published by the
+ Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
+ >>>NOTE<<< The modification to the GPL is included to allow you to
+ distribute a combined work that includes FreeRTOS without being obliged to
+ provide the source code for proprietary components outside of the FreeRTOS
+ kernel. FreeRTOS is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ more details. You should have received a copy of the GNU General Public
+ License and the FreeRTOS license exception along with FreeRTOS; if not it
+ can be viewed here: http://www.freertos.org/a00114.html and also obtained
+ by writing to Richard Barry, contact details for whom are available on the
+ FreeRTOS WEB site.
+
+ 1 tab == 4 spaces!
+
+ ***************************************************************************
+ * *
+ * Having a problem? Start by reading the FAQ "My application does *
+ * not run, what could be wrong? *
+ * *
+ * http://www.FreeRTOS.org/FAQHelp.html *
+ * *
+ ***************************************************************************
+
+
+ http://www.FreeRTOS.org - Documentation, training, latest information,
+ license and contact details.
+
+ http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
+ including FreeRTOS+Trace - an indispensable productivity tool.
+
+ Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
+ the code with commercial support, indemnification, and middleware, under
+ the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
+ provide a safety engineered and independently SIL3 certified version under
+ the SafeRTOS brand: http://www.SafeRTOS.com.
+*/
+
+/*
+Changes from V1.2.3
+
+ + The function xPortInitMinimal() has been renamed to
+ xSerialPortInitMinimal() and the function xPortInit() has been renamed
+ to xSerialPortInit().
+
+Changes from V2.0.0
+
+ + Delay periods are now specified using variables and constants of
+ portTickType rather than unsigned long.
+ + xQueueReceiveFromISR() used in place of xQueueReceive() within the ISR.
+
+Changes from V2.6.0
+
+ + Replaced the inb() and outb() functions with direct memory
+ access. This allows the port to be built with the 20050414 build of
+ WinAVR.
+*/
+
+/* BASIC INTERRUPT DRIVEN SERIAL PORT DRIVER. */
+
+
+#include <stdlib.h>
+#include <avr/interrupt.h>
+#include "FreeRTOS.h"
+#include "queue.h"
+#include "task.h"
+#include "serial.h"
+
+#define serBAUD_DIV_CONSTANT ( ( unsigned long ) 16 )
+
+/* Constants for writing to UCSRB. */
+#define serRX_INT_ENABLE ( ( unsigned char ) 0x80 )
+#define serRX_ENABLE ( ( unsigned char ) 0x10 )
+#define serTX_ENABLE ( ( unsigned char ) 0x08 )
+#define serTX_INT_ENABLE ( ( unsigned char ) 0x20 )
+
+/* Constants for writing to UCSRC. */
+#define serUCSRC_SELECT ( ( unsigned char ) 0x80 )
+#define serEIGHT_DATA_BITS ( ( unsigned char ) 0x06 )
+
+static xQueueHandle xRxedChars;
+static xQueueHandle xCharsForTx;
+
+#define vInterruptOn() \
+{ \
+ unsigned char ucByte; \
+ \
+ ucByte = UCSRB; \
+ ucByte |= serTX_INT_ENABLE; \
+ UCSRB = ucByte; \
+}
+/*-----------------------------------------------------------*/
+
+#define vInterruptOff() \
+{ \
+ unsigned char ucInByte; \
+ \
+ ucInByte = UCSRB; \
+ ucInByte &= ~serTX_INT_ENABLE; \
+ UCSRB = ucInByte; \
+}
+/*-----------------------------------------------------------*/
+
+xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
+{
+unsigned long ulBaudRateCounter;
+unsigned char ucByte;
+
+ portENTER_CRITICAL();
+ {
+ /* Create the queues used by the com test task. */
+ xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed char ) );
+ xCharsForTx = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed char ) );
+
+ /* Calculate the baud rate register value from the equation in the
+ data sheet. */
+ ulBaudRateCounter = ( configCPU_CLOCK_HZ / ( serBAUD_DIV_CONSTANT * ulWantedBaud ) ) - ( unsigned long ) 1;
+
+ /* Set the baud rate. */
+ ucByte = ( unsigned char ) ( ulBaudRateCounter & ( unsigned long ) 0xff );
+ UBRRL = ucByte;
+
+ ulBaudRateCounter >>= ( unsigned long ) 8;
+ ucByte = ( unsigned char ) ( ulBaudRateCounter & ( unsigned long ) 0xff );
+ UBRRH = ucByte;
+
+ /* Enable the Rx interrupt. The Tx interrupt will get enabled
+ later. Also enable the Rx and Tx. */
+ UCSRB = ( serRX_INT_ENABLE | serRX_ENABLE | serTX_ENABLE );
+
+ /* Set the data bits to 8. */
+ UCSRC = ( serUCSRC_SELECT | serEIGHT_DATA_BITS );
+ }
+ portEXIT_CRITICAL();
+
+ /* Unlike other ports, this serial code does not allow for more than one
+ com port. We therefore don't return a pointer to a port structure and can
+ instead just return NULL. */
+ return NULL;
+}
+/*-----------------------------------------------------------*/
+
+signed portBASE_TYPE xSerialGetChar( xComPortHandle pxPort, signed char *pcRxedChar, portTickType xBlockTime )
+{
+ /* Only one port is supported. */
+ ( void ) pxPort;
+
+ /* Get the next character from the buffer. Return false if no characters
+ are available, or arrive before xBlockTime expires. */
+ if( xQueueReceive( xRxedChars, pcRxedChar, xBlockTime ) )
+ {
+ return pdTRUE;
+ }
+ else
+ {
+ return pdFALSE;
+ }
+}
+/*-----------------------------------------------------------*/
+
+signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, portTickType xBlockTime )
+{
+ /* Only one port is supported. */
+ ( void ) pxPort;
+
+ /* Return false if after the block time there is no room on the Tx queue. */
+ if( xQueueSend( xCharsForTx, &cOutChar, xBlockTime ) != pdPASS )
+ {
+ return pdFAIL;
+ }
+
+ vInterruptOn();
+
+ return pdPASS;
+}
+/*-----------------------------------------------------------*/
+
+void vSerialClose( xComPortHandle xPort )
+{
+unsigned char ucByte;
+
+ /* The parameter is not used. */
+ ( void ) xPort;
+
+ /* Turn off the interrupts. We may also want to delete the queues and/or
+ re-install the original ISR. */
+
+ portENTER_CRITICAL();
+ {
+ vInterruptOff();
+ ucByte = UCSRB;
+ ucByte &= ~serRX_INT_ENABLE;
+ UCSRB = ucByte;
+ }
+ portEXIT_CRITICAL();
+}
+/*-----------------------------------------------------------*/
+
+SIGNAL( SIG_UART_RECV )
+{
+signed char cChar;
+signed portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
+
+ /* Get the character and post it on the queue of Rxed characters.
+ If the post causes a task to wake force a context switch as the woken task
+ may have a higher priority than the task we have interrupted. */
+ cChar = UDR;
+
+ xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken );
+
+ if( xHigherPriorityTaskWoken != pdFALSE )
+ {
+ taskYIELD();
+ }
+}
+/*-----------------------------------------------------------*/
+
+SIGNAL( SIG_UART_DATA )
+{
+signed char cChar, cTaskWoken;
+
+ if( xQueueReceiveFromISR( xCharsForTx, &cChar, &cTaskWoken ) == pdTRUE )
+ {
+ /* Send the next character queued for Tx. */
+ UDR = cChar;
+ }
+ else
+ {
+ /* Queue empty, nothing to send. */
+ vInterruptOff();
+ }
+}
+