Microcontroller functions#

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.

Functions#

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
MICRO_DISABLE_WATCH_DOG_KEY 0xA5U

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

Function Documentation#

halInit#

void halInit (void )

Initializes microcontroller-specific peripherals.

Parameters
TypeDirectionArgument NameDescription
voidN/A

halReboot#

void halReboot (void )

Restarts the microcontroller and therefore everything else.

Parameters
TypeDirectionArgument NameDescription
voidN/A

halInternalEnableWatchDog#

void halInternalEnableWatchDog (void )

Enables the watchdog timer.

Parameters
TypeDirectionArgument NameDescription
voidN/A

halInternalDisableWatchDog#

void halInternalDisableWatchDog (uint8_t magicKey)

Disables the watchdog timer.

Parameters
TypeDirectionArgument NameDescription
uint8_tN/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.


halInternalWatchDogEnabled#

bool halInternalWatchDogEnabled (void )

Determines whether the watchdog has been enabled or disabled.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

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


halResetWatchdog#

void halResetWatchdog (void )

hal Reset Watchdog

Parameters
TypeDirectionArgument NameDescription
voidN/A

halInternalSetCtune#

void halInternalSetCtune (uint16_t tune)

Change the CTUNE value.

Parameters
TypeDirectionArgument NameDescription
uint16_tN/Atune

Value to set CTUNE to.

Involves switching to HFRCO and turning off the HFXO temporarily.


halInternalGetCtune#

uint16_t halInternalGetCtune (void )

Get the CTUNE value.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • Current CTUNE value.


halGetResetInfo#

uint8_t halGetResetInfo (void )

Gets information about what caused the microcontroller to reset.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Returns

  • A code identifying the cause of the reset.


halGetResetString#

const char * halGetResetString (void )

Calls halGetResetInfo() and supplies a string describing it.

Parameters
TypeDirectionArgument NameDescription
voidN/A

Useful for diagnostic printing of text just after program initialization.

Returns

  • A pointer to a program space string.