CMSIS-Driver_PIC32CZ-CA70  
Peripheral Library (PLIB) Documentation
 
Loading...
Searching...
No Matches
UART Interface

Driver API for UART (plib_uart0.h) More...

Macros

#define UART_ERROR_NONE   (0U)
 Error status when no error has occurred.
 
#define UART_ERROR_OVERRUN   (UART_SR_OVRE_Msk)
 Error status when an overrun error has occurred.
 
#define UART_ERROR_PARITY   (UART_SR_PARE_Msk)
 Error status when a parity error has occurred.
 
#define UART_ERROR_FRAMING   (UART_SR_FRAME_Msk)
 Error status when a framing error has occurred.
 

Typedefs

typedef void(* UART_INTERRUPT_HANDLER) (void)
 Function pointer type for UART interrupt handlers.
 
typedef uint32_t UART_ERROR
 Type for representing UART error status.
 
typedef void(* UART_CALLBACK_HANDLER) (UART_EVENT event)
 Function pointer type for UART event callback handler.
 

Enumerations

enum  UART_HWREG_STATUS { UART_HWREG_STATUS_OK = 0 , UART_HWREG_STATUS_ERROR , UART_HWREG_STATUS_INVALID_PARAM , UART_HWREG_STATUS_BUSY }
 Status codes for UART hardware register operations. More...
 
enum  UART_EVENT { UART_EVENT_TX_READY = 0 , UART_EVENT_TX_COMPLETE , UART_EVENT_RX_READY , UART_EVENT_ERROR }
 UART interrupt event types. More...
 
enum  UART_PARITY_MODE {
  UART_PARITY_EVEN = UART_MR_PAR_EVEN , UART_PARITY_ODD = UART_MR_PAR_ODD , UART_PARITY_SPACE = UART_MR_PAR_SPACE , UART_PARITY_MARK = UART_MR_PAR_MARK ,
  UART_PARITY_NONE = UART_MR_PAR_NO
}
 UART parity mode selection. More...
 
enum  UART_OPMODE { UART_OPMODE_PERIPH_CLK = UART_MR_BRSRCCK_PERIPH_CLK , UART_OPMODE_PMC_PCK = UART_MR_BRSRCCK_PMC_PCK }
 UART baud rate source clock selection. More...
 

Functions

void UART0_Enable (void)
 Enables the UART0 peripheral (receiver and transmitter).
 
void UART0_Disable (void)
 Disables the UART0 peripheral (receiver and transmitter).
 
void UART0_EnableReceiver (void)
 Enables the UART0 receiver.
 
void UART0_DisableReceiver (void)
 Disables the UART0 receiver.
 
void UART0_EnableTransmitter (void)
 Enables the UART0 transmitter.
 
void UART0_DisableTransmitter (void)
 Disables the UART0 transmitter.
 
void UART0_SetOperatingMode (UART_OPMODE mode)
 Sets the UART0 baud rate source clock.
 
void UART0_SetParityMode (UART_PARITY_MODE parity)
 Sets the UART0 parity mode.
 
UART_HWREG_STATUS UART0_SetBaudrate (uint32_t baud, uint32_t clk_frequency)
 Sets the UART0 baud rate.
 
void UART0_EnableRxReadyInterrupt (void)
 Enables the UART0 receiver ready interrupt.
 
void UART0_DisableRxReadyInterrupt (void)
 Disables the UART0 receiver ready interrupt.
 
void UART0_EnableTxCompleteInterrupt (void)
 Enables the UART0 transmit complete interrupt.
 
void UART0_DisableTxCompleteInterrupt (void)
 Disables the UART0 transmit complete interrupt.
 
void UART0_EnableTxReadyInterrupt (void)
 Enables the UART0 transmitter ready interrupt.
 
void UART0_DisableTxReadyInterrupt (void)
 Disables the UART0 transmitter ready interrupt.
 
void UART0_EnableErrorInterrupt (void)
 Enables the UART0 error interrupt (overrun, framing, parity).
 
void UART0_DisableErrorInterrupt (void)
 Disables the UART0 error interrupt.
 
bool UART0_ReceiverIsReady (void)
 Checks if the UART0 receiver has data available.
 
bool UART0_TransmitterIsReady (void)
 Checks if the UART0 transmitter data register is empty.
 
bool UART0_TransmitIsComplete (void)
 Checks if the UART0 transmission is complete (shift register empty).
 
UART_ERROR UART0_GetError (void)
 Gets the current UART0 error status and clears it.
 
uint8_t UART0_Receive (void)
 Receives a byte of data from UART0.
 
void UART0_Send (uint8_t data)
 Sends a byte of data via UART0.
 
void UART0_SetCallbackHandler (UART_CALLBACK_HANDLER callback)
 Registers callback for UART0 interrupt events.
 
void UART0_ResetSoftware (void)
 Performs a software reset of UART0 (receiver, transmitter, and status).
 
void UART0_SetInterruptHandler (void)
 Assigns the interrupt handler for UART0.
 

Variables

volatile UART_INTERRUPT_HANDLER UART0_InterruptHandler
 Interrupt handler for UART0 peripheral.
 

Description

Driver API for UART (plib_uart0.h)

Macro Definition Documentation

◆ UART_ERROR_FRAMING

#define UART_ERROR_FRAMING   (UART_SR_FRAME_Msk)

Error status when a framing error has occurred.

◆ UART_ERROR_NONE

#define UART_ERROR_NONE   (0U)

Error status when no error has occurred.

◆ UART_ERROR_OVERRUN

#define UART_ERROR_OVERRUN   (UART_SR_OVRE_Msk)

Error status when an overrun error has occurred.

◆ UART_ERROR_PARITY

#define UART_ERROR_PARITY   (UART_SR_PARE_Msk)

Error status when a parity error has occurred.

Typedef Documentation

◆ UART_CALLBACK_HANDLER

UART_CALLBACK_HANDLER

Function pointer type for UART event callback handler.

This typedef defines a callback function type that is called when a UART event occurs. The callback receives a single parameter indicating the event type.

Parameters
eventThe UART event that triggered the callback.
See also
UART_EVENT

◆ UART_ERROR

Type for representing UART error status.

◆ UART_INTERRUPT_HANDLER

UART_INTERRUPT_HANDLER

Function pointer type for UART interrupt handlers.

This typedef defines a function pointer for interrupt handlers associated with UART. The handler function must take no parameters and return void.

Enumeration Type Documentation

◆ UART_EVENT

enum UART_EVENT

UART interrupt event types.

Enumerator
UART_EVENT_TX_READY 

Transmitter ready (data register empty)

UART_EVENT_TX_COMPLETE 

Transmission complete (shift register empty)

UART_EVENT_RX_READY 

Receiver ready (data available)

UART_EVENT_ERROR 

Error occurred (overrun, framing, or parity)

◆ UART_HWREG_STATUS

Status codes for UART hardware register operations.

Enumerator
UART_HWREG_STATUS_OK 

Operation successful

UART_HWREG_STATUS_ERROR 

Generic error

UART_HWREG_STATUS_INVALID_PARAM 

Invalid parameter passed

UART_HWREG_STATUS_BUSY 

Hardware is busy

◆ UART_OPMODE

UART baud rate source clock selection.

Enumerator
UART_OPMODE_PERIPH_CLK 

Peripheral clock

UART_OPMODE_PMC_PCK 

PMC programmable clock (PCK)

◆ UART_PARITY_MODE

UART parity mode selection.

Enumerator
UART_PARITY_EVEN 

Even parity

UART_PARITY_ODD 

Odd parity

UART_PARITY_SPACE 

Parity forced to 0 (Space)

UART_PARITY_MARK 

Parity forced to 1 (Mark)

UART_PARITY_NONE 

No parity

Function Documentation

◆ UART0_Disable()

void UART0_Disable ( void )

Disables the UART0 peripheral (receiver and transmitter).

Parameters
None.
Returns
None.

◆ UART0_DisableErrorInterrupt()

void UART0_DisableErrorInterrupt ( void )

Disables the UART0 error interrupt.

Parameters
None.
Returns
None.

◆ UART0_DisableReceiver()

void UART0_DisableReceiver ( void )

Disables the UART0 receiver.

Parameters
None.
Returns
None.

◆ UART0_DisableRxReadyInterrupt()

void UART0_DisableRxReadyInterrupt ( void )

Disables the UART0 receiver ready interrupt.

Parameters
None.
Returns
None.

◆ UART0_DisableTransmitter()

void UART0_DisableTransmitter ( void )

Disables the UART0 transmitter.

Parameters
None.
Returns
None.

◆ UART0_DisableTxCompleteInterrupt()

void UART0_DisableTxCompleteInterrupt ( void )

Disables the UART0 transmit complete interrupt.

Parameters
None.
Returns
None.

◆ UART0_DisableTxReadyInterrupt()

void UART0_DisableTxReadyInterrupt ( void )

Disables the UART0 transmitter ready interrupt.

Parameters
None.
Returns
None.

◆ UART0_Enable()

void UART0_Enable ( void )

Enables the UART0 peripheral (receiver and transmitter).

Parameters
None.
Returns
None.

◆ UART0_EnableErrorInterrupt()

void UART0_EnableErrorInterrupt ( void )

Enables the UART0 error interrupt (overrun, framing, parity).

Parameters
None.
Returns
None.

◆ UART0_EnableReceiver()

void UART0_EnableReceiver ( void )

Enables the UART0 receiver.

Parameters
None.
Returns
None.

◆ UART0_EnableRxReadyInterrupt()

void UART0_EnableRxReadyInterrupt ( void )

Enables the UART0 receiver ready interrupt.

Parameters
None.
Returns
None.

◆ UART0_EnableTransmitter()

void UART0_EnableTransmitter ( void )

Enables the UART0 transmitter.

Parameters
None.
Returns
None.

◆ UART0_EnableTxCompleteInterrupt()

void UART0_EnableTxCompleteInterrupt ( void )

Enables the UART0 transmit complete interrupt.

Parameters
None.
Returns
None.

◆ UART0_EnableTxReadyInterrupt()

void UART0_EnableTxReadyInterrupt ( void )

Enables the UART0 transmitter ready interrupt.

Parameters
None.
Returns
None.

◆ UART0_GetError()

UART_ERROR UART0_GetError ( void )

Gets the current UART0 error status and clears it.

Parameters
None.
Returns
The current error status (see UART_ERROR).

◆ UART0_Receive()

uint8_t UART0_Receive ( void )

Receives a byte of data from UART0.

Parameters
None.
Returns
Received byte.

◆ UART0_ReceiverIsReady()

bool UART0_ReceiverIsReady ( void )

Checks if the UART0 receiver has data available.

Parameters
None.
Returns
true if receiver is ready, false otherwise.

◆ UART0_ResetSoftware()

void UART0_ResetSoftware ( void )

Performs a software reset of UART0 (receiver, transmitter, and status).

Parameters
None.
Returns
None.

◆ UART0_Send()

void UART0_Send ( uint8_t data)

Sends a byte of data via UART0.

Parameters
data- Byte to send.
Returns
None.

◆ UART0_SetBaudrate()

UART_HWREG_STATUS UART0_SetBaudrate ( uint32_t baud,
uint32_t clk_frequency )

Sets the UART0 baud rate.

Parameters
baud- Desired baud rate in bits per second.
clk_frequency- Source clock frequency in Hz.
Returns
Status of the operation (see UART_HWREG_STATUS).

◆ UART0_SetCallbackHandler()

void UART0_SetCallbackHandler ( UART_CALLBACK_HANDLER callback)

Registers callback for UART0 interrupt events.

Parameters
callback- Pointer to the callback function, or NULL to deregister.
Returns
None.

◆ UART0_SetInterruptHandler()

void UART0_SetInterruptHandler ( void )

Assigns the interrupt handler for UART0.

Note
Call this API to route UART0 interrupts to the internal handler.
Parameters
None.
Returns
None.

◆ UART0_SetOperatingMode()

void UART0_SetOperatingMode ( UART_OPMODE mode)

Sets the UART0 baud rate source clock.

Parameters
mode- The desired clock source (see UART_OPMODE).
Returns
None.

◆ UART0_SetParityMode()

void UART0_SetParityMode ( UART_PARITY_MODE parity)

Sets the UART0 parity mode.

Parameters
parity- The desired parity mode (see UART_PARITY_MODE).
Returns
None.

◆ UART0_TransmitIsComplete()

bool UART0_TransmitIsComplete ( void )

Checks if the UART0 transmission is complete (shift register empty).

Parameters
None.
Returns
true if transmission is complete, false otherwise.

◆ UART0_TransmitterIsReady()

bool UART0_TransmitterIsReady ( void )

Checks if the UART0 transmitter data register is empty.

Parameters
None.
Returns
true if transmitter is ready, false otherwise.

Variable Documentation

◆ UART0_InterruptHandler

volatile UART_INTERRUPT_HANDLER UART0_InterruptHandler
extern

Interrupt handler for UART0 peripheral.

This variable holds the function pointer to the current interrupt handler for the UART0 module. It should be assigned to a function that matches the UART_INTERRUPT_HANDLER signature. The variable is declared as volatile because it may be modified by interrupt service routines.