Energy Micro IEC60355 Library Example Project 1.0 (internal use only!) GCC-Version
Example project demonstrating POST and BIST library functions

IEC60335 Class-B Library Example

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:

  1. HiTOP for ARM Cortex or similar version and Debugging interface
  2. Hitex GCC 4.5.0 compiler for cortex
  3. Evaluation hardware from Energy Micro populated with EFM232G890F128 device
  4. knowledge of Cortex in general and the EFM device specificly Several Projects are implemented for the following tool chains:
  5. HiTOP for Cortex
  6. IAR Kickstart 6.1
  7. Keil uVision 4 All the projects are related to the same source code. Special compiler specific
    mnemonics are defined and activated by the compiler by setting special defines
    during compilation and link process. Special focus must be set to the configuration and CMSIS library extension.
More...

Collaboration diagram for IEC60335 Class-B Library Example:

Modules

 Library Tool functions
 

the software includes functions to demonstrate the libraries capabilities
on the real hardware. The modules are fixed on
the Gecko Evalboard from Energy Micro.


 Library Configuration
 

This modules are prepared for specific devices and compilers.
Changing any of this will cause non or mail functionality and requires new compilation and tests.
Compiler specific issues must be regarded in concern to the user
application. Specific modules have their own configurations to keep
cross effects minimized.

  1. development environment
  2. physical target devices
  3. other internal components and structures like memory size
  4. special conditions (Tessy)

 CMSIS Library Extension (Interrupts)
 

This modules is an extension to the EFM32 library.
Here interrupt handler and exceptions are defined for direkt usage
under CMSIS compliant software.


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

Detailed Description

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:

  1. HiTOP for ARM Cortex or similar version and Debugging interface
  2. Hitex GCC 4.5.0 compiler for cortex
  3. Evaluation hardware from Energy Micro populated with EFM232G890F128 device
  4. knowledge of Cortex in general and the EFM device specificly Several Projects are implemented for the following tool chains:
  5. HiTOP for Cortex
  6. IAR Kickstart 6.1
  7. Keil uVision 4 All the projects are related to the same source code. Special compiler specific
    mnemonics are defined and activated by the compiler by setting special defines
    during compilation and link process. Special focus must be set to the configuration and CMSIS library extension.

Function Documentation

void initController ( void  )

short basic initialization to enable generic controller functions

Note:
user initialization can vary here

Definition at line 98 of file main.c.

Referenced by main().

{
  /* Enable required clock domains */
  CMU_ClockEnable(cmuClock_HFPER, true);
  /* TODO : user initialization here */
}

Here is the caller graph for this function:

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;
  }
}

Here is the caller graph for this function:

int main ( void  )

main routine testing the library content

Note:
POST tests are located in the startup files

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();
    }
  }
}

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

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();
}

Here is the call graph for this function:


Variable Documentation

Definition at line 44 of file main.c.

RTC/Timer-test structure

Definition at line 52 of file iec60335_class_b_timer_rtc_test.c.

IRQ-test structure

Definition at line 43 of file main.c.