MAX32665 SDK Documentation  0.2
Software Development Kit Overview and API Documentation
UART

Modules

 UART_Registers
 Registers, Bit Masks and Bit Positions for the UART Peripheral Module.
 

Data Structures

struct  uart_cfg_t
 UART configuration type. More...
 
struct  uart_req_t
 Non-blocking UART transaction request. More...
 

Enumerations

enum  uart_parity_t {
  UART_PARITY_DISABLE = 0,
  UART_PARITY_EVEN_0,
  UART_PARITY_EVEN_1,
  UART_PARITY_EVEN = UART_PARITY_EVEN_1,
  UART_PARITY_ODD_0,
  UART_PARITY_ODD_1,
  UART_PARITY_ODD = UART_PARITY_ODD_1,
  UART_PARITY_MARK_0,
  UART_PARITY_MARK_1,
  UART_PARITY_MARK = UART_PARITY_MARK_1,
  UART_PARITY_SPACE_0,
  UART_PARITY_SPACE_1,
  UART_PARITY_SPACE = UART_PARITY_SPACE_1
}
 Parity settings type. More...
 
enum  uart_size_t {
  UART_DATA_SIZE_5_BITS = MXC_S_UART_CTRL_CHAR_SIZE_5,
  UART_DATA_SIZE_6_BITS = MXC_S_UART_CTRL_CHAR_SIZE_6,
  UART_DATA_SIZE_7_BITS = MXC_S_UART_CTRL_CHAR_SIZE_7,
  UART_DATA_SIZE_8_BITS = MXC_S_UART_CTRL_CHAR_SIZE_8
}
 Message size settings. More...
 
enum  uart_stop_t {
  UART_STOP_1 = 0,
  UART_STOP_1P5 = MXC_F_UART_CTRL_STOPBITS,
  UART_STOP_2 = MXC_F_UART_CTRL_STOPBITS
}
 Stop bit settings. More...
 
enum  uart_flow_ctrl_t {
  UART_FLOW_CTRL_DIS = 0,
  UART_FLOW_CTRL_EN = MXC_F_UART_CTRL_FLOW_CTRL
}
 Flow control. More...
 
enum  uart_flow_pol_t {
  UART_FLOW_POL_DIS = 0,
  UART_FLOW_POL_EN = MXC_F_UART_CTRL_FLOW_POL
}
 Flow control Polarity. More...
 
enum  uart_clksel_t {
  UART_CLKSEL_SYSTEM = 0,
  UART_CLKSEL_ALTERNATE = MXC_F_UART_CTRL_CLKSEL
}
 Clock Source Select. More...
 

Functions

int UART_Init (mxc_uart_regs_t *uart, const uart_cfg_t *cfg, const sys_cfg_uart_t *sys_cfg)
 Initialize and enable UART module. More...
 
int UART_Shutdown (mxc_uart_regs_t *uart)
 Shutdown UART module. More...
 
void UART_Handler (mxc_uart_regs_t *uart)
 UART interrupt handler. More...
 
int UART_Read (mxc_uart_regs_t *uart, uint8_t *data, int len, int *num)
 Read UART data, blocking until transaction is complete. More...
 
int UART_Write (mxc_uart_regs_t *uart, const uint8_t *data, int len)
 Write UART data. More...
 
int UART_ReadAsync (mxc_uart_regs_t *uart, uart_req_t *req)
 Asynchronously read UART data. More...
 
int UART_WriteAsync (mxc_uart_regs_t *uart, uart_req_t *req)
 Asynchronously write/transmit UART data. More...
 
uint8_t UART_ReadByte (mxc_uart_regs_t *uart)
 Read a single byte from the UART. More...
 
void UART_WriteByte (mxc_uart_regs_t *uart, uint8_t data)
 Write one byte at a time to the UART. More...
 
int UART_Busy (mxc_uart_regs_t *uart)
 Check to see if the UART is busy. More...
 
int UART_PrepForSleep (mxc_uart_regs_t *uart)
 Prepare the UART for entry into a Low-Power mode (DEEPSLEEP/BACKUP). More...
 
int UART_AbortAsync (uart_req_t *req)
 Abort asynchronous request. More...
 
unsigned UART_NumWriteAvail (mxc_uart_regs_t *uart)
 Returns the number of bytes still pending transmission in the UART TX FIFO. More...
 
unsigned UART_NumReadAvail (mxc_uart_regs_t *uart)
 Returns the number of bytes available to be read from the RX FIFO. More...
 
void UART_ClearFlags (mxc_uart_regs_t *uart, uint32_t mask)
 Clears the specified interrupt flags. More...
 
unsigned UART_GetFlags (mxc_uart_regs_t *uart)
 Get the UART interrupt flags. More...
 
void UART_Disable (mxc_uart_regs_t *uart)
 Disable the UART. More...
 
void UART_Enable (mxc_uart_regs_t *uart)
 Enables the UART. More...
 
void UART_DrainRX (mxc_uart_regs_t *uart)
 Drains/empties and data in the RX FIFO, discarding any bytes not yet consumed. More...
 
void UART_DrainTX (mxc_uart_regs_t *uart)
 Drains/empties any data in the TX FIFO, discarding any bytes not yet transmitted. More...
 
int SYS_UART_Shutdown (mxc_uart_regs_t *uart)
 System level shutdown for UART module. More...
 

Detailed Description

Enumeration Type Documentation

◆ uart_parity_t

Enumerator
UART_PARITY_DISABLE 

Parity disabled.

UART_PARITY_EVEN_0 

Use for even parity 0.

UART_PARITY_EVEN_1 

Use for even parity 1.

UART_PARITY_EVEN 

Conventional even parity.

UART_PARITY_ODD_0 

Use for odd parity 0.

UART_PARITY_ODD_1 

Use for odd parity 1.

UART_PARITY_ODD 

Conventional odd parity.

UART_PARITY_MARK_0 

Use for mark parity 0.

UART_PARITY_MARK_1 

Use for mark parity 1.

UART_PARITY_MARK 

Conventional mark parity.

UART_PARITY_SPACE_0 

Use for space parity 0.

UART_PARITY_SPACE_1 

Use for space parity 1.

UART_PARITY_SPACE 

Conventional space parity.

◆ uart_size_t

Enumerator
UART_DATA_SIZE_5_BITS 

Data Size 5 Bits.

UART_DATA_SIZE_6_BITS 

Data Size 6 Bits.

UART_DATA_SIZE_7_BITS 

Data Size 7 Bits.

UART_DATA_SIZE_8_BITS 

Data Size 8 Bits.

◆ uart_stop_t

Enumerator
UART_STOP_1 

UART Stop 1 clock cycle.

UART_STOP_1P5 

UART Stop 1.5 clock cycle.

UART_STOP_2 

UART Stop 2 clock cycle.

◆ uart_flow_ctrl_t

Enumerator
UART_FLOW_CTRL_DIS 

RTS/CTS flow is disabled.

UART_FLOW_CTRL_EN 

RTS/CTS flow is enabled.

◆ uart_flow_pol_t

Enumerator
UART_FLOW_POL_DIS 

RTS/CTS asserted is low.

UART_FLOW_POL_EN 

RTS/CTS asserted is high.

◆ uart_clksel_t

Enumerator
UART_CLKSEL_SYSTEM 

Peripheral clock will be used as the bit rate clock.

UART_CLKSEL_ALTERNATE 

Use the device's alternate UART bit rate clock.

Function Documentation

◆ UART_Init()

int UART_Init ( mxc_uart_regs_t uart,
const uart_cfg_t cfg,
const sys_cfg_uart_t sys_cfg 
)
Parameters
uartPointer to the UART registers.
cfgPointer to UART configuration.
sys_cfgPointer to system configuration object
Returns
E_NO_ERROR UART initialized successfully, error if unsuccessful.

◆ UART_Shutdown()

int UART_Shutdown ( mxc_uart_regs_t uart)
Parameters
uartPointer to the UART registers.
Returns
E_NO_ERROR UART shutdown successfully, error if unsuccessful.

◆ UART_Handler()

void UART_Handler ( mxc_uart_regs_t uart)

This function should be called by the application from the interrupt handler if UART interrupts are enabled. Alternately, this function can be periodically called by the application if UART interrupts are disabled. It is only necessary to call this when using asynchronous functions.

Parameters
uartPointer to the UART registers.

◆ UART_Read()

int UART_Read ( mxc_uart_regs_t uart,
uint8_t *  data,
int  len,
int *  num 
)
Parameters
uartPointer to the UART registers.
dataPointer to buffer to save the data read.
lenNumber of bytes to read.
numPointer to store the number of bytes actually read, pass NULL if not needed.
Returns
Number of bytes read, error if unsuccessful.

◆ UART_Write()

int UART_Write ( mxc_uart_regs_t uart,
const uint8_t *  data,
int  len 
)

This function blocks until the write transaction is complete.

Parameters
uartPointer to the UART registers.
dataPointer to buffer for write data.
lenNumber of bytes to write.
Note
This function will return once data has been put into FIFO, not necessarily transmitted.
Returns
Number of bytes written if successful, error if unsuccessful.

◆ UART_ReadAsync()

int UART_ReadAsync ( mxc_uart_regs_t uart,
uart_req_t *  req 
)
Parameters
uartPointer to the UART registers.
reqPointer to request for a UART transaction, see uart_req.
Note
Request struct must remain allocated until callback function specified in 'req' is called.
Returns
E_NO_ERROR Asynchronous read successfully started, error if unsuccessful.

◆ UART_WriteAsync()

int UART_WriteAsync ( mxc_uart_regs_t uart,
uart_req_t *  req 
)
Parameters
uartPointer to the UART registers.
reqRequest for a UART transaction, see uart_req.
Note
Request struct must remain allocated until callback function specified in 'req' is called.
Returns
E_NO_ERROR Asynchronous write successfully started, error if unsuccessful.

◆ UART_ReadByte()

uint8_t UART_ReadByte ( mxc_uart_regs_t uart)
Note
This function will block until a character is available.
Parameters
uartPointer to the UART registers.
Returns
The byte read.

◆ UART_WriteByte()

void UART_WriteByte ( mxc_uart_regs_t uart,
uint8_t  data 
)
Note
This function will block until the character has been placed in the transmit FIFO. It may return before the character is actually transmitted.
Parameters
uartPointer to the UART registers.
dataThe byte to write.

◆ UART_Busy()

int UART_Busy ( mxc_uart_regs_t uart)
Parameters
uartPointer to the UART registers.
Returns
E_NO_ERROR if the UART is idle, E_BUSY if the UART is in use.

◆ UART_PrepForSleep()

int UART_PrepForSleep ( mxc_uart_regs_t uart)

Checks for any ongoing transactions. Disables interrupts if the UART is idle.

Parameters
uartPointer to the UART registers.
Returns
E_NO_ERROR UART is ready to enter Low-Power modes (DEEPSLEEP/BACKUP).
E_BUSY UART is active and busy and not ready to enter a Low-Power mode (DEEPSLEEP/BACKUP).

◆ UART_AbortAsync()

int UART_AbortAsync ( uart_req_t *  req)
Parameters
reqPointer to the request to abort. See uart_req.
Returns
E_NO_ERROR if the asynchronous request aborted successfully started, error if unsuccessful.

◆ UART_NumWriteAvail()

unsigned UART_NumWriteAvail ( mxc_uart_regs_t uart)
Parameters
uartPointer to the UART registers.
Returns
Number of unused bytes in the TX FIFO.

◆ UART_NumReadAvail()

unsigned UART_NumReadAvail ( mxc_uart_regs_t uart)
Parameters
uartPointer to the UART registers.
Returns
The number of bytes available to read in the RX FIFO.

◆ UART_ClearFlags()

void UART_ClearFlags ( mxc_uart_regs_t uart,
uint32_t  mask 
)
Parameters
uartPointer to the UART registers.
maskMask of the UART interrupts to clear, see UART_INT_FL Register.

◆ UART_GetFlags()

unsigned UART_GetFlags ( mxc_uart_regs_t uart)
Parameters
uartPointer to the UART registers.
Returns
Mask of active flags.

◆ UART_Disable()

void UART_Disable ( mxc_uart_regs_t uart)
Note
This function does not change the existing UART configuration.
Parameters
uartPointer to the UART registers.

◆ UART_Enable()

void UART_Enable ( mxc_uart_regs_t uart)
Note
This function does not change the existing UART configuration.
Parameters
uartPointer to the UART registers.

◆ UART_DrainRX()

void UART_DrainRX ( mxc_uart_regs_t uart)
Parameters
uartPointer to the UART registers.

◆ UART_DrainTX()

void UART_DrainTX ( mxc_uart_regs_t uart)
Parameters
uartPointer to the UART registers.

◆ SYS_UART_Shutdown()

int SYS_UART_Shutdown ( mxc_uart_regs_t uart)
Parameters
uartPointer to UART module registers
Returns
E_NO_ERROR if everything is successful