Microcontroller functions#

See also hal/micro/cortexm3/micro.h for source code.

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.

Vector Table Index Definitions#

These are numerical definitions for vector table.Only Cortex-M standard exception vectors (indices 0 through 15) are represented since device specific vectors can be (and often are) different across dies.

#define

A numerical definition for a vector.

#define

reset vector index

#define

nmi vector index

#define

hard fault vector index

#define

memory fault vector index

#define

bus fault vector index

#define

usage fault vector index

#define

reserved07 vector index

#define

reserved08 vector index

#define

reserved09 vector index

#define

reserved10 vector index

#define

svcall vector index

#define

debug monitor vector index

#define

reserved13 vector index

#define

pendsv vector index

#define

systick vector index

#define

Utility macro to convert from IRQ numbers to exception numbers/ vector indices.

#define
VECTOR_TABLE_LENGTH (IRQ_TO_VECTOR_NUMBER(EXT_IRQ_COUNT))

Number of vectors.

Functions#

void
halInternalSysReset(uint16_t extendedCause)

Records the specified reset cause then forces a reboot.

uint16_t

Returns the Extended Reset Cause information.

uint8_t

Calls halGetExtendedResetInfo() and translates the EM35x reset code to the corresponding value used by the EM2XX HAL.

const char *

Calls halGetExtendedResetInfo() and supplies a string describing the extended cause of the reset.

void
halInit(void)

Initializes microcontroller-specific peripherals.

void
halReboot(void)

Restarts the microcontroller and therefore everything else.

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

hal Reset Watchdog

void
halInternalSetCtune(uint16_t tune)

Change the CTUNE value.

uint16_t

Get the CTUNE value.

uint8_t

Gets information about what caused the microcontroller to reset.

const char *

Calls halGetResetInfo() and supplies a string describing it.

Macros#

#define

EM2xx-compatible reset code returned by halGetEm2xxResetInfo()

#define

EM2XX reports POWERON instead.

#define

EM2XX reset poweron.

#define

EM2XX reset watchdog.

#define

EM2XX reset assert.

#define

EM2XX reset bootloader.

#define

EM2XX reset software.

#define

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#

STACK_VECTOR_INDEX#

#define STACK_VECTOR_INDEX
Value:
0U

A numerical definition for a vector.

special case: stack pointer at reset


Definition at line 110 of file platform/service/legacy_hal/inc/efm32_micro.h

RESET_VECTOR_INDEX#

#define RESET_VECTOR_INDEX
Value:
1U

reset vector index


Definition at line 111 of file platform/service/legacy_hal/inc/efm32_micro.h

NMI_VECTOR_INDEX#

#define NMI_VECTOR_INDEX
Value:
2U

nmi vector index


Definition at line 112 of file platform/service/legacy_hal/inc/efm32_micro.h

HARD_FAULT_VECTOR_INDEX#

#define HARD_FAULT_VECTOR_INDEX
Value:
3U

hard fault vector index


Definition at line 113 of file platform/service/legacy_hal/inc/efm32_micro.h

MEMORY_FAULT_VECTOR_INDEX#

#define MEMORY_FAULT_VECTOR_INDEX
Value:
4U

memory fault vector index


Definition at line 114 of file platform/service/legacy_hal/inc/efm32_micro.h

BUS_FAULT_VECTOR_INDEX#

#define BUS_FAULT_VECTOR_INDEX
Value:
5U

bus fault vector index


Definition at line 115 of file platform/service/legacy_hal/inc/efm32_micro.h

USAGE_FAULT_VECTOR_INDEX#

#define USAGE_FAULT_VECTOR_INDEX
Value:
6U

usage fault vector index


Definition at line 116 of file platform/service/legacy_hal/inc/efm32_micro.h

RESERVED07_VECTOR_INDEX#

#define RESERVED07_VECTOR_INDEX
Value:
7U

reserved07 vector index


Definition at line 117 of file platform/service/legacy_hal/inc/efm32_micro.h

RESERVED08_VECTOR_INDEX#

#define RESERVED08_VECTOR_INDEX
Value:
8U

reserved08 vector index


Definition at line 118 of file platform/service/legacy_hal/inc/efm32_micro.h

RESERVED09_VECTOR_INDEX#

#define RESERVED09_VECTOR_INDEX
Value:
9U

reserved09 vector index


Definition at line 119 of file platform/service/legacy_hal/inc/efm32_micro.h

RESERVED10_VECTOR_INDEX#

#define RESERVED10_VECTOR_INDEX
Value:
10U

reserved10 vector index


Definition at line 120 of file platform/service/legacy_hal/inc/efm32_micro.h

SVCALL_VECTOR_INDEX#

#define SVCALL_VECTOR_INDEX
Value:
11U

svcall vector index


Definition at line 121 of file platform/service/legacy_hal/inc/efm32_micro.h

DEBUG_MONITOR_VECTOR_INDEX#

#define DEBUG_MONITOR_VECTOR_INDEX
Value:
12U

debug monitor vector index


Definition at line 122 of file platform/service/legacy_hal/inc/efm32_micro.h

RESERVED13_VECTOR_INDEX#

#define RESERVED13_VECTOR_INDEX
Value:
13U

reserved13 vector index


Definition at line 123 of file platform/service/legacy_hal/inc/efm32_micro.h

PENDSV_VECTOR_INDEX#

#define PENDSV_VECTOR_INDEX
Value:
14U

pendsv vector index


Definition at line 124 of file platform/service/legacy_hal/inc/efm32_micro.h

SYSTICK_VECTOR_INDEX#

#define SYSTICK_VECTOR_INDEX
Value:
15U

systick vector index


Definition at line 125 of file platform/service/legacy_hal/inc/efm32_micro.h

IRQ_TO_VECTOR_NUMBER#

#define IRQ_TO_VECTOR_NUMBER
Value:
(x)

Utility macro to convert from IRQ numbers to exception numbers/ vector indices.

These are different because the latter include the Cortex-M standard exceptions while the former do not.


Definition at line 134 of file platform/service/legacy_hal/inc/efm32_micro.h

VECTOR_TABLE_LENGTH#

#define VECTOR_TABLE_LENGTH
Value:
(IRQ_TO_VECTOR_NUMBER(EXT_IRQ_COUNT))

Number of vectors.

EXT_IRQ_COUNT is defined in the device header but does not include the Cortex-M standard exceptions.


Definition at line 142 of file platform/service/legacy_hal/inc/efm32_micro.h

Function Documentation#

halInternalSysReset#

void halInternalSysReset (uint16_t extendedCause)

Records the specified reset cause then forces a reboot.

Parameters
N/AextendedCause

Definition at line 162 of file platform/service/legacy_hal/inc/efm32_micro.h

halGetExtendedResetInfo#

uint16_t halGetExtendedResetInfo (void )

Returns the Extended Reset Cause information.

Parameters
N/A

Returns

  • A 16-bit code identifying the base and extended cause of the reset


Definition at line 169 of file platform/service/legacy_hal/inc/efm32_micro.h

halGetEm2xxResetInfo#

uint8_t halGetEm2xxResetInfo (void )

Calls halGetExtendedResetInfo() and translates the EM35x reset code to the corresponding value used by the EM2XX HAL.

Parameters
N/A

Any reset codes not present in the EM2XX are returned after being OR'ed with 0x80.

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 180 of file platform/service/legacy_hal/inc/efm32_micro.h

halGetExtendedResetString#

const char * halGetExtendedResetString (void )

Calls halGetExtendedResetInfo() and supplies a string describing the extended cause of the reset.

Parameters
N/A

halGetResetString() should also be called to get the string for the base reset cause

Useful for diagnostic printing of text just after program initialization.

Returns

  • A pointer to a program space string.


Definition at line 191 of file platform/service/legacy_hal/inc/efm32_micro.h

halInit#

void halInit (void )

Initializes microcontroller-specific peripherals.

Parameters
N/A

Definition at line 33 of file platform/service/legacy_hal/inc/micro-common.h

halReboot#

void halReboot (void )

Restarts the microcontroller and therefore everything else.

Parameters
N/A

Definition at line 37 of file platform/service/legacy_hal/inc/micro-common.h

halInternalEnableWatchDog#

void halInternalEnableWatchDog (void )

Enables the watchdog timer.

Parameters
N/A

Definition at line 47 of file platform/service/legacy_hal/inc/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 56 of file platform/service/legacy_hal/inc/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 62 of file platform/service/legacy_hal/inc/micro-common.h

halResetWatchdog#

void halResetWatchdog (void )

hal Reset Watchdog

Parameters
N/A

Definition at line 64 of file platform/service/legacy_hal/inc/micro-common.h

halInternalSetCtune#

void halInternalSetCtune (uint16_t tune)

Change the CTUNE value.

Parameters
N/Atune

Value to set CTUNE to.

Involves switching to HFRCO and turning off the HFXO temporarily.


Definition at line 73 of file platform/service/legacy_hal/inc/micro-common.h

halInternalGetCtune#

uint16_t halInternalGetCtune (void )

Get the CTUNE value.

Parameters
N/A

Returns

  • Current CTUNE value.


Definition at line 81 of file platform/service/legacy_hal/inc/micro-common.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 66 of file platform/service/legacy_hal/inc/micro.h

halGetResetString#

const char * halGetResetString (void )

Calls halGetResetInfo() and supplies a string describing it.

Parameters
N/A

Useful for diagnostic printing of text just after program initialization.

Returns

  • A pointer to a program space string.


Definition at line 75 of file platform/service/legacy_hal/inc/micro.h

Macro Definition Documentation#

EM2XX_RESET_UNKNOWN#

#define EM2XX_RESET_UNKNOWN
Value:
0

EM2xx-compatible reset code returned by halGetEm2xxResetInfo()

EN2XX reset unknow


Definition at line 149 of file platform/service/legacy_hal/inc/efm32_micro.h

EM2XX_RESET_EXTERNAL#

#define EM2XX_RESET_EXTERNAL
Value:
1

EM2XX reports POWERON instead.


Definition at line 150 of file platform/service/legacy_hal/inc/efm32_micro.h

EM2XX_RESET_POWERON#

#define EM2XX_RESET_POWERON
Value:
2

EM2XX reset poweron.


Definition at line 151 of file platform/service/legacy_hal/inc/efm32_micro.h

EM2XX_RESET_WATCHDOG#

#define EM2XX_RESET_WATCHDOG
Value:
3

EM2XX reset watchdog.


Definition at line 152 of file platform/service/legacy_hal/inc/efm32_micro.h

EM2XX_RESET_ASSERT#

#define EM2XX_RESET_ASSERT
Value:
6

EM2XX reset assert.


Definition at line 153 of file platform/service/legacy_hal/inc/efm32_micro.h

EM2XX_RESET_BOOTLOADER#

#define EM2XX_RESET_BOOTLOADER
Value:
9

EM2XX reset bootloader.


Definition at line 154 of file platform/service/legacy_hal/inc/efm32_micro.h

EM2XX_RESET_SOFTWARE#

#define EM2XX_RESET_SOFTWARE
Value:
11

EM2XX reset software.


Definition at line 155 of file platform/service/legacy_hal/inc/efm32_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 43 of file platform/service/legacy_hal/inc/micro-common.h