Serial HAL API.
More...
#include <stddef.h>
#include <stdint.h>
#include "furi_hal_serial_types.h"
Go to the source code of this file.
|
#define | FURI_HAL_SERIAL_DMA_BUFFER_SIZE (256u) |
|
|
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_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 directon.
|
|
void | furi_hal_serial_disable_direction (FuriHalSerialHandle *handle, FuriHalSerialDirection direction) |
| Disable an input/output directon.
|
|
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.
|
|
◆ FuriHalSerialAsyncRxCallback
Receive callback.
- Warning
- Callback will be called in interrupt context, ensure thread safety on your side.
- Parameters
-
handle | Serial handle |
event | FuriHalSerialRxEvent |
context | Callback context provided earlier |
◆ FuriHalSerialDmaRxCallback
Receive DMA callback.
- Warning
- DMA Callback will be called in interrupt context, ensure thread safety on your side.
- Parameters
-
handle | Serial handle |
event | FuriHalSerialDmaRxEvent |
data_len | Received data |
context | Callback context provided earlier |
◆ FuriHalSerialRxEvent
Serial RX events.
Enumerator |
---|
FuriHalSerialRxEventData | Data: new data available.
|
FuriHalSerialRxEventIdle | Idle: bus idle detected.
|
FuriHalSerialRxEventFrameError | Framing Error: incorrect frame detected.
|
FuriHalSerialRxEventNoiseError | Noise Error: noise on the line detected.
|
FuriHalSerialRxEventOverrunError | Overrun Error: no space for received data.
|
◆ furi_hal_serial_async_rx()
Get data Serial receive.
- Warning
- This function must be called only from the callback FuriHalSerialAsyncRxCallback
- Parameters
-
- Returns
- data
◆ furi_hal_serial_async_rx_available()
Check if there is data available for reading.
- Warning
- This function must be called only from the callback FuriHalSerialAsyncRxCallback
- Parameters
-
- Returns
- true if data is available for reading, false otherwise
◆ furi_hal_serial_async_rx_start()
Start and sets Serial Receive callback.
- Warning
- Callback will be called in interrupt context, ensure thread safety on your side
- Parameters
-
| handle | Serial handle |
| callback | callback pointer |
| context | callback context |
[in] | report_errors | report RX error |
◆ furi_hal_serial_async_rx_stop()
Stop Serial Receive.
- Parameters
-
◆ furi_hal_serial_deinit()
De-initialize Serial.
Configures GPIO to analog, clears callback and callback context, disables hardware
- Parameters
-
◆ furi_hal_serial_disable_direction()
void furi_hal_serial_disable_direction |
( |
FuriHalSerialHandle * | handle, |
|
|
FuriHalSerialDirection | direction ) |
Disable an input/output directon.
Releases the respective pin by reconfiguring it to initial state, making possible its use for other purposes.
- Parameters
-
handle | Serial handle |
direction | Direction to disable |
◆ furi_hal_serial_dma_rx()
Get data Serial receive DMA.
- Warning
- This function must be called only from the callback FuriHalSerialDmaRxCallback
- Parameters
-
handle | Serial handle |
data | pointer to data buffer |
len | get data size (in bytes) |
- Returns
- size actual data receive (in bytes)
◆ furi_hal_serial_dma_rx_start()
Start and sets Serial event callback receive DMA.
- Parameters
-
| handle | Serial handle |
| callback | callback pointer |
| context | callback context |
[in] | report_errors | report RX error |
◆ furi_hal_serial_dma_rx_stop()
Stop Serial receive DMA.
- Parameters
-
◆ furi_hal_serial_enable_direction()
void furi_hal_serial_enable_direction |
( |
FuriHalSerialHandle * | handle, |
|
|
FuriHalSerialDirection | direction ) |
Enable an input/output directon.
Takes over the respective pin by reconfiguring it to the appropriate alternative function.
- Parameters
-
handle | Serial handle |
direction | Direction to enable |
◆ furi_hal_serial_get_gpio_pin()
Get the GPIO pin associated with a serial.
- Parameters
-
handle | Serial handle |
direction | Direction to query |
- Returns
- pointer to the respective pin instance
◆ furi_hal_serial_init()
Initialize Serial.
Configures GPIO, configures and enables transceiver.
- Parameters
-
handle | Serial handle |
baud | baud rate |
◆ furi_hal_serial_is_baud_rate_supported()
Determine whether a certain baud rate is supported.
- Parameters
-
handle | Serial handle |
baud | baud rate to be checked |
- Returns
- true if baud rate is supported, false otherwise.
◆ furi_hal_serial_resume()
Resume operation.
Resumes hardware from suspended state
- Parameters
-
◆ furi_hal_serial_set_br()
Changes baud rate.
- Parameters
-
handle | Serial handle |
baud | baud rate |
◆ furi_hal_serial_suspend()
Suspend operation.
Suspend hardware, settings and callbacks are preserved
- Parameters
-
◆ furi_hal_serial_tx()
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.
- Parameters
-
handle | Serial handle |
buffer | data |
buffer_size | data size (in bytes) |
◆ furi_hal_serial_tx_wait_complete()
Wait until transmission is completed.
Ensures that all data has been sent.
- Parameters
-