+/*\r
+ FreeRTOS.org V4.0.5 - Copyright (C) 2003-2006 Richard Barry.\r
+\r
+ This file is part of the FreeRTOS.org distribution.\r
+\r
+ FreeRTOS.org is free software; you can redistribute it and/or modify\r
+ it under the terms of the GNU General Public License as published by\r
+ the Free Software Foundation; either version 2 of the License, or\r
+ (at your option) any later version.\r
+\r
+ FreeRTOS.org is distributed in the hope that it will be useful,\r
+ but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ GNU General Public License for more details.\r
+\r
+ You should have received a copy of the GNU General Public License\r
+ along with FreeRTOS.org; if not, write to the Free Software\r
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\r
+\r
+ A special exception to the GPL can be applied should you wish to distribute\r
+ a combined work that includes FreeRTOS.org, without being obliged to provide\r
+ the source code for any proprietary components. See the licensing section\r
+ of http://www.FreeRTOS.org for full details of how and when the exception\r
+ can be applied.\r
+\r
+ ***************************************************************************\r
+ See http://www.FreeRTOS.org for documentation, latest information, license\r
+ and contact details. Please ensure to read the configuration and relevant\r
+ port sections of the online documentation.\r
+ ***************************************************************************\r
+*/\r
+\r
+/* Scheduler include files. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+\r
+/* Demo file headers. */\r
+#include "regtest.h"\r
+\r
+/*\r
+ * Test tasks that sets registers to known values, then checks to ensure the\r
+ * values remain as expected. Test 1 and test 2 use different values.\r
+ */\r
+static void prvRegisterCheck1( void *pvParameters );\r
+static void prvRegisterCheck2( void *pvParameters );\r
+\r
+/* Set to a non zero value should an error be found. */\r
+portBASE_TYPE xRegTestError = pdFALSE;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void vStartRegTestTasks( void )\r
+{\r
+ xTaskCreate( prvRegisterCheck1, "Reg1", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );\r
+ xTaskCreate( prvRegisterCheck2, "Reg2", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); \r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+portBASE_TYPE xAreRegTestTasksStillRunning( void )\r
+{\r
+portBASE_TYPE xReturn;\r
+\r
+ /* If a register was found to contain an unexpected value then the\r
+ xRegTestError variable would have been set to a non zero value. */\r
+ if( xRegTestError == pdFALSE )\r
+ {\r
+ xReturn = pdTRUE;\r
+ }\r
+ else\r
+ {\r
+ xReturn = pdFALSE;\r
+ }\r
+ \r
+ return xReturn;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvRegisterCheck1( void *pvParameters )\r
+{\r
+ ( void ) pvParameters;\r
+\r
+ for( ;; )\r
+ {\r
+ asm( "LDI r31, 5" ); \r
+ asm( "MOV r0, r31" );\r
+ asm( "LDI r31, 6" );\r
+ asm( "MOV r1, r31" );\r
+ asm( "LDI r31, 7" );\r
+ asm( "MOV r2, r31" );\r
+ asm( "LDI r31, 8" );\r
+ asm( "MOV r3, r31" );\r
+ asm( "LDI r31, 9" );\r
+ asm( "MOV r4, r31" );\r
+ asm( "LDI r31, 10" );\r
+ asm( "MOV r5, r31" );\r
+ asm( "LDI r31, 11" );\r
+ asm( "MOV r6, r31" );\r
+ asm( "LDI r31, 12" );\r
+ asm( "MOV r7, r31" );\r
+ asm( "LDI r31, 13" );\r
+ asm( "MOV r8, r31" );\r
+ asm( "LDI r31, 14" );\r
+ asm( "MOV r9, r31" );\r
+ asm( "LDI r31, 15" );\r
+ asm( "MOV r10, r31" );\r
+ asm( "LDI r31, 16" );\r
+ asm( "MOV r11, r31" );\r
+ asm( "LDI r31, 17" );\r
+ asm( "MOV r12, r31" );\r
+ asm( "LDI r31, 18" );\r
+ asm( "MOV r13, r31" );\r
+ asm( "LDI r31, 19" );\r
+ asm( "MOV r14, r31" );\r
+ asm( "LDI r31, 20" );\r
+ asm( "MOV r15, r31" );\r
+ asm( "LDI r16, 21" );\r
+ asm( "LDI r17, 22" );\r
+ asm( "LDI r18, 23" );\r
+ asm( "LDI r19, 24" );\r
+ asm( "LDI r20, 25" );\r
+ asm( "LDI r21, 26" );\r
+ asm( "LDI r22, 27" );\r
+ asm( "LDI r23, 28" );\r
+ asm( "LDI r24, 29" );\r
+ asm( "LDI r25, 30" );\r
+ asm( "LDI r26, 31" );\r
+ asm( "LDI r27, 32" );\r
+ asm( "LDI r30, 33" );\r
+\r
+ asm( "LDI r31, 5" );\r
+ asm( "CPSE r31, r0" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 6" );\r
+ asm( "CPSE r31, r1" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 7" );\r
+ asm( "CPSE r31, r2" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 8" );\r
+ asm( "CPSE r31, r3" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 9" );\r
+ asm( "CPSE r31, r4" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 10" );\r
+ asm( "CPSE r31, r5" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 11" );\r
+ asm( "CPSE r31, r6" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 12" );\r
+ asm( "CPSE r31, r7" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 13" );\r
+ asm( "CPSE r31, r8" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 14" );\r
+ asm( "CPSE r31, r9" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 15" );\r
+ asm( "CPSE r31, r10" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 16" );\r
+ asm( "CPSE r31, r11" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 17" );\r
+ asm( "CPSE r31, r12" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 18" );\r
+ asm( "CPSE r31, r13" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 19" );\r
+ asm( "CPSE r31, r14" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 20" );\r
+ asm( "CPSE r31, r15" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 21" );\r
+ asm( "CPSE r31, r16" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 22" );\r
+ asm( "CPSE r31, r17" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 23" );\r
+ asm( "CPSE r31, r18" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 24" );\r
+ asm( "CPSE r31, r19" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 25" );\r
+ asm( "CPSE r31, r20" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 26" );\r
+ asm( "CPSE r31, r21" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 27" );\r
+ asm( "CPSE r31, r22" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 28" );\r
+ asm( "CPSE r31, r23" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 29" );\r
+ asm( "CPSE r31, r24" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 30" );\r
+ asm( "CPSE r31, r25" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 31" );\r
+ asm( "CPSE r31, r26" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 32" );\r
+ asm( "CPSE r31, r27" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 33" );\r
+ asm( "CPSE r31, r30" );\r
+ asm( "STS xRegTestError, r0" );\r
+ }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvRegisterCheck2( void *pvParameters )\r
+{\r
+ ( void ) pvParameters;\r
+\r
+ for( ;; )\r
+ {\r
+ asm( "LDI r31, 1" ); \r
+ asm( "MOV r0, r31" );\r
+ asm( "LDI r31, 2" );\r
+ asm( "MOV r1, r31" );\r
+ asm( "LDI r31, 3" );\r
+ asm( "MOV r2, r31" );\r
+ asm( "LDI r31, 4" );\r
+ asm( "MOV r3, r31" );\r
+ asm( "LDI r31, 5" );\r
+ asm( "MOV r4, r31" );\r
+ asm( "LDI r31, 6" );\r
+ asm( "MOV r5, r31" );\r
+ asm( "LDI r31, 7" );\r
+ asm( "MOV r6, r31" );\r
+ asm( "LDI r31, 8" );\r
+ asm( "MOV r7, r31" );\r
+ asm( "LDI r31, 9" );\r
+ asm( "MOV r8, r31" );\r
+ asm( "LDI r31, 10" );\r
+ asm( "MOV r9, r31" );\r
+ asm( "LDI r31, 11" );\r
+ asm( "MOV r10, r31" );\r
+ asm( "LDI r31, 12" );\r
+ asm( "MOV r11, r31" );\r
+ asm( "LDI r31, 13" );\r
+ asm( "MOV r12, r31" );\r
+ asm( "LDI r31, 14" );\r
+ asm( "MOV r13, r31" );\r
+ asm( "LDI r31, 15" );\r
+ asm( "MOV r14, r31" );\r
+ asm( "LDI r31, 16" );\r
+ asm( "MOV r15, r31" );\r
+ asm( "LDI r16, 17" );\r
+ asm( "LDI r17, 18" );\r
+ asm( "LDI r18, 19" );\r
+ asm( "LDI r19, 20" );\r
+ asm( "LDI r20, 21" );\r
+ asm( "LDI r21, 22" );\r
+ asm( "LDI r22, 23" );\r
+ asm( "LDI r23, 24" );\r
+ asm( "LDI r24, 25" );\r
+ asm( "LDI r25, 26" );\r
+ asm( "LDI r26, 27" );\r
+ asm( "LDI r27, 28" );\r
+ asm( "LDI r30, 29" );\r
+\r
+ asm( "LDI r31, 1" );\r
+ asm( "CPSE r31, r0" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 2" );\r
+ asm( "CPSE r31, r1" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 3" );\r
+ asm( "CPSE r31, r2" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 4" );\r
+ asm( "CPSE r31, r3" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 5" );\r
+ asm( "CPSE r31, r4" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 6" );\r
+ asm( "CPSE r31, r5" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 7" );\r
+ asm( "CPSE r31, r6" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 8" );\r
+ asm( "CPSE r31, r7" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 9" );\r
+ asm( "CPSE r31, r8" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 10" );\r
+ asm( "CPSE r31, r9" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 11" );\r
+ asm( "CPSE r31, r10" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 12" );\r
+ asm( "CPSE r31, r11" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 13" );\r
+ asm( "CPSE r31, r12" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 14" );\r
+ asm( "CPSE r31, r13" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 15" );\r
+ asm( "CPSE r31, r14" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 16" );\r
+ asm( "CPSE r31, r15" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 17" );\r
+ asm( "CPSE r31, r16" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 18" );\r
+ asm( "CPSE r31, r17" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 19" );\r
+ asm( "CPSE r31, r18" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 20" );\r
+ asm( "CPSE r31, r19" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 21" );\r
+ asm( "CPSE r31, r20" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 22" );\r
+ asm( "CPSE r31, r21" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 23" );\r
+ asm( "CPSE r31, r22" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 24" );\r
+ asm( "CPSE r31, r23" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 25" );\r
+ asm( "CPSE r31, r24" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 26" );\r
+ asm( "CPSE r31, r25" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 27" );\r
+ asm( "CPSE r31, r26" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 28" );\r
+ asm( "CPSE r31, r27" );\r
+ asm( "STS xRegTestError, r0" );\r
+ asm( "LDI r31, 29" );\r
+ asm( "CPSE r31, r30" );\r
+ asm( "STS xRegTestError, r0" );\r
+ }\r
+}\r
+\r