Modules#
Common Microcontroller Functions#
Many of the supplied example applications use these microcontroller functions. See hal/micro/micro.h for source code.
Note
The term SFD refers to the Start Frame Delimiter.
Many of the supplied example applications use these microcontroller functions. See hal/micro/micro-common.h for source code.
See also hal/micro/cortexm3/micro.h for source code.
Vector Table Index Definitions#
These are numerical definitions for vector table. Indices 0 through 15 are Cortex-M3 standard exception vectors and indices 16 through 35 are EM3XX specific interrupt vectors.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
A numerical definition for a vector.
Number of vectors.
Enumerations#
Enumerations for the possible microcontroller sleep modes.
Variables#
Helper variable to track the state of 1.8V regulator.
Functions#
Called from emberInit and provides a means for the HAL to increment a boot counter, most commonly in non-volatile memory.
Gets information about what caused the microcontroller to reset.
Calls halGetResetInfo() and supplies a string describing it.
Initializes microcontroller-specific peripherals.
Restarts the microcontroller and therefore everything else.
Powers up microcontroller peripherals and board peripherals.
Powers down microcontroller peripherals and board peripherals.
Resumes microcontroller peripherals and board peripherals.
Suspends microcontroller peripherals and board peripherals.
Enables the watchdog timer.
Disables the watchdog timer.
Determines whether the watchdog has been enabled or disabled.
Puts the microcontroller to sleep in a specified mode.
Same as halSleep() except it preserves the current interrupt state rather than always enabling interrupts prior to returning.
Blocks the current thread of execution for the specified amount of time, in microseconds.
Disable the 1.8V regulator. This function is to be used when the 1.8V supply is provided externally. Disabling the regulator saves current consumption. Disabling the regulator will cause ADC readings of external signals to be wrong. These exteranl signals include analog sources ADC0 thru ADC5 and VDD_PADS/4.
Enable the 1.8V regulator. Normally the 1.8V regulator is enabled out of reset. This function is only needed if the 1.8V regulator has been disabled and ADC conversions on external signals are needed. These exteranl signals include analog sources ADC0 thru ADC5 and VDD_PADS/4. The state of 1v8 survives deep sleep.
Records the specified reset cause then forces a reboot.
Returns the Extended Reset Cause information.
Calls halGetExtendedResetInfo() and supplies a string describing the extended cause of the reset. halGetResetString() should also be called to get the string for the base reset cause.
Enables or disables Radio HoldOff support.
Returns whether Radio HoldOff has been enabled or not.
To assist with saving power when the radio automatically powers down, this function allows the stack to tell the HAL to put pins specific to radio functionality in their powerdown state. The pin state used is the state used by halInternalPowerDownBoard, but applied only to the pins identified in the global variable gpioRadioPowerBoardMask. The stack will automatically call this function as needed, but it will only change GPIO state based on gpioRadioPowerBoardMask. Most commonly, the bits set in gpioRadioPowerBoardMask petain to using a Front End Module. This function is often called from interrupt context.
To assist with saving power when radio2 automatically powers down, this function allows the stack to tell the HAL to put pins specific to radio functionality in their powerdown state. The pin state used is the state used by halInternalPowerDownBoard, but applied only to the pins identified in the global variable gpioRadioPowerBoardMask. The stack will automatically call this function as needed, but it will only change GPIO state based on gpioRadioPowerBoardMask. Most commonly, the bits set in gpioRadioPowerBoardMask petain to using a Front End Module. This function is often called from interrupt context.
To assist with saving power when the radio automatically powers up, this function allows the stack to tell the HAL to put pins specific to radio functionality in their powerup state. The pin state used is the state used by halInternalPowerUpBoard, but applied only to the pins identified in the global variable gpioRadioPowerBoardMask. The stack will automatically call this function as needed, but it will only change GPIO state based on gpioRadioPowerBoardMask. Most commonly, the bits set in gpioRadioPowerBoardMask petain to using a Front End Module. This function can be called from interrupt context.
To assist with saving power when radio2 automatically powers up, this function allows the stack to tell the HAL to put pins specific to radio functionality in their powerup state. The pin state used is the state used by halInternalPowerUpBoard, but applied only to the pins identified in the global variable gpioRadioPowerBoardMask. The stack will automatically call this function as needed, but it will only change GPIO state based on gpioRadioPowerBoardMask. Most commonly, the bits set in gpioRadioPowerBoardMask petain to using a Front End Module. This function can be called from interrupt context.
This function is called automatically by the stack prior to Radio power-up and after Radio power-down. It can be used to prepare for the radio being powered on and to clean up after it's been powered off. Unlike halStackRadioPowerUpBoard() and halStackRadioPowerDownBoard(), which can be called from interrupt context, this function is only called from main-line context.
Handler called in main context prior to radio being powered on.
Handler called in main context after radio has been powered off.
Macros#
Calls halGetExtendedResetInfo() and translates the EM35x reset code to the corresponding value used by the EM2XX HAL. Any reset codes not present in the EM2XX are returned after being OR'ed with 0x80.
The value that must be passed as the single parameter to halInternalDisableWatchDog() in order to successfully disable the watchdog timer.
Vector Table Index Definitions Documentation#
Enumeration Documentation#
SleepModes#
SleepModes
Enumerations for the possible microcontroller sleep modes.
SLEEPMODE_RUNNING Everything is active and running. In practice this mode is not used, but it is defined for completeness of information.
SLEEPMODE_IDLE Only the CPU is idled. The rest of the chip continues running normally. The chip will wake from any interrupt.
SLEEPMODE_WAKETIMER The sleep timer clock sources remain running. The RC is always running and the 32kHz XTAL depends on the board header. Wakeup is possible from both GPIO and the sleep timer. System time is maintained. The sleep timer is assumed to be configured properly for wake events.
SLEEPMODE_MAINTAINTIMER The sleep timer clock sources remain running. The RC is always running and the 32kHz XTAL depends on the board header. Wakeup is possible from only GPIO. System time is maintained. NOTE: This mode is not available on EM2XX chips.
SLEEPMODE_NOTIMER The sleep timer clock sources (both RC and XTAL) are turned off. Wakeup is possible from only GPIO. System time is lost.
SLEEPMODE_HIBERNATE This maps to EM4 Hibernate on the EFM32/EFR32 devices. RAM is not retained in SLEEPMODE_HIBERNATE so waking up from this sleepmode will behave like a reset. NOTE: This mode is only available on EFM32/EFR32
Enumerator | |
---|---|
SLEEPMODE_RUNNING | |
SLEEPMODE_IDLE | |
SLEEPMODE_WAKETIMER | |
SLEEPMODE_MAINTAINTIMER | |
SLEEPMODE_NOTIMER | |
SLEEPMODE_HIBERNATE | |
SLEEPMODE_RESERVED | |
SLEEPMODE_POWERDOWN | |
SLEEPMODE_POWERSAVE |
Variable Documentation#
halCommonVreg1v8EnableCount#
volatile int8_t halCommonVreg1v8EnableCount
Helper variable to track the state of 1.8V regulator.
Note
: Only used when DISABLE_INTERNAL_1V8_REGULATOR is defined.
Function Documentation#
halStackProcessBootCount#
void halStackProcessBootCount (void )
Called from emberInit and provides a means for the HAL to increment a boot counter, most commonly in non-volatile memory.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
This is useful while debugging to determine the number of resets that might be seen over a period of time. Exposing this functionality allows the application to disable or alter processing of the boot counter if, for example, the application is expecting a lot of resets that could wear out non-volatile storage or some
@stackusage Called from emberInit only as helpful debugging information. This should be left enabled by default, but this function can also be reduced to a simple return statement if boot counting is not desired.
halGetResetInfo#
uint8_t halGetResetInfo (void )
Gets information about what caused the microcontroller to reset.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Returns
A code identifying the cause of the reset.
halGetResetString#
PGM_P halGetResetString (void )
Calls halGetResetInfo() and supplies a string describing it.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
@appusage Useful for diagnostic printing of text just after program initialization.
Returns
A pointer to a program space string.
halInit#
void halInit (void )
Initializes microcontroller-specific peripherals.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
halReboot#
void halReboot (void )
Restarts the microcontroller and therefore everything else.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
halPowerUp#
void halPowerUp (void )
Powers up microcontroller peripherals and board peripherals.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
halPowerDown#
void halPowerDown (void )
Powers down microcontroller peripherals and board peripherals.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
halResume#
void halResume (void )
Resumes microcontroller peripherals and board peripherals.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
halSuspend#
void halSuspend (void )
Suspends microcontroller peripherals and board peripherals.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
halInternalEnableWatchDog#
void halInternalEnableWatchDog (void )
Enables the watchdog timer.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
halInternalDisableWatchDog#
void halInternalDisableWatchDog (uint8_t magicKey)
Disables the watchdog timer.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint8_t | N/A | magicKey | A value (MICRO_DISABLE_WATCH_DOG_KEY) that enables the function. |
Note
To prevent the watchdog from being disabled accidentally, a magic key must be provided.
halInternalWatchDogEnabled#
bool halInternalWatchDogEnabled (void )
Determines whether the watchdog has been enabled or disabled.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Returns
A bool value indicating if the watchdog is current enabled.
halSleep#
void halSleep (SleepModes sleepMode)
Puts the microcontroller to sleep in a specified mode.
Type | Direction | Argument Name | Description |
---|---|---|---|
SleepModes | N/A | sleepMode | A microcontroller sleep mode |
Note
This routine always enables interrupts.
See Also
halSleepPreserveInts#
void halSleepPreserveInts (SleepModes sleepMode)
Same as halSleep() except it preserves the current interrupt state rather than always enabling interrupts prior to returning.
Type | Direction | Argument Name | Description |
---|---|---|---|
SleepModes | N/A | sleepMode | A microcontroller sleep mode |
See Also
halCommonDelayMicroseconds#
void halCommonDelayMicroseconds (uint16_t us)
Blocks the current thread of execution for the specified amount of time, in microseconds.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint16_t | N/A | us | The specified time, in microseconds. Values should be between 1 and 65535 microseconds. |
The function is implemented with cycle-counted busy loops and is intended to create the short delays required when interfacing with hardware peripherals.
The accuracy of the timing provided by this function is not specified, but a general rule is that when running off of a crystal oscillator it will be within 10us. If the micro is running off of another type of oscillator (e.g. RC) the timing accuracy will potentially be much worse.
halCommonDisableVreg1v8#
void halCommonDisableVreg1v8 (void )
Disable the 1.8V regulator. This function is to be used when the 1.8V supply is provided externally. Disabling the regulator saves current consumption. Disabling the regulator will cause ADC readings of external signals to be wrong. These exteranl signals include analog sources ADC0 thru ADC5 and VDD_PADS/4.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Note
: Only used when DISABLE_INTERNAL_1V8_REGULATOR is defined.
halCommonEnableVreg1v8#
void halCommonEnableVreg1v8 (void )
Enable the 1.8V regulator. Normally the 1.8V regulator is enabled out of reset. This function is only needed if the 1.8V regulator has been disabled and ADC conversions on external signals are needed. These exteranl signals include analog sources ADC0 thru ADC5 and VDD_PADS/4. The state of 1v8 survives deep sleep.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Note
: Only used when DISABLE_INTERNAL_1V8_REGULATOR is defined.
halBeforeEM4#
void halBeforeEM4 (uint32_t duration, RTCCRamData input)
Type | Direction | Argument Name | Description |
---|---|---|---|
uint32_t | N/A | duration | |
RTCCRamData | N/A | input |
halInternalSysReset#
void halInternalSysReset (uint16_t extendedCause)
Records the specified reset cause then forces a reboot.
Type | Direction | Argument Name | Description |
---|---|---|---|
uint16_t | N/A | extendedCause |
halGetExtendedResetInfo#
uint16_t halGetExtendedResetInfo (void )
Returns the Extended Reset Cause information.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Returns
A 16-bit code identifying the base and extended cause of the reset
halGetExtendedResetString#
PGM_P halGetExtendedResetString (void )
Calls halGetExtendedResetInfo() and supplies a string describing the extended cause of the reset. halGetResetString() should also be called to get the string for the base reset cause.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
@appusage Useful for diagnostic printing of text just after program initialization.
Returns
A pointer to a program space string.
halSetRadioHoldOff#
EmberStatus halSetRadioHoldOff (bool enable)
Enables or disables Radio HoldOff support.
Type | Direction | Argument Name | Description |
---|---|---|---|
bool | N/A | enable | When true, configures ::RHO_GPIO in BOARD_HEADER as an input which, when asserted, will prevent the radio from transmitting. When false, configures ::RHO_GPIO for its original default purpose. |
Returns
EMBER_SUCCESS if Radio HoldOff was configured as desired or EMBER_BAD_ARGUMENT if requesting it be enabled but RHO has not been configured by the BOARD_HEADER.
halGetRadioHoldOff#
bool halGetRadioHoldOff (void )
Returns whether Radio HoldOff has been enabled or not.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
Returns
true if Radio HoldOff has been enabled, false otherwise.
halStackRadioPowerDownBoard#
void halStackRadioPowerDownBoard (void )
To assist with saving power when the radio automatically powers down, this function allows the stack to tell the HAL to put pins specific to radio functionality in their powerdown state. The pin state used is the state used by halInternalPowerDownBoard, but applied only to the pins identified in the global variable gpioRadioPowerBoardMask. The stack will automatically call this function as needed, but it will only change GPIO state based on gpioRadioPowerBoardMask. Most commonly, the bits set in gpioRadioPowerBoardMask petain to using a Front End Module. This function is often called from interrupt context.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
halStackRadio2PowerDownBoard#
void halStackRadio2PowerDownBoard (void )
To assist with saving power when radio2 automatically powers down, this function allows the stack to tell the HAL to put pins specific to radio functionality in their powerdown state. The pin state used is the state used by halInternalPowerDownBoard, but applied only to the pins identified in the global variable gpioRadioPowerBoardMask. The stack will automatically call this function as needed, but it will only change GPIO state based on gpioRadioPowerBoardMask. Most commonly, the bits set in gpioRadioPowerBoardMask petain to using a Front End Module. This function is often called from interrupt context.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
halStackRadioPowerUpBoard#
void halStackRadioPowerUpBoard (void )
To assist with saving power when the radio automatically powers up, this function allows the stack to tell the HAL to put pins specific to radio functionality in their powerup state. The pin state used is the state used by halInternalPowerUpBoard, but applied only to the pins identified in the global variable gpioRadioPowerBoardMask. The stack will automatically call this function as needed, but it will only change GPIO state based on gpioRadioPowerBoardMask. Most commonly, the bits set in gpioRadioPowerBoardMask petain to using a Front End Module. This function can be called from interrupt context.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
halStackRadio2PowerUpBoard#
void halStackRadio2PowerUpBoard (void )
To assist with saving power when radio2 automatically powers up, this function allows the stack to tell the HAL to put pins specific to radio functionality in their powerup state. The pin state used is the state used by halInternalPowerUpBoard, but applied only to the pins identified in the global variable gpioRadioPowerBoardMask. The stack will automatically call this function as needed, but it will only change GPIO state based on gpioRadioPowerBoardMask. Most commonly, the bits set in gpioRadioPowerBoardMask petain to using a Front End Module. This function can be called from interrupt context.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
halStackRadioPowerMainControl#
void halStackRadioPowerMainControl (bool powerUp)
This function is called automatically by the stack prior to Radio power-up and after Radio power-down. It can be used to prepare for the radio being powered on and to clean up after it's been powered off. Unlike halStackRadioPowerUpBoard() and halStackRadioPowerDownBoard(), which can be called from interrupt context, this function is only called from main-line context.
Type | Direction | Argument Name | Description |
---|---|---|---|
bool | N/A | powerUp |
halRadioPowerUpHandler#
void halRadioPowerUpHandler (void )
Handler called in main context prior to radio being powered on.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |
halRadioPowerDownHandler#
void halRadioPowerDownHandler (void )
Handler called in main context after radio has been powered off.
Type | Direction | Argument Name | Description |
---|---|---|---|
void | N/A |