Driver API for USART (plib_usart0.h) More...
Macros | |
| #define | USART_ERROR_NONE (0U) |
| Error status when no error has occurred. | |
| #define | USART_ERROR_OVERRUN (US_CSR_USART_OVRE_Msk) |
| Error status when an overrun error has occurred. | |
| #define | USART_ERROR_PARITY (US_CSR_USART_PARE_Msk) |
| Error status when a parity error has occurred. | |
| #define | USART_ERROR_FRAMING (US_CSR_USART_FRAME_Msk) |
| Error status when a framing error has occurred. | |
Typedefs | |
| typedef void(* | USART_INTERRUPT_HANDLER) (void) |
| Function pointer type for USART interrupt handlers. | |
| typedef uint32_t | USART_ERROR |
| Type for representing USART error status. | |
| typedef void(* | USART_CALLBACK_HANDLER) (USART_EVENT event) |
| Function pointer type for USART event callback handler. | |
Enumerations | |
| enum | USART_HWREG_STATUS { USART_HWREG_STATUS_OK = 0 , USART_HWREG_STATUS_ERROR , USART_HWREG_STATUS_INVALID_PARAM , USART_HWREG_STATUS_BUSY } |
| Status codes for USART hardware register operations. More... | |
| enum | USART_EVENT { USART_EVENT_TX_READY = 0 , USART_EVENT_TX_COMPLETE , USART_EVENT_RX_READY , USART_EVENT_ERROR } |
| USART interrupt event types. More... | |
| enum | USART_DATA_SIZE { USART_DATA_SIZE_5_BIT = US_MR_USART_CHRL_5_BIT , USART_DATA_SIZE_6_BIT = US_MR_USART_CHRL_6_BIT , USART_DATA_SIZE_7_BIT = US_MR_USART_CHRL_7_BIT , USART_DATA_SIZE_8_BIT = US_MR_USART_CHRL_8_BIT , USART_DATA_SIZE_9_BIT = US_MR_USART_MODE9_Msk } |
| USART character size selection. More... | |
| enum | USART_PARITY_MODE { USART_PARITY_EVEN = US_MR_USART_PAR_EVEN , USART_PARITY_ODD = US_MR_USART_PAR_ODD , USART_PARITY_SPACE = US_MR_USART_PAR_SPACE , USART_PARITY_MARK = US_MR_USART_PAR_MARK , USART_PARITY_NONE = US_MR_USART_PAR_NO , USART_PARITY_MULTIDROP = US_MR_USART_PAR_MULTIDROP } |
| USART parity mode selection. More... | |
| enum | USART_STOP_BITS { USART_STOP_BITS_1 = US_MR_USART_NBSTOP_1_BIT , USART_STOP_BITS_1_5 = US_MR_USART_NBSTOP_1_5_BIT , USART_STOP_BITS_2 = US_MR_USART_NBSTOP_2_BIT } |
| USART stop bits selection. More... | |
| enum | USART_DATA_ORDER { USART_DATA_ORDER_LSB_FIRST = 0U , USART_DATA_ORDER_MSB_FIRST = US_MR_USART_MSBF_Msk } |
| USART data order selection. More... | |
| enum | USART_OPMODE { USART_OPMODE_MCK = US_MR_USART_USCLKS_MCK , USART_OPMODE_DIV = US_MR_USART_USCLKS_DIV , USART_OPMODE_PCK = US_MR_USART_USCLKS_PCK , USART_OPMODE_SCK = US_MR_USART_USCLKS_SCK } |
| USART clock source selection. More... | |
| enum | USART_COMM_MODE { USART_COMM_MODE_ASYNC = 0U , USART_COMM_MODE_SYNC = US_MR_USART_SYNC_Msk } |
| USART communication mode selection. More... | |
Functions | |
| void | USART0_Enable (void) |
| Enables the USART0 peripheral (receiver and transmitter). | |
| void | USART0_Disable (void) |
| Disables the USART0 peripheral (receiver and transmitter). | |
| void | USART0_EnableReceiver (void) |
| Enables the USART0 receiver. | |
| void | USART0_DisableReceiver (void) |
| Disables the USART0 receiver. | |
| void | USART0_EnableTransmitter (void) |
| Enables the USART0 transmitter. | |
| void | USART0_DisableTransmitter (void) |
| Disables the USART0 transmitter. | |
| void | USART0_SetOperatingMode (USART_OPMODE mode) |
| Sets the USART0 clock source. | |
| void | USART0_SetCommunicationMode (USART_COMM_MODE mode) |
| Sets the USART0 communication mode. | |
| void | USART0_SetDataSize (USART_DATA_SIZE data_size) |
| Sets the USART0 character size. | |
| void | USART0_SetParityMode (USART_PARITY_MODE parity) |
| Sets the USART0 parity mode. | |
| void | USART0_SetStopBits (USART_STOP_BITS stop_bits) |
| Sets the USART0 number of stop bits. | |
| void | USART0_SetDataOrder (USART_DATA_ORDER order) |
| Sets the USART0 data order. | |
| USART_HWREG_STATUS | USART0_SetBaudrate (uint32_t baud, uint32_t clk_frequency) |
| Sets the USART0 baud rate. | |
| void | USART0_EnableRxReadyInterrupt (void) |
| Enables the USART0 receiver ready interrupt. | |
| void | USART0_DisableRxReadyInterrupt (void) |
| Disables the USART0 receiver ready interrupt. | |
| void | USART0_EnableTxCompleteInterrupt (void) |
| Enables the USART0 transmit complete interrupt. | |
| void | USART0_DisableTxCompleteInterrupt (void) |
| Disables the USART0 transmit complete interrupt. | |
| void | USART0_EnableTxReadyInterrupt (void) |
| Enables the USART0 transmitter ready interrupt. | |
| void | USART0_DisableTxReadyInterrupt (void) |
| Disables the USART0 transmitter ready interrupt. | |
| void | USART0_EnableErrorInterrupt (void) |
| Enables the USART0 error interrupt (overrun, framing, parity). | |
| void | USART0_DisableErrorInterrupt (void) |
| Disables the USART0 error interrupt. | |
| bool | USART0_ReceiverIsReady (void) |
| Checks if the USART0 receiver has data available. | |
| bool | USART0_TransmitterIsReady (void) |
| Checks if the USART0 transmitter data register is empty. | |
| bool | USART0_TransmitIsComplete (void) |
| Checks if the USART0 transmission is complete (shift register empty). | |
| USART_ERROR | USART0_GetError (void) |
| Gets the current USART0 error status and clears it. | |
| uint8_t | USART0_Receive (void) |
| Receives a byte of data from USART0. | |
| void | USART0_Send (uint8_t data) |
| Sends a byte of data via USART0. | |
| uint16_t | USART0_Receive9Bit (void) |
| Receives 9-bit data from USART0. | |
| void | USART0_Send9Bit (uint16_t data) |
| Sends 9-bit data via USART0. | |
| void | USART0_SetCallbackHandler (USART_CALLBACK_HANDLER callback) |
| Registers callback for USART0 interrupt events. | |
| void | USART0_ResetSoftware (void) |
| Performs a software reset of USART0 (receiver, transmitter, and status). | |
| void | USART0_SetInterruptHandler (void) |
| Assigns the interrupt handler for USART0. | |
Variables | |
| volatile USART_INTERRUPT_HANDLER | USART0_InterruptHandler |
| Interrupt handler for USART0 peripheral. | |
Driver API for USART (plib_usart0.h)
| #define USART_ERROR_FRAMING (US_CSR_USART_FRAME_Msk) |
Error status when a framing error has occurred.
| #define USART_ERROR_NONE (0U) |
Error status when no error has occurred.
| #define USART_ERROR_OVERRUN (US_CSR_USART_OVRE_Msk) |
Error status when an overrun error has occurred.
| #define USART_ERROR_PARITY (US_CSR_USART_PARE_Msk) |
Error status when a parity error has occurred.
| USART_CALLBACK_HANDLER |
Function pointer type for USART event callback handler.
This typedef defines a callback function type that is called when a USART event occurs. The callback receives a single parameter indicating the event type.
| event | The USART event that triggered the callback. |
Type for representing USART error status.
| USART_INTERRUPT_HANDLER |
Function pointer type for USART interrupt handlers.
This typedef defines a function pointer for interrupt handlers associated with USART. The handler function must take no parameters and return void.
| enum USART_COMM_MODE |
| enum USART_DATA_ORDER |
| enum USART_DATA_SIZE |
| enum USART_EVENT |
| enum USART_HWREG_STATUS |
| enum USART_OPMODE |
| enum USART_PARITY_MODE |
| enum USART_STOP_BITS |
| void USART0_Disable | ( | void | ) |
Disables the USART0 peripheral (receiver and transmitter).
| None. |
| void USART0_DisableErrorInterrupt | ( | void | ) |
Disables the USART0 error interrupt.
| None. |
| void USART0_DisableReceiver | ( | void | ) |
Disables the USART0 receiver.
| None. |
| void USART0_DisableRxReadyInterrupt | ( | void | ) |
Disables the USART0 receiver ready interrupt.
| None. |
| void USART0_DisableTransmitter | ( | void | ) |
Disables the USART0 transmitter.
| None. |
| void USART0_DisableTxCompleteInterrupt | ( | void | ) |
Disables the USART0 transmit complete interrupt.
| None. |
| void USART0_DisableTxReadyInterrupt | ( | void | ) |
Disables the USART0 transmitter ready interrupt.
| None. |
| void USART0_Enable | ( | void | ) |
Enables the USART0 peripheral (receiver and transmitter).
| None. |
| void USART0_EnableErrorInterrupt | ( | void | ) |
Enables the USART0 error interrupt (overrun, framing, parity).
| None. |
| void USART0_EnableReceiver | ( | void | ) |
Enables the USART0 receiver.
| None. |
| void USART0_EnableRxReadyInterrupt | ( | void | ) |
Enables the USART0 receiver ready interrupt.
| None. |
| void USART0_EnableTransmitter | ( | void | ) |
Enables the USART0 transmitter.
| None. |
| void USART0_EnableTxCompleteInterrupt | ( | void | ) |
Enables the USART0 transmit complete interrupt.
| None. |
| void USART0_EnableTxReadyInterrupt | ( | void | ) |
Enables the USART0 transmitter ready interrupt.
| None. |
| USART_ERROR USART0_GetError | ( | void | ) |
Gets the current USART0 error status and clears it.
| None. |
| uint8_t USART0_Receive | ( | void | ) |
Receives a byte of data from USART0.
| None. |
| uint16_t USART0_Receive9Bit | ( | void | ) |
Receives 9-bit data from USART0.
| None. |
| bool USART0_ReceiverIsReady | ( | void | ) |
Checks if the USART0 receiver has data available.
| None. |
| void USART0_ResetSoftware | ( | void | ) |
Performs a software reset of USART0 (receiver, transmitter, and status).
| None. |
| void USART0_Send | ( | uint8_t | data | ) |
Sends a byte of data via USART0.
| data | - Byte to send. |
| void USART0_Send9Bit | ( | uint16_t | data | ) |
Sends 9-bit data via USART0.
| data | - 9-bit data to send. |
| USART_HWREG_STATUS USART0_SetBaudrate | ( | uint32_t | baud, |
| uint32_t | clk_frequency ) |
Sets the USART0 baud rate.
| baud | - Desired baud rate in bits per second. |
| clk_frequency | - Source clock frequency in Hz. |
| void USART0_SetCallbackHandler | ( | USART_CALLBACK_HANDLER | callback | ) |
Registers callback for USART0 interrupt events.
| callback | - Pointer to the callback function, or NULL to deregister. |
| void USART0_SetCommunicationMode | ( | USART_COMM_MODE | mode | ) |
Sets the USART0 communication mode.
| mode | - The desired communication mode (see USART_COMM_MODE). |
| void USART0_SetDataOrder | ( | USART_DATA_ORDER | order | ) |
Sets the USART0 data order.
| order | - The desired data order (see USART_DATA_ORDER). |
| void USART0_SetDataSize | ( | USART_DATA_SIZE | data_size | ) |
Sets the USART0 character size.
| data_size | - The desired character size (see USART_DATA_SIZE). |
| void USART0_SetInterruptHandler | ( | void | ) |
Assigns the interrupt handler for USART0.
| None. |
| void USART0_SetOperatingMode | ( | USART_OPMODE | mode | ) |
Sets the USART0 clock source.
| mode | - The desired clock source (see USART_OPMODE). |
| void USART0_SetParityMode | ( | USART_PARITY_MODE | parity | ) |
Sets the USART0 parity mode.
| parity | - The desired parity mode (see USART_PARITY_MODE). |
| void USART0_SetStopBits | ( | USART_STOP_BITS | stop_bits | ) |
Sets the USART0 number of stop bits.
| stop_bits | - The desired stop bits (see USART_STOP_BITS). |
| bool USART0_TransmitIsComplete | ( | void | ) |
Checks if the USART0 transmission is complete (shift register empty).
| None. |
| bool USART0_TransmitterIsReady | ( | void | ) |
Checks if the USART0 transmitter data register is empty.
| None. |
|
extern |
Interrupt handler for USART0 peripheral.
This variable holds the function pointer to the current interrupt handler for the USART0 module. It should be assigned to a function that matches the USART_INTERRUPT_HANDLER signature. The variable is declared as volatile because it may be modified by interrupt service routines.