]> git.sur5r.net Git - freertos/commitdiff
Complete SAMD20 demo - still needs tidy up.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 8 Oct 2013 15:56:06 +0000 (15:56 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 8 Oct 2013 15:56:06 +0000 (15:56 +0000)
Add comments to the XMC1000 reg test files.

git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2058 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

14 files changed:
FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo.atsuo
FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/RTOSDemo.cproj
FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/ASF/sam0/drivers/sercom/sercom_interrupt.c
FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/ASF/sam0/drivers/sercom/usart/usart_interrupt.c
FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/RegTest.c [new file with mode: 0644]
FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/config/FreeRTOSConfig.h
FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/config/conf_clocks.h
FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/main-blinky.c [new file with mode: 0644]
FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/main-full.c [new file with mode: 0644]
FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/main.c
FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/printf-stdarg.c [new file with mode: 0644]
FreeRTOS/Demo/CORTEX_M0_Infineon_XMC1000_IAR_Keil_GCC/Atollic_Specific/RegTest.c
FreeRTOS/Demo/CORTEX_M0_Infineon_XMC1000_IAR_Keil_GCC/IAR_Specific/RegTest_IAR.s
FreeRTOS/Demo/CORTEX_M0_Infineon_XMC1000_IAR_Keil_GCC/Keil_Specific/RegTest_Keil.s

index c05015591135a7018cf9d0f1d9c37d13f3b57667..deb7a887dfad740137ab7e0b6926d6d968b4794f 100644 (file)
Binary files a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo.atsuo and b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo.atsuo differ
index e3144d198ff08aa9b75a57fd492629e542cfe350..8bd150753f6b62fa45f33b318b2675ac54325514 100644 (file)
       <Value>../../../../Source/include</Value>\r
       <Value>../../../../Source/portable/GCC/ARM_CM0</Value>\r
       <Value>../../../../../FreeRTOS-Plus/Source/FreeRTOS-Plus-CLI</Value>\r
+      <Value>../../../Common/include</Value>\r
     </ListValues>\r
   </armgcc.compiler.directories.IncludePaths>\r
   <armgcc.compiler.optimization.OtherFlags>-fdata-sections</armgcc.compiler.optimization.OtherFlags>\r
     <GenerateEepFile>True</GenerateEepFile>\r
   </PropertyGroup>\r
   <ItemGroup>\r
+    <Compile Include="..\..\Common\Minimal\blocktim.c">\r
+      <SubType>compile</SubType>\r
+      <Link>src\Common-Demo-Tasks\blocktim.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\Common\Minimal\countsem.c">\r
+      <SubType>compile</SubType>\r
+      <Link>src\Common-Demo-Tasks\countsem.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\Common\Minimal\dynamic.c">\r
+      <SubType>compile</SubType>\r
+      <Link>src\Common-Demo-Tasks\dynamic.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\Common\Minimal\GenQTest.c">\r
+      <SubType>compile</SubType>\r
+      <Link>src\Common-Demo-Tasks\GenQTest.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\Common\Minimal\QueueOverwrite.c">\r
+      <SubType>compile</SubType>\r
+      <Link>src\Common-Demo-Tasks\QueueOverwrite.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\Common\Minimal\QueueSet.c">\r
+      <SubType>compile</SubType>\r
+      <Link>src\Common-Demo-Tasks\QueueSet.c</Link>\r
+    </Compile>\r
+    <Compile Include="..\..\Common\Minimal\recmutex.c">\r
+      <SubType>compile</SubType>\r
+      <Link>src\Common-Demo-Tasks\recmutex.c</Link>\r
+    </Compile>\r
+    <Compile Include="src\Common-Demo-Tasks\QPeek.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="src\main-blinky.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="src\main-full.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="src\printf-stdarg.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
+    <Compile Include="src\RegTest.c">\r
+      <SubType>compile</SubType>\r
+    </Compile>\r
     <Compile Include="src\Sample-CLI-commands.c">\r
       <SubType>compile</SubType>\r
     </Compile>\r
     <Compile Include="src\ASF\sam0\utils\cmsis\samd20\source\system_samd20.c">\r
       <SubType>compile</SubType>\r
     </Compile>\r
-    <Compile Include="src\ASF\sam0\utils\syscalls\gcc\syscalls.c">\r
+    <None Include="src\ASF\sam0\utils\syscalls\gcc\syscalls.c">\r
       <SubType>compile</SubType>\r
-    </Compile>\r
+    </None>\r
     <None Include="src\asf.h">\r
       <SubType>compile</SubType>\r
     </None>\r
     <Folder Include="src\FreeRTOS-Source\include" />\r
     <Folder Include="src\FreeRTOS-Source\portable" />\r
     <Folder Include="src\FreeRTOS-CLI" />\r
+    <Folder Include="src\Common-Demo-Tasks" />\r
   </ItemGroup>\r
   <Import Project="$(AVRSTUDIO_EXE_PATH)\\Vs\\Compiler.targets" />\r
 </Project>
\ No newline at end of file
index 042e5b30ddfc6757b233f287ca5e65b98afe2ce0..5de0a7261d7e36e4e16a82f23783706734161f87 100644 (file)
@@ -59,6 +59,7 @@ static void (*_sercom_interrupt_handlers[SERCOM_INST_NUM])(const uint8_t instanc
 static void _sercom_default_handler(\r
                const uint8_t instance)\r
 {\r
+       ( void ) instance;\r
        Assert(false);\r
 }\r
 \r
index e0dec61a03e3cec359fb0cd56b376e5e4e7eb960..acf7f18079c08e6ab5558a70dc4a89a76f11207e 100644 (file)
@@ -482,8 +482,11 @@ void _usart_interrupt_handler(
                module->tx_status = STATUS_OK;\r
 \r
                /* Run callback if registered and enabled */\r
-               if (callback_status & (1 << USART_CALLBACK_BUFFER_TRANSMITTED)) {\r
-                       (*(module->callback[USART_CALLBACK_BUFFER_TRANSMITTED]))(module);\r
+               if( module->remaining_tx_buffer_length == 0 ) /* Added by _RB_ */\r
+               {\r
+                       if (callback_status & (1 << USART_CALLBACK_BUFFER_TRANSMITTED)) {\r
+                               (*(module->callback[USART_CALLBACK_BUFFER_TRANSMITTED]))(module);\r
+                       }\r
                }\r
 \r
        /* Check if the Receive Complete interrupt has occurred, and that\r
diff --git a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/RegTest.c b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/RegTest.c
new file mode 100644 (file)
index 0000000..dfe4590
--- /dev/null
@@ -0,0 +1,248 @@
+/*\r
+    FreeRTOS V7.5.2 - Copyright (C) 2013 Real Time Engineers Ltd.\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that has become a de facto standard.             *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly and support the FreeRTOS         *\r
+     *    project by purchasing a FreeRTOS tutorial book, reference          *\r
+     *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
+     *                                                                       *\r
+     *    Thank you!                                                         *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    >>! NOTE: The modification to the GPL is included to allow you to distribute\r
+    >>! a combined work that includes FreeRTOS without being obliged to provide\r
+    >>! the source code for proprietary components outside of the FreeRTOS\r
+    >>! kernel.\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    1 tab == 4 spaces!\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    Having a problem?  Start by reading the FAQ "My application does   *\r
+     *    not run, what could be wrong?"                                     *\r
+     *                                                                       *\r
+     *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
+    license and Real Time Engineers Ltd. contact details.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+    Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+/* \r
+ * "Reg test" tasks - These fill the registers with known values, then check\r
+ * that each register maintains its expected value for the lifetime of the\r
+ * task.  Each task uses a different set of values.  The reg test tasks execute\r
+ * with a very low priority, so get preempted very frequently.  A register\r
+ * containing an unexpected value is indicative of an error in the context\r
+ * switching mechanism.\r
+ */\r
+\r
+void vRegTest1Task( void ) __attribute__((naked));\r
+void vRegTest2Task( void ) __attribute__((naked));\r
+\r
+void vRegTest1Task( void )\r
+{\r
+       __asm volatile\r
+       (\r
+               ".extern ulRegTest1LoopCounter          \n"\r
+               "                                                                       \n"\r
+               "       /* Fill the core registers with known values. */ \n"\r
+               "       movs r1, #101                                   \n"\r
+               "       movs r2, #102                                   \n"\r
+               "       movs r3, #103                                   \n"\r
+               "       movs r4, #104                                   \n"\r
+               "       movs r5, #105                                   \n"\r
+               "       movs r6, #106                                   \n"\r
+               "       movs r7, #107                                   \n"\r
+               "       movs r0, #108                                   \n"\r
+               "       mov      r8, r0                                         \n"\r
+               "       movs r0, #109                                   \n"\r
+               "       mov  r9, r0                                             \n"\r
+               "       movs r0, #110                                   \n"\r
+               "       mov      r10, r0                                        \n"\r
+               "       movs r0, #111                                   \n"\r
+               "       mov      r11, r0                                        \n"\r
+               "       movs r0, #112                                   \n"\r
+               "       mov  r12, r0                                    \n"\r
+               "       movs r0, #100                                   \n"\r
+               "                                                                       \n"\r
+               "reg1_loop:                                                     \n"\r
+               "                                                                       \n"\r
+               "       cmp     r0, #100                                        \n"\r
+               "       bne     reg1_error_loop                         \n"\r
+               "       cmp     r1, #101                                        \n"\r
+               "       bne     reg1_error_loop                         \n"\r
+               "       cmp     r2, #102                                        \n"\r
+               "       bne     reg1_error_loop                         \n"\r
+               "       cmp r3, #103                                    \n"\r
+               "       bne     reg1_error_loop                         \n"\r
+               "       cmp     r4, #104                                        \n"\r
+               "       bne     reg1_error_loop                         \n"\r
+               "       cmp     r5, #105                                        \n"\r
+               "       bne     reg1_error_loop                         \n"\r
+               "       cmp     r6, #106                                        \n"\r
+               "       bne     reg1_error_loop                         \n"\r
+               "       cmp     r7, #107                                        \n"\r
+               "       bne     reg1_error_loop                         \n"\r
+               "       movs r0, #108                                   \n"\r
+               "       cmp     r8, r0                                          \n"\r
+               "       bne     reg1_error_loop                         \n"\r
+               "       movs r0, #109                                   \n"\r
+               "       cmp     r9, r0                                          \n"\r
+               "       bne     reg1_error_loop                         \n"\r
+               "       movs r0, #110                                   \n"\r
+               "       cmp     r10, r0                                         \n"\r
+               "       bne     reg1_error_loop                         \n"\r
+               "       movs r0, #111                                   \n"\r
+               "       cmp     r11, r0                                         \n"\r
+               "       bne     reg1_error_loop                         \n"\r
+               "       movs r0, #112                                   \n"\r
+               "       cmp     r12, r0                                         \n"\r
+               "       bne     reg1_error_loop                         \n"\r
+               "                                                                       \n"\r
+               "       /* Everything passed, increment the loop counter. */ \n"\r
+               "       push { r1 }                                             \n"\r
+               "       ldr     r0, =ulRegTest1LoopCounter      \n"\r
+               "       ldr r1, [r0]                                    \n"\r
+               "       add r1, r1, #1                                  \n"\r
+               "       str r1, [r0]                                    \n"\r
+               "                                                                       \n"\r
+               "       /* Yield to increase test coverage. */ \n"\r
+               "       movs r0, #0x01                                  \n"\r
+               "       ldr r1, =0xe000ed04                     \n" /*NVIC_INT_CTRL */\r
+               "       lsl r0, #28                                     \n" /* Shift to PendSV bit */\r
+               "       str r0, [r1]                                    \n"\r
+               "       dsb                                                             \n"\r
+               "       pop { r1 }                                              \n"\r
+               "                                                                       \n"\r
+               "       /* Start again. */                              \n"\r
+               "       movs r0, #100                                   \n"\r
+               "       b reg1_loop                                             \n"\r
+               "                                                                       \n"\r
+               "reg1_error_loop:                                       \n"\r
+               "       /* If this line is hit then there was an error in a core register value.        \n"\r
+               "       The loop ensures the loop counter stops incrementing. */                                        \n"\r
+               "       b reg1_error_loop                               \n"\r
+               "       nop                                                             \n"\r
+       );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vRegTest2Task( void )\r
+{\r
+       __asm volatile\r
+       (\r
+               ".extern ulRegTest2LoopCounter          \n"\r
+               "                                                                       \n"\r
+               "       /* Fill the core registers with known values. */ \n"\r
+               "       movs r1, #1                                             \n"\r
+               "       movs r2, #2                                             \n"\r
+               "       movs r3, #3                                             \n"\r
+               "       movs r4, #4                                             \n"\r
+               "       movs r5, #5                                             \n"\r
+               "       movs r6, #6                                             \n"\r
+               "       movs r7, #7                                             \n"\r
+               "       movs r0, #8                                             \n"\r
+               "       movs r8, r0                                             \n"\r
+               "       movs r0, #9                                             \n"\r
+               "       mov  r9, r0                                             \n"\r
+               "       movs r0, #10                                    \n"\r
+               "       mov      r10, r0                                        \n"\r
+               "       movs r0, #11                                    \n"\r
+               "       mov      r11, r0                                        \n"\r
+               "       movs r0, #12                                    \n"\r
+               "       mov  r12, r0                                    \n"\r
+               "       movs r0, #10                                    \n"\r
+               "                                                                       \n"\r
+               "reg2_loop:                                                     \n"\r
+               "                                                                       \n"\r
+               "       cmp     r0, #10                                         \n"\r
+               "       bne     reg2_error_loop                         \n"\r
+               "       cmp     r1, #1                                          \n"\r
+               "       bne     reg2_error_loop                         \n"\r
+               "       cmp     r2, #2                                          \n"\r
+               "       bne     reg2_error_loop                         \n"\r
+               "       cmp r3, #3                                              \n"\r
+               "       bne     reg2_error_loop                         \n"\r
+               "       cmp     r4, #4                                          \n"\r
+               "       bne     reg2_error_loop                         \n"\r
+               "       cmp     r5, #5                                          \n"\r
+               "       bne     reg2_error_loop                         \n"\r
+               "       cmp     r6, #6                                          \n"\r
+               "       bne     reg2_error_loop                         \n"\r
+               "       cmp     r7, #7                                          \n"\r
+               "       bne     reg2_error_loop                         \n"\r
+               "       movs r0, #8                                             \n"\r
+               "       cmp     r8, r0                                          \n"\r
+               "       bne     reg2_error_loop                         \n"\r
+               "       movs r0, #9                                             \n"\r
+               "       cmp     r9, r0                                          \n"\r
+               "       bne     reg2_error_loop                         \n"\r
+               "       movs r0, #10                                    \n"\r
+               "       cmp     r10, r0                                         \n"\r
+               "       bne     reg2_error_loop                         \n"\r
+               "       movs r0, #11                                    \n"\r
+               "       cmp     r11, r0                                         \n"\r
+               "       bne     reg2_error_loop                         \n"\r
+               "       movs r0, #12                                    \n"\r
+               "       cmp     r12, r0                                         \n"\r
+               "       bne     reg2_error_loop                         \n"\r
+               "                                                                       \n"\r
+               "       /* Everything passed, increment the loop counter. */ \n"\r
+               "       push { r1 }                                             \n"\r
+               "       ldr     r0, =ulRegTest2LoopCounter      \n"\r
+               "       ldr r1, [r0]                                    \n"\r
+               "       add r1, r1, #1                                  \n"\r
+               "       str r1, [r0]                                    \n"\r
+               "       pop { r1 }                                              \n"\r
+               "                                                                       \n"\r
+               "       /* Start again. */                              \n"\r
+               "       movs r0, #10                                    \n"\r
+               "       b reg2_loop                                             \n"\r
+               "                                                                       \n"\r
+               "reg2_error_loop:                                       \n"\r
+               "       /* If this line is hit then there was an error in a core register value.        \n"\r
+               "       The loop ensures the loop counter stops incrementing. */                                        \n"\r
+               "       b reg2_error_loop                               \n"\r
+               "       nop                                                             \n"\r
+       );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+\r
+\r
+\r
index 9ce799cd3ebe81be76823c24e5035d550288fe62..ca79bcc0c575bc4073de1a33aa4281bab753caff 100644 (file)
  * See http://www.freertos.org/a00110.html.\r
  *----------------------------------------------------------*/\r
 \r
-#include <stdint.h>\r
-extern uint32_t SystemCoreClock;\r
+#include <asf.h>\r
 \r
 #define configUSE_PREEMPTION                   1\r
 #define configUSE_IDLE_HOOK                            0\r
 #define configUSE_TICK_HOOK                            1\r
-#define configCPU_CLOCK_HZ                             ( SystemCoreClock )\r
+#define configCPU_CLOCK_HZ                             ( system_clock_source_get_hz( SYSTEM_CLOCK_SOURCE_DFLL ) )\r
 #define configTICK_RATE_HZ                             ( ( portTickType ) 500 )\r
 #define configMAX_PRIORITIES                   ( ( unsigned portBASE_TYPE ) 5 )\r
 #define configMINIMAL_STACK_SIZE               ( ( unsigned short ) 60 )\r
-#define configTOTAL_HEAP_SIZE                  ( ( size_t ) ( 11000 ) )\r
+#define configTOTAL_HEAP_SIZE                  ( ( size_t ) ( 16000 ) )\r
 #define configMAX_TASK_NAME_LEN                        ( 5 )\r
 #define configUSE_TRACE_FACILITY               1\r
 #define configUSE_16_BIT_TICKS                 0\r
index faed281d5eb930d0eb710d7256cf68dce7a2d1d4..2da2cbedf25c36fe266c97f1fc0f62e862205153 100644 (file)
@@ -47,7 +47,7 @@
 \r
 /* System clock bus configuration */\r
 #  define CONF_CLOCK_CPU_CLOCK_FAILURE_DETECT     true\r
-#  define CONF_CLOCK_FLASH_WAIT_STATES            0\r
+#  define CONF_CLOCK_FLASH_WAIT_STATES            2\r
 #  define CONF_CLOCK_CPU_DIVIDER                  SYSTEM_MAIN_CLOCK_DIV_1\r
 #  define CONF_CLOCK_APBA_DIVIDER                 SYSTEM_MAIN_CLOCK_DIV_1\r
 #  define CONF_CLOCK_APBB_DIVIDER                 SYSTEM_MAIN_CLOCK_DIV_1\r
@@ -86,8 +86,8 @@
 #  define CONF_CLOCK_OSC32K_RUN_IN_STANDBY        false\r
 \r
 /* SYSTEM_CLOCK_SOURCE_DFLL configuration - Digital Frequency Locked Loop */\r
-#  define CONF_CLOCK_DFLL_ENABLE                  false\r
-#  define CONF_CLOCK_DFLL_LOOP_MODE               SYSTEM_CLOCK_DFLL_LOOP_MODE_OPEN\r
+#  define CONF_CLOCK_DFLL_ENABLE                  true\r
+#  define CONF_CLOCK_DFLL_LOOP_MODE               SYSTEM_CLOCK_DFLL_LOOP_MODE_CLOSED\r
 #  define CONF_CLOCK_DFLL_ON_DEMAND               false\r
 #  define CONF_CLOCK_DFLL_RUN_IN_STANDBY          false\r
 \r
 /* Configure GCLK generator 0 (Main Clock) */\r
 #  define CONF_CLOCK_GCLK_0_ENABLE                true\r
 #  define CONF_CLOCK_GCLK_0_RUN_IN_STANDBY        false\r
-#  define CONF_CLOCK_GCLK_0_CLOCK_SOURCE          SYSTEM_CLOCK_SOURCE_OSC8M\r
+#  define CONF_CLOCK_GCLK_0_CLOCK_SOURCE          SYSTEM_CLOCK_SOURCE_DFLL\r
 #  define CONF_CLOCK_GCLK_0_PRESCALER             1\r
 #  define CONF_CLOCK_GCLK_0_OUTPUT_ENABLE         false\r
 \r
 /* Configure GCLK generator 1 */\r
-#  define CONF_CLOCK_GCLK_1_ENABLE                false\r
+#  define CONF_CLOCK_GCLK_1_ENABLE                true\r
 #  define CONF_CLOCK_GCLK_1_RUN_IN_STANDBY        false\r
 #  define CONF_CLOCK_GCLK_1_CLOCK_SOURCE          SYSTEM_CLOCK_SOURCE_OSC8M\r
 #  define CONF_CLOCK_GCLK_1_PRESCALER             1\r
diff --git a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/main-blinky.c b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/main-blinky.c
new file mode 100644 (file)
index 0000000..7f866c6
--- /dev/null
@@ -0,0 +1,231 @@
+/*\r
+    FreeRTOS V7.5.2 - Copyright (C) 2013 Real Time Engineers Ltd.\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that has become a de facto standard.             *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly and support the FreeRTOS         *\r
+     *    project by purchasing a FreeRTOS tutorial book, reference          *\r
+     *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
+     *                                                                       *\r
+     *    Thank you!                                                         *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    >>! NOTE: The modification to the GPL is included to allow you to distribute\r
+    >>! a combined work that includes FreeRTOS without being obliged to provide\r
+    >>! the source code for proprietary components outside of the FreeRTOS\r
+    >>! kernel.\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    1 tab == 4 spaces!\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    Having a problem?  Start by reading the FAQ "My application does   *\r
+     *    not run, what could be wrong?"                                     *\r
+     *                                                                       *\r
+     *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
+    license and Real Time Engineers Ltd. contact details.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+    Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+/******************************************************************************\r
+ * NOTE 1:  This project provides two demo applications.  A simple blinky style\r
+ * project, and a more comprehensive test and demo application.  The\r
+ * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select\r
+ * between the two.  See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY\r
+ * in main.c.  This file implements the simply blinky style version.\r
+ *\r
+ * NOTE 2:  This file only contains the source code that is specific to the\r
+ * basic demo.  Generic functions, such FreeRTOS hook functions, and functions\r
+ * required to configure the hardware, are defined in main.c.\r
+ ******************************************************************************\r
+ *\r
+ * main_blinky() creates one queue, and two tasks.  It then starts the\r
+ * scheduler.\r
+ *\r
+ * The Queue Send Task:\r
+ * The queue send task is implemented by the prvQueueSendTask() function in\r
+ * this file.  prvQueueSendTask() sits in a loop that causes it to repeatedly\r
+ * block for 200 milliseconds before sending the value 100 to the queue that\r
+ * was created within main_blinky().  Once the value is sent, the task loops\r
+ * back around to block for another 200 milliseconds.\r
+ *\r
+ * The Queue Receive Task:\r
+ * The queue receive task is implemented by the prvQueueReceiveTask() function\r
+ * in this file.  prvQueueReceiveTask() sits in a loop where it repeatedly\r
+ * blocks on attempts to read data from the queue that was created within\r
+ * main_blinky().  When data is received, the task checks the value of the\r
+ * data, and if the value equals the expected 100, toggles the LED.  The 'block\r
+ * time' parameter passed to the queue receive function specifies that the\r
+ * task should be held in the Blocked state indefinitely to wait for data to\r
+ * be available on the queue.  The queue receive task will only leave the\r
+ * Blocked state when the queue send task writes to the queue.  As the queue\r
+ * send task writes to the queue every 200 milliseconds, the queue receive\r
+ * task leaves the Blocked state every 200 milliseconds, and therefore toggles\r
+ * the LED every 200 milliseconds.\r
+ */\r
+\r
+/* Kernel includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+#include "queue.h"\r
+\r
+/* Priorities at which the tasks are created. */\r
+#define mainQUEUE_RECEIVE_TASK_PRIORITY                ( tskIDLE_PRIORITY + 2 )\r
+#define        mainQUEUE_SEND_TASK_PRIORITY            ( tskIDLE_PRIORITY + 1 )\r
+\r
+/* The rate at which data is sent to the queue.  The 200ms value is converted\r
+to ticks using the portTICK_RATE_MS constant. */\r
+#define mainQUEUE_SEND_FREQUENCY_MS                    ( 200 / portTICK_RATE_MS )\r
+\r
+/* The number of items the queue can hold.  This is 1 as the receive task\r
+will remove items as they are added, meaning the send task should always find\r
+the queue empty. */\r
+#define mainQUEUE_LENGTH                                       ( 1 )\r
+\r
+/* Values passed to the two tasks just to check the task parameter\r
+functionality. */\r
+#define mainQUEUE_SEND_PARAMETER                       ( 0x1111UL )\r
+#define mainQUEUE_RECEIVE_PARAMETER                    ( 0x22UL )\r
+\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * The tasks as described in the comments at the top of this file.\r
+ */\r
+static void prvQueueReceiveTask( void *pvParameters );\r
+static void prvQueueSendTask( void *pvParameters );\r
+\r
+/*\r
+ * Called by main() to create the simply blinky style application if\r
+ * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.\r
+ */\r
+void main_blinky( void );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* The queue used by both tasks. */\r
+static xQueueHandle xQueue = NULL;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void main_blinky( void )\r
+{\r
+       /* Create the queue. */\r
+       xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( unsigned long ) );\r
+\r
+       if( xQueue != NULL )\r
+       {\r
+               /* Start the two tasks as described in the comments at the top of this\r
+               file. */\r
+               xTaskCreate( prvQueueReceiveTask,                                       /* The function that implements the task. */\r
+                                       ( signed char * ) "Rx",                                 /* The text name assigned to the task - for debug only as it is not used by the kernel. */\r
+                                       configMINIMAL_STACK_SIZE,                               /* The size of the stack to allocate to the task. */\r
+                                       ( void * ) mainQUEUE_RECEIVE_PARAMETER, /* The parameter passed to the task - just to check the functionality. */\r
+                                       mainQUEUE_RECEIVE_TASK_PRIORITY,                /* The priority assigned to the task. */\r
+                                       NULL );                                                                 /* The task handle is not required, so NULL is passed. */\r
+\r
+               xTaskCreate( prvQueueSendTask, ( signed char * ) "TX", configMINIMAL_STACK_SIZE, ( void * ) mainQUEUE_SEND_PARAMETER, mainQUEUE_SEND_TASK_PRIORITY, NULL );\r
+\r
+               /* Start the tasks and timer running. */\r
+               vTaskStartScheduler();\r
+       }\r
+\r
+       /* If all is well, the scheduler will now be running, and the following\r
+       line will never be reached.  If the following line does execute, then\r
+       there was insufficient FreeRTOS heap memory available for the idle and/or\r
+       timer tasks     to be created.  See the memory management section on the\r
+       FreeRTOS web site for more details. */\r
+       for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvQueueSendTask( void *pvParameters )\r
+{\r
+portTickType xNextWakeTime;\r
+const unsigned long ulValueToSend = 100UL;\r
+\r
+       /* Check the task parameter is as expected. */\r
+       configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_SEND_PARAMETER );\r
+\r
+       /* Initialise xNextWakeTime - this only needs to be done once. */\r
+       xNextWakeTime = xTaskGetTickCount();\r
+\r
+       for( ;; )\r
+       {\r
+               /* Place this task in the blocked state until it is time to run again.\r
+               The block time is specified in ticks, the constant used converts ticks\r
+               to ms.  While in the Blocked state this task will not consume any CPU\r
+               time. */\r
+               vTaskDelayUntil( &xNextWakeTime, mainQUEUE_SEND_FREQUENCY_MS );\r
+\r
+               /* Send to the queue - causing the queue receive task to unblock and\r
+               toggle the LED.  0 is used as the block time so the sending operation\r
+               will not block - it shouldn't need to block as the queue should always\r
+               be empty at this point in the code. */\r
+               xQueueSend( xQueue, &ulValueToSend, 0U );\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+static void prvQueueReceiveTask( void *pvParameters )\r
+{\r
+unsigned long ulReceivedValue;\r
+\r
+       /* Check the task parameter is as expected. */\r
+       configASSERT( ( ( unsigned long ) pvParameters ) == mainQUEUE_RECEIVE_PARAMETER );\r
+\r
+       for( ;; )\r
+       {\r
+               /* Wait until something arrives in the queue - this task will block\r
+               indefinitely provided INCLUDE_vTaskSuspend is set to 1 in\r
+               FreeRTOSConfig.h. */\r
+               xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY );\r
+\r
+               /*  To get here something must have been received from the queue, but\r
+               is it the expected value?  If it is, toggle the LED. */\r
+               if( ulReceivedValue == 100UL )\r
+               {\r
+                       /* Toggle the LED. */\r
+                       port_pin_toggle_output_level( LED_0_PIN );\r
+                       ulReceivedValue = 0U;\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
diff --git a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/main-full.c b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/main-full.c
new file mode 100644 (file)
index 0000000..618bd8a
--- /dev/null
@@ -0,0 +1,327 @@
+/*\r
+    FreeRTOS V7.5.2 - Copyright (C) 2013 Real Time Engineers Ltd.\r
+\r
+    VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    FreeRTOS provides completely free yet professionally developed,    *\r
+     *    robust, strictly quality controlled, supported, and cross          *\r
+     *    platform software that has become a de facto standard.             *\r
+     *                                                                       *\r
+     *    Help yourself get started quickly and support the FreeRTOS         *\r
+     *    project by purchasing a FreeRTOS tutorial book, reference          *\r
+     *    manual, or both from: http://www.FreeRTOS.org/Documentation        *\r
+     *                                                                       *\r
+     *    Thank you!                                                         *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    This file is part of the FreeRTOS distribution.\r
+\r
+    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+    the terms of the GNU General Public License (version 2) as published by the\r
+    Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.\r
+\r
+    >>! NOTE: The modification to the GPL is included to allow you to distribute\r
+    >>! a combined work that includes FreeRTOS without being obliged to provide\r
+    >>! the source code for proprietary components outside of the FreeRTOS\r
+    >>! kernel.\r
+\r
+    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY\r
+    WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+    FOR A PARTICULAR PURPOSE.  Full license text is available from the following\r
+    link: http://www.freertos.org/a00114.html\r
+\r
+    1 tab == 4 spaces!\r
+\r
+    ***************************************************************************\r
+     *                                                                       *\r
+     *    Having a problem?  Start by reading the FAQ "My application does   *\r
+     *    not run, what could be wrong?"                                     *\r
+     *                                                                       *\r
+     *    http://www.FreeRTOS.org/FAQHelp.html                               *\r
+     *                                                                       *\r
+    ***************************************************************************\r
+\r
+    http://www.FreeRTOS.org - Documentation, books, training, latest versions,\r
+    license and Real Time Engineers Ltd. contact details.\r
+\r
+    http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
+    including FreeRTOS+Trace - an indispensable productivity tool, a DOS\r
+    compatible FAT file system, and our tiny thread aware UDP/IP stack.\r
+\r
+    http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High\r
+    Integrity Systems to sell under the OpenRTOS brand.  Low cost OpenRTOS\r
+    licenses offer ticketed support, indemnification and middleware.\r
+\r
+    http://www.SafeRTOS.com - High Integrity Systems also provide a safety\r
+    engineered and independently SIL3 certified version for use in safety and\r
+    mission critical applications that require provable dependability.\r
+\r
+    1 tab == 4 spaces!\r
+*/\r
+\r
+/******************************************************************************\r
+ * NOTE 1:  This project provides two demo applications.  A simple blinky style\r
+ * project, and a more comprehensive test and demo application.  The\r
+ * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select\r
+ * between the two.  See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY\r
+ * in main.c.  This file implements the comprehensive test and demo version.\r
+ *\r
+ * NOTE 2:  This file only contains the source code that is specific to the\r
+ * full demo.  Generic functions, such FreeRTOS hook functions, and functions\r
+ * required to configure the hardware, are defined in main.c.\r
+ ******************************************************************************\r
+ *\r
+ * main_full() creates a set of standard demo tasks, some application specific\r
+ * tasks, and a timer.  It then starts the scheduler.  The web documentation\r
+ * provides more details of the standard demo application tasks, which provide\r
+ * no particular functionality, but do provide a good example of how to use the\r
+ * FreeRTOS API.\r
+ *\r
+ * In addition to the standard demo tasks, the following tasks and timer are\r
+ * defined and/or created within this file:\r
+ *\r
+ * "Reg test" tasks - These fill the registers with known values, then check\r
+ * that each register maintains its expected value for the lifetime of the\r
+ * task.  Each task uses a different set of values.  The reg test tasks execute\r
+ * with a very low priority, so get preempted very frequently.  A register\r
+ * containing an unexpected value is indicative of an error in the context\r
+ * switching mechanism.\r
+ *\r
+ * "Check" software timer - The check timer period is initially set to three\r
+ * seconds.  Its callback function checks that all the standard demo tasks, and\r
+ * the register check tasks, are not only still executing, but are executing\r
+ * without reporting any errors.  If the check timer callback discovers that a\r
+ * task has either stalled, or reported an error, then it changes the period of\r
+ * the check timer from the initial three seconds, to just 200ms.  The callback\r
+ * function also toggles the LED each time it is called.  This provides a\r
+ * visual indication of the system status:  If the LED toggles every three\r
+ * seconds then no issues have been discovered.  If the LED toggles every 200ms,\r
+ * then an issue has been discovered with at least one task.\r
+ */\r
+\r
+/* Kernel includes. */\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+#include "queue.h"\r
+#include "semphr.h"\r
+#include "timers.h"\r
+\r
+/* Common demo includes. */\r
+#include "blocktim.h"\r
+#include "countsem.h"\r
+#include "recmutex.h"\r
+#include "ParTest.h"\r
+#include "dynamic.h"\r
+#include "QueueOverwrite.h"\r
+#include "QueueSet.h"\r
+#include "GenQTest.h"\r
+#include "QPeek.h"\r
+\r
+/* The period after which the check timer will expire provided no errors have\r
+been reported by any of the standard demo tasks.  ms are converted to the\r
+equivalent in ticks using the portTICK_RATE_MS constant. */\r
+#define mainCHECK_TIMER_PERIOD_MS                      ( 3000UL / portTICK_RATE_MS )\r
+\r
+/* The period at which the check timer will expire if an error has been\r
+reported in one of the standard demo tasks.  ms are converted to the equivalent\r
+in ticks using the portTICK_RATE_MS constant. */\r
+#define mainERROR_CHECK_TIMER_PERIOD_MS        ( 200UL / portTICK_RATE_MS )\r
+\r
+/* A block time of zero simply means "don't block". */\r
+#define mainDONT_BLOCK                                         ( 0UL )\r
+\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Register check tasks, as described at the top of this file.  The nature of\r
+ * these files necessitates that they are written in an assembly.\r
+ */\r
+extern void vRegTest1Task( void *pvParameters );\r
+extern void vRegTest2Task( void *pvParameters );\r
+\r
+/*\r
+ * Function that starts the command console.\r
+ */\r
+extern void vUARTCommandConsoleStart( uint16_t usStackSize, unsigned portBASE_TYPE uxPriority );\r
+\r
+/*\r
+ * The check timer callback function, as described at the top of this file.\r
+ */\r
+static void prvCheckTimerCallback( xTimerHandle xTimer );\r
+\r
+/*\r
+ * Called by main() to create the comprehensive test/demo application if\r
+ * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is not set to 1.\r
+ */\r
+void main_full( void );\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* The following two variables are used to communicate the status of the\r
+register check tasks to the check software timer.  If the variables keep\r
+incrementing, then the register check tasks has not discovered any errors.  If\r
+a variable stops incrementing, then an error has been found. */\r
+volatile unsigned long ulRegTest1LoopCounter = 0UL, ulRegTest2LoopCounter = 0UL;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+void main_full( void )\r
+{\r
+xTimerHandle xTimer = NULL;\r
+\r
+/* The register test tasks are asm functions that don't use a stack.  The\r
+stack allocated just has to be large enough to hold the task context, and\r
+for the additional required for the stack overflow checking to work (if\r
+configured). */\r
+const size_t xRegTestStackSize = 25U;\r
+\r
+       /* Create the standard demo tasks */\r
+       vCreateBlockTimeTasks();\r
+       vStartDynamicPriorityTasks();\r
+       vStartCountingSemaphoreTasks();\r
+       vStartRecursiveMutexTasks();\r
+       vStartQueueOverwriteTask( tskIDLE_PRIORITY );\r
+       vStartQueueSetTasks();\r
+       vStartGenericQueueTasks( tskIDLE_PRIORITY );\r
+       vStartQueuePeekTasks();\r
+       \r
+       /* Start the task that manages the command console for FreeRTOS+CLI. */\r
+       vUARTCommandConsoleStart( ( configMINIMAL_STACK_SIZE * 3 ), tskIDLE_PRIORITY ); \r
+\r
+       /* Create the register test tasks as described at the top of this file.\r
+       These are naked functions that don't use any stack.  A stack still has\r
+       to be allocated to hold the task context. */\r
+       xTaskCreate(    vRegTest1Task,                  /* Function that implements the task. */\r
+                                       ( signed char * ) "Reg1", /* Text name of the task. */\r
+                                       xRegTestStackSize,              /* Stack allocated to the task. */\r
+                                       NULL,                                   /* The task parameter is not used. */\r
+                                       tskIDLE_PRIORITY,               /* The priority to assign to the task. */\r
+                                       NULL );                                 /* Don't receive a handle back, it is not needed. */\r
+\r
+       xTaskCreate(    vRegTest2Task,                  /* Function that implements the task. */\r
+                                       ( signed char * ) "Reg2", /* Text name of the task. */\r
+                                       xRegTestStackSize,              /* Stack allocated to the task. */\r
+                                       NULL,                                   /* The task parameter is not used. */\r
+                                       tskIDLE_PRIORITY,               /* The priority to assign to the task. */\r
+                                       NULL );                                 /* Don't receive a handle back, it is not needed. */\r
+\r
+       /* Create the software timer that performs the 'check' functionality,\r
+       as described at the top of this file. */\r
+       xTimer = xTimerCreate(  ( const signed char * ) "CheckTimer",/* A text name, purely to help debugging. */\r
+                                                       ( mainCHECK_TIMER_PERIOD_MS ),          /* The timer period, in this case 3000ms (3s). */\r
+                                                       pdTRUE,                                                         /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */\r
+                                                       ( void * ) 0,                                           /* The ID is not used, so can be set to anything. */\r
+                                                       prvCheckTimerCallback                           /* The callback function that inspects the status of all the other tasks. */\r
+                                               );\r
+\r
+       /* If the software timer was created successfully, start it.  It won't\r
+       actually start running until the scheduler starts.  A block time of\r
+       zero is used in this call, although any value could be used as the block\r
+       time will be ignored because the scheduler has not started yet. */\r
+       if( xTimer != NULL )\r
+       {\r
+               xTimerStart( xTimer, mainDONT_BLOCK );\r
+       }\r
+\r
+       /* Start the kernel.  From here on, only tasks and interrupts will run. */\r
+       vTaskStartScheduler();\r
+\r
+       /* If all is well, the scheduler will now be running, and the following\r
+       line will never be reached.  If the following line does execute, then there\r
+       was     insufficient FreeRTOS heap memory available for the idle and/or timer\r
+       tasks to be created.  See the memory management section on the FreeRTOS web\r
+       site, or the FreeRTOS tutorial books for more details. */\r
+       for( ;; );\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+/* See the description at the top of this file. */\r
+static void prvCheckTimerCallback( xTimerHandle xTimer )\r
+{\r
+static long lChangedTimerPeriodAlready = pdFALSE;\r
+static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0;\r
+unsigned long ulErrorFound = pdFALSE;\r
+\r
+       /* Check all the demo and test tasks to ensure that they are all still\r
+       running, and that none have detected an error. */\r
+       if( xAreDynamicPriorityTasksStillRunning() != pdPASS )\r
+       {\r
+               ulErrorFound |= ( 0x01UL << 0UL );\r
+       }\r
+\r
+       if( xAreBlockTimeTestTasksStillRunning() != pdPASS )\r
+       {\r
+               ulErrorFound |= ( 0x01UL << 1UL );\r
+       }\r
+\r
+       if( xAreCountingSemaphoreTasksStillRunning() != pdPASS )\r
+       {\r
+               ulErrorFound |= ( 0x01UL << 2UL );\r
+       }\r
+\r
+       if( xAreRecursiveMutexTasksStillRunning() != pdPASS )\r
+       {\r
+               ulErrorFound |= ( 0x01UL << 3UL );\r
+       }\r
+\r
+       /* Check that the register test 1 task is still running. */\r
+       if( ulLastRegTest1Value == ulRegTest1LoopCounter )\r
+       {\r
+               ulErrorFound |= ( 0x01UL << 4UL );\r
+       }\r
+       ulLastRegTest1Value = ulRegTest1LoopCounter;\r
+\r
+       /* Check that the register test 2 task is still running. */\r
+       if( ulLastRegTest2Value == ulRegTest2LoopCounter )\r
+       {\r
+               ulErrorFound |= ( 0x01UL << 5UL );\r
+       }\r
+       ulLastRegTest2Value = ulRegTest2LoopCounter;\r
+\r
+       if( xAreQueueSetTasksStillRunning() != pdPASS )\r
+       {\r
+               ulErrorFound |= ( 0x01UL << 6UL );\r
+       }\r
+\r
+       if( xIsQueueOverwriteTaskStillRunning() != pdPASS )\r
+       {\r
+               ulErrorFound |= ( 0x01UL << 7UL );\r
+       }\r
+       \r
+       if( xAreGenericQueueTasksStillRunning() != pdPASS )\r
+       {\r
+               ulErrorFound |= ( 0x01UL << 8UL );\r
+       }\r
+       \r
+       if( xAreQueuePeekTasksStillRunning() != pdPASS )\r
+       {\r
+               ulErrorFound |= ( 0x01UL << 9UL );\r
+       }\r
+       \r
+       /* Toggle the check LED to give an indication of the system status.  If\r
+       the LED toggles every mainCHECK_TIMER_PERIOD_MS milliseconds then\r
+       everything is ok.  A faster toggle indicates an error. */\r
+       port_pin_toggle_output_level( LED_0_PIN );\r
+\r
+       /* Have any errors been latched in ulErrorFound?  If so, shorten the\r
+       period of the check timer to mainERROR_CHECK_TIMER_PERIOD_MS milliseconds.\r
+       This will result in an increase in the rate at which the LED toggles. */\r
+       if( ulErrorFound != pdFALSE )\r
+       {\r
+               if( lChangedTimerPeriodAlready == pdFALSE )\r
+               {\r
+                       lChangedTimerPeriodAlready = pdTRUE;\r
+\r
+                       /* This call to xTimerChangePeriod() uses a zero block time.\r
+                       Functions called from inside of a timer callback function must\r
+                       *never* attempt to block. */\r
+                       xTimerChangePeriod( xTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK );\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
index b916b791e2f72c84d51cbdbe8da72701537000bf..080586c31086ff5a22e9ff7e7e88a0a18d905fa0 100644 (file)
     1 tab == 4 spaces!\r
 */\r
 \r
+/******************************************************************************\r
+ * This project provides two demo applications.  A simple blinky style project,\r
+ * and a more comprehensive test and demo application.  The\r
+ * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this file) is used to\r
+ * select between the two.  The simply blinky demo is implemented and described\r
+ * in main_blinky.c.  The more comprehensive test and demo application is\r
+ * implemented and described in main_full.c.\r
+ *\r
+ * This file implements the code that is not demo specific, including the\r
+ * hardware setup and FreeRTOS hook functions.  It also contains a dummy\r
+ * interrupt service routine called Dummy_IRQHandler() that is provided as an\r
+ * example of how to use interrupt safe FreeRTOS API functions (those that end\r
+ * in "FromISR").\r
+ *\r
+ *****************************************************************************/\r
+\r
 /* FreeRTOS includes. */\r
 #include "FreeRTOS.h"\r
 #include "task.h"\r
 /* Demo app includes. */\r
 #include "UARTCommandConsole.h"\r
 \r
+/* Demo application include. */\r
+#include "QueueSet.h"\r
+\r
 /* Library includes. */\r
 #include <asf.h>\r
 \r
+/* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,\r
+or 0 to run the more comprehensive test and demo application. */\r
+#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY     0\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /*\r
- * Hardware and driver initialisation can be done in this function.\r
+ * Perform any application specific hardware configuration.  The clocks,\r
+ * memory, etc. are configured before main() is called.\r
  */\r
 static void prvSetupHardware( void );\r
 \r
@@ -88,6 +112,13 @@ void vApplicationIdleHook( void );
 void vApplicationStackOverflowHook( xTaskHandle pxTask, signed char *pcTaskName );\r
 void vApplicationTickHook( void );\r
 \r
+/*\r
+ * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.\r
+ * main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.\r
+ */\r
+extern void main_blinky( void );\r
+extern void main_full( void );\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /* Used in the run time stats calculations. */\r
@@ -97,23 +128,26 @@ static unsigned long ulClocksPer10thOfAMilliSecond = 0UL;
 \r
 int main (void)\r
 {\r
+       /* Prepare the hardware for the demo. */\r
        prvSetupHardware();\r
-       vUARTCommandConsoleStart( ( configMINIMAL_STACK_SIZE * 3 ), tskIDLE_PRIORITY ); \r
-       \r
-       /* Start the scheduler. */\r
-       vTaskStartScheduler();\r
-\r
-       /* If all is well, the scheduler will now be running, and the following line\r
-       will never be reached.  If the following line does execute, then there was\r
-       insufficient FreeRTOS heap memory available for the idle and/or timer tasks\r
-       to be created.  See the memory management section on the FreeRTOS web site\r
-       for more details. */\r
-       for( ;; );\r
+\r
+       /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top\r
+       of this file. */\r
+       #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1\r
+       {\r
+               main_blinky();\r
+       }\r
+       #else\r
+       {\r
+               main_full();\r
+       }\r
+       #endif\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
 static void prvSetupHardware( void )\r
 {\r
+       /* Initialisation is performed by the Atmel board support package. */\r
        system_init();\r
 }\r
 /*-----------------------------------------------------------*/\r
@@ -168,7 +202,22 @@ void vApplicationTickHook( void )
        configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h.  User code can be\r
        added here, but the tick hook is called from an interrupt context, so\r
        code must not attempt to block, and only the interrupt safe FreeRTOS API\r
-       functions can be used (those that end in FromISR()). */\r
+       functions can be used (those that end in FromISR()).  The code in this\r
+       tick hook implementation is for demonstration only - it has no real\r
+       purpose.  It just gives a semaphore every 50ms.  The semaphore unblocks a\r
+       task that then toggles an LED.  Additionally, the call to\r
+       vQueueSetAccessQueueSetFromISR() is part of the "standard demo tasks"\r
+       functionality. */\r
+\r
+       /* The semaphore and associated task are not created when the simple blinky\r
+       demo is used. */\r
+       #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0\r
+       {\r
+               /* Write to a queue that is in use as part of the queue set demo to\r
+               demonstrate using queue sets from an ISR. */\r
+               vQueueSetAccessQueueSetFromISR();\r
+       }\r
+       #endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
diff --git a/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/printf-stdarg.c b/FreeRTOS/Demo/CORTEX_M0+_Atmel_SAMD20_XPlained/RTOSDemo/src/printf-stdarg.c
new file mode 100644 (file)
index 0000000..b5ac41b
--- /dev/null
@@ -0,0 +1,293 @@
+/*\r
+       Copyright 2001, 2002 Georges Menie (www.menie.org)\r
+       stdarg version contributed by Christian Ettinger\r
+\r
+    This program is free software; you can redistribute it and/or modify\r
+    it under the terms of the GNU Lesser 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
+    This program 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 Lesser General Public License for more details.\r
+\r
+    You should have received a copy of the GNU Lesser General Public License\r
+    along with this program; if not, write to the Free Software\r
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+*/\r
+\r
+/*\r
+       putchar is the only external dependency for this file,\r
+       if you have a working putchar, leave it commented out.\r
+       If not, uncomment the define below and\r
+       replace outbyte(c) by your own function call.\r
+\r
+*/\r
+\r
+#define putchar(c) c\r
+\r
+#include <stdarg.h>\r
+\r
+static void printchar(char **str, int c)\r
+{\r
+       //extern int putchar(int c);\r
+       \r
+       if (str) {\r
+               **str = (char)c;\r
+               ++(*str);\r
+       }\r
+       else\r
+       { \r
+               (void)putchar(c);\r
+       }\r
+}\r
+\r
+#define PAD_RIGHT 1\r
+#define PAD_ZERO 2\r
+\r
+static int prints(char **out, const char *string, int width, int pad)\r
+{\r
+       register int pc = 0, padchar = ' ';\r
+\r
+       if (width > 0) {\r
+               register int len = 0;\r
+               register const char *ptr;\r
+               for (ptr = string; *ptr; ++ptr) ++len;\r
+               if (len >= width) width = 0;\r
+               else width -= len;\r
+               if (pad & PAD_ZERO) padchar = '0';\r
+       }\r
+       if (!(pad & PAD_RIGHT)) {\r
+               for ( ; width > 0; --width) {\r
+                       printchar (out, padchar);\r
+                       ++pc;\r
+               }\r
+       }\r
+       for ( ; *string ; ++string) {\r
+               printchar (out, *string);\r
+               ++pc;\r
+       }\r
+       for ( ; width > 0; --width) {\r
+               printchar (out, padchar);\r
+               ++pc;\r
+       }\r
+\r
+       return pc;\r
+}\r
+\r
+/* the following should be enough for 32 bit int */\r
+#define PRINT_BUF_LEN 12\r
+\r
+static int printi(char **out, int i, int b, int sg, int width, int pad, int letbase)\r
+{\r
+       char print_buf[PRINT_BUF_LEN];\r
+       register char *s;\r
+       register int t, neg = 0, pc = 0;\r
+       register unsigned int u = (unsigned int)i;\r
+\r
+       if (i == 0) {\r
+               print_buf[0] = '0';\r
+               print_buf[1] = '\0';\r
+               return prints (out, print_buf, width, pad);\r
+       }\r
+\r
+       if (sg && b == 10 && i < 0) {\r
+               neg = 1;\r
+               u = (unsigned int)-i;\r
+       }\r
+\r
+       s = print_buf + PRINT_BUF_LEN-1;\r
+       *s = '\0';\r
+\r
+       while (u) {\r
+               t = (unsigned int)u % b;\r
+               if( t >= 10 )\r
+                       t += letbase - '0' - 10;\r
+               *--s = (char)(t + '0');\r
+               u /= b;\r
+       }\r
+\r
+       if (neg) {\r
+               if( width && (pad & PAD_ZERO) ) {\r
+                       printchar (out, '-');\r
+                       ++pc;\r
+                       --width;\r
+               }\r
+               else {\r
+                       *--s = '-';\r
+               }\r
+       }\r
+\r
+       return pc + prints (out, s, width, pad);\r
+}\r
+\r
+static int print( char **out, const char *format, va_list args )\r
+{\r
+       register int width, pad;\r
+       register int pc = 0;\r
+       char scr[2];\r
+\r
+       for (; *format != 0; ++format) {\r
+               if (*format == '%') {\r
+                       ++format;\r
+                       width = pad = 0;\r
+                       if (*format == '\0') break;\r
+                       if (*format == '%') goto out;\r
+                       if (*format == '-') {\r
+                               ++format;\r
+                               pad = PAD_RIGHT;\r
+                       }\r
+                       while (*format == '0') {\r
+                               ++format;\r
+                               pad |= PAD_ZERO;\r
+                       }\r
+                       for ( ; *format >= '0' && *format <= '9'; ++format) {\r
+                               width *= 10;\r
+                               width += *format - '0';\r
+                       }\r
+                       if( *format == 's' ) {\r
+                               register char *s = (char *)va_arg( args, int );\r
+                               pc += prints (out, s?s:"(null)", width, pad);\r
+                               continue;\r
+                       }\r
+                       if( *format == 'd' ) {\r
+                               pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a');\r
+                               continue;\r
+                       }\r
+                       if( *format == 'x' ) {\r
+                               pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a');\r
+                               continue;\r
+                       }\r
+                       if( *format == 'X' ) {\r
+                               pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A');\r
+                               continue;\r
+                       }\r
+                       if( *format == 'u' ) {\r
+                               pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a');\r
+                               continue;\r
+                       }\r
+                       if( *format == 'c' ) {\r
+                               /* char are converted to int then pushed on the stack */\r
+                               scr[0] = (char)va_arg( args, int );\r
+                               scr[1] = '\0';\r
+                               pc += prints (out, scr, width, pad);\r
+                               continue;\r
+                       }\r
+               }\r
+               else {\r
+               out:\r
+                       printchar (out, *format);\r
+                       ++pc;\r
+               }\r
+       }\r
+       if (out) **out = '\0';\r
+       va_end( args );\r
+       return pc;\r
+}\r
+\r
+int printf(const char *format, ...)\r
+{\r
+        va_list args;\r
+        \r
+        va_start( args, format );\r
+        return print( 0, format, args );\r
+}\r
+\r
+int sprintf(char *out, const char *format, ...)\r
+{\r
+        va_list args;\r
+        \r
+        va_start( args, format );\r
+        return print( &out, format, args );\r
+}\r
+\r
+\r
+int snprintf( char *buf, unsigned int count, const char *format, ... )\r
+{\r
+        va_list args;\r
+        \r
+        ( void ) count;\r
+        \r
+        va_start( args, format );\r
+        return print( &buf, format, args );\r
+}\r
+\r
+\r
+#ifdef TEST_PRINTF\r
+int main(void)\r
+{\r
+       char *ptr = "Hello world!";\r
+       char *np = 0;\r
+       int i = 5;\r
+       unsigned int bs = sizeof(int)*8;\r
+       int mi;\r
+       char buf[80];\r
+\r
+       mi = (1 << (bs-1)) + 1;\r
+       printf("%s\n", ptr);\r
+       printf("printf test\n");\r
+       printf("%s is null pointer\n", np);\r
+       printf("%d = 5\n", i);\r
+       printf("%d = - max int\n", mi);\r
+       printf("char %c = 'a'\n", 'a');\r
+       printf("hex %x = ff\n", 0xff);\r
+       printf("hex %02x = 00\n", 0);\r
+       printf("signed %d = unsigned %u = hex %x\n", -3, -3, -3);\r
+       printf("%d %s(s)%", 0, "message");\r
+       printf("\n");\r
+       printf("%d %s(s) with %%\n", 0, "message");\r
+       sprintf(buf, "justif: \"%-10s\"\n", "left"); printf("%s", buf);\r
+       sprintf(buf, "justif: \"%10s\"\n", "right"); printf("%s", buf);\r
+       sprintf(buf, " 3: %04d zero padded\n", 3); printf("%s", buf);\r
+       sprintf(buf, " 3: %-4d left justif.\n", 3); printf("%s", buf);\r
+       sprintf(buf, " 3: %4d right justif.\n", 3); printf("%s", buf);\r
+       sprintf(buf, "-3: %04d zero padded\n", -3); printf("%s", buf);\r
+       sprintf(buf, "-3: %-4d left justif.\n", -3); printf("%s", buf);\r
+       sprintf(buf, "-3: %4d right justif.\n", -3); printf("%s", buf);\r
+\r
+       return 0;\r
+}\r
+\r
+/*\r
+ * if you compile this file with\r
+ *   gcc -Wall $(YOUR_C_OPTIONS) -DTEST_PRINTF -c printf.c\r
+ * you will get a normal warning:\r
+ *   printf.c:214: warning: spurious trailing `%' in format\r
+ * this line is testing an invalid % at the end of the format string.\r
+ *\r
+ * this should display (on 32bit int machine) :\r
+ *\r
+ * Hello world!\r
+ * printf test\r
+ * (null) is null pointer\r
+ * 5 = 5\r
+ * -2147483647 = - max int\r
+ * char a = 'a'\r
+ * hex ff = ff\r
+ * hex 00 = 00\r
+ * signed -3 = unsigned 4294967293 = hex fffffffd\r
+ * 0 message(s)\r
+ * 0 message(s) with %\r
+ * justif: "left      "\r
+ * justif: "     right"\r
+ *  3: 0003 zero padded\r
+ *  3: 3    left justif.\r
+ *  3:    3 right justif.\r
+ * -3: -003 zero padded\r
+ * -3: -3   left justif.\r
+ * -3:   -3 right justif.\r
+ */\r
+\r
+#endif\r
+\r
+\r
+/* To keep linker happy. */\r
+int    write( int i, char* c, int n)\r
+{\r
+       (void)i;\r
+       (void)n;\r
+       (void)c;\r
+       return 0;\r
+}\r
+\r
index f0bbd2bdbfb811fd047d344c17ebfad5b36ca33b..5faf19e59c4e26f31e54ee9933c3ebecae82eaa2 100644 (file)
     1 tab == 4 spaces!\r
 */\r
 \r
+/* \r
+ * "Reg test" tasks - These fill the registers with known values, then check\r
+ * that each register maintains its expected value for the lifetime of the\r
+ * task.  Each task uses a different set of values.  The reg test tasks execute\r
+ * with a very low priority, so get preempted very frequently.  A register\r
+ * containing an unexpected value is indicative of an error in the context\r
+ * switching mechanism.\r
+ */\r
\r
 void vRegTest1Task( void ) __attribute__((naked));\r
 void vRegTest2Task( void ) __attribute__((naked));\r
 \r
index b22027bc4c99e3eb96eb5065eb2ec5b44b12aa7c..606587a01d2f98907e6292884ae35d13f68d2f33 100644 (file)
     1 tab == 4 spaces!\r
 */\r
 \r
+/* \r
+ * "Reg test" tasks - These fill the registers with known values, then check\r
+ * that each register maintains its expected value for the lifetime of the\r
+ * task.  Each task uses a different set of values.  The reg test tasks execute\r
+ * with a very low priority, so get preempted very frequently.  A register\r
+ * containing an unexpected value is indicative of an error in the context\r
+ * switching mechanism.\r
+ */\r
\r
        RSEG    CODE:CODE(2)\r
        thumb\r
 \r
index a51261c15b9d4333103321ce2c0c111e1f1c535e..7bddfb51a970d67f120b78926facf8e07f6d6e41 100644 (file)
 ;    1 tab == 4 spaces!\r
 ;*/\r
 \r
+;/* \r
+; * "Reg test" tasks - These fill the registers with known values, then check\r
+; * that each register maintains its expected value for the lifetime of the\r
+; * task.  Each task uses a different set of values.  The reg test tasks execute\r
+; * with a very low priority, so get preempted very frequently.  A register\r
+; * containing an unexpected value is indicative of an error in the context\r
+; * switching mechanism.\r
+; */\r
\r
        PRESERVE8\r
        THUMB\r
 \r