![]() |
Energy Micro IEC60355 Library Example Project 1.0 (internal use only!) GCC-Version
Example project demonstrating POST and BIST library functions
|
The IEC60335 Class-B Library Example is a formal and simple software
to show the usage of the iec60335_classb library.
Easy and simple coded functions are showing most of the library functions. To run the example the following conditions are required:
|
Modules | |
| Library Tool functions | |
the software includes functions to demonstrate the libraries capabilities | |
| Library Configuration | |
This modules are prepared for specific devices and compilers.
| |
| CMSIS Library Extension (Interrupts) | |
This modules is an extension to the EFM32 library. | |
Functions | |
| void | SysTick_Handler (void) |
| SysTick_Handler Interrupt Service Routine for system tick counter. | |
| void | TIMER0_IRQHandler (void) |
| TIMER0_IRQHandler Interrupt Service Routine for timer0. | |
| void | initSystick (uint32_t mode) |
| void | initController (void) |
| short basic initialization to enable generic controller functions | |
| int | main (void) |
| main routine testing the library content | |
| void | Reset (void) |
| Initial Entry after POR or SW-Reset, prepares bss section and initial values, branch to main Input : None Output : None Return : None. | |
Variables | |
| IRQTestData_t | IRQtest |
| FlashCRC_t | bistTest |
| ClockTest_t | ClockTest |
The IEC60335 Class-B Library Example is a formal and simple software
to show the usage of the iec60335_classb library.
Easy and simple coded functions are showing most of the library functions. To run the example the following conditions are required:
| void initController | ( | void | ) |
short basic initialization to enable generic controller functions
Definition at line 98 of file main.c.
Referenced by main().
{
/* Enable required clock domains */
CMU_ClockEnable(cmuClock_HFPER, true);
/* TODO : user initialization here */
}

| void initSystick | ( | uint32_t | mode | ) |
Definition at line 69 of file main.c.
Referenced by main().
{
if (mode == 1) // enable
{
/* Setup SysTick Timer for 10 msec interrupts */
/* set reload register */
SysTick->LOAD = ((14000000 / 100) & SysTick_LOAD_RELOAD_Msk) - 1;
/* set Priority for Cortex-M3 System Interrupts */
SCB->SHP[((uint32_t)(SysTick_IRQn) & 0xF) - 4] = ((((1 << __NVIC_PRIO_BITS) - 1) << (8 - __NVIC_PRIO_BITS)) & 0xff);
/* Load the SysTick Counter Value */
SysTick->VAL = 0;
/* Enable SysTick IRQ and SysTick Timer */
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk | SysTick_CTRL_ENABLE_Msk;
}
if (mode == 0) // disable
{
/* set reload register */
SysTick->LOAD = 0;
/* Load the SysTick Counter Value */
SysTick->VAL = 0;
/* Enable SysTick IRQ and SysTick Timer */
SysTick->CTRL = 0;
}
}

| int main | ( | void | ) |
main routine testing the library content
Definition at line 109 of file main.c.
References CallIRQHandler, critical_uint32_t_struct::data, FLASH_CRC_Restart, IEC60335_ClassB_Clocktest_PollHandler(), IEC60335_ClassB_CPUregTest_BIST(), IEC60335_ClassB_CriticalDataInit, IEC60335_ClassB_CriticalDataPush, IEC60335_ClassB_CriticalDataValidate, IEC60335_ClassB_FLASHtest_BIST(), IEC60335_ClassB_initClockTest(), IEC60335_ClassB_InitInterruptTest(), IEC60335_ClassB_InterruptCheck(), IEC60335_ClassB_PCTest_BIST(), IEC60335_ClassB_RAMtest_BIST(), IEC60335_testFailed, IEC60335_testPassed, initController(), initSystick(), IRQTestData_t::MaxThres, and IRQTestData_t::MinThres.
{
testResult_t result = IEC60335_testFailed; /* test results */
/* critical data */
critical_uint32_t Crit_test = IEC60335_ClassB_CriticalDataInit(12345678);
/* hardware setup */
initController();
/* critical data */
IEC60335_ClassB_CriticalDataPush(Crit_test, 0x87654321); /* regular usage */
result = IEC60335_ClassB_CriticalDataValidate(Crit_test);
/* not allowed by compiler */
// Crit_test = 34343434;
result = IEC60335_ClassB_CriticalDataValidate(Crit_test);
Crit_test.data = 89898989; /* not allowed in runtime */
result = IEC60335_ClassB_CriticalDataValidate(Crit_test);
/* clock/rtc test */
IEC60335_ClassB_initClockTest(100, 5); /* init clock test */
result = IEC60335_ClassB_Clocktest_PollHandler(); /* check evidence */
/* IRQ test */
IRQtest.MaxThres = 1000; /* IRQ test parameter */
IRQtest.MinThres = 10;
initSystick(1);
IEC60335_ClassB_InitInterruptTest(SysTick_IRQn, CallIRQHandler, &IRQtest);
while (IEC60335_ClassB_InterruptCheck(SysTick_IRQn) != IEC60335_testPassed)
{}
/* IRQ test off */
IEC60335_ClassB_InitInterruptTest(SVCall_IRQn, 0, 0);
initSystick(0);
/* Flash test */
result = IEC60335_ClassB_FLASHtest_BIST (FLASH_CRC_Restart);
while (1)
{
result = IEC60335_ClassB_CPUregTest_BIST();
result = IEC60335_ClassB_FLASHtest_BIST (0);
result = IEC60335_ClassB_PCTest_BIST();
result = IEC60335_ClassB_RAMtest_BIST (0x20000100, 0x10);
if (result != IEC60335_testPassed)
{
/* Break point here to test with debugger */
__NOP();
}
}
}

| void Reset | ( | void | ) |
Initial Entry after POR or SW-Reset, prepares bss section and initial values, branch to main Input : None Output : None Return : None.
< The initial stack pointer
< -15 reset handler
< -14 NMI handler
< -13 hard fault handler
< -12 MPU fault handler
< -11 bus fault handler
< -10 usage fault handler
< Reserved
< Reserved
< Reserved
< Reserved
< -5 SVCall exception handler
< -4 Debug monitor handler
< Reserved
< -2 The PendSVC handler
< -1 SysTick handler
< 0, DMA handler
< 1, GPIO_EVEN handler
< 2, TIMER0 handler
< 3, USART0_RX handler
< 4, USART0_TX handler
< 5, ACMP0 handler
< 6, ADC0 handler
< 7, DAC0 handler
< 8, I2C0 handler
< 9, GPIO_ODD handler
< 10, TIMER1 handler
< 11, TIMER2 handler
< 12, USART1_RX handler
< 13, USART1_TX handler
< 14, USART2_RX handler
< 15, USART2_TX handler
< 16, UART0_RX handler
< 17, UART0_TX handler
< 18, LEUART0 handler
< 19, LEUART1 handler
< 20, LETIMER0 handler
< 21, PCNT0 handler
< 22, PCNT1 handler
< 23, PCNT2 handler
< 24, RTC handler
< 25, CMU handler
< 26, VCMP handler
< 27, LCD handler
< 28, MSC handler
< 29, AES handler
Definition at line 132 of file startup.c.
References ACMP0_IRQHandler, ADC0_IRQHandler, AES_IRQHandler, BusFault_Handler, CMU_IRQHandler, DAC0_IRQHandler, DebugMon_Handler, DMA_IRQHandler, GPIO_EVEN_IRQHandler, GPIO_ODD_IRQHandler, HardFault_Handler, I2C0_IRQHandler, LCD_IRQHandler, LETIMER0_IRQHandler, LEUART0_IRQHandler, LEUART1_IRQHandler, MemManage_Handler, MSC_IRQHandler, NMI_Handler, PCNT0_IRQHandler, PCNT1_IRQHandler, PCNT2_IRQHandler, PendSV_Handler, Reset(), RTC_IRQHandler, SVC_Handler, SysTick_Handler, TIMER0_IRQHandler, TIMER1_IRQHandler, TIMER2_IRQHandler, UART0_RX_IRQHandler, UART0_TX_IRQHandler, UsageFault_Handler, USART0_RX_IRQHandler, USART0_TX_IRQHandler, USART1_RX_IRQHandler, USART1_TX_IRQHandler, USART2_RX_IRQHandler, USART2_TX_IRQHandler, and VCMP_IRQHandler.
Referenced by Reset().


| void SysTick_Handler | ( | void | ) |
SysTick_Handler Interrupt Service Routine for system tick counter.
Definition at line 53 of file main.c.
References IEC60335_ClassB_Clocktest_TimerHandler().

| void TIMER0_IRQHandler | ( | void | ) |
TIMER0_IRQHandler Interrupt Service Routine for timer0.
2, handler for TIMER0 interrupt
Definition at line 62 of file main.c.
References IEC60335_ClassB_Clocktest_TimerHandler().
{
/* Clear Interrupt */
TIMER0->IFC = TIMER_IFC_OF;
IEC60335_ClassB_Clocktest_TimerHandler();
}

RTC/Timer-test structure
Definition at line 52 of file iec60335_class_b_timer_rtc_test.c.