]> begriffs open source - cmsis-freertos/blob - Demo/CORTEX_R4_RM48_TMS570_CCS5/main.c
Updated pack to FreeRTOS 10.4.4
[cmsis-freertos] / Demo / CORTEX_R4_RM48_TMS570_CCS5 / main.c
1 /*
2  * FreeRTOS V202107.00
3  * Copyright (C) 2020 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  * http://www.FreeRTOS.org
23  * http://aws.amazon.com/freertos
24  *
25  * 1 tab == 4 spaces!
26  */
27
28 /******************************************************************************
29  * This project provides two demo applications.  A simple blinky style project,
30  * and a more comprehensive test and demo application.  The
31  * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this file) is used to
32  * select between the two.  The simply blinky demo is implemented and described
33  * in main_blinky.c.  The more comprehensive test and demo application is
34  * implemented and described in main_full.c.
35  *
36  * This file implements the code that is not demo specific, including the
37  * hardware setup and FreeRTOS hook functions.
38  *
39  */
40
41 /* Standard includes. */
42 #include <stdio.h>
43
44 /* Kernel includes. */
45 #include "FreeRTOS.h"
46 #include "task.h"
47
48 /* Standard demo includes - just needed for the LED (ParTest) initialisation
49 function. */
50 #include "partest.h"
51
52 /* Library includes. */
53 #include "het.h"
54
55 /* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo,
56 or 0 to run the more comprehensive test and demo application. */
57 #define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY      0
58
59 /*-----------------------------------------------------------*/
60
61 /*
62  * Set up the hardware ready to run this demo.
63  */
64 static void prvSetupHardware( void );
65
66 /*
67  * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.
68  * main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.
69  */
70 extern void main_blinky( void );
71 extern void main_full( void );
72
73 /*-----------------------------------------------------------*/
74
75 /* See the documentation page for this demo on the FreeRTOS.org web site for
76 full information - including hardware setup requirements. */
77 int main( void )
78 {
79         /* Prepare the hardware to run this demo. */
80         prvSetupHardware();
81
82         /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
83         of this file. */
84         #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1
85         {
86                 main_blinky();
87         }
88         #else
89         {
90                 main_full();
91         }
92         #endif
93
94         return 0;
95 }
96 /*-----------------------------------------------------------*/
97
98 static void prvSetupHardware( void )
99 {
100         /* Perform any configuration necessary to use the ParTest LED output
101         functions. */
102         vParTestInitialise();
103 }
104 /*-----------------------------------------------------------*/
105
106 void vApplicationMallocFailedHook( void )
107 {
108         /* vApplicationMallocFailedHook() will only be called if
109         configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h.  It is a hook
110         function that will get called if a call to pvPortMalloc() fails.
111         pvPortMalloc() is called internally by the kernel whenever a task, queue,
112         timer or semaphore is created.  It is also called by various parts of the
113         demo application.  If heap_1.c or heap_2.c are used, then the size of the
114         heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
115         FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
116         to query the size of free heap space that remains (although it does not
117         provide information on how the remaining heap might be fragmented). */
118         taskDISABLE_INTERRUPTS();
119         for( ;; );
120 }
121 /*-----------------------------------------------------------*/
122
123 void vApplicationIdleHook( void )
124 {
125         /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set
126         to 1 in FreeRTOSConfig.h.  It will be called on each iteration of the idle
127         task.  It is essential that code added to this hook function never attempts
128         to block in any way (for example, call xQueueReceive() with a block time
129         specified, or call vTaskDelay()).  If the application makes use of the
130         vTaskDelete() API function (as this demo application does) then it is also
131         important that vApplicationIdleHook() is permitted to return to its calling
132         function, because it is the responsibility of the idle task to clean up
133         memory allocated by the kernel to any task that has since been deleted. */
134 }
135 /*-----------------------------------------------------------*/
136
137 void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
138 {
139         ( void ) pcTaskName;
140         ( void ) pxTask;
141
142         /* Run time stack overflow checking is performed if
143         configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2.  This hook
144         function is called if a stack overflow is detected. */
145         taskDISABLE_INTERRUPTS();
146         for( ;; );
147 }
148 /*-----------------------------------------------------------*/
149
150 void vApplicationTickHook( void )
151 {
152         /* This function will be called by each tick interrupt if
153         configUSE_TICK_HOOK is set to 1 in FreeRTOSConfig.h.  User code can be
154         added here, but the tick hook is called from an interrupt context, so
155         code must not attempt to block, and only the interrupt safe FreeRTOS API
156         functions can be used (those that end in FromISR()). */
157 }
158 /*-----------------------------------------------------------*/
159