Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
uart.h File Reference
#include "ultibo/globaltypes.h"
#include "ultibo/globalconst.h"
#include "ultibo/devices.h"
#include "ultibo/serial.h"

Go to the source code of this file.

Data Structures

struct  _UART_PROPERTIES
struct  _UART_DEVICE

Macros

#define UART_NAME_PREFIX   "UART"
 Name prefix for UART Devices.
#define UART_PUSH_TIMEOUT   SERIAL_PUSH_TIMEOUT
 Timeout (Milliseconds) for Push RX/TX (Implementation specific).
#define UART_TYPE_NONE   0
#define UART_TYPE_8250   1
 8250 UART and similar variants (Differences are handled by driver)
#define UART_TYPE_16550   2
 16550 UART and similar variants (eg 16550A) (Differences are handled by driver)
#define UART_TYPE_16650   3
 16650 UART and similar variants (eg 16C650) (Differences are handled by driver)
#define UART_TYPE_MAX   3
#define UART_MODE_NONE   0
#define UART_MODE_UART   1
 The UART was opened as a UART device and all reads and writes are direct.
#define UART_MODE_SERIAL   2
 The UART was opened as a Serial device so reads and writes are being buffered.
#define UART_MODE_MAX   2
#define UART_STATE_DISABLED   0
#define UART_STATE_ENABLED   1
#define UART_STATE_MAX   1
#define UART_FLAG_NONE   SERIAL_FLAG_NONE
#define UART_FLAG_DATA_8BIT   SERIAL_FLAG_DATA_8BIT
 Device supports 8 data bits.
#define UART_FLAG_DATA_7BIT   SERIAL_FLAG_DATA_7BIT
 Device supports 7 data bits.
#define UART_FLAG_DATA_6BIT   SERIAL_FLAG_DATA_6BIT
 Device supports 6 data bits.
#define UART_FLAG_DATA_5BIT   SERIAL_FLAG_DATA_5BIT
 Device supports 5 data bits.
#define UART_FLAG_STOP_1BIT   SERIAL_FLAG_STOP_1BIT
 Device supports 1 stop bit.
#define UART_FLAG_STOP_2BIT   SERIAL_FLAG_STOP_2BIT
 Device supports 2 stop bits.
#define UART_FLAG_STOP_1BIT5   SERIAL_FLAG_STOP_1BIT5
 Device supports 1.5 stop bits.
#define UART_FLAG_PARITY_ODD   SERIAL_FLAG_PARITY_ODD
 Device supports odd parity.
#define UART_FLAG_PARITY_EVEN   SERIAL_FLAG_PARITY_EVEN
 Device supports even parity.
#define UART_FLAG_PARITY_MARK   SERIAL_FLAG_PARITY_MARK
 Device supports mark parity.
#define UART_FLAG_PARITY_SPACE   SERIAL_FLAG_PARITY_SPACE
 Device supports space parity.
#define UART_FLAG_FLOW_RTS_CTS   SERIAL_FLAG_FLOW_RTS_CTS
 Device supports RTS/CTS flow control.
#define UART_FLAG_FLOW_DSR_DTR   SERIAL_FLAG_FLOW_DSR_DTR
 Device supports DSR/DTR flow control.
#define UART_FLAG_PUSH_RX   SERIAL_FLAG_PUSH_RX
 Device requires pushed receive (Implementation specific).
#define UART_FLAG_PUSH_TX   SERIAL_FLAG_PUSH_TX
 Device requires pushed transmit (Implementation specific).
#define UART_READ_NONE   SERIAL_READ_NONE
#define UART_READ_NON_BLOCK   SERIAL_READ_NON_BLOCK
 Do not block when receiving, if the FIFO is empty return immediately.
#define UART_WRITE_NONE   SERIAL_WRITE_NONE
#define UART_WRITE_NON_BLOCK   SERIAL_WRITE_NON_BLOCK
 Do not block when transmitting, if the FIFO is full return immediately.
#define UART_WAIT_NONE   SERIAL_WAIT_NONE
#define UART_WAIT_RECEIVE   SERIAL_WAIT_RECEIVE
 Wait for data to be available in the receive FIFO.
#define UART_WAIT_TRANSMIT   SERIAL_WAIT_TRANSMIT
 Wait for space to be available in the transmit FIFO.
#define UART_STATUS_NONE   SERIAL_STATUS_NONE
#define UART_STATUS_RTS   SERIAL_STATUS_RTS
#define UART_STATUS_CTS   SERIAL_STATUS_CTS
#define UART_STATUS_DSR   SERIAL_STATUS_DSR
#define UART_STATUS_DTR   SERIAL_STATUS_DTR
#define UART_STATUS_RX_FULL   SERIAL_STATUS_RX_FULL
#define UART_STATUS_RX_EMPTY   SERIAL_STATUS_RX_EMPTY
#define UART_STATUS_TX_FULL   SERIAL_STATUS_TX_FULL
#define UART_STATUS_TX_EMPTY   SERIAL_STATUS_TX_EMPTY
#define UART_STATUS_BUSY   SERIAL_STATUS_BUSY
#define UART_STATUS_BREAK_ERROR   SERIAL_STATUS_BREAK_ERROR
#define UART_STATUS_PARITY_ERROR   SERIAL_STATUS_PARITY_ERROR
#define UART_STATUS_FRAMING_ERROR   SERIAL_STATUS_FRAMING_ERROR
#define UART_STATUS_OVERRUN_ERROR   SERIAL_STATUS_OVERRUN_ERROR
#define UART_STATUS_DCD   SERIAL_STATUS_DCD
#define UART_STATUS_RI   SERIAL_STATUS_RI

Typedefs

typedef struct _UART_PROPERTIES UART_PROPERTIES
typedef struct _UART_DEVICE UART_DEVICE
typedef uint32_t STDCALL(* uart_enumerate_cb) (UART_DEVICE *uart, void *data)
typedef uint32_t STDCALL(* uart_notification_cb) (DEVICE *device, void *data, uint32_t notification)
typedef uint32_t STDCALL(* uart_device_open_proc) (UART_DEVICE *uart, uint32_t baudrate, uint32_t databits, uint32_t stopbits, uint32_t parity, uint32_t flowcontrol)
typedef uint32_t STDCALL(* uart_device_close_proc) (UART_DEVICE *uart)
typedef uint32_t STDCALL(* uart_device_read_proc) (UART_DEVICE *uart, void *buffer, uint32_t size, uint32_t flags, uint32_t *count)
typedef uint32_t STDCALL(* uart_device_write_proc) (UART_DEVICE *uart, void *buffer, uint32_t size, uint32_t flags, uint32_t *count)
typedef uint32_t STDCALL(* uart_device_wait_proc) (UART_DEVICE *uart, uint32_t direction, uint32_t timeout)
typedef uint32_t STDCALL(* uart_device_get_status_proc) (UART_DEVICE *uart)
typedef uint32_t STDCALL(* uart_device_set_status_proc) (UART_DEVICE *uart, uint32_t status)
typedef uint32_t STDCALL(* uart_device_get_properties_proc) (UART_DEVICE *uart, UART_PROPERTIES *properties)
typedef uint32_t STDCALL(* uart_device_set_properties_proc) (UART_DEVICE *uart, UART_PROPERTIES *properties)

Functions

uint32_t STDCALL uart_device_open (UART_DEVICE *uart, uint32_t baudrate, uint32_t databits, uint32_t stopbits, uint32_t parity, uint32_t flowcontrol)
 Open a UART device ready for sending and receiving.
uint32_t STDCALL uart_device_close (UART_DEVICE *uart)
 Close a UART device and terminate sending and receiving.
uint32_t STDCALL uart_device_read (UART_DEVICE *uart, void *buffer, uint32_t size, uint32_t flags, uint32_t *count)
 Read data from a UART device.
uint32_t STDCALL uart_device_write (UART_DEVICE *uart, void *buffer, uint32_t size, uint32_t flags, uint32_t *count)
 Write data to a UART device.
uint32_t STDCALL uart_device_wait (UART_DEVICE *uart, uint32_t direction, uint32_t timeout)
 Wait for data to be available in the receive or transmit FIFO of a UART device.
uint32_t STDCALL uart_device_status (UART_DEVICE *uart)
 Get the current line status of a UART device.
uint32_t STDCALL uart_device_get_status (UART_DEVICE *uart)
 Get the current line status of a UART device.
uint32_t STDCALL uart_device_set_status (UART_DEVICE *uart, uint32_t status)
 Set the current line status of a UART device.
uint32_t STDCALL uart_device_properties (UART_DEVICE *uart, UART_PROPERTIES *properties)
 Get the properties for the specified UART device.
uint32_t STDCALL uart_device_get_properties (UART_DEVICE *uart, UART_PROPERTIES *properties)
 Get the properties for the specified UART device.
uint32_t STDCALL uart_device_set_properties (UART_DEVICE *uart, UART_PROPERTIES *properties)
 Set the properties for the specified UART device.
UART_DEVICE *STDCALL uart_device_create (void)
 Create a new UART entry.
UART_DEVICE *STDCALL uart_device_create_ex (uint32_t size)
 Create a new UART entry.
uint32_t STDCALL uart_device_destroy (UART_DEVICE *uart)
 Destroy an existing UART entry.
uint32_t STDCALL uart_device_register (UART_DEVICE *uart)
 Register a new UART in the UART table.
uint32_t STDCALL uart_device_deregister (UART_DEVICE *uart)
 Deregister a UART from the UART table.
UART_DEVICE *STDCALL uart_device_find (uint32_t uartid)
 Find a UART device by ID in the UART table.
UART_DEVICE *STDCALL uart_device_find_by_name (const char *name)
 Find a UART device by name in the UART table.
UART_DEVICE *STDCALL uart_device_find_by_description (const char *description)
 Find a UART device by description in the UART table.
uint32_t STDCALL uart_device_enumerate (uart_enumerate_cb callback, void *data)
 Enumerate all UART devices in the UART table.
uint32_t STDCALL uart_device_notification (UART_DEVICE *uart, uart_notification_cb callback, void *data, uint32_t notification, uint32_t flags)
 Register a notification for UART device changes.
uint32_t STDCALL uart_get_count (void)
 Get the current UART count.
UART_DEVICE *STDCALL uart_device_get_default (void)
 Get the current default UART device.
uint32_t STDCALL uart_device_set_default (UART_DEVICE *uart)
 Set the current default UART device.
UART_DEVICE *STDCALL uart_device_check (UART_DEVICE *uart)
 Check if the supplied UART is in the UART table.
uint32_t STDCALL uart_type_to_string (uint32_t uarttype, char *string, uint32_t len)
 Convert a UART type value to a string.
uint32_t STDCALL uart_mode_to_string (uint32_t uartmode, char *string, uint32_t len)
 Convert a UART mode to a string.
uint32_t STDCALL uart_state_to_string (uint32_t uartstate, char *string, uint32_t len)
 Convert a UART state value to a string.
uint32_t STDCALL uart_serial_device_receive (UART_DEVICE *uart)
 Read data from a UART device into the receive buffer of the associated Serial device.
uint32_t STDCALL uart_serial_device_transmit (UART_DEVICE *uart)
 Write data to a UART device from the transmit buffer of the associated Serial device.

Macro Definition Documentation

◆ UART_NAME_PREFIX

#define UART_NAME_PREFIX   "UART"

Name prefix for UART Devices.

UART specific constants

◆ UART_PUSH_TIMEOUT

#define UART_PUSH_TIMEOUT   SERIAL_PUSH_TIMEOUT

Timeout (Milliseconds) for Push RX/TX (Implementation specific).

◆ UART_TYPE_NONE

#define UART_TYPE_NONE   0

UART Device Types

◆ UART_TYPE_8250

#define UART_TYPE_8250   1

8250 UART and similar variants (Differences are handled by driver)

◆ UART_TYPE_16550

#define UART_TYPE_16550   2

16550 UART and similar variants (eg 16550A) (Differences are handled by driver)

◆ UART_TYPE_16650

#define UART_TYPE_16650   3

16650 UART and similar variants (eg 16C650) (Differences are handled by driver)

◆ UART_TYPE_MAX

#define UART_TYPE_MAX   3

◆ UART_MODE_NONE

#define UART_MODE_NONE   0

UART Device Modes

◆ UART_MODE_UART

#define UART_MODE_UART   1

The UART was opened as a UART device and all reads and writes are direct.

◆ UART_MODE_SERIAL

#define UART_MODE_SERIAL   2

The UART was opened as a Serial device so reads and writes are being buffered.

◆ UART_MODE_MAX

#define UART_MODE_MAX   2

◆ UART_STATE_DISABLED

#define UART_STATE_DISABLED   0

UART Device States

◆ UART_STATE_ENABLED

#define UART_STATE_ENABLED   1

◆ UART_STATE_MAX

#define UART_STATE_MAX   1

◆ UART_FLAG_NONE

#define UART_FLAG_NONE   SERIAL_FLAG_NONE

UART Device Flags

◆ UART_FLAG_DATA_8BIT

#define UART_FLAG_DATA_8BIT   SERIAL_FLAG_DATA_8BIT

Device supports 8 data bits.

◆ UART_FLAG_DATA_7BIT

#define UART_FLAG_DATA_7BIT   SERIAL_FLAG_DATA_7BIT

Device supports 7 data bits.

◆ UART_FLAG_DATA_6BIT

#define UART_FLAG_DATA_6BIT   SERIAL_FLAG_DATA_6BIT

Device supports 6 data bits.

◆ UART_FLAG_DATA_5BIT

#define UART_FLAG_DATA_5BIT   SERIAL_FLAG_DATA_5BIT

Device supports 5 data bits.

◆ UART_FLAG_STOP_1BIT

#define UART_FLAG_STOP_1BIT   SERIAL_FLAG_STOP_1BIT

Device supports 1 stop bit.

◆ UART_FLAG_STOP_2BIT

#define UART_FLAG_STOP_2BIT   SERIAL_FLAG_STOP_2BIT

Device supports 2 stop bits.

◆ UART_FLAG_STOP_1BIT5

#define UART_FLAG_STOP_1BIT5   SERIAL_FLAG_STOP_1BIT5

Device supports 1.5 stop bits.

◆ UART_FLAG_PARITY_ODD

#define UART_FLAG_PARITY_ODD   SERIAL_FLAG_PARITY_ODD

Device supports odd parity.

◆ UART_FLAG_PARITY_EVEN

#define UART_FLAG_PARITY_EVEN   SERIAL_FLAG_PARITY_EVEN

Device supports even parity.

◆ UART_FLAG_PARITY_MARK

#define UART_FLAG_PARITY_MARK   SERIAL_FLAG_PARITY_MARK

Device supports mark parity.

◆ UART_FLAG_PARITY_SPACE

#define UART_FLAG_PARITY_SPACE   SERIAL_FLAG_PARITY_SPACE

Device supports space parity.

◆ UART_FLAG_FLOW_RTS_CTS

#define UART_FLAG_FLOW_RTS_CTS   SERIAL_FLAG_FLOW_RTS_CTS

Device supports RTS/CTS flow control.

◆ UART_FLAG_FLOW_DSR_DTR

#define UART_FLAG_FLOW_DSR_DTR   SERIAL_FLAG_FLOW_DSR_DTR

Device supports DSR/DTR flow control.

◆ UART_FLAG_PUSH_RX

#define UART_FLAG_PUSH_RX   SERIAL_FLAG_PUSH_RX

Device requires pushed receive (Implementation specific).

◆ UART_FLAG_PUSH_TX

#define UART_FLAG_PUSH_TX   SERIAL_FLAG_PUSH_TX

Device requires pushed transmit (Implementation specific).

◆ UART_READ_NONE

#define UART_READ_NONE   SERIAL_READ_NONE

UART Read Flags

◆ UART_READ_NON_BLOCK

#define UART_READ_NON_BLOCK   SERIAL_READ_NON_BLOCK

Do not block when receiving, if the FIFO is empty return immediately.

◆ UART_WRITE_NONE

#define UART_WRITE_NONE   SERIAL_WRITE_NONE

UART Write Flags

◆ UART_WRITE_NON_BLOCK

#define UART_WRITE_NON_BLOCK   SERIAL_WRITE_NON_BLOCK

Do not block when transmitting, if the FIFO is full return immediately.

◆ UART_WAIT_NONE

#define UART_WAIT_NONE   SERIAL_WAIT_NONE

UART Wait Directions

◆ UART_WAIT_RECEIVE

#define UART_WAIT_RECEIVE   SERIAL_WAIT_RECEIVE

Wait for data to be available in the receive FIFO.

◆ UART_WAIT_TRANSMIT

#define UART_WAIT_TRANSMIT   SERIAL_WAIT_TRANSMIT

Wait for space to be available in the transmit FIFO.

◆ UART_STATUS_NONE

#define UART_STATUS_NONE   SERIAL_STATUS_NONE

UART Status Flags

◆ UART_STATUS_RTS

#define UART_STATUS_RTS   SERIAL_STATUS_RTS

◆ UART_STATUS_CTS

#define UART_STATUS_CTS   SERIAL_STATUS_CTS

◆ UART_STATUS_DSR

#define UART_STATUS_DSR   SERIAL_STATUS_DSR

◆ UART_STATUS_DTR

#define UART_STATUS_DTR   SERIAL_STATUS_DTR

◆ UART_STATUS_RX_FULL

#define UART_STATUS_RX_FULL   SERIAL_STATUS_RX_FULL

◆ UART_STATUS_RX_EMPTY

#define UART_STATUS_RX_EMPTY   SERIAL_STATUS_RX_EMPTY

◆ UART_STATUS_TX_FULL

#define UART_STATUS_TX_FULL   SERIAL_STATUS_TX_FULL

◆ UART_STATUS_TX_EMPTY

#define UART_STATUS_TX_EMPTY   SERIAL_STATUS_TX_EMPTY

◆ UART_STATUS_BUSY

#define UART_STATUS_BUSY   SERIAL_STATUS_BUSY

◆ UART_STATUS_BREAK_ERROR

#define UART_STATUS_BREAK_ERROR   SERIAL_STATUS_BREAK_ERROR

◆ UART_STATUS_PARITY_ERROR

#define UART_STATUS_PARITY_ERROR   SERIAL_STATUS_PARITY_ERROR

◆ UART_STATUS_FRAMING_ERROR

#define UART_STATUS_FRAMING_ERROR   SERIAL_STATUS_FRAMING_ERROR

◆ UART_STATUS_OVERRUN_ERROR

#define UART_STATUS_OVERRUN_ERROR   SERIAL_STATUS_OVERRUN_ERROR

◆ UART_STATUS_DCD

#define UART_STATUS_DCD   SERIAL_STATUS_DCD

◆ UART_STATUS_RI

#define UART_STATUS_RI   SERIAL_STATUS_RI

Typedef Documentation

◆ UART_PROPERTIES

UART specific types UART Properties

◆ UART_DEVICE

typedef struct _UART_DEVICE UART_DEVICE

UART Device

◆ uart_enumerate_cb

typedef uint32_t STDCALL(* uart_enumerate_cb) (UART_DEVICE *uart, void *data)

UART Enumeration Callback

◆ uart_notification_cb

typedef uint32_t STDCALL(* uart_notification_cb) (DEVICE *device, void *data, uint32_t notification)

UART Notification Callback

◆ uart_device_open_proc

typedef uint32_t STDCALL(* uart_device_open_proc) (UART_DEVICE *uart, uint32_t baudrate, uint32_t databits, uint32_t stopbits, uint32_t parity, uint32_t flowcontrol)

UART Device Methods

◆ uart_device_close_proc

typedef uint32_t STDCALL(* uart_device_close_proc) (UART_DEVICE *uart)

◆ uart_device_read_proc

typedef uint32_t STDCALL(* uart_device_read_proc) (UART_DEVICE *uart, void *buffer, uint32_t size, uint32_t flags, uint32_t *count)

◆ uart_device_write_proc

typedef uint32_t STDCALL(* uart_device_write_proc) (UART_DEVICE *uart, void *buffer, uint32_t size, uint32_t flags, uint32_t *count)

◆ uart_device_wait_proc

typedef uint32_t STDCALL(* uart_device_wait_proc) (UART_DEVICE *uart, uint32_t direction, uint32_t timeout)

◆ uart_device_get_status_proc

typedef uint32_t STDCALL(* uart_device_get_status_proc) (UART_DEVICE *uart)

◆ uart_device_set_status_proc

typedef uint32_t STDCALL(* uart_device_set_status_proc) (UART_DEVICE *uart, uint32_t status)

◆ uart_device_get_properties_proc

typedef uint32_t STDCALL(* uart_device_get_properties_proc) (UART_DEVICE *uart, UART_PROPERTIES *properties)

◆ uart_device_set_properties_proc

typedef uint32_t STDCALL(* uart_device_set_properties_proc) (UART_DEVICE *uart, UART_PROPERTIES *properties)

Function Documentation

◆ uart_device_open()

uint32_t STDCALL uart_device_open ( UART_DEVICE * uart,
uint32_t baudrate,
uint32_t databits,
uint32_t stopbits,
uint32_t parity,
uint32_t flowcontrol )

Open a UART device ready for sending and receiving.

UART Functions

Parameters
UARTThe UART device to open
BaudRateBaud rate for the connection (eg 9600, 57600, 115200 etc
DataBitsSize of the data (eg SERIAL_DATA_8BIT)
StopBitsNumber of stop bits (eg SERIAL_STOP_1BIT)
ParityParity type for the data (eg SERIAL_PARITY_NONE)
FlowControlFlow control for the connection (eg SERIAL_FLOW_NONE)
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ uart_device_close()

uint32_t STDCALL uart_device_close ( UART_DEVICE * uart)

Close a UART device and terminate sending and receiving.

Parameters
UARTThe UART device to close
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ uart_device_read()

uint32_t STDCALL uart_device_read ( UART_DEVICE * uart,
void * buffer,
uint32_t size,
uint32_t flags,
uint32_t * count )

Read data from a UART device.

Parameters
UARTThe UART device to read from
BufferPointer to a buffer to receive the data
SizeThe size of the buffer
FlagsThe flags to control reading (eg UART_READ_NON_BLOCK)
CountThe number of bytes read on return
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ uart_device_write()

uint32_t STDCALL uart_device_write ( UART_DEVICE * uart,
void * buffer,
uint32_t size,
uint32_t flags,
uint32_t * count )

Write data to a UART device.

Parameters
UARTThe UART device to write to
BufferPointer to a buffer of data to transmit
SizeThe size of the buffer
FlagsThe flags to control writing (eg UART_WRITE_NON_BLOCK)
CountThe number of bytes written on return
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ uart_device_wait()

uint32_t STDCALL uart_device_wait ( UART_DEVICE * uart,
uint32_t direction,
uint32_t timeout )

Wait for data to be available in the receive or transmit FIFO of a UART device.

Parameters
UARTThe UART device to wait for
DirectionThe direction of data to wait for (eg UART_WAIT_RECEIVE)
TimeoutThe number of milliseconds to wait for data (INFINITE to wait forever)
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ uart_device_status()

uint32_t STDCALL uart_device_status ( UART_DEVICE * uart)

Get the current line status of a UART device.

Parameters
UARTThe UART device to get the status from
Returns
A set of flags containing the device status (eg UART_STATUS_RTS)
Note
Replaced by UARTDeviceGetStatus for consistency

◆ uart_device_get_status()

uint32_t STDCALL uart_device_get_status ( UART_DEVICE * uart)

Get the current line status of a UART device.

Parameters
UARTThe UART device to get the status from
Returns
A set of flags containing the device status (eg UART_STATUS_RTS)

◆ uart_device_set_status()

uint32_t STDCALL uart_device_set_status ( UART_DEVICE * uart,
uint32_t status )

Set the current line status of a UART device.

Parameters
UARTThe UART device to set the status for
StatusThe device status flags to be set (eg UART_STATUS_RTS)
Returns
ERROR_SUCCESS if completed or another error code on failure
Note
Not all UART_STATUS_* flags can be set, the device may ignore invalid values
Not all UART devices support set status, returns ERROR_CALL_NOT_IMPLEMENTED if not supported

◆ uart_device_properties()

uint32_t STDCALL uart_device_properties ( UART_DEVICE * uart,
UART_PROPERTIES * properties )

Get the properties for the specified UART device.

Parameters
UARTThe UART device to get properties from
PropertiesPointer to a PUARTProperties structure to fill in
Returns
ERROR_SUCCESS if completed or another error code on failure
Note
Replaced by UARTDeviceGetProperties for consistency

◆ uart_device_get_properties()

uint32_t STDCALL uart_device_get_properties ( UART_DEVICE * uart,
UART_PROPERTIES * properties )

Get the properties for the specified UART device.

Parameters
UARTThe UART device to get properties from
PropertiesPointer to a PUARTProperties structure to fill in
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ uart_device_set_properties()

uint32_t STDCALL uart_device_set_properties ( UART_DEVICE * uart,
UART_PROPERTIES * properties )

Set the properties for the specified UART device.

Parameters
UARTThe UART device to set properties for
PropertiesPointer to a PUARTProperties structure to use
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ uart_device_create()

UART_DEVICE *STDCALL uart_device_create ( void )

Create a new UART entry.

Returns
Pointer to new UART entry or nil if UART could not be created

◆ uart_device_create_ex()

UART_DEVICE *STDCALL uart_device_create_ex ( uint32_t size)

Create a new UART entry.

Parameters
SizeSize in bytes to allocate for new UART (Including the UART entry)
Returns
Pointer to new UART entry or nil if UART could not be created

◆ uart_device_destroy()

uint32_t STDCALL uart_device_destroy ( UART_DEVICE * uart)

Destroy an existing UART entry.

Parameters
UARTThe UART device to destroy
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ uart_device_register()

uint32_t STDCALL uart_device_register ( UART_DEVICE * uart)

Register a new UART in the UART table.

Parameters
UARTThe UART device to register
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ uart_device_deregister()

uint32_t STDCALL uart_device_deregister ( UART_DEVICE * uart)

Deregister a UART from the UART table.

Parameters
UARTThe UART device to deregister
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ uart_device_find()

UART_DEVICE *STDCALL uart_device_find ( uint32_t uartid)

Find a UART device by ID in the UART table.

Parameters
UARTIdThe ID number of the UART to find
Returns
Pointer to UART device entry or nil if not found

◆ uart_device_find_by_name()

UART_DEVICE *STDCALL uart_device_find_by_name ( const char * name)

Find a UART device by name in the UART table.

Parameters
NameThe name of the UART to find (eg UART0)
Returns
Pointer to UART device entry or nil if not found

◆ uart_device_find_by_description()

UART_DEVICE *STDCALL uart_device_find_by_description ( const char * description)

Find a UART device by description in the UART table.

Parameters
DescriptionThe description of the UART to find (eg BCM2836 PL011 UART)
Returns
Pointer to UART device entry or nil if not found

◆ uart_device_enumerate()

uint32_t STDCALL uart_device_enumerate ( uart_enumerate_cb callback,
void * data )

Enumerate all UART devices in the UART table.

Parameters
CallbackThe callback function to call for each UART in the table
DataA private data pointer to pass to callback for each UART in the table
Returns
ERROR_SUCCESS if completed or another error code on failure

◆ uart_device_notification()

uint32_t STDCALL uart_device_notification ( UART_DEVICE * uart,
uart_notification_cb callback,
void * data,
uint32_t notification,
uint32_t flags )

Register a notification for UART device changes.

Parameters
UARTThe UART device to notify changes for (Optional, pass nil for all UART devices)
CallbackThe function to call when a notification event occurs
DataA private data pointer to pass to callback when a notification event occurs
NotificationThe events to register for notification of (eg DEVICE_NOTIFICATION_REGISTER)
FlagsThe flags to control the notification (eg NOTIFIER_FLAG_WORKER)

◆ uart_get_count()

uint32_t STDCALL uart_get_count ( void )

Get the current UART count.

UART Helper Functions

◆ uart_device_get_default()

UART_DEVICE *STDCALL uart_device_get_default ( void )

Get the current default UART device.

◆ uart_device_set_default()

uint32_t STDCALL uart_device_set_default ( UART_DEVICE * uart)

Set the current default UART device.

◆ uart_device_check()

UART_DEVICE *STDCALL uart_device_check ( UART_DEVICE * uart)

Check if the supplied UART is in the UART table.

◆ uart_type_to_string()

uint32_t STDCALL uart_type_to_string ( uint32_t uarttype,
char * string,
uint32_t len )

Convert a UART type value to a string.

◆ uart_mode_to_string()

uint32_t STDCALL uart_mode_to_string ( uint32_t uartmode,
char * string,
uint32_t len )

Convert a UART mode to a string.

◆ uart_state_to_string()

uint32_t STDCALL uart_state_to_string ( uint32_t uartstate,
char * string,
uint32_t len )

Convert a UART state value to a string.

◆ uart_serial_device_receive()

uint32_t STDCALL uart_serial_device_receive ( UART_DEVICE * uart)

Read data from a UART device into the receive buffer of the associated Serial device.

UART Serial Helper Functions

Note
Not intended to be called directly by applications
Caller must hold the lock on the serial device which owns the UART

◆ uart_serial_device_transmit()

uint32_t STDCALL uart_serial_device_transmit ( UART_DEVICE * uart)

Write data to a UART device from the transmit buffer of the associated Serial device.

Note
Not intended to be called directly by applications
Caller must hold the lock on the serial device which owns the UART