![]() |
Energy Micro IEC60355 Library Example Project 1.0 (internal use only!) GCC-Version
Example project demonstrating POST and BIST library functions
|
00001 /***************************************************************************/ 00029 #ifndef EFM32G890F128 00030 #define EFM32G890F128 00031 #endif 00032 00033 #include "efm32.h" 00034 #include "iec60335_class_b.h" 00035 #include "efm32g890f128.h" 00036 #include "main.h" 00037 #include "efm32_cmu.h" 00038 00043 IRQTestData_t IRQtest; 00044 FlashCRC_t bistTest; 00045 00046 extern ClockTest_t ClockTest; 00047 extern IRQTestData_t IRQtest; 00053 void SysTick_Handler(void) 00054 { 00055 IEC60335_ClassB_Clocktest_TimerHandler(); 00056 } 00057 00062 void TIMER0_IRQHandler(void) 00063 { 00064 /* Clear Interrupt */ 00065 TIMER0->IFC = TIMER_IFC_OF; 00066 IEC60335_ClassB_Clocktest_TimerHandler(); 00067 } 00068 00069 void initSystick(uint32_t mode) 00070 { 00071 if (mode == 1) // enable 00072 { 00073 /* Setup SysTick Timer for 10 msec interrupts */ 00074 /* set reload register */ 00075 SysTick->LOAD = ((14000000 / 100) & SysTick_LOAD_RELOAD_Msk) - 1; 00076 /* set Priority for Cortex-M3 System Interrupts */ 00077 SCB->SHP[((uint32_t)(SysTick_IRQn) & 0xF) - 4] = ((((1 << __NVIC_PRIO_BITS) - 1) << (8 - __NVIC_PRIO_BITS)) & 0xff); 00078 /* Load the SysTick Counter Value */ 00079 SysTick->VAL = 0; 00080 /* Enable SysTick IRQ and SysTick Timer */ 00081 SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk; 00082 } 00083 if (mode == 0) // disable 00084 { 00085 /* set reload register */ 00086 SysTick->LOAD = 0; 00087 /* Load the SysTick Counter Value */ 00088 SysTick->VAL = 0; 00089 /* Enable SysTick IRQ and SysTick Timer */ 00090 SysTick->CTRL = 0; 00091 } 00092 } 00093 00098 void initController(void) 00099 { 00100 /* Enable required clock domains */ 00101 CMU_ClockEnable(cmuClock_HFPER, true); 00102 /* TODO : user initialization here */ 00103 } 00104 00109 int main (void) 00110 { 00111 testResult_t result = IEC60335_testFailed; /* test results */ 00112 /* critical data */ 00113 critical_uint32_t Crit_test = IEC60335_ClassB_CriticalDataInit(12345678); 00114 /* hardware setup */ 00115 initController(); 00116 00117 /* critical data */ 00118 IEC60335_ClassB_CriticalDataPush(Crit_test, 0x87654321); /* regular usage */ 00119 result = IEC60335_ClassB_CriticalDataValidate(Crit_test); 00120 00121 /* not allowed by compiler */ 00122 // Crit_test = 34343434; 00123 result = IEC60335_ClassB_CriticalDataValidate(Crit_test); 00124 00125 Crit_test.data = 89898989; /* not allowed in runtime */ 00126 result = IEC60335_ClassB_CriticalDataValidate(Crit_test); 00127 00128 /* clock/rtc test */ 00129 IEC60335_ClassB_initClockTest(100, 5); /* init clock test */ 00130 result = IEC60335_ClassB_Clocktest_PollHandler(); /* check evidence */ 00131 00132 /* IRQ test */ 00133 IRQtest.MaxThres = 1000; /* IRQ test parameter */ 00134 IRQtest.MinThres = 10; 00135 initSystick(1); 00136 IEC60335_ClassB_InitInterruptTest(SysTick_IRQn, CallIRQHandler, &IRQtest); 00137 while (IEC60335_ClassB_InterruptCheck(SysTick_IRQn) != IEC60335_testPassed) 00138 {} 00139 /* IRQ test off */ 00140 IEC60335_ClassB_InitInterruptTest(SVCall_IRQn, 0, 0); 00141 initSystick(0); 00142 00143 /* Flash test */ 00144 result = IEC60335_ClassB_FLASHtest_BIST (FLASH_CRC_Restart); 00145 00146 while (1) 00147 { 00148 result = IEC60335_ClassB_CPUregTest_BIST(); 00149 00150 result = IEC60335_ClassB_FLASHtest_BIST (0); 00151 00152 result = IEC60335_ClassB_PCTest_BIST(); 00153 00154 result = IEC60335_ClassB_RAMtest_BIST (0x20000100, 0x10); 00155 00156 if (result != IEC60335_testPassed) 00157 { 00158 /* Break point here to test with debugger */ 00159 __NOP(); 00160 } 00161 } 00162 } 00166 /************************************** EOF *********************************/