Morse Micro IoT SDK  2.10.4
Morse Micro Operating System Hardware Abstraction Layer (mmhal_os) API

Detailed Description

This provide an abstraction layer for hardware specific functionality used by the Morse Micro Operating System Abstraction Layer (mmosal) API.

Note
This API is not used by morselib.

Enumerations

enum  mmhal_sleep_state { MMHAL_SLEEP_DISABLED , MMHAL_SLEEP_SHALLOW , MMHAL_SLEEP_DEEP }
 Enumeration of MCU sleep state. More...
 
enum  mmhal_isr_state { MMHAL_NOT_IN_ISR , MMHAL_IN_ISR , MMHAL_ISR_STATE_UNKNOWN }
 Enumeration of ISR states (i.e., whether in ISR or not). More...
 

Functions

void mmhal_early_init (void)
 Initialization before RTOS scheduler starts.
 
void mmhal_init (void)
 Initialization after RTOS scheduler started.
 
void mmhal_reset (void)
 Reset the microcontroller.
 
enum mmhal_sleep_state mmhal_sleep_prepare (uint32_t expected_idle_time_ms)
 Function to prepare MCU to enter sleep. More...
 
uint32_t mmhal_sleep (enum mmhal_sleep_state sleep_state, uint32_t expected_idle_time_ms)
 Function to enter MCU sleep. More...
 
void mmhal_sleep_abort (enum mmhal_sleep_state sleep_state)
 Function to abort the MCU sleep state. More...
 
void mmhal_sleep_cleanup (void)
 Function to cleanup on exit from the MCU sleep state.
 
enum mmhal_isr_state mmhal_get_isr_state (void)
 Get the current ISR state (i.e., whether in ISR or not). More...
 
void mmhal_log_write (const uint8_t *data, size_t len)
 Write to the debug log. More...
 
void mmhal_log_flush (void)
 Flush the debug log before returning. More...
 

Enumeration Type Documentation

◆ mmhal_isr_state

Enumeration of ISR states (i.e., whether in ISR or not).

Enumerator
MMHAL_NOT_IN_ISR 

The function was not executed from ISR context.

MMHAL_IN_ISR 

The function was executed from ISR context.

MMHAL_ISR_STATE_UNKNOWN 

The HAL does not support checking ISR state.

Definition at line 83 of file mmhal_os.h.

◆ mmhal_sleep_state

Enumeration of MCU sleep state.

Enumerator
MMHAL_SLEEP_DISABLED 

Disable MCU sleep.

MMHAL_SLEEP_SHALLOW 

MCU to enter shallow sleep.

MMHAL_SLEEP_DEEP 

MCU can enter deep sleep.

Definition at line 40 of file mmhal_os.h.

Function Documentation

◆ mmhal_get_isr_state()

enum mmhal_isr_state mmhal_get_isr_state ( void  )

Get the current ISR state (i.e., whether in ISR or not).

Returns
the current ISR state, or MMHAL_ISR_STATE_UNKNOWN if the HAL does not support checking ISR state.

◆ mmhal_log_flush()

void mmhal_log_flush ( void  )

Flush the debug log before returning.

Warning
Implementations of this function must support being invoked with interrupts disabled.

◆ mmhal_log_write()

void mmhal_log_write ( const uint8_t *  data,
size_t  len 
)

Write to the debug log.

It is assumed the caller will have mechanisms in place to prevent concurrent access.

Parameters
dataBuffer containing data to write.
lenLength of data in buffer.

◆ mmhal_sleep()

uint32_t mmhal_sleep ( enum mmhal_sleep_state  sleep_state,
uint32_t  expected_idle_time_ms 
)

Function to enter MCU sleep.

Parameters
sleep_stateSleep state to enter into.
expected_idle_time_msExpected time to sleep in milliseconds.
Returns
Elapsed sleep time in milliseconds.

◆ mmhal_sleep_abort()

void mmhal_sleep_abort ( enum mmhal_sleep_state  sleep_state)

Function to abort the MCU sleep state.

Note
This must only be invoked after mmhal_sleep_prepare() and before mmhal_sleep().
Parameters
sleep_stateSleep state to abort.

◆ mmhal_sleep_prepare()

enum mmhal_sleep_state mmhal_sleep_prepare ( uint32_t  expected_idle_time_ms)

Function to prepare MCU to enter sleep.

This will halt the timer that generates the RTOS tick.

Parameters
expected_idle_time_msExpected time to sleep in milliseconds.
Returns
the type of sleep permitted by the current system state.