![]() |
CMSIS Driver
Version 1.10 - Preliminary
Middleware Driver API for microcontroller peripherals
|
Driver API for Universal Asynchronous Receiver/Transmitter (Driver_UART.h) More...
Data Structures | |
struct | ARM_DRIVER_UART |
Access structure of the UART Driver. More... | |
struct | ARM_UART_CAPABILITIES |
UART Device Driver Capabilities. More... | |
struct | ARM_UART_COM_ERROR |
UART Communication Error. More... | |
struct | ARM_UART_MODEM_STATUS |
UART Modem Status. More... | |
Typedefs | |
typedef void(* | ARM_UART_SignalEvent_t )(ARM_UART_EVENT event) |
Pointer to ARM_UART_SignalEvent : Signal UART Event. | |
Functions | |
DRV_VERSION | ARM_UART_GetVersion (void) |
Get driver version. | |
ARM_UART_CAPABILITIES | ARM_UART_GetCapabilities (void) |
Get driver capabilities. | |
ARM_UART_STATUS | ARM_UART_Initialize (ARM_UART_SignalEvent_t cb_event, uint32_t event_mask) |
Initialize UART Interface. | |
ARM_UART_STATUS | ARM_UART_Uninitialize (void) |
De-initialize UART Interface. | |
ARM_UART_STATUS | ARM_UART_PowerControl (ARM_POWER_STATE state) |
Control UART Interface Power. | |
ARM_UART_STATUS | ARM_UART_Configure (uint32_t baudrate, uint8_t data_bits, ARM_UART_PARITY parity, ARM_UART_STOP_BITS stop_bits, ARM_UART_FLOW_CONTROL flow_control) |
Configure UART Interface. | |
int32_t | ARM_UART_WriteData (const uint8_t *data, uint32_t size) |
Write data to UART transmitter. | |
int32_t | ARM_UART_ReadData (uint8_t *data, uint32_t size) |
Read data from UART receiver. | |
int32_t | ARM_UART_DataAvailable (void) |
Check available data in UART receiver. | |
bool | ARM_UART_TxDone (void) |
Check if UART transmission is completed. | |
ARM_UART_STATUS | ARM_UART_SetTxThreshold (uint32_t level) |
Set transmit threshold for UART_TX_THRESHOLD event. | |
ARM_UART_STATUS | ARM_UART_SetRxThreshold (uint32_t level) |
Set receive threshold for UART_RX_THRESHOLD event. | |
ARM_UART_STATUS | ARM_UART_FlushTxBuffer (void) |
Flush UART transmit buffer. | |
ARM_UART_STATUS | ARM_UART_FlushRxBuffer (void) |
Flush UART receive buffer. | |
ARM_UART_COM_ERROR | ARM_UART_GetComError (void) |
Get UART Communication errors. | |
ARM_UART_STATUS | ARM_UART_SetComBreak (void) |
Suspend transmission and put UART Transmission line in a break state. | |
ARM_UART_STATUS | ARM_UART_ClearComBreak (void) |
Resume transmission and put UART Transmission line in a non-break state. | |
ARM_UART_STATUS | ARM_UART_SetModemControl (ARM_UART_MODEM_CONTROL control) |
Set UART Modem Control line state. | |
ARM_UART_MODEM_STATUS | ARM_UART_GetModemStatus (void) |
Get UART Modem Status lines state. | |
void | ARM_UART_SignalEvent (ARM_UART_EVENT event) |
Signal UART Event. | |
Driver API for Universal Asynchronous Receiver/Transmitter (Driver_UART.h)
The Universal Asynchronous Receiver/Transmitter (UART) implements an asynchronous serial bus for exchanging data. Almost all microcontrollers have a serial interface (UART peripheral). A UART is a simple device to send data to a PC via a terminal emulation program (Hyperterm, TeraTerm) or to another microcontroller and can operate in both synchronous and asynchronous mode. A UART takes bytes of data and transmits the individual bits in a sequential mode. At the destination, a second UART reassembles the bits into complete bytes. Each UART contains a shift register for converting between serial and parallel transmission forms. Wikipedia offers more information about the Universal asynchronous receiver/transmitter.
The following header files define the Application Programming Interface (API) for the UART interface:
The driver implementation is a typical part of the Device Family Pack (DFP) that supports the peripherals of the microcontroller family.
The driver functions are published in the access struct as explained in Driver Functions
A typical setup sequence for the driver is shown below:
Example Code:
struct ARM_DRIVER_UART |
Access structure of the UART Driver.
The functions of the UART driver are accessed by function pointers exposed by this structure. Refer to Driver Functions for overview information.
Each instance of an UART interface provides such an access structure. The instance is identified by a postfix number in the symbol name of the access structure, for example:
A middleware configuration setting allows connecting the middleware to a specific driver instance ARM_DRIVER_UARTn. The default is 0, which connects a middleware to the first instance of a driver.
Data Fields | |
ARM_DRV_VERSION(* | GetVersion )(void) |
Pointer to ARM_UART_GetVersion : Get driver version. | |
ARM_UART_CAPABILITIES(* | GetCapabilities )(void) |
Pointer to ARM_UART_GetCapabilities : Get driver capabilities. | |
ARM_UART_STATUS(* | Initialize )(ARM_UART_SignalEvent_t cb_event, uint32_t event_mask) |
Pointer to ARM_UART_Initialize : Initialize UART Interface. | |
ARM_UART_STATUS(* | Uninitialize )(void) |
Pointer to ARM_UART_Uninitialize : De-initialize UART Interface. | |
ARM_UART_STATUS(* | PowerControl )(ARM_POWER_STATE state) |
Pointer to ARM_UART_PowerControl : Control UART Interface Power. | |
ARM_UART_STATUS(* | Configure )(uint32_t baudrate, uint8_t data_bits, ARM_UART_PARITY parity, ARM_UART_STOP_BITS stop_bits, ARM_UART_FLOW_CONTROL flow_control) |
Pointer to ARM_UART_Configure : Configure UART Interface. | |
int32_t(* | WriteData )(const uint8_t *data, uint32_t size) |
Pointer to ARM_UART_WriteData : Write data to UART transmitter. | |
int32_t(* | ReadData )(uint8_t *data, uint32_t size) |
Pointer to ARM_UART_ReadData : Read data from UART receiver. | |
int32_t(* | DataAvailable )(void) |
Pointer to ARM_UART_DataAvailable : Check available data in UART receiver. | |
bool(* | TxDone )(void) |
Pointer to ARM_UART_TxDone : Check if UART transmission is completed. | |
ARM_UART_STATUS(* | SetTxThreshold )(uint32_t level) |
Pointer to ARM_UART_SetTxThreshold : Set transmit threshold. | |
ARM_UART_STATUS(* | SetRxThreshold )(uint32_t level) |
Pointer to ARM_UART_SetRxThreshold : Set receive threshold. | |
ARM_UART_STATUS(* | FlushTxBuffer )(void) |
Pointer to ARM_UART_FlushTxBuffer : Flush UART transmit buffer. | |
ARM_UART_STATUS(* | FlushRxBuffer )(void) |
Pointer to ARM_UART_FlushRxBuffer : Flush UART receive buffer. | |
ARM_UART_COM_ERROR(* | GetComError )(void) |
Pointer to ARM_UART_GetComError : Get UART Communication errors. | |
ARM_UART_STATUS(* | SetComBreak )(void) |
Pointer to ARM_UART_SetComBreak : Suspend transmission and put UART Transmission line in a break state. | |
ARM_UART_STATUS(* | ClearComBreak )(void) |
Pointer to ARM_UART_ClearComBreak : Resume transmission and put UART Transmission line in a non-break state. | |
ARM_UART_STATUS(* | SetModemControl )(ARM_UART_MODEM_CONTROL control) |
Pointer to ARM_UART_SetModemControl : Set UART Modem Control line state. | |
ARM_UART_MODEM_STATUS(* | GetModemStatus )(void) |
Pointer to ARM_UART_GetModemStatus : Get UART Modem Status lines state. | |
ARM_UART_STATUS(* ClearComBreak)(void) |
Pointer to ARM_UART_ClearComBreak : Resume transmission and put UART Transmission line in a non-break state.
ARM_UART_STATUS(* Configure)(uint32_t baudrate, uint8_t data_bits, ARM_UART_PARITY parity, ARM_UART_STOP_BITS stop_bits, ARM_UART_FLOW_CONTROL flow_control) |
Pointer to ARM_UART_Configure : Configure UART Interface.
int32_t(* DataAvailable)(void) |
Pointer to ARM_UART_DataAvailable : Check available data in UART receiver.
ARM_UART_STATUS(* FlushRxBuffer)(void) |
Pointer to ARM_UART_FlushRxBuffer : Flush UART receive buffer.
ARM_UART_STATUS(* FlushTxBuffer)(void) |
Pointer to ARM_UART_FlushTxBuffer : Flush UART transmit buffer.
ARM_UART_CAPABILITIES(* GetCapabilities)(void) |
Pointer to ARM_UART_GetCapabilities : Get driver capabilities.
ARM_UART_COM_ERROR(* GetComError)(void) |
Pointer to ARM_UART_GetComError : Get UART Communication errors.
ARM_UART_MODEM_STATUS(* GetModemStatus)(void) |
Pointer to ARM_UART_GetModemStatus : Get UART Modem Status lines state.
ARM_DRV_VERSION(* GetVersion)(void) |
Pointer to ARM_UART_GetVersion : Get driver version.
ARM_UART_STATUS(* Initialize)(ARM_UART_SignalEvent_t cb_event, uint32_t event_mask) |
Pointer to ARM_UART_Initialize : Initialize UART Interface.
ARM_UART_STATUS(* PowerControl)(ARM_POWER_STATE state) |
Pointer to ARM_UART_PowerControl : Control UART Interface Power.
int32_t(* ReadData)(uint8_t *data, uint32_t size) |
Pointer to ARM_UART_ReadData : Read data from UART receiver.
ARM_UART_STATUS(* SetComBreak)(void) |
Pointer to ARM_UART_SetComBreak : Suspend transmission and put UART Transmission line in a break state.
ARM_UART_STATUS(* SetModemControl)(ARM_UART_MODEM_CONTROL control) |
Pointer to ARM_UART_SetModemControl : Set UART Modem Control line state.
ARM_UART_STATUS(* SetRxThreshold)(uint32_t level) |
Pointer to ARM_UART_SetRxThreshold : Set receive threshold.
ARM_UART_STATUS(* SetTxThreshold)(uint32_t level) |
Pointer to ARM_UART_SetTxThreshold : Set transmit threshold.
bool(* TxDone)(void) |
Pointer to ARM_UART_TxDone : Check if UART transmission is completed.
ARM_UART_STATUS(* Uninitialize)(void) |
Pointer to ARM_UART_Uninitialize : De-initialize UART Interface.
int32_t(* WriteData)(const uint8_t *data, uint32_t size) |
Pointer to ARM_UART_WriteData : Write data to UART transmitter.
struct ARM_UART_CAPABILITIES |
UART Device Driver Capabilities.
An UART driver can be implemented with different capabilities. The bitfield members of this struct encode the capabilities implemented by this driver.
Returned by:
Data Fields | ||
---|---|---|
uint32_t | cts: 1 | CTS Line: 0=not available, 1=available. |
uint32_t | cts_event: 1 | Signal CTS change event: ARM_UART_EVENT_CTS. |
uint32_t | dcd: 1 | DCD Line: 0=not available, 1=available. |
uint32_t | dcd_event: 1 | Signal DCD change event: ARM_UART_EVENT_DCD. |
uint32_t | dsr: 1 | DSR Line: 0=not available, 1=available. |
uint32_t | dsr_event: 1 | Signal DSR change event: ARM_UART_EVENT_DSR. |
uint32_t | reserved: 23 | reserved for future use |
uint32_t | ri: 1 | RI Line: 0=not available, 1=available. |
uint32_t | ri_event: 1 | Signal RI change event: ARM_UART_EVENT_RI. |
uint32_t | rx_buffer_size | Receive Buffer Size. |
uint32_t | rx_timeout_event: 1 | Signal receive character timeout event: ARM_UART_EVENT_RX_TIMEOUT. |
uint32_t | tx_buffer_size | Transmit Buffer Size. |
struct ARM_UART_COM_ERROR |
UART Communication Error.
Provides standardized values for UART communication errors.
Returned by:
struct ARM_UART_MODEM_STATUS |
UART Modem Status.
Provides standardized values for the modem status.
Returned by:
ARM_UART_SignalEvent_t |
Pointer to ARM_UART_SignalEvent : Signal UART Event.
Provides the typedef for the callback function ARM_UART_SignalEvent.
Parameter for:
enum ARM_UART_EVENT |
UART Event.
Provides values for for the ARM_UART_SignalEvent callback function (which is registered by the function ARM_UART_Initialize). The function ARM_UART_GetCapabilities returns information about the implemented callback events in a driver.
UART Flow Control.
Provides standardized values for setting the flow control of an UART.
Parameter for:
UART Modem Control.
Provides standardized values for controlling the modem.
Returned by:
enum ARM_UART_PARITY |
UART Parity.
Provides standardized values for setting the parity bit of an UART.
Parameter for:
enum ARM_UART_STATUS |
UART Status of executed operation.
Defines status and error codes returned by most of the MCI driver functions.
Returned by:
enum ARM_UART_STOP_BITS |
UART Stop Bits.
Provides standardized values for setting the stop bits of an UART.
Parameter for:
ARM_UART_STATUS ARM_UART_ClearComBreak | ( | void | ) |
Resume transmission and put UART Transmission line in a non-break state.
Resume transmission and put the UART Transmission line in a non-break state.
ARM_UART_STATUS ARM_UART_Configure | ( | uint32_t | baudrate, |
uint8_t | data_bits, | ||
ARM_UART_PARITY | parity, | ||
ARM_UART_STOP_BITS | stop_bits, | ||
ARM_UART_FLOW_CONTROL | flow_control | ||
) |
Configure UART Interface.
[in] | baudrate | Requested baudrate in bits/s |
[in] | data_bits | Number of data bits |
[in] | parity | ARM_UART_PARITY |
[in] | stop_bits | ARM_UART_STOP_BITS |
[in] | flow_control | ARM_UART_FLOW_CONTROL |
Configure the UART Interface.
int32_t ARM_UART_DataAvailable | ( | void | ) |
Check available data in UART receiver.
Check available data available in the UART receiver.
ARM_UART_STATUS ARM_UART_FlushRxBuffer | ( | void | ) |
ARM_UART_STATUS ARM_UART_FlushTxBuffer | ( | void | ) |
ARM_UART_CAPABILITIES ARM_UART_GetCapabilities | ( | void | ) |
Get driver capabilities.
Retrieves information about capabilities in this driver implementation. The bitfield members of the struct ARM_UART_CAPABILITIES encode various capabilities, for example if a hardware is capable to create signal events using the ARM_UART_SignalEvent callback function.
Example:
ARM_UART_COM_ERROR ARM_UART_GetComError | ( | void | ) |
ARM_UART_MODEM_STATUS ARM_UART_GetModemStatus | ( | void | ) |
Get UART Modem Status lines state.
Get the UART Modem Status lines state.
ARM_DRV_VERSION ARM_UART_GetVersion | ( | void | ) |
Get driver version.
ARM_UART_STATUS ARM_UART_Initialize | ( | ARM_UART_SignalEvent_t | cb_event, |
uint32_t | event_mask | ||
) |
Initialize UART Interface.
[in] | cb_event | Pointer to ARM_UART_SignalEvent |
[in] | event_mask | Events that are reported through callbacks |
The function initializes the UART interface. It is called when the middleware component starts operation.
The function performs the following operations:
The parameter cb_event is a pointer to the ARM_UART_SignalEvent callback function; use a NULL pointer when no callback signals are required.
The parameter event_mask configures the events that get reported through callbacks.
Example:
ARM_UART_STATUS ARM_UART_PowerControl | ( | ARM_POWER_STATE | state | ) |
Control UART Interface Power.
[in] | state | Power state |
Control the UART Interface Power.
int32_t ARM_UART_ReadData | ( | uint8_t * | data, |
uint32_t | size | ||
) |
Read data from UART receiver.
[out] | data | Pointer to buffer for data read from UART receiver |
[in] | size | Data buffer size in bytes |
Read data from an UART receiver.
ARM_UART_STATUS ARM_UART_SetComBreak | ( | void | ) |
Suspend transmission and put UART Transmission line in a break state.
Suspend transmission and put the UART Transmission line in a break state.
ARM_UART_STATUS ARM_UART_SetModemControl | ( | ARM_UART_MODEM_CONTROL | control | ) |
Set UART Modem Control line state.
[in] | control | ARM_UART_MODEM_CONTROL |
Set the UART Modem Control line state.
ARM_UART_STATUS ARM_UART_SetRxThreshold | ( | uint32_t | level | ) |
Set receive threshold for UART_RX_THRESHOLD event.
[in] | level | Number of character in receive buffer |
Set the receive threshold.
ARM_UART_STATUS ARM_UART_SetTxThreshold | ( | uint32_t | level | ) |
Set transmit threshold for UART_TX_THRESHOLD event.
[in] | level | Number of character in transmit buffer |
Set the transmission threshold.
void ARM_UART_SignalEvent | ( | ARM_UART_EVENT | event | ) |
bool ARM_UART_TxDone | ( | void | ) |
Check if UART transmission is completed.
Check if the UART transmission is completed.
ARM_UART_STATUS ARM_UART_Uninitialize | ( | void | ) |
De-initialize UART Interface.
The function ARM_UART_Uninitialize de-initializes the resources of UART interface and sets the peripheral to ARM_POWER_OFF power mode.
It is called when the middleware component stops operation and releases the software resources used by the interface.
int32_t ARM_UART_WriteData | ( | const uint8_t * | data, |
uint32_t | size | ||
) |
Write data to UART transmitter.
[in] | data | Pointer to buffer with data to write to UART transmitter |
[in] | size | Data buffer size in bytes |
Write data to the UART transmitter.