]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M7_SAMV71_Xplained_IAR_Keil/main.c
Update version numbers ready for release.
[freertos] / FreeRTOS / Demo / CORTEX_M7_SAMV71_Xplained_IAR_Keil / main.c
1 /*\r
2  * FreeRTOS Kernel V10.1.1\r
3  * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\r
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of\r
6  * this software and associated documentation files (the "Software"), to deal in\r
7  * the Software without restriction, including without limitation the rights to\r
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\r
9  * the Software, and to permit persons to whom the Software is furnished to do so,\r
10  * subject to the following conditions:\r
11  *\r
12  * The above copyright notice and this permission notice shall be included in all\r
13  * copies or substantial portions of the Software.\r
14  *\r
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\r
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\r
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\r
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28 /******************************************************************************\r
29  * This project provides two demo applications.  A simple blinky style project,\r
30  * and a more comprehensive test and demo application.  The\r
31  * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this file) is used to\r
32  * select between the two.  The simply blinky demo is implemented and described\r
33  * in main_blinky.c.  The more comprehensive test and demo application is\r
34  * implemented and described in main_full.c.\r
35  *\r
36  * This file implements the code that is not demo specific, including the\r
37  * hardware setup and standard FreeRTOS hook functions.\r
38  *\r
39  * ENSURE TO READ THE DOCUMENTATION PAGE FOR THIS PORT AND DEMO APPLICATION ON\r
40  * THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO\r
41  * APPLICATION, AND ITS ASSOCIATE FreeRTOS ARCHITECTURE PORT!\r
42  *\r
43  */\r
44 \r
45 /* Scheduler include files. */\r
46 #include "FreeRTOS.h"\r
47 #include "task.h"\r
48 #include "semphr.h"\r
49 \r
50 /* Standard demo includes. */\r
51 #include "TimerDemo.h"\r
52 #include "QueueOverwrite.h"\r
53 #include "EventGroupsDemo.h"\r
54 #include "IntSemTest.h"\r
55 #include "TaskNotify.h"\r
56 \r
57 /* Library includes. */\r
58 #include "board.h"\r
59 \r
60 /* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,\r
61 or 0 to run the more comprehensive test and demo application. */\r
62 #define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY      0\r
63 \r
64 /*-----------------------------------------------------------*/\r
65 \r
66 /*\r
67  * Configure the hardware as necessary to run this demo.\r
68  */\r
69 static void prvSetupHardware( void );\r
70 \r
71 /*\r
72  * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.\r
73  * main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.\r
74  */\r
75 #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1\r
76         extern void main_blinky( void );\r
77 #else\r
78         extern void main_full( void );\r
79 #endif /* #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 */\r
80 \r
81 /* Prototypes for the standard FreeRTOS callback/hook functions implemented\r
82 within this file. */\r
83 void vApplicationMallocFailedHook( void );\r
84 void vApplicationIdleHook( void );\r
85 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );\r
86 void vApplicationTickHook( void );\r
87 \r
88 /*-----------------------------------------------------------*/\r
89 \r
90 int main( void )\r
91 {\r
92         /* Configure the hardware ready to run the demo. */\r
93         prvSetupHardware();\r
94 \r
95         /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top\r
96         of this file. */\r
97         #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )\r
98         {\r
99                 main_blinky();\r
100         }\r
101         #else\r
102         {\r
103                 main_full();\r
104         }\r
105         #endif\r
106 \r
107         return 0;\r
108 }\r
109 /*-----------------------------------------------------------*/\r
110 \r
111 static void prvSetupHardware( void )\r
112 {\r
113         /* Disable watchdog. */\r
114         WDT_Disable( WDT0 );\r
115         WDT_Disable( WDT1 );\r
116 \r
117         SCB_EnableICache();\r
118         SCB_EnableDCache();\r
119 \r
120     LED_Configure( 0 );\r
121     LED_Configure( 1 );\r
122 }\r
123 /*-----------------------------------------------------------*/\r
124 \r
125 void vApplicationMallocFailedHook( void )\r
126 {\r
127         /* Called if a call to pvPortMalloc() fails because there is insufficient\r
128         free memory available in the FreeRTOS heap.  pvPortMalloc() is called\r
129         internally by FreeRTOS API functions that create tasks, queues, software\r
130         timers, and semaphores.  The size of the FreeRTOS heap is set by the\r
131         configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */\r
132 \r
133         /* Force an assert. */\r
134         configASSERT( ( volatile void * ) NULL );\r
135 }\r
136 /*-----------------------------------------------------------*/\r
137 \r
138 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )\r
139 {\r
140         ( void ) pcTaskName;\r
141         ( void ) pxTask;\r
142 \r
143         /* Run time stack overflow checking is performed if\r
144         configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2.  This hook\r
145         function is called if a stack overflow is detected. */\r
146 \r
147         /* Force an assert. */\r
148         configASSERT( ( volatile void * ) NULL );\r
149 }\r
150 /*-----------------------------------------------------------*/\r
151 \r
152 void vApplicationIdleHook( void )\r
153 {\r
154 volatile size_t xFreeHeapSpace;\r
155 \r
156         /* This is just a trivial example of an idle hook.  It is called on each\r
157         cycle of the idle task.  It must *NOT* attempt to block.  In this case the\r
158         idle task just queries the amount of FreeRTOS heap that remains.  See the\r
159         memory management section on the http://www.FreeRTOS.org web site for memory\r
160         management options.  If there is a lot of heap memory free then the\r
161         configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up\r
162         RAM. */\r
163         xFreeHeapSpace = xPortGetFreeHeapSize();\r
164 \r
165         /* Remove compiler warning about xFreeHeapSpace being set but never used. */\r
166         ( void ) xFreeHeapSpace;\r
167 }\r
168 /*-----------------------------------------------------------*/\r
169 \r
170 void vApplicationTickHook( void )\r
171 {\r
172         #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0\r
173         {\r
174                 /* The full demo includes a software timer demo/test that requires\r
175                 prodding periodically from the tick interrupt. */\r
176                 vTimerPeriodicISRTests();\r
177 \r
178                 /* Call the periodic queue overwrite from ISR demo. */\r
179                 vQueueOverwritePeriodicISRDemo();\r
180 \r
181                 /* Call the periodic event group from ISR demo. */\r
182                 vPeriodicEventGroupsProcessing();\r
183 \r
184                 /* Call the code that uses a mutex from an ISR. */\r
185                 vInterruptSemaphorePeriodicTest();\r
186 \r
187                 /* Call the code that 'gives' a task notification from an ISR. */\r
188                 xNotifyTaskFromISR();\r
189         }\r
190         #endif\r
191 }\r
192 /*-----------------------------------------------------------*/\r
193 \r
194 /* Just to keep the linker happy. */\r
195 int __write( int x );\r
196 int __write( int x )\r
197 {\r
198         return x;\r
199 }\r