caffeine-hal 0.6.6
A Header-Defined Interface c library, it provides the hal layer for the Caffeine framework
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Enumerations | Functions
cfn_hal_uart.h File Reference

Universal Asynchronous Receiver-Transmitter (UART) HAL API. More...

#include "cfn_hal.h"
#include "cfn_hal_base.h"
#include "cfn_hal_gpio.h"
#include "cfn_hal_types.h"

Go to the source code of this file.

Data Structures

struct  cfn_hal_uart_phy_t
 UART hardware physical mapping. More...
 
struct  cfn_hal_uart_config_t
 UART configuration structure. More...
 
struct  cfn_hal_uart_api_s
 UART Virtual Method Table (VMT). More...
 

Macros

#define CFN_HAL_UART_FLAG_CONTINUOUS_RX   CFN_HAL_BIT(0)
 UART continuous RX flag for tracking state in the base driver.
 

Typedefs

typedef struct cfn_hal_uart_s cfn_hal_uart_t
 
typedef struct cfn_hal_uart_api_s cfn_hal_uart_api_t
 
typedef void(* cfn_hal_uart_callback_t) (cfn_hal_uart_t *driver, uint32_t event_mask, uint32_t error_mask, uint8_t *data, size_t nbr_of_bytes, void *user_arg)
 UART callback signature.
 

Enumerations

enum  cfn_hal_uart_event_t {
  CFN_HAL_UART_EVENT_NONE = 0 , CFN_HAL_UART_EVENT_TX_COMPLETE = CFN_HAL_BIT(0) , CFN_HAL_UART_EVENT_RX_READY = CFN_HAL_BIT(1) , CFN_HAL_UART_EVENT_BUS_IDLE = CFN_HAL_BIT(2) ,
  CFN_HAL_UART_EVENT_RX_BYTE = CFN_HAL_BIT(3)
}
 UART nominal event flags. More...
 
enum  cfn_hal_uart_error_t {
  CFN_HAL_UART_ERROR_NONE = 0 , CFN_HAL_UART_ERROR_FRAMING = CFN_HAL_BIT(0) , CFN_HAL_UART_ERROR_PARITY = CFN_HAL_BIT(1) , CFN_HAL_UART_ERROR_OVERRUN = CFN_HAL_BIT(2) ,
  CFN_HAL_UART_ERROR_TIMEOUT = CFN_HAL_BIT(3) , CFN_HAL_UART_ERROR_GENERAL = CFN_HAL_BIT(4)
}
 UART exception error flags. More...
 
enum  cfn_hal_uart_config_parity_t { CFN_HAL_UART_CONFIG_PARITY_NONE , CFN_HAL_UART_CONFIG_PARITY_EVEN , CFN_HAL_UART_CONFIG_PARITY_ODD , CFN_HAL_UART_CONFIG_PARITY_MAX }
 UART parity configuration. More...
 
enum  cfn_hal_uart_config_stop_bits_t { CFN_HAL_UART_CONFIG_STOP_ONE_BIT , CFN_HAL_UART_CONFIG_STOP_TWO_BITS , CFN_HAL_UART_CONFIG_STOP_MAX }
 UART stop bits configuration. More...
 
enum  cfn_hal_uart_config_data_len_t {
  CFN_HAL_UART_CONFIG_DATA_LEN_5 , CFN_HAL_UART_CONFIG_DATA_LEN_6 , CFN_HAL_UART_CONFIG_DATA_LEN_7 , CFN_HAL_UART_CONFIG_DATA_LEN_8 ,
  CFN_HAL_UART_CONFIG_DATA_LEN_9 , CFN_HAL_UART_CONFIG_DATA_LEN_MAX
}
 UART data length configuration. More...
 
enum  cfn_hal_uart_config_flow_ctrl_t {
  CFN_HAL_UART_CONFIG_FLOW_CTRL_NONE , CFN_HAL_UART_CONFIG_FLOW_CTRL_CTS , CFN_HAL_UART_CONFIG_FLOW_CTRL_RTS , CFN_HAL_UART_CONFIG_FLOW_CTRL_RTS_CTS ,
  CFN_HAL_UART_CONFIG_FLOW_CTRL_MAX
}
 UART hardware flow control configuration. More...
 
enum  cfn_hal_uart_config_mode_t {
  CFN_HAL_UART_CONFIG_MODE_NONE , CFN_HAL_UART_CONFIG_MODE_BLOCKING , CFN_HAL_UART_CONFIG_MODE_INTERRUPT , CFN_HAL_UART_CONFIG_MODE_DMA ,
  CFN_HAL_UART_CONFIG_MODE_MAX
}
 UART I/O operation mode. More...
 
enum  cfn_hal_uart_config_direction_t {
  CFN_HAL_UART_CONFIG_DIRECTION_NONE , CFN_HAL_UART_CONFIG_DIRECTION_TX_ONLY , CFN_HAL_UART_CONFIG_DIRECTION_RX_ONLY , CFN_HAL_UART_CONFIG_DIRECTION_TX_RX ,
  CFN_HAL_UART_CONFIG_DIRECTION_MAX
}
 UART I/O operation mode. More...
 

Functions

 CFN_HAL_VMT_CHECK (struct cfn_hal_uart_api_s)
 
 CFN_HAL_CREATE_DRIVER_TYPE (uart, cfn_hal_uart_config_t, cfn_hal_uart_api_t, cfn_hal_uart_phy_t, cfn_hal_uart_callback_t)
 
CFN_HAL_INLINE void cfn_hal_uart_populate (cfn_hal_uart_t *driver, uint32_t peripheral_id, struct cfn_hal_clock_s *clock, void *dependency, const cfn_hal_uart_api_t *api, const cfn_hal_uart_phy_t *phy, const cfn_hal_uart_config_t *config, cfn_hal_uart_callback_t callback, void *user_arg)
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_config_validate (const cfn_hal_uart_t *driver, const cfn_hal_uart_config_t *config)
 Validates the UART configuration.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_init (cfn_hal_uart_t *driver)
 Initializes the UART driver.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_deinit (cfn_hal_uart_t *driver)
 Deinitializes the UART driver.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_config_set (cfn_hal_uart_t *driver, const cfn_hal_uart_config_t *config)
 Sets the UART configuration.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_config_get (cfn_hal_uart_t *driver, cfn_hal_uart_config_t *config)
 Gets the current UART configuration.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_callback_register (cfn_hal_uart_t *driver, const cfn_hal_uart_callback_t callback, void *user_arg)
 Registers a callback for UART events and errors.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_power_state_set (cfn_hal_uart_t *driver, cfn_hal_power_state_t state)
 Sets the UART power state.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_event_enable (cfn_hal_uart_t *driver, uint32_t event_mask)
 Enables one or more UART nominal events.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_event_disable (cfn_hal_uart_t *driver, uint32_t event_mask)
 Disables one or more UART nominal events.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_event_get (cfn_hal_uart_t *driver, uint32_t *event_mask)
 Retrieves the current UART nominal event status.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_error_enable (cfn_hal_uart_t *driver, uint32_t error_mask)
 Enables one or more UART exception errors.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_error_disable (cfn_hal_uart_t *driver, uint32_t error_mask)
 Disables one or more UART exception errors.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_error_get (cfn_hal_uart_t *driver, uint32_t *error_mask)
 Retrieves the current UART exception error status.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_tx_irq (cfn_hal_uart_t *driver, const uint8_t *data, size_t nbr_of_bytes)
 Starts UART data transmission using interrupts (non-blocking).
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_tx_irq_abort (cfn_hal_uart_t *driver)
 Aborts an ongoing interrupt-based transmission.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_rx_n_irq (cfn_hal_uart_t *driver, uint8_t *data, size_t nbr_of_bytes)
 Starts UART data reception using interrupts to receive exactly N bytes.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_rx_irq (cfn_hal_uart_t *driver)
 Starts UART data reception in continuous interrupt mode.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_rx_irq_abort (cfn_hal_uart_t *driver)
 Aborts an ongoing interrupt-based reception.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_tx_polling (cfn_hal_uart_t *driver, const uint8_t *data, size_t nbr_of_bytes, uint32_t timeout)
 Transmits data using polling (blocking).
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_rx_polling (cfn_hal_uart_t *driver, uint8_t *data, size_t nbr_of_bytes, uint32_t timeout)
 Receives data using polling (blocking).
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_rx_to_idle (cfn_hal_uart_t *driver, uint8_t *data, size_t max_bytes, size_t *received_bytes, uint32_t timeout)
 Receives data until an idle condition or max bytes reached.
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_tx_dma (cfn_hal_uart_t *driver, const uint8_t *data, size_t nbr_of_bytes)
 Transmits data using DMA (non-blocking).
 
CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_rx_dma (cfn_hal_uart_t *driver, uint8_t *data, size_t nbr_of_bytes)
 Receives data using DMA (non-blocking).
 
cfn_hal_error_code_t cfn_hal_uart_construct (cfn_hal_uart_t *driver, const cfn_hal_uart_config_t *config, const cfn_hal_uart_phy_t *phy, struct cfn_hal_clock_s *clock, void *dependency, cfn_hal_uart_callback_t callback, void *user_arg)
 
cfn_hal_error_code_t cfn_hal_uart_destruct (cfn_hal_uart_t *driver)
 

Detailed Description

Universal Asynchronous Receiver-Transmitter (UART) HAL API.

Copyright (c) 2026 Hisham Moussa Daou https://www.whileone.me

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Macro Definition Documentation

◆ CFN_HAL_UART_FLAG_CONTINUOUS_RX

#define CFN_HAL_UART_FLAG_CONTINUOUS_RX   CFN_HAL_BIT(0)

UART continuous RX flag for tracking state in the base driver.

Typedef Documentation

◆ cfn_hal_uart_api_t

◆ cfn_hal_uart_callback_t

typedef void(* cfn_hal_uart_callback_t) (cfn_hal_uart_t *driver, uint32_t event_mask, uint32_t error_mask, uint8_t *data, size_t nbr_of_bytes, void *user_arg)

UART callback signature.

Parameters
driverPointer to the UART driver instance.
event_maskMask of triggered nominal events.
error_maskMask of triggered exception errors.
dataPointer to the transaction buffer (if applicable).
nbr_of_bytesNumber of bytes transferred.
user_argUser-defined argument passed during registration.

◆ cfn_hal_uart_t

typedef struct cfn_hal_uart_s cfn_hal_uart_t

Enumeration Type Documentation

◆ cfn_hal_uart_config_data_len_t

UART data length configuration.

Enumerator
CFN_HAL_UART_CONFIG_DATA_LEN_5 

5 bits per word

CFN_HAL_UART_CONFIG_DATA_LEN_6 

6 bits per word

CFN_HAL_UART_CONFIG_DATA_LEN_7 

7 bits per word

CFN_HAL_UART_CONFIG_DATA_LEN_8 

8 bits per word

CFN_HAL_UART_CONFIG_DATA_LEN_9 

9 bits per word

CFN_HAL_UART_CONFIG_DATA_LEN_MAX 

◆ cfn_hal_uart_config_direction_t

UART I/O operation mode.

Enumerator
CFN_HAL_UART_CONFIG_DIRECTION_NONE 
CFN_HAL_UART_CONFIG_DIRECTION_TX_ONLY 
CFN_HAL_UART_CONFIG_DIRECTION_RX_ONLY 
CFN_HAL_UART_CONFIG_DIRECTION_TX_RX 
CFN_HAL_UART_CONFIG_DIRECTION_MAX 

◆ cfn_hal_uart_config_flow_ctrl_t

UART hardware flow control configuration.

Enumerator
CFN_HAL_UART_CONFIG_FLOW_CTRL_NONE 

No flow control

CFN_HAL_UART_CONFIG_FLOW_CTRL_CTS 

Hardware CTS only

CFN_HAL_UART_CONFIG_FLOW_CTRL_RTS 

Hardware RTS only

CFN_HAL_UART_CONFIG_FLOW_CTRL_RTS_CTS 

Hardware RTS and CTS

CFN_HAL_UART_CONFIG_FLOW_CTRL_MAX 

◆ cfn_hal_uart_config_mode_t

UART I/O operation mode.

Enumerator
CFN_HAL_UART_CONFIG_MODE_NONE 

Disabled

CFN_HAL_UART_CONFIG_MODE_BLOCKING 

Polling based

CFN_HAL_UART_CONFIG_MODE_INTERRUPT 

Interrupt based

CFN_HAL_UART_CONFIG_MODE_DMA 

DMA based

CFN_HAL_UART_CONFIG_MODE_MAX 

◆ cfn_hal_uart_config_parity_t

UART parity configuration.

Enumerator
CFN_HAL_UART_CONFIG_PARITY_NONE 

No parity

CFN_HAL_UART_CONFIG_PARITY_EVEN 

Even parity

CFN_HAL_UART_CONFIG_PARITY_ODD 

Odd parity

CFN_HAL_UART_CONFIG_PARITY_MAX 

◆ cfn_hal_uart_config_stop_bits_t

UART stop bits configuration.

Enumerator
CFN_HAL_UART_CONFIG_STOP_ONE_BIT 

1 stop bit

CFN_HAL_UART_CONFIG_STOP_TWO_BITS 

2 stop bits

CFN_HAL_UART_CONFIG_STOP_MAX 

◆ cfn_hal_uart_error_t

UART exception error flags.

Enumerator
CFN_HAL_UART_ERROR_NONE 
CFN_HAL_UART_ERROR_FRAMING 

Start/stop bit synchronization error

CFN_HAL_UART_ERROR_PARITY 

Parity check failed

CFN_HAL_UART_ERROR_OVERRUN 

Buffer overflow error

CFN_HAL_UART_ERROR_TIMEOUT 

Data reception timeout

CFN_HAL_UART_ERROR_GENERAL 

General hardware error

◆ cfn_hal_uart_event_t

UART nominal event flags.

Enumerator
CFN_HAL_UART_EVENT_NONE 
CFN_HAL_UART_EVENT_TX_COMPLETE 

Data transmission finished

CFN_HAL_UART_EVENT_RX_READY 

Data reception finished

CFN_HAL_UART_EVENT_BUS_IDLE 

UART bus idle detected

CFN_HAL_UART_EVENT_RX_BYTE 

Single byte received (continuous mode)

Function Documentation

◆ CFN_HAL_CREATE_DRIVER_TYPE()

CFN_HAL_CREATE_DRIVER_TYPE ( uart  ,
cfn_hal_uart_config_t  ,
cfn_hal_uart_api_t  ,
cfn_hal_uart_phy_t  ,
cfn_hal_uart_callback_t   
)

◆ cfn_hal_uart_callback_register()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_callback_register ( cfn_hal_uart_t driver,
const cfn_hal_uart_callback_t  callback,
void *  user_arg 
)

Registers a callback for UART events and errors.

Parameters
driverPointer to the UART driver instance.
callbackThe callback function to register.
user_argUser-defined argument passed to the callback.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_config_get()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_config_get ( cfn_hal_uart_t driver,
cfn_hal_uart_config_t config 
)

Gets the current UART configuration.

Parameters
driverPointer to the UART driver instance.
config[out] Pointer to store the configuration.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_config_set()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_config_set ( cfn_hal_uart_t driver,
const cfn_hal_uart_config_t config 
)

Sets the UART configuration.

Parameters
driverPointer to the UART driver instance.
configPointer to the configuration structure.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_config_validate()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_config_validate ( const cfn_hal_uart_t driver,
const cfn_hal_uart_config_t config 
)

Validates the UART configuration.

Parameters
driverPointer to the UART driver instance.
configPointer to the configuration structure.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_construct()

cfn_hal_error_code_t cfn_hal_uart_construct ( cfn_hal_uart_t driver,
const cfn_hal_uart_config_t config,
const cfn_hal_uart_phy_t phy,
struct cfn_hal_clock_s *  clock,
void *  dependency,
cfn_hal_uart_callback_t  callback,
void *  user_arg 
)

◆ cfn_hal_uart_deinit()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_deinit ( cfn_hal_uart_t driver)

Deinitializes the UART driver.

Parameters
driverPointer to the UART driver instance.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_destruct()

cfn_hal_error_code_t cfn_hal_uart_destruct ( cfn_hal_uart_t driver)

◆ cfn_hal_uart_error_disable()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_error_disable ( cfn_hal_uart_t driver,
uint32_t  error_mask 
)

Disables one or more UART exception errors.

Parameters
driverPointer to the UART driver instance.
error_maskMask of errors to disable.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_error_enable()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_error_enable ( cfn_hal_uart_t driver,
uint32_t  error_mask 
)

Enables one or more UART exception errors.

Parameters
driverPointer to the UART driver instance.
error_maskMask of errors to enable.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_error_get()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_error_get ( cfn_hal_uart_t driver,
uint32_t *  error_mask 
)

Retrieves the current UART exception error status.

Parameters
driverPointer to the UART driver instance.
error_mask[out] Pointer to store the error mask.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_event_disable()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_event_disable ( cfn_hal_uart_t driver,
uint32_t  event_mask 
)

Disables one or more UART nominal events.

Parameters
driverPointer to the UART driver instance.
event_maskMask of events to disable.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_event_enable()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_event_enable ( cfn_hal_uart_t driver,
uint32_t  event_mask 
)

Enables one or more UART nominal events.

Parameters
driverPointer to the UART driver instance.
event_maskMask of events to enable.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_event_get()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_event_get ( cfn_hal_uart_t driver,
uint32_t *  event_mask 
)

Retrieves the current UART nominal event status.

Parameters
driverPointer to the UART driver instance.
event_mask[out] Pointer to store the event mask.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_init()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_init ( cfn_hal_uart_t driver)

Initializes the UART driver.

Parameters
driverPointer to the UART driver instance.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_populate()

CFN_HAL_INLINE void cfn_hal_uart_populate ( cfn_hal_uart_t driver,
uint32_t  peripheral_id,
struct cfn_hal_clock_s *  clock,
void *  dependency,
const cfn_hal_uart_api_t api,
const cfn_hal_uart_phy_t phy,
const cfn_hal_uart_config_t config,
cfn_hal_uart_callback_t  callback,
void *  user_arg 
)

◆ cfn_hal_uart_power_state_set()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_power_state_set ( cfn_hal_uart_t driver,
cfn_hal_power_state_t  state 
)

Sets the UART power state.

Parameters
driverPointer to the UART driver instance.
stateTarget power state.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_rx_dma()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_rx_dma ( cfn_hal_uart_t driver,
uint8_t *  data,
size_t  nbr_of_bytes 
)

Receives data using DMA (non-blocking).

Parameters
driverPointer to the UART driver instance.
dataPointer to the buffer to store received data.
nbr_of_bytesNumber of bytes to receive.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_rx_irq()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_rx_irq ( cfn_hal_uart_t driver)

Starts UART data reception in continuous interrupt mode.

Parameters
driverPointer to the UART driver instance.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_rx_irq_abort()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_rx_irq_abort ( cfn_hal_uart_t driver)

Aborts an ongoing interrupt-based reception.

Parameters
driverPointer to the UART driver instance.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_rx_n_irq()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_rx_n_irq ( cfn_hal_uart_t driver,
uint8_t *  data,
size_t  nbr_of_bytes 
)

Starts UART data reception using interrupts to receive exactly N bytes.

Parameters
driverPointer to the UART driver instance.
dataPointer to the buffer to store received data.
nbr_of_bytesNumber of bytes to receive.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_rx_polling()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_rx_polling ( cfn_hal_uart_t driver,
uint8_t *  data,
size_t  nbr_of_bytes,
uint32_t  timeout 
)

Receives data using polling (blocking).

Parameters
driverPointer to the UART driver instance.
dataPointer to the buffer to store received data.
nbr_of_bytesNumber of bytes to receive.
timeoutTimeout duration in milliseconds.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_rx_to_idle()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_rx_to_idle ( cfn_hal_uart_t driver,
uint8_t *  data,
size_t  max_bytes,
size_t *  received_bytes,
uint32_t  timeout 
)

Receives data until an idle condition or max bytes reached.

Parameters
driverPointer to the UART driver instance.
dataPointer to the buffer to store received data.
max_bytesMaximum capacity of the data buffer.
received_bytes[out] Actual number of bytes received.
timeoutTimeout duration in milliseconds.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_tx_dma()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_tx_dma ( cfn_hal_uart_t driver,
const uint8_t *  data,
size_t  nbr_of_bytes 
)

Transmits data using DMA (non-blocking).

Parameters
driverPointer to the UART driver instance.
dataPointer to the buffer containing data to transmit.
nbr_of_bytesNumber of bytes to transmit.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_tx_irq()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_tx_irq ( cfn_hal_uart_t driver,
const uint8_t *  data,
size_t  nbr_of_bytes 
)

Starts UART data transmission using interrupts (non-blocking).

Parameters
driverPointer to the UART driver instance.
dataPointer to the buffer containing data to transmit.
nbr_of_bytesNumber of bytes to transmit.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_tx_irq_abort()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_tx_irq_abort ( cfn_hal_uart_t driver)

Aborts an ongoing interrupt-based transmission.

Parameters
driverPointer to the UART driver instance.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ cfn_hal_uart_tx_polling()

CFN_HAL_INLINE cfn_hal_error_code_t cfn_hal_uart_tx_polling ( cfn_hal_uart_t driver,
const uint8_t *  data,
size_t  nbr_of_bytes,
uint32_t  timeout 
)

Transmits data using polling (blocking).

Parameters
driverPointer to the UART driver instance.
dataPointer to the buffer containing data to transmit.
nbr_of_bytesNumber of bytes to transmit.
timeoutTimeout duration in milliseconds.
Returns
CFN_HAL_ERROR_OK on success, or a specific error code on failure.

◆ CFN_HAL_VMT_CHECK()

CFN_HAL_VMT_CHECK ( struct cfn_hal_uart_api_s  )