NHS31xx SW API
startup: Startup and exception handlers

Detailed Description

This module implements the vector table for all exceptions. It also implements default handlers for all exceptions.

There are two flavors of exceptions: exceptions internal to the CPU core (the ARM), and exceptions external to the CPU core. The former are dictated by ARM and occupy the first 16 slots. The latter are dictated by the (peripherals of the ARM) and occupy slot 16 and onwards. The external exceptions are also referred to as (peripheral) interrupts, and have their own numbering.

An example of a peripheral interrupt is a timer overflow. An example o an ARM internal exception is the hard fault exception. A special case is the first ARM internal exception: reset.

The startup module has a common implementation for every handler. The implementation consists of an ASSERT(false) followed by an infinite loop. Only the reset handler has a real implementation, see below.

All handlers have a so-called "weak" implementation. This means that the application can override them by declaring a handler with exactly the same name/signature.

Details on reset
This module implements the reset handler. The implementation should be sufficient for most applications. However, the ResetISR is a weak implementation, so an application has the option to override it. The implementation of the reset handler consists of 3 steps:
  1. Initialization (cq zeroing) of all variables
  2. Initialization of the runtime lib (C++ only)
  3. Calling main
There is a fourth step: when main returns (should never happen), there is an assert and hang.
Example 1 - Implement timer interrupt handler
When using a timer interrupt, the default handler for the timer needs to be overridden. Declare a function with the exact name 'CT16B0_IRQHandler': The following code configures and starts the timer:
Example 2 - Firing a hard fault to own handler
Declare a function with the exact name 'HardFault_Handler' to override the default hard fault handler:
{
ASSERT(false);
}
The following code causes a hard fault by calling an illegal address:
((void(*)(void))40000)(); /* assumption: 40000 is not a valid address */
Example 3 - Overriding the reset vector
Include the function with the exact name 'ResetISR' to override the default reset handler. The most basic implementation is shown. It initializes (c.q. zeros) all variables, and calls main():
void ResetISR(void)
{
Startup_VarInit(); /* initialization of static variables */
MyPreMain();
extern int main(void);
main();
}

Macros

#define WEAK   __attribute__ ((weak))
 

Functions

void ResetISR (void)
 
void NMI_Handler (void)
 
void HardFault_Handler (void)
 
void SVC_Handler (void)
 
void PendSV_Handler (void)
 
void SysTick_Handler (void)
 
void RFFIELD_IRQHandler (void)
 
void RTCPWREQ_IRQHandler (void)
 
void NFC_IRQHandler (void)
 
void RTC_IRQHandler (void)
 
void I2C0_IRQHandler (void)
 
void PMUFLD_IRQHandler (void)
 
void PMUBOD_IRQHandler (void)
 
void SSP0_IRQHandler (void)
 
void TSEN_IRQHandler (void)
 
void C2D_IRQHandler (void)
 
void I2D_IRQHandler (void)
 
void ADC_IRQHandler (void)
 
void WDT_IRQHandler (void)
 
void FLASH_IRQHandler (void)
 
void EEPROM_IRQHandler (void)
 
void PIO0_IRQHandler (void)
 
void Startup_VarInit (void)
 
void PIO0_0_IRQHandler (void)
 
void PIO0_1_IRQHandler (void)
 
void PIO0_2_IRQHandler (void)
 
void PIO0_3_IRQHandler (void)
 
void PIO0_4_IRQHandler (void)
 
void PIO0_5_IRQHandler (void)
 
void PIO0_6_IRQHandler (void)
 
void PIO0_7_IRQHandler (void)
 
void PIO0_8_IRQHandler (void)
 
void PIO0_9_IRQHandler (void)
 
void PIO0_10_IRQHandler (void)
 
void CT16B0_IRQHandler (void)
 
void CT32B0_IRQHandler (void)
 

Macro Definition Documentation

◆ WEAK

#define WEAK   __attribute__ ((weak))

Macro to annotate a function as "weak".

Note
A weak function is linked-in, unless a function with the exact same name and signature exists (at application level). The latter function will be linked-in instead. This is primarily useful in defining library functions that can be overridden in user code.
See also
https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html

Function Documentation

◆ ResetISR()

void ResetISR ( void  )

Handler for (ARM) Reset Interrupt. This handler takes care of the target's initialization before running application code. This handler has a default (WEAK) implementation which performs flowing steps:

  1. Call Startup_VarInit (Variable initialization etc.)
  2. Initialization of the runtime libraries (if c++)
  3. Call main to start the actual application
Note
If user overrides its WEAK implementation, he should not forget to call Startup_VarInit and main.

◆ NMI_Handler()

void NMI_Handler ( void  )

Handler for (ARM) None Maskable Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality.

◆ HardFault_Handler()

void HardFault_Handler ( void  )

Handler for (ARM) HardFault Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality.

◆ SVC_Handler()

void SVC_Handler ( void  )

Handler for (ARM) SuperVisor Call Interrupt (Mostly used by an OS). This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ PendSV_Handler()

void PendSV_Handler ( void  )

Handler for (ARM) Pending system-level service Interrupt (Mostly used by an OS). This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ SysTick_Handler()

void SysTick_Handler ( void  )

Handler for (ARM) System Tick Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality
Note
To enable SysTick please refer to System Tick Timer (SysTick)

◆ PIO0_0_IRQHandler()

void PIO0_0_IRQHandler ( void  )

Handler for (Peripheral) the respective PIO Start Logic Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality
'System wake-up start logic' for more info on the Start Logic.

◆ PIO0_1_IRQHandler()

void PIO0_1_IRQHandler ( void  )

Handler for (Peripheral) the respective PIO Start Logic Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality
'System wake-up start logic' for more info on the Start Logic.

◆ PIO0_2_IRQHandler()

void PIO0_2_IRQHandler ( void  )

Handler for (Peripheral) the respective PIO Start Logic Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality
'System wake-up start logic' for more info on the Start Logic.

◆ PIO0_3_IRQHandler()

void PIO0_3_IRQHandler ( void  )

Handler for (Peripheral) the respective PIO Start Logic Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality
'System wake-up start logic' for more info on the Start Logic.

◆ PIO0_4_IRQHandler()

void PIO0_4_IRQHandler ( void  )

Handler for (Peripheral) the respective PIO Start Logic Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality
'System wake-up start logic' for more info on the Start Logic.

◆ PIO0_5_IRQHandler()

void PIO0_5_IRQHandler ( void  )

Handler for (Peripheral) the respective PIO Start Logic Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality
'System wake-up start logic' for more info on the Start Logic.

◆ PIO0_6_IRQHandler()

void PIO0_6_IRQHandler ( void  )

Handler for (Peripheral) the respective PIO Start Logic Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality
'System wake-up start logic' for more info on the Start Logic.

◆ PIO0_7_IRQHandler()

void PIO0_7_IRQHandler ( void  )

Handler for (Peripheral) the respective PIO Start Logic Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality
'System wake-up start logic' for more info on the Start Logic.

◆ PIO0_8_IRQHandler()

void PIO0_8_IRQHandler ( void  )

Handler for (Peripheral) the respective PIO Start Logic Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality
'System wake-up start logic' for more info on the Start Logic.

◆ PIO0_9_IRQHandler()

void PIO0_9_IRQHandler ( void  )

Handler for (Peripheral) the respective PIO Start Logic Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality
'System wake-up start logic' for more info on the Start Logic.

◆ PIO0_10_IRQHandler()

void PIO0_10_IRQHandler ( void  )

Handler for (Peripheral) the respective PIO Start Logic Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality
'System wake-up start logic' for more info on the Start Logic.

◆ RFFIELD_IRQHandler()

void RFFIELD_IRQHandler ( void  )

Handler for (Peripheral) NFC Access Start Logic Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality
'System wake-up start logic' for more info on the Start Logic.

◆ RTCPWREQ_IRQHandler()

void RTCPWREQ_IRQHandler ( void  )

Handler for (Peripheral) RTC Wake Up Request Start Logic Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality
'System wake-up start logic' for more info on the Start Logic.

◆ NFC_IRQHandler()

void NFC_IRQHandler ( void  )

Handler for (Peripheral) NFC Read/Write Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ RTC_IRQHandler()

void RTC_IRQHandler ( void  )

Handler for (Peripheral) RTC Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality
Warning
A possible spurious interrupt can occur. Be sure to guard the code in the interrupt handler by checking the interrupt status using Chip_RTC_Int_GetRawStatus. See

◆ I2C0_IRQHandler()

void I2C0_IRQHandler ( void  )

Handler for (Peripheral) I2C0 Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ CT16B0_IRQHandler()

void CT16B0_IRQHandler ( void  )

Handler for (Peripheral) Respective Timer Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ CT32B0_IRQHandler()

void CT32B0_IRQHandler ( void  )

Handler for (Peripheral) Respective Timer Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ PMUFLD_IRQHandler()

void PMUFLD_IRQHandler ( void  )

Handler for (Peripheral) PMU RF Power Detection Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ PMUBOD_IRQHandler()

void PMUBOD_IRQHandler ( void  )

Handler for (Peripheral) PMU Brown Out Detection Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ SSP0_IRQHandler()

void SSP0_IRQHandler ( void  )

Handler for (Peripheral) SSP Read/Write Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ TSEN_IRQHandler()

void TSEN_IRQHandler ( void  )

Handler for (Peripheral) Temperature Sensor Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ C2D_IRQHandler()

void C2D_IRQHandler ( void  )

Handler for (Peripheral) Capacitance-to-Digital converter Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ I2D_IRQHandler()

void I2D_IRQHandler ( void  )

Handler for (Peripheral) Current-to-Digital converter Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ ADC_IRQHandler()

void ADC_IRQHandler ( void  )

Handler for (Peripheral) Analog-to-Digital/Digital-to-Analog converter Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ WDT_IRQHandler()

void WDT_IRQHandler ( void  )

Handler for (Peripheral) Watchdog Timer Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ FLASH_IRQHandler()

void FLASH_IRQHandler ( void  )

Handler for (Peripheral) FLASH memory Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ EEPROM_IRQHandler()

void EEPROM_IRQHandler ( void  )

Handler for (Peripheral) EEPROM memory Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ PIO0_IRQHandler()

void PIO0_IRQHandler ( void  )

Handler for (Peripheral) GPIO Port 0 Interrupt. This handler has a default (WEAK) implementation

See also
WEAK for documentation on overriding this handler's functionality

◆ Startup_VarInit()

void Startup_VarInit ( void  )

Initializes all static variables with an initializer and zeros all other variables.

Note
This function should only be called when implementing an application specific ResetISR(). The default ResetISR() already calls this function before calling main().