Serial HAL API. More...
#include <stddef.h>#include <stdint.h>#include "furi_hal_serial_types.h"Go to the source code of this file.
Macros | |
| #define | FURI_HAL_SERIAL_DMA_BUFFER_SIZE (256u) |
Typedefs | |
| typedef void(* | FuriHalSerialAsyncRxCallback) (FuriHalSerialHandle *handle, FuriHalSerialRxEvent event, void *context) |
| Receive callback. | |
| typedef void(* | FuriHalSerialDmaRxCallback) (FuriHalSerialHandle *handle, FuriHalSerialRxEvent event, size_t data_len, void *context) |
| Receive DMA callback. | |
Enumerations | |
| enum | FuriHalSerialRxEvent { FuriHalSerialRxEventData = (1 << 0) , FuriHalSerialRxEventIdle = (1 << 1) , FuriHalSerialRxEventFrameError = (1 << 2) , FuriHalSerialRxEventNoiseError = (1 << 3) , FuriHalSerialRxEventOverrunError = (1 << 4) , FuriHalSerialRxEventParityError = (1 << 5) } |
| Serial RX events. More... | |
Functions | |
| void | furi_hal_serial_init (FuriHalSerialHandle *handle, uint32_t baud) |
| Initialize Serial. | |
| void | furi_hal_serial_deinit (FuriHalSerialHandle *handle) |
| De-initialize Serial. | |
| void | furi_hal_serial_suspend (FuriHalSerialHandle *handle) |
| Suspend operation. | |
| void | furi_hal_serial_resume (FuriHalSerialHandle *handle) |
| Resume operation. | |
| bool | furi_hal_serial_is_baud_rate_supported (FuriHalSerialHandle *handle, uint32_t baud) |
| Determine whether a certain baud rate is supported. | |
| void | furi_hal_serial_set_br (FuriHalSerialHandle *handle, uint32_t baud) |
| Changes baud rate. | |
| void | furi_hal_serial_configure_framing (FuriHalSerialHandle *handle, FuriHalSerialDataBits data_bits, FuriHalSerialParity parity, FuriHalSerialStopBits stop_bits) |
| Configures framing of a serial interface. | |
| void | furi_hal_serial_tx (FuriHalSerialHandle *handle, const uint8_t *buffer, size_t buffer_size) |
| Transmits data in semi-blocking mode. | |
| void | furi_hal_serial_tx_wait_complete (FuriHalSerialHandle *handle) |
| Wait until transmission is completed. | |
| void | furi_hal_serial_async_rx_start (FuriHalSerialHandle *handle, FuriHalSerialAsyncRxCallback callback, void *context, bool report_errors) |
| Start and sets Serial Receive callback. | |
| void | furi_hal_serial_async_rx_stop (FuriHalSerialHandle *handle) |
| Stop Serial Receive. | |
| bool | furi_hal_serial_async_rx_available (FuriHalSerialHandle *handle) |
| Check if there is data available for reading. | |
| uint8_t | furi_hal_serial_async_rx (FuriHalSerialHandle *handle) |
| Get data Serial receive. | |
| void | furi_hal_serial_enable_direction (FuriHalSerialHandle *handle, FuriHalSerialDirection direction) |
| Enable an input/output direction. | |
| void | furi_hal_serial_disable_direction (FuriHalSerialHandle *handle, FuriHalSerialDirection direction) |
| Disable an input/output direction. | |
| const GpioPin * | furi_hal_serial_get_gpio_pin (FuriHalSerialHandle *handle, FuriHalSerialDirection direction) |
| Get the GPIO pin associated with a serial. | |
| void | furi_hal_serial_dma_rx_start (FuriHalSerialHandle *handle, FuriHalSerialDmaRxCallback callback, void *context, bool report_errors) |
| Start and sets Serial event callback receive DMA. | |
| void | furi_hal_serial_dma_rx_stop (FuriHalSerialHandle *handle) |
| Stop Serial receive DMA. | |
| size_t | furi_hal_serial_dma_rx (FuriHalSerialHandle *handle, uint8_t *data, size_t len) |
| Get data Serial receive DMA. | |
Serial HAL API.
| typedef void(* FuriHalSerialAsyncRxCallback) (FuriHalSerialHandle *handle, FuriHalSerialRxEvent event, void *context) |
Receive callback.
| handle | Serial handle |
| event | FuriHalSerialRxEvent |
| context | Callback context provided earlier |
| typedef void(* FuriHalSerialDmaRxCallback) (FuriHalSerialHandle *handle, FuriHalSerialRxEvent event, size_t data_len, void *context) |
Receive DMA callback.
| handle | Serial handle |
| event | FuriHalSerialDmaRxEvent |
| data_len | Received data |
| context | Callback context provided earlier |
| enum FuriHalSerialRxEvent |
Serial RX events.
| uint8_t furi_hal_serial_async_rx | ( | FuriHalSerialHandle * | handle | ) |
Get data Serial receive.
| handle | Serial handle |
| bool furi_hal_serial_async_rx_available | ( | FuriHalSerialHandle * | handle | ) |
Check if there is data available for reading.
| handle | Serial handle |
| void furi_hal_serial_async_rx_start | ( | FuriHalSerialHandle * | handle, |
| FuriHalSerialAsyncRxCallback | callback, | ||
| void * | context, | ||
| bool | report_errors ) |
Start and sets Serial Receive callback.
| handle | Serial handle | |
| callback | callback pointer | |
| context | callback context | |
| [in] | report_errors | report RX error |
| void furi_hal_serial_async_rx_stop | ( | FuriHalSerialHandle * | handle | ) |
Stop Serial Receive.
| handle | Serial handle |
| void furi_hal_serial_configure_framing | ( | FuriHalSerialHandle * | handle, |
| FuriHalSerialDataBits | data_bits, | ||
| FuriHalSerialParity | parity, | ||
| FuriHalSerialStopBits | stop_bits ) |
Configures framing of a serial interface.
| handle | Serial handle |
| data_bits | Data bits |
| parity | Parity |
| stop_bits | Stop bits |
| void furi_hal_serial_deinit | ( | FuriHalSerialHandle * | handle | ) |
De-initialize Serial.
Configures GPIO to analog, clears callback and callback context, disables hardware
| handle | Serial handle |
| void furi_hal_serial_disable_direction | ( | FuriHalSerialHandle * | handle, |
| FuriHalSerialDirection | direction ) |
Disable an input/output direction.
Releases the respective pin by reconfiguring it to initial state, making possible its use for other purposes.
| handle | Serial handle |
| direction | Direction to disable |
| size_t furi_hal_serial_dma_rx | ( | FuriHalSerialHandle * | handle, |
| uint8_t * | data, | ||
| size_t | len ) |
Get data Serial receive DMA.
| handle | Serial handle |
| data | pointer to data buffer |
| len | get data size (in bytes) |
| void furi_hal_serial_dma_rx_start | ( | FuriHalSerialHandle * | handle, |
| FuriHalSerialDmaRxCallback | callback, | ||
| void * | context, | ||
| bool | report_errors ) |
Start and sets Serial event callback receive DMA.
| handle | Serial handle | |
| callback | callback pointer | |
| context | callback context | |
| [in] | report_errors | report RX error |
| void furi_hal_serial_dma_rx_stop | ( | FuriHalSerialHandle * | handle | ) |
Stop Serial receive DMA.
| handle | Serial handle |
| void furi_hal_serial_enable_direction | ( | FuriHalSerialHandle * | handle, |
| FuriHalSerialDirection | direction ) |
Enable an input/output direction.
Takes over the respective pin by reconfiguring it to the appropriate alternative function.
| handle | Serial handle |
| direction | Direction to enable |
| const GpioPin * furi_hal_serial_get_gpio_pin | ( | FuriHalSerialHandle * | handle, |
| FuriHalSerialDirection | direction ) |
Get the GPIO pin associated with a serial.
| handle | Serial handle |
| direction | Direction to query |
| void furi_hal_serial_init | ( | FuriHalSerialHandle * | handle, |
| uint32_t | baud ) |
Initialize Serial.
Configures GPIO, configures and enables transceiver. Default framing settings are used: 8 data bits, no parity, 1 stop bit. Override them with furi_hal_serial_configure_framing.
| handle | Serial handle |
| baud | baud rate |
| bool furi_hal_serial_is_baud_rate_supported | ( | FuriHalSerialHandle * | handle, |
| uint32_t | baud ) |
Determine whether a certain baud rate is supported.
| handle | Serial handle |
| baud | baud rate to be checked |
| void furi_hal_serial_resume | ( | FuriHalSerialHandle * | handle | ) |
Resume operation.
Resumes hardware from suspended state
| handle | Serial handle |
| void furi_hal_serial_set_br | ( | FuriHalSerialHandle * | handle, |
| uint32_t | baud ) |
Changes baud rate.
| handle | Serial handle |
| baud | baud rate |
| void furi_hal_serial_suspend | ( | FuriHalSerialHandle * | handle | ) |
Suspend operation.
Suspend hardware, settings and callbacks are preserved
| handle | Serial handle |
| void furi_hal_serial_tx | ( | FuriHalSerialHandle * | handle, |
| const uint8_t * | buffer, | ||
| size_t | buffer_size ) |
Transmits data in semi-blocking mode.
Fills transmission pipe with data, returns as soon as all bytes from buffer are in the pipe.
Real transmission will be completed later. Use furi_hal_serial_tx_wait_complete to wait for completion if you need it.
| handle | Serial handle |
| buffer | data |
| buffer_size | data size (in bytes) |
| void furi_hal_serial_tx_wait_complete | ( | FuriHalSerialHandle * | handle | ) |
Wait until transmission is completed.
Ensures that all data has been sent.
| handle | Serial handle |