Microcontroller functions#

Microcontroller functions.

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

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#

uint8_t

Gets information about what caused the microcontroller to reset.

const char *

Calls halGetResetInfo() and supplies a string describing it.

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
halInternalSetCtune(uint16_t tune)

Change the CTUNE value.

uint16_t

Get the CTUNE value.

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 95 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 96 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 97 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 98 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 99 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 100 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 101 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 102 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 103 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 104 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 105 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 106 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 107 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 108 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 109 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 110 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 119 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 127 of file platform/service/legacy_hal/inc/efm32_micro.h

Function Documentation#

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

halInternalSysReset#

void halInternalSysReset (uint16_t extendedCause)

Records the specified reset cause then forces a reboot.

Parameters
N/AextendedCause

Definition at line 147 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 154 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 165 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 176 of file platform/service/legacy_hal/inc/efm32_micro.h

halInit#

void halInit (void )

Initializes microcontroller-specific peripherals.

Parameters
N/A

Definition at line 37 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 41 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 85 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 93 of file platform/service/legacy_hal/inc/micro-common.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 134 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 135 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 136 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 137 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 138 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 139 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 140 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 47 of file platform/service/legacy_hal/inc/micro-common.h

halInternalEnableWatchDog#

#define halInternalEnableWatchDog

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

halInternalDisableWatchDog#

#define halInternalDisableWatchDog

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

halInternalWatchDogEnabled#

#define halInternalWatchDogEnabled
Value:
(...)

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

halResetWatchdog#

#define halResetWatchdog

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