]> begriffs open source - cmsis/blob - CMSIS/CoreValidation/Tests/main.c
Updated WiFi Driver API 1.0.0-beta
[cmsis] / CMSIS / CoreValidation / Tests / main.c
1 /*----------------------------------------------------------------------------
2  * Name:    main.c
3  *----------------------------------------------------------------------------*/
4
5 /* Includes ------------------------------------------------------------------*/
6
7 #include <stdio.h>
8 #include <stdlib.h>
9
10 #include "RTE_Components.h"
11 #include  CMSIS_device_header
12  
13 #ifdef RTE_Compiler_EventRecorder
14 #include "EventRecorder.h"
15 #endif
16
17 #include "cmsis_cv.h"
18 #include "CV_Report.h"
19
20 //lint -e970 allow using int for main
21
22 /* Private functions ---------------------------------------------------------*/
23 int main (void);
24
25 /**
26   * @brief  Main program
27   * @param  None
28   * @retval None
29   */
30 int main (void)
31 {  
32
33   // System Initialization
34   SystemCoreClockUpdate();
35 #ifdef RTE_Compiler_EventRecorder
36   // Initialize and start Event Recorder
37   (void)EventRecorderInitialize(EventRecordError, 1U);
38   (void)EventRecorderEnable    (EventRecordAll, 0xFEU, 0xFEU);
39 #endif
40   
41   cmsis_cv();
42   
43   #ifdef __MICROLIB
44   for(;;) {}
45   #else
46   exit(0);
47   #endif
48 }
49
50 #if defined(__CORTEX_A)
51 #include "irq_ctrl.h"
52
53 #if (defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)) || \
54   (defined ( __GNUC__ ))
55 #define __IRQ __attribute__((interrupt("IRQ")))
56 #elif defined ( __CC_ARM )
57 #define __IRQ __irq
58 #elif defined ( __ICCARM__ )
59 #define __IRQ __irq __arm
60 #else
61 #error "Unsupported compiler!"
62 #endif
63
64 __IRQ
65 void IRQ_Handler(void) {
66   const IRQn_ID_t irqn = IRQ_GetActiveIRQ();
67   IRQHandler_t const handler = IRQ_GetHandler(irqn);
68   if (handler != NULL) {
69     __enable_irq();
70     handler();
71     __disable_irq();
72   }
73   IRQ_EndOfInterrupt(irqn);
74 }
75
76 __IRQ
77 void Undef_Handler (void) {
78   cmsis_cv_abort(__FILENAME__, __LINE__, "Undefined Instruction!");
79   exit(0);
80 }
81
82 __IRQ
83 void SVC_Handler   (void) {
84 }
85
86 __IRQ
87 void PAbt_Handler  (void) {
88   cmsis_cv_abort(__FILENAME__, __LINE__, "Prefetch Abort!");
89   exit(0);
90 }
91
92 __IRQ
93 void DAbt_Handler  (void) {
94   cmsis_cv_abort(__FILENAME__, __LINE__, "Data Abort!");
95   exit(0);
96 }
97
98 __IRQ
99 void FIQ_Handler   (void) {
100 }
101 #endif
102
103 #if defined(__CORTEX_M)
104 __NO_RETURN
105 extern void HardFault_Handler(void);
106 void HardFault_Handler(void) {
107   cmsis_cv_abort(__FILENAME__, __LINE__, "HardFault!");
108   #ifdef __MICROLIB
109   for(;;) {}
110   #else
111   exit(0);
112   #endif
113 }
114 #endif