This provides an abstraction layer for a UART interface.
This is used by MM-IoT-SDK example applications.
This is a very simple API and leaves UART configuration to the HAL.
|
| typedef void(* | mmhal_uart_rx_cb_t) (const uint8_t *data, size_t length, void *arg) |
| | Function type for UART RX callback. More...
|
| |
◆ 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. As such, it is safe for implementations of this callback to assume that it will not be invoked from interrupt context. However, implementations of this function should avoid blocking for long periods of time, since this may result in the UART HAL dropping received data if its buffer becomes full.
- Parameters
-
| data | The received data. |
| length | Length of the received data. |
| arg | Opaque argument (as passed in to mmhal_uart_init()). |
Definition at line 44 of file mmhal_uart.h.
◆ 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 78 of file mmhal_uart.h.
◆ mmhal_uart_configure()
Configure the UART to change the current operation.
- Parameters
-
| config | Pointer to configuration options for the UART peripheral. |
- Returns
true if the new config was applied, else false.
◆ mmhal_uart_init()
Initialize the UART HAL and perform any setup necessary.
- Parameters
-
| rx_cb | Optional callback to be invoked on receive (may be NULL). |
| rx_cb_arg | Optional opaque argument to be passed to the RX callback. May be NULL. |
◆ mmhal_uart_set_deep_sleep_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
-
| mode | The 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
-
| data | Data to transmit. |
| length | Length of data. |
◆ mmhal_uart_validate_config()
Validate the given UART configuration options struct.
- Parameters
-
| config | Pointer to configuration options for the UART peripheral. |
- Returns
true if the arguments are valid, else false.