![]() |
BSB Developer Docs
|
Serial HAL API. More...
#include <stddef.h>#include <stdint.h>#include <stdbool.h>#include <furi_hal_serial_types.h>Go to the source code of this file.
Typedefs | |
| typedef void(* | FuriHalSerialTxCallback) (FuriHalSerialHandle *handle, FuriHalSerialTxEvent event, void *context) |
| Receive callback function type. | |
| typedef void(* | FuriHalSerialRxCallback) (FuriHalSerialHandle *handle, FuriHalSerialRxEvent event, void *context) |
| Transmit callback function type. | |
Enumerations | |
| enum | FuriHalSerialHwFlowControl { FuriHalSerialHwFlowControlNone , FuriHalSerialHwFlowControlRtsCts } |
| Serial hardware flow control modes. More... | |
| enum | FuriHalSerialRxEvent { FuriHalSerialRxEventData = (1 << 0) , FuriHalSerialRxEventIdle = (1 << 1) , FuriHalSerialRxEventBreak = (1 << 2) , FuriHalSerialRxEventFrameError = (1 << 3) , FuriHalSerialRxEventNoiseError = (1 << 4) , FuriHalSerialRxEventOverrunError = (1 << 5) } |
| Serial RX events. More... | |
| enum | FuriHalSerialTxEvent { FuriHalSerialTxEventComplete = (1 << 0) } |
| Serial TX events. More... | |
Functions | |
| void | furi_hal_serial_init (FuriHalSerialHandle *handle, uint32_t baud_rate) |
| Initialize the serial interface. | |
| void | furi_hal_serial_deinit (FuriHalSerialHandle *handle) |
| Deinitialize the serial interface. | |
| void | furi_hal_serial_suspend (FuriHalSerialHandle *handle) |
| Suspend the serial interface. | |
| void | furi_hal_serial_resume (FuriHalSerialHandle *handle) |
| Resume the serial interface. | |
| bool | furi_hal_serial_is_baud_rate_supported (FuriHalSerialHandle *handle, uint32_t baud_rate) |
| Determine whether a certain baud rate is supported. | |
| void | furi_hal_serial_set_baud_rate (FuriHalSerialHandle *handle, uint32_t baud_rate) |
| Set the baud rate for the serial interface. | |
| void | furi_hal_serial_set_hw_flow_control (FuriHalSerialHandle *handle, FuriHalSerialHwFlowControl flow_control) |
| Set the hardware flow control mode for the serial interface. | |
| void | furi_hal_serial_set_tx_callback (FuriHalSerialHandle *handle, FuriHalSerialTxCallback callback, void *context) |
| Set the transmit callback function for the serial interface. | |
| void | furi_hal_serial_set_rx_callback (FuriHalSerialHandle *handle, FuriHalSerialRxCallback callback, void *context) |
| Set the receive callback function for the serial interface. | |
| size_t | furi_hal_serial_tx (FuriHalSerialHandle *handle, const uint8_t *buffer, size_t buffer_size, uint32_t timeout) |
| Put data into the UART transmit FIFO buffer. | |
| bool | furi_hal_serial_tx_wait_complete (FuriHalSerialHandle *handle, uint32_t timeout) |
| Wait for the UART transmit FIFO buffer to empty, meaning all bytes have been transmitted. | |
| bool | furi_hal_serial_rx_available (FuriHalSerialHandle *handle) |
| Determine whether there is received data ready for reading. | |
| uint8_t | furi_hal_serial_rx (FuriHalSerialHandle *handle) |
| Read the next received data character. | |
| void | furi_hal_serial_async_rx_start (FuriHalSerialHandle *handle, bool report_errors) |
| Start receiving in interrupt-driven mode. | |
| void | furi_hal_serial_async_rx_stop (FuriHalSerialHandle *handle) |
| Stop receiving in interrupt-driven mode. | |
| void | furi_hal_serial_dma_init (FuriHalSerialHandle *handle) |
| Enable DMA-related functions for the serial instance. | |
| void | furi_hal_serial_dma_deinit (FuriHalSerialHandle *handle) |
| Disable DMA-related functions for the serial instance. | |
| void | furi_hal_serial_dma_tx (FuriHalSerialHandle *handle, const uint8_t *buffer, size_t buffer_size) |
| Transmit data over the serial interface using DMA. | |
| void | furi_hal_serial_dma_rx_start (FuriHalSerialHandle *handle, uint8_t *buffer, size_t buffer_size) |
| Start receiving in DMA mode. | |
| void | furi_hal_serial_dma_rx_stop (FuriHalSerialHandle *handle) |
| Stop receiving in DMA mode. | |
| void | furi_hal_serial_clear (FuriHalSerialHandle *handle, FuriHalSerialDirection direction) |
| Clear pending characters in (a) specified direction(s). | |
| bool | furi_hal_serial_get_pin_state (FuriHalSerialHandle *handle, FuriHalSerialPin pin) |
| Get the state of a designated pin associated with the serial. | |
Serial HAL API.
| typedef void(* FuriHalSerialRxCallback) (FuriHalSerialHandle *handle, FuriHalSerialRxEvent event, void *context) |
Transmit callback function type.
| handle | Pointer to the serial handle. |
| event | Bitmask of occurred events. |
| context | Pointer to the context object. |
| typedef void(* FuriHalSerialTxCallback) (FuriHalSerialHandle *handle, FuriHalSerialTxEvent event, void *context) |
Receive callback function type.
| handle | Pointer to the serial handle. |
| event | Bitmask of occurred events. |
| context | Pointer to the context object. |
| enum FuriHalSerialRxEvent |
Serial RX events.
| enum FuriHalSerialTxEvent |
| void furi_hal_serial_async_rx_start | ( | FuriHalSerialHandle * | handle, |
| bool | report_errors ) |
Start receiving in interrupt-driven mode.
| handle | Pointer to the serial handle. |
| report_errors | Enable error events if set to true, do not enable otherwise. |
| void furi_hal_serial_async_rx_stop | ( | FuriHalSerialHandle * | handle | ) |
Stop receiving in interrupt-driven mode.
| handle | Pointer to the serial handle. |
| void furi_hal_serial_clear | ( | FuriHalSerialHandle * | handle, |
| FuriHalSerialDirection | direction ) |
Clear pending characters in (a) specified direction(s).
| handle | Pointer to the serial handle. |
| direction | Direction (transmit, receive or both) to clear. |
| void furi_hal_serial_deinit | ( | FuriHalSerialHandle * | handle | ) |
Deinitialize the serial interface.
| handle | Pointer to the serial handle. |
| void furi_hal_serial_dma_deinit | ( | FuriHalSerialHandle * | handle | ) |
Disable DMA-related functions for the serial instance.
| void furi_hal_serial_dma_init | ( | FuriHalSerialHandle * | handle | ) |
Enable DMA-related functions for the serial instance.
| handle | Pointer to the serial handle. |
| void furi_hal_serial_dma_rx_start | ( | FuriHalSerialHandle * | handle, |
| uint8_t * | buffer, | ||
| size_t | buffer_size ) |
Start receiving in DMA mode.
| handle | Pointer to the serial handle. |
| buffer | Pointer to the receive buffer (must be allocated and of appropriate size). |
| buffer_size | Size of the receive buffer. |
| void furi_hal_serial_dma_rx_stop | ( | FuriHalSerialHandle * | handle | ) |
Stop receiving in DMA mode.
| handle | Pointer to the serial handle. |
| void furi_hal_serial_dma_tx | ( | FuriHalSerialHandle * | handle, |
| const uint8_t * | buffer, | ||
| size_t | buffer_size ) |
Transmit data over the serial interface using DMA.
| handle | Pointer to the serial handle. |
| buffer | Pointer to the data buffer. |
| buffer_size | Size of the data buffer. |
| bool furi_hal_serial_get_pin_state | ( | FuriHalSerialHandle * | handle, |
| FuriHalSerialPin | pin ) |
Get the state of a designated pin associated with the serial.
| handle | Pointer to the serial handle. |
| pin | Pin identifier from FuriHalSerialPin enum. |
| void furi_hal_serial_init | ( | FuriHalSerialHandle * | handle, |
| uint32_t | baud_rate ) |
Initialize the serial interface.
| handle | Pointer to the serial handle. |
| baud_rate | Baud rate. |
| bool furi_hal_serial_is_baud_rate_supported | ( | FuriHalSerialHandle * | handle, |
| uint32_t | baud_rate ) |
Determine whether a certain baud rate is supported.
| handle | Serial handle |
| baud_rate | Baud rate to be checked |
|
inline |
Resume the serial interface.
| handle | Pointer to the serial handle. |
| uint8_t furi_hal_serial_rx | ( | FuriHalSerialHandle * | handle | ) |
Read the next received data character.
| handle | Pointer to the serial handle. |
| bool furi_hal_serial_rx_available | ( | FuriHalSerialHandle * | handle | ) |
Determine whether there is received data ready for reading.
| handle | Pointer to the serial handle. |
| void furi_hal_serial_set_baud_rate | ( | FuriHalSerialHandle * | handle, |
| uint32_t | baud_rate ) |
Set the baud rate for the serial interface.
| handle | Pointer to the serial handle. |
| baud_rate | Baud rate. |
| void furi_hal_serial_set_hw_flow_control | ( | FuriHalSerialHandle * | handle, |
| FuriHalSerialHwFlowControl | flow_control ) |
Set the hardware flow control mode for the serial interface.
| handle | Pointer to the serial handle. |
| flow_control | Flow control mode. |
| void furi_hal_serial_set_rx_callback | ( | FuriHalSerialHandle * | handle, |
| FuriHalSerialRxCallback | callback, | ||
| void * | context ) |
Set the receive callback function for the serial interface.
| handle | Pointer to the serial handle. |
| callback | Pointer to the receive callback function. |
| context | Pointer to the context object. |
| void furi_hal_serial_set_tx_callback | ( | FuriHalSerialHandle * | handle, |
| FuriHalSerialTxCallback | callback, | ||
| void * | context ) |
Set the transmit callback function for the serial interface.
| handle | Pointer to the serial handle. |
| callback | Pointer to the transmit callback function. |
| context | Pointer to the context object. |
|
inline |
Suspend the serial interface.
| handle | Pointer to the serial handle. |
| size_t furi_hal_serial_tx | ( | FuriHalSerialHandle * | handle, |
| const uint8_t * | buffer, | ||
| size_t | buffer_size, | ||
| uint32_t | timeout ) |
Put data into the UART transmit FIFO buffer.
| handle | Pointer to the serial handle. |
| buffer | Pointer to the data buffer. |
| buffer_size | Size of the data buffer. |
| timeout | Timeout in milliseconds, or FuriWaitForever. |
| bool furi_hal_serial_tx_wait_complete | ( | FuriHalSerialHandle * | handle, |
| uint32_t | timeout ) |
Wait for the UART transmit FIFO buffer to empty, meaning all bytes have been transmitted.
| handle | Pointer to the serial handle. |
| timeout | Timeout in milliseconds. |