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.

Modules#

RTCCRamData

Enumerations#

enum
SLEEPMODE_RUNNING = 0U
SLEEPMODE_IDLE = 1U
SLEEPMODE_WAKETIMER = 2U
SLEEPMODE_MAINTAINTIMER = 3U
SLEEPMODE_NOTIMER = 4U
SLEEPMODE_HIBERNATE = 5U
SLEEPMODE_RESERVED = 6U
SLEEPMODE_POWERDOWN = 7U
SLEEPMODE_POWERSAVE = 8U
}

Enumerations for the possible microcontroller sleep modes.

Typedefs#

typedef uint32_t
typedef uint32_t

Variables#

volatile int8_t

Helper variable to track the state of 1.8V regulator.

Functions#

void

Called from emberInit and provides a means for the HAL to increment a boot counter, most commonly in non-volatile memory.

uint8_t

Gets information about what caused the microcontroller to reset.

PGM_P

Calls halGetResetInfo() and supplies a string describing it.

void
halInit(void)

Initializes microcontroller-specific peripherals.

void
halReboot(void)

Restarts the microcontroller and therefore everything else.

void

Powers up microcontroller peripherals and board peripherals.

void

Powers down microcontroller peripherals and board peripherals.

void
halResume(void)

Resumes microcontroller peripherals and board peripherals.

void

Suspends microcontroller peripherals and board peripherals.

void

Enables the watchdog timer.

void
halInternalDisableWatchDog(uint8_t magicKey)

Disables the watchdog timer.

bool

Determines whether the watchdog has been enabled or disabled.

void
halSleep(SleepModes sleepMode)

Puts the microcontroller to sleep in a specified mode.

void
halSleepPreserveInts(SleepModes sleepMode)

Same as halSleep() except it preserves the current interrupt state rather than always enabling interrupts prior to returning.

void

Blocks the current thread of execution for the specified amount of time, in microseconds.

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.

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.

void
halBeforeEM4(uint32_t duration, RTCCRamData input)

Macros#

#define

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.

#define

The value that must be passed as the single parameter to halInternalDisableWatchDog() in order to successfully disable the watchdog timer.

#define
#define
GPIO_MASK 0xFFFFFF
#define
WAKE_GPIO_MASK GPIO_MASK
#define
WAKE_GPIO_SIZE GPIO_MASK_SIZE
#define
#define
#define

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

Definition at line 106 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

Typedef Documentation#

WakeEvents#

typedef uint32_t WakeEvents

Definition at line 141 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

WakeMask#

typedef uint32_t WakeMask

Definition at line 142 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

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.


Definition at line 195 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

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.

Parameters
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

  • EmberStack Usage:\n 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.


Definition at line 68 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro.h

halGetResetInfo#

uint8_t halGetResetInfo (void )

Gets information about what caused the microcontroller to reset.

Parameters
N/A

Returns

  • A code identifying the cause of the reset.


Definition at line 74 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro.h

halGetResetString#

PGM_P halGetResetString (void )

Calls halGetResetInfo() and supplies a string describing it.

Parameters
N/A
  • Application Usage:\n Useful for diagnostic printing of text just after program#

    initialization.

Returns

  • A pointer to a program space string.


Definition at line 83 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro.h

halInit#

void halInit (void )

Initializes microcontroller-specific peripherals.

Parameters
N/A

Definition at line 30 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

halReboot#

void halReboot (void )

Restarts the microcontroller and therefore everything else.

Parameters
N/A

Definition at line 34 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

halPowerUp#

void halPowerUp (void )

Powers up microcontroller peripherals and board peripherals.

Parameters
N/A

Definition at line 38 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

halPowerDown#

void halPowerDown (void )

Powers down microcontroller peripherals and board peripherals.

Parameters
N/A

Definition at line 42 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

halResume#

void halResume (void )

Resumes microcontroller peripherals and board peripherals.

Parameters
N/A

Definition at line 46 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

halSuspend#

void halSuspend (void )

Suspends microcontroller peripherals and board peripherals.

Parameters
N/A

Definition at line 50 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

halInternalEnableWatchDog#

void halInternalEnableWatchDog (void )

Enables the watchdog timer.

Parameters
N/A

Definition at line 60 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

halInternalDisableWatchDog#

void halInternalDisableWatchDog (uint8_t magicKey)

Disables the watchdog timer.

Parameters
N/AmagicKey

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.


Definition at line 69 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

halInternalWatchDogEnabled#

bool halInternalWatchDogEnabled (void )

Determines whether the watchdog has been enabled or disabled.

Parameters
N/A

Returns

  • A bool value indicating if the watchdog is current enabled.


Definition at line 75 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

halSleep#

void halSleep (SleepModes sleepMode)

Puts the microcontroller to sleep in a specified mode.

Parameters
N/AsleepMode

A microcontroller sleep mode

Note

  • This routine always enables interrupts.

See Also


Definition at line 160 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

halSleepPreserveInts#

void halSleepPreserveInts (SleepModes sleepMode)

Same as halSleep() except it preserves the current interrupt state rather than always enabling interrupts prior to returning.

Parameters
N/AsleepMode

A microcontroller sleep mode

See Also


Definition at line 169 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

halCommonDelayMicroseconds#

void halCommonDelayMicroseconds (uint16_t us)

Blocks the current thread of execution for the specified amount of time, in microseconds.

Parameters
N/Aus

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.


Definition at line 186 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

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.

Parameters
N/A

Note

  • : Only used when DISABLE_INTERNAL_1V8_REGULATOR is defined.


Definition at line 206 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

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.

Parameters
N/A

Note

  • : Only used when DISABLE_INTERNAL_1V8_REGULATOR is defined.


Definition at line 217 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

halBeforeEM4#

void halBeforeEM4 (uint32_t duration, RTCCRamData input)
Parameters
N/Aduration
N/Ainput

Definition at line 228 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

halAfterEM4#

RTCCRamData halAfterEM4 (void )
Parameters
N/A

Definition at line 229 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

Macro Definition Documentation#

halGetEm2xxResetInfo#

#define halGetEm2xxResetInfo
Value:
()

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.

  • Application Usage:\n Used by the EZSP host as a platform-independent NCP reset code.#

Returns

  • The EM2XX-compatible reset code. If not supported by the EM2XX, return the platform-specific code with B7 set.


Definition at line 98 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro.h

MICRO_DISABLE_WATCH_DOG_KEY#

#define MICRO_DISABLE_WATCH_DOG_KEY
Value:
0xA5U

The value that must be passed as the single parameter to halInternalDisableWatchDog() in order to successfully disable the watchdog timer.


Definition at line 56 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

GPIO_MASK_SIZE#

#define GPIO_MASK_SIZE
Value:
24

Definition at line 137 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

GPIO_MASK#

#define GPIO_MASK
Value:
0xFFFFFF

Definition at line 138 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

WAKE_GPIO_MASK#

#define WAKE_GPIO_MASK
Value:
GPIO_MASK

Definition at line 139 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

WAKE_GPIO_SIZE#

#define WAKE_GPIO_SIZE
Value:
GPIO_MASK_SIZE

Definition at line 140 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

WAKE_MASK_INVALID#

#define WAKE_MASK_INVALID
Value:
(-1)

Definition at line 145 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

WAKE_EVENT_SIZE#

#define WAKE_EVENT_SIZE
Value:
WakeMask

Note

  • The preprocessor symbol WAKE_EVENT_SIZE has been deprecated. Please use WakeMask instead.


Definition at line 150 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h

DEBUG_TOGGLE#

#define DEBUG_TOGGLE

Definition at line 188 of file /mnt/raid/workspaces/ws.S2kiimDMR/overlay/gsdk/platform/base/hal/micro/micro-common.h