uart_half_duplex.h¶
Interface definition for half-duplex UART driver.
-
UART_HALF_DUPLEX_DEFAULT_TIMEOUT_US
¶ Default recv timeout (in microseconds)
1
(20000LU)
-
UART_HALF_DUPLEX_DIR_NONE
¶ Don’t manage direction.
1
{ NULL, NULL, NULL }
-
enum
@173
¶ - UART_HALF_DUPLEX_OK
= UART_OK
- everything in order
- UART_HALF_DUPLEX_NODEV
= UART_NODEV
- invalid UART device given
- UART_HALF_DUPLEX_NOBAUD
= UART_NOBAUD
- given baudrate is not applicable
- UART_HALF_DUPLEX_INTERR
= UART_INTERR
- all other internal errors
- UART_HALF_DUPLEX_NOMODE
= UART_NOMODE
- given mode is not applicable
- UART_HALF_DUPLEX_NOBUFF
= -5
- invalid buffer given
- UART_HALF_DUPLEX_OK
-
int
uart_half_duplex_init
(uart_half_duplex_t * dev, uint8_t * buffer,msp430_types.h::size_t
buffer_max_size, const uart_half_duplex_params_t * params)¶ Initialize the half-duplex UART bus to communicate with devices.
Parameters
dev: the device buffer: the buffer used for TX and RX buffer_max_size: the buffer size params: the initialization parameters Return values
- 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 occured
- UART_HALF_DUPLEX_NOMODE if the given mode is not applicable
- UART_HALF_DUPLEX_NOBUFF if an invalid buffer was given
-
void
uart_half_duplex_set_tx
(uart_half_duplex_t * dev)¶ Set the half-duplex UART bus in TX mode.
Parameters
dev: the device
-
void
uart_half_duplex_set_rx
(uart_half_duplex_t * dev)¶ Set the half-duplex UART bus in RX mode.
Parameters
dev: the device
-
msp430_types.h::size_t
uart_half_duplex_send
(const uart_half_duplex_t * dev,msp430_types.h::size_t
size)¶ Send the data contained in the driver’s buffer.
Parameters
dev: the device size: the number of characters to send Return values
- the number of characters actually sent
-
msp430_types.h::size_t
uart_half_duplex_recv
(const uart_half_duplex_t * dev,msp430_types.h::size_t
size)¶ Recv data an fill the driver’s buffer.
Parameters
dev: the device size: the number of characters to receive Return values
- the number of characters actually received
-
struct
uart_half_duplex_dir_t
¶ half-duplex UART direction management method type
-
void(*
init
()¶ function initializing direction management method
-
void(*
enable_tx
()¶ function enabling TX
-
void(*
disable_tx
()¶ function disabling TX
-
void(*
-
struct
uart_half_duplex_params_t
¶ Configuration for half-duplex UART.
-
uart.h::uart_t
uart
¶ the half-duplex UART bus to use
-
uint32_t
baudrate
¶ the baudrate to use
-
uart_half_duplex_dir_t
dir
¶ the direction management method
-
-
struct
uart_half_duplex_t
¶ Descriptor struct for half-duplex UART.
-
uint8_t *
buffer
¶ the buffer used for TX and RX
-
msp430_types.h::size_t
size
¶ the number of available elements for TX/RX
-
msp430_types.h::size_t
buffer_max_size
¶ the buffer size
-
uint32_t
timeout_us
¶ the maximum duration (in microseconds) for waiting data
-
uart_half_duplex_params_t
params
¶ the half-duplex UART configuration
-
uint8_t *