]> begriffs open source - cmsis-freertos/blob - Demo/AVR_Dx_Atmel_Studio/RTOSDemo/main.c
Update README.md - branch main is now the base branch
[cmsis-freertos] / Demo / AVR_Dx_Atmel_Studio / RTOSDemo / main.c
1 /*
2 (C) 2020 Microchip Technology Inc. and its subsidiaries.
3
4 Subject to your compliance with these terms, you may use Microchip software and
5 any derivatives exclusively with Microchip products. It is your responsibility
6 to comply with third party license terms applicable to your use of third party
7 software (including open source software) that may accompany Microchip software.
8
9 THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS".  NO WARRANTIES, WHETHER EXPRESS,
10 IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES
11 OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
12 IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
13 INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER
14 RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF
15 THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE.  TO THE FULLEST EXTENT ALLOWED
16 BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO THIS
17 SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY
18 TO MICROCHIP FOR THIS SOFTWARE.
19 */
20
21 #include <avr/io.h>
22 #include "FreeRTOS.h"
23 #include "clk_config.h"
24
25 #define mainSELECTED_APPLICATION    0
26
27 /* Configure the hardware as necessary to run this demo. */
28 static void prvSetupHardware( void );
29
30 #if ( mainSELECTED_APPLICATION == 0 )
31 extern void main_blinky( void );
32 extern void init_blinky( void );
33 #elif ( mainSELECTED_APPLICATION == 1 )
34 extern void main_minimal( void );
35 extern void init_minimal( void );
36 #elif ( mainSELECTED_APPLICATION == 2 )
37 extern void main_full( void );
38 extern void init_full( void );
39 #else
40 #error Invalid mainSELECTED_APPLICATION setting. See the comments at the top of this file and above the mainSELECTED_APPLICATION definition.
41 #endif
42
43 int main( void )
44 {
45     prvSetupHardware();
46
47 #if ( mainSELECTED_APPLICATION == 0 )
48     main_blinky();
49 #elif ( mainSELECTED_APPLICATION == 1 )
50     main_minimal();
51 #elif ( mainSELECTED_APPLICATION == 2 )
52     main_full();
53 #endif
54
55     return 0;
56 }
57
58 static void prvSetupHardware( void )
59 {
60     /* Ensure no interrupts execute while the scheduler is in an inconsistent
61     state.  Interrupts are automatically enabled when the scheduler is
62     started. */
63     portDISABLE_INTERRUPTS();
64
65     CLK_init();
66
67 #if ( mainSELECTED_APPLICATION == 0 )
68     init_blinky();
69 #elif ( mainSELECTED_APPLICATION == 1 )
70     init_minimal();
71 #elif ( mainSELECTED_APPLICATION == 2 )
72     init_full();
73 #endif
74 }
75
76 /* vApplicationStackOverflowHook is called when a stack overflow occurs.
77 This is usefull in application development, for debugging.  To use this
78 hook, uncomment it, and set configCHECK_FOR_STACK_OVERFLOW to 1 in
79 "FreeRTOSConfig.h" header file. */
80
81 // void vApplicationStackOverflowHook(TaskHandle_t *pxTask, char *pcTaskName )
82 // {
83 //     for( ;; );
84 // }
85
86 /* vApplicationMallocFailedHook is called when memorry allocation fails.
87 This is usefull in application development, for debugging.  To use this
88 hook, uncomment it, and set configUSE_MALLOC_FAILED_HOOK to 1 in
89 "FreeRTOSConfig.h" header file. */
90
91 // void vApplicationMallocFailedHook( void )
92 // {
93 //     for( ;; );
94 // }