Loading...
Searching...
No Matches
half-duplex UART Driver

This module contains drivers for UART half-duplex communication bus. More...

Detailed Description

This module contains drivers for UART half-duplex communication bus.

It needs to manage the communication direction by enabling or disabling TX.

Files

file  uart_half_duplex.h
 Interface definition for half-duplex UART driver.
 

Data Structures

struct  uart_half_duplex_dir_t
 half-duplex UART direction management method type More...
 
struct  uart_half_duplex_params_t
 Configuration for half-duplex UART. More...
 
struct  uart_half_duplex_t
 Descriptor struct for half-duplex UART. More...
 

Macros

#define UART_HALF_DUPLEX_DEFAULT_TIMEOUT_US   (20000LU)
 Default recv timeout (in microseconds)
 
#define UART_HALF_DUPLEX_DIR_NONE   { NULL, NULL, NULL }
 Don't manage direction.
 

Enumerations

enum  {
  UART_HALF_DUPLEX_OK = UART_OK , UART_HALF_DUPLEX_NODEV = UART_NODEV , UART_HALF_DUPLEX_NOBAUD = UART_NOBAUD , UART_HALF_DUPLEX_INTERR = UART_INTERR ,
  UART_HALF_DUPLEX_NOMODE = UART_NOMODE , UART_HALF_DUPLEX_NOBUFF = -5
}
 Possible UART_HALF_DUPLEX return values. More...
 

Functions

int uart_half_duplex_init (uart_half_duplex_t *dev, uint8_t *buffer, size_t buffer_max_size, const uart_half_duplex_params_t *params)
 Initialize the half-duplex UART bus to communicate with devices.
 
static void uart_half_duplex_set_tx (uart_half_duplex_t *dev)
 Set the half-duplex UART bus in TX mode.
 
static void uart_half_duplex_set_rx (uart_half_duplex_t *dev)
 Set the half-duplex UART bus in RX mode.
 
size_t uart_half_duplex_send (const uart_half_duplex_t *dev, size_t size)
 Send the data contained in the driver's buffer.
 
size_t uart_half_duplex_recv (const uart_half_duplex_t *dev, size_t size)
 Recv data an fill the driver's buffer.
 

Macro Definition Documentation

◆ UART_HALF_DUPLEX_DEFAULT_TIMEOUT_US

#define UART_HALF_DUPLEX_DEFAULT_TIMEOUT_US   (20000LU)

Default recv timeout (in microseconds)

Definition at line 36 of file uart_half_duplex.h.

◆ UART_HALF_DUPLEX_DIR_NONE

#define UART_HALF_DUPLEX_DIR_NONE   { NULL, NULL, NULL }

Don't manage direction.

Definition at line 48 of file uart_half_duplex.h.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Possible UART_HALF_DUPLEX return values.

Enumerator
UART_HALF_DUPLEX_OK 

everything in order

UART_HALF_DUPLEX_NODEV 

invalid UART device given

UART_HALF_DUPLEX_NOBAUD 

given baudrate is not applicable

UART_HALF_DUPLEX_INTERR 

all other internal errors

UART_HALF_DUPLEX_NOMODE 

given mode is not applicable

UART_HALF_DUPLEX_NOBUFF 

invalid buffer given

Definition at line 73 of file uart_half_duplex.h.

Function Documentation

◆ uart_half_duplex_init()

int uart_half_duplex_init ( uart_half_duplex_t dev,
uint8_t *  buffer,
size_t  buffer_max_size,
const uart_half_duplex_params_t params 
)

Initialize the half-duplex UART bus to communicate with devices.

Parameters
[out]devthe device
[in]bufferthe buffer used for TX and RX
[in]buffer_max_sizethe buffer size
[in]paramsthe initialization parameters
Returns
UART_HALF_DUPLEX_OK if everything is in order
UART_HALF_DUPLEX_NODEV if invalid UART device was given
UART_HALF_DUPLEX_NOBAUD if given baudrate is not applicable
UART_HALF_DUPLEX_INTERR if an other internal error occurred
UART_HALF_DUPLEX_NOMODE if the given mode is not applicable
UART_HALF_DUPLEX_NOBUFF if an invalid buffer was given

◆ uart_half_duplex_recv()

size_t uart_half_duplex_recv ( const uart_half_duplex_t dev,
size_t  size 
)

Recv data an fill the driver's buffer.

Parameters
[in]devthe device
[in]sizethe number of characters to receive
Returns
the number of characters actually received

◆ uart_half_duplex_send()

size_t uart_half_duplex_send ( const uart_half_duplex_t dev,
size_t  size 
)

Send the data contained in the driver's buffer.

Parameters
[in]devthe device
[in]sizethe number of characters to send
Returns
the number of characters actually sent

◆ uart_half_duplex_set_rx()

static void uart_half_duplex_set_rx ( uart_half_duplex_t dev)
inlinestatic

Set the half-duplex UART bus in RX mode.

Parameters
[in]devthe device

Definition at line 114 of file uart_half_duplex.h.

◆ uart_half_duplex_set_tx()

static void uart_half_duplex_set_tx ( uart_half_duplex_t dev)
inlinestatic

Set the half-duplex UART bus in TX mode.

Parameters
[in]devthe device

Definition at line 104 of file uart_half_duplex.h.