Morse Micro IoT SDK  2.6.4-esp32
Morse Micro Abstraction Layer API for UART

Detailed Description

This provides an abstraction layer for a UART.

This is used by MM-IoT-SDK example applications.

This is a very simple API and leaves UART configuration to the HAL.

Typedefs

typedef void(* mmhal_uart_rx_cb_t) (const uint8_t *data, size_t length, void *arg)
 Function type for UART RX callback. More...
 

Enumerations

enum  mmhal_uart_deep_sleep_mode { MMHAL_UART_DEEP_SLEEP_DISABLED , MMHAL_UART_DEEP_SLEEP_ONE_SHOT }
 Enumeration of deep sleep modes for the UART HAL. More...
 

Functions

void mmhal_uart_init (mmhal_uart_rx_cb_t rx_cb, void *rx_cb_arg)
 Initialize the UART HAL and perform any setup necessary. More...
 
void mmhal_uart_deinit (void)
 Deinitialize the UART HAL, and disable the UART.
 
void mmhal_uart_tx (const uint8_t *data, size_t length)
 Transmit data on the UART. More...
 
bool mmhal_uart_set_deep_sleep_mode (enum mmhal_uart_deep_sleep_mode mode)
 Set the deep sleep mode for the UART. More...
 

Typedef Documentation

◆ mmhal_uart_rx_cb_t

typedef void(* mmhal_uart_rx_cb_t) (const uint8_t *data, size_t length, void *arg)

Function type for UART RX callback.

Note
The UART HAL must not invoke this function from interrupt context. However, the implementation should not block for long periods of time or received data may be lost.
Parameters
dataThe received data.
lengthLength of the received data.
argOpaque argument (as passed in to mmhal_uart_init()).

Definition at line 42 of file mmhal_uart.h.

Enumeration Type Documentation

◆ mmhal_uart_deep_sleep_mode

Enumeration of deep sleep modes for the UART HAL.

Enumerator
MMHAL_UART_DEEP_SLEEP_DISABLED 

Deep sleep mode is disabled.

MMHAL_UART_DEEP_SLEEP_ONE_SHOT 

Enable deep sleep until activity occurs on data-link transport.

Definition at line 70 of file mmhal_uart.h.

Function Documentation

◆ mmhal_uart_init()

void mmhal_uart_init ( mmhal_uart_rx_cb_t  rx_cb,
void *  rx_cb_arg 
)

Initialize the UART HAL and perform any setup necessary.

Parameters
rx_cbOptional callback to be invoked on receive (may be NULL). This callback may be invoked from interrupt context so should return quickly.
rx_cb_argOptional opaque argument to be passed to the RX callback. May be NULL.

◆ mmhal_uart_set_deep_sleep_mode()

bool mmhal_uart_set_deep_sleep_mode ( enum mmhal_uart_deep_sleep_mode  mode)

Set the deep sleep mode for the UART.

See mmhal_uart_deep_sleep_mode for possible deep sleep modes. Note that a given platform may not support all modes.

Parameters
modeThe deep sleep mode to set.
Returns
true if the mode was set successfully; false on failure (e.g., unsupported mode).

◆ mmhal_uart_tx()

void mmhal_uart_tx ( const uint8_t *  data,
size_t  length 
)

Transmit data on the UART.

This will block until all data is buffered for transmit (but may return before transmission has completed).

Parameters
dataData to transmit.
lengthLength of data.