51 #include "../inc/hw_types.h" 52 #include "../inc/hw_uart.h" 53 #include "../inc/hw_memmap.h" 54 #include "../inc/hw_ints.h" 74 #define UART_INT_EOT (UART_IMSC_EOT_M) 75 #define UART_INT_OE (UART_IMSC_OE_M) 76 #define UART_INT_BE (UART_IMSC_BE_M) 77 #define UART_INT_PE (UART_IMSC_PE_M) 78 #define UART_INT_FE (UART_IMSC_FE_M) 79 #define UART_INT_RT (UART_IMSC_RT_M) 80 #define UART_INT_RX (UART_IMSC_RX_M) 81 #define UART_INT_TX (UART_IMSC_TX_M) 82 #define UART_INT_CTS (UART_IMSC_CTSM_M) 83 #define UART_INT_TXDMADONE (UART_IMSC_TXDMADONE_M) 84 #define UART_INT_RXDMADONE (UART_IMSC_RXDMADONE_M) 92 #define UART_CONFIG_WLEN_MASK UART_LCRH_WLEN_M 93 #define UART_CONFIG_WLEN_8 UART_LCRH_WLEN_BITL8 94 #define UART_CONFIG_WLEN_7 UART_LCRH_WLEN_BITL7 95 #define UART_CONFIG_WLEN_6 UART_LCRH_WLEN_BITL6 96 #define UART_CONFIG_WLEN_5 UART_LCRH_WLEN_BITL5 97 #define UART_CONFIG_STOP_MASK UART_LCRH_STP2_M 98 #define UART_CONFIG_STOP_ONE 0x00000000 99 #define UART_CONFIG_STOP_TWO UART_LCRH_STP2 100 #define UART_CONFIG_PAR_MASK 0x00000086 101 #define UART_CONFIG_PAR_NONE 0x00000000 102 #define UART_CONFIG_PAR_EVEN 0x00000006 103 #define UART_CONFIG_PAR_ODD 0x00000002 104 #define UART_CONFIG_PAR_ONE 0x00000082 105 #define UART_CONFIG_PAR_ZERO 0x00000086 112 #define UART_FIFO_TX2_8 UART_IFLS_TXSEL_QUARTER 113 #define UART_FIFO_TX4_8 UART_IFLS_TXSEL_HALF 114 #define UART_FIFO_TX6_8 UART_IFLS_TXSEL_THREEQU 121 #define UART_FIFO_RX2_8 UART_IFLS_RXSEL_QUARTER 122 #define UART_FIFO_RX4_8 UART_IFLS_RXSEL_HALF 123 #define UART_FIFO_RX6_8 UART_IFLS_RXSEL_THREEQU 130 #define UART_DMA_ERR_RXSTOP 0x00000004 131 #define UART_DMA_TX 0x00000002 132 #define UART_DMA_RX 0x00000001 139 #define UART_RXERROR_OVERRUN 0x00000008 140 #define UART_RXERROR_BREAK 0x00000004 141 #define UART_RXERROR_PARITY 0x00000002 142 #define UART_RXERROR_FRAMING 0x00000001 177 HWREG(base + UART_O_IFLS) = txLevel | rxLevel;
212 extern void UARTConfigSetExpClk(uint32_t base, uint32_t UARTClkFreq, uint32_t baudFreq, uint32_t config);
242 HWREG(base + UART_O_LCRH) |= UART_LCRH_FEN;
259 HWREG(base + UART_O_LCRH) &= ~(UART_LCRH_FEN);
279 return ((HWREG(base + UART_O_FR) & UART_FR_RXFE) ?
false :
true);
302 return (HWREGB(base + UART_O_DR));
337 return ((HWREG(base + UART_O_FR) & UART_FR_TXFF) ?
false :
true);
361 HWREG(base + UART_O_DR) = data;
378 extern void UARTPutChar(uint32_t base, uint8_t data);
399 return ((HWREG(base + UART_O_FR) & UART_FR_BUSY) ?
true :
false);
431 HWREG(base + UART_O_IMSC) |= intFlags;
462 HWREG(base + UART_O_IMSC) &= ~(intFlags);
498 return (HWREG(base + UART_O_MIS));
502 return (HWREG(base + UART_O_RIS));
550 HWREG(base + UART_O_ICR) = intFlags;
577 HWREG(base + UART_O_DMACTL) |= dmaFlags;
600 HWREG(base + UART_O_DMACTL) &= ~dmaFlags;
625 return (HWREG(base + UART_O_RSR_ECR) & 0x0000000F);
646 HWREG(base + UART_O_RSR_ECR) = 0;
662 HWREG(base + UART_O_CTL) |= (UART_CTL_CTSEN);
678 HWREG(base + UART_O_CTL) |= (UART_CTL_RTSEN);
694 HWREG(base + UART_O_CTL) &= ~(UART_CTL_CTSEN);
710 HWREG(base + UART_O_CTL) &= ~(UART_CTL_RTSEN);
__STATIC_INLINE void UARTPutCharNonBlocking(uint32_t base, uint8_t data)
Sends a character to the specified port.
Definition: uart.h:358
#define UART_FIFO_RX2_8
Receive interrupt at 1/4 Full.
Definition: uart.h:121
__STATIC_INLINE uint32_t UARTIntStatus(uint32_t base, bool masked)
Gets the current interrupt status.
Definition: uart.h:492
__STATIC_INLINE uint8_t UARTGetCharNonBlocking(uint32_t base)
Receives a character from the specified port.
Definition: uart.h:299
__STATIC_INLINE void UARTSetFifoLevel(uint32_t base, uint32_t txLevel, uint32_t rxLevel)
Sets the FIFO level at which interrupts are generated.
Definition: uart.h:170
__STATIC_INLINE void UARTEnableInt(uint32_t base, uint32_t intFlags)
Enables individual UART interrupt sources.
Definition: uart.h:428
#define UART_FIFO_RX6_8
Receive interrupt at 3/4 Full.
Definition: uart.h:123
__STATIC_INLINE bool UARTBusy(uint32_t base)
Determines whether the UART transmitter is busy or not.
Definition: uart.h:396
__STATIC_INLINE void UARTDisableCTS(uint32_t base)
Disable CTS flow control.
Definition: uart.h:692
__STATIC_INLINE void UARTDisableFIFO(uint32_t base)
Disables the transmit and receive FIFOs.
Definition: uart.h:256
__STATIC_INLINE void UARTClearInt(uint32_t base, uint32_t intFlags)
Clears UART interrupt sources.
Definition: uart.h:547
void UARTDisable(uint32_t base)
Disables transmitting and receiving.
Definition: uart.c:69
__STATIC_INLINE void UARTEnableFifo(uint32_t base)
Enables the transmit and receive FIFOs.
Definition: uart.h:239
__STATIC_INLINE void UARTDisableDMA(uint32_t base, uint32_t dmaFlags)
Disable UART DMA operation.
Definition: uart.h:597
#define ASSERT(expr)
Definition: debug.h:71
void UARTPutChar(uint32_t base, uint8_t data)
Waits to send a character to the specified port.
Definition: uart.c:100
#define UART_FIFO_TX6_8
Transmit interrupt at 3/4 Full.
Definition: uart.h:114
__STATIC_INLINE bool UARTSpaceAvailable(uint32_t base)
Determines if there is any space in the transmit FIFO.
Definition: uart.h:334
#define UART_FIFO_TX4_8
Transmit interrupt at 1/2 Full.
Definition: uart.h:113
uint8_t UARTGetChar(uint32_t base)
Waits for a character from the specified port.
Definition: uart.c:86
#define UART_FIFO_RX4_8
Receive interrupt at 1/2 Full.
Definition: uart.h:122
__STATIC_INLINE void UARTDisableInt(uint32_t base, uint32_t intFlags)
Disables individual UART interrupt sources.
Definition: uart.h:459
__STATIC_INLINE bool UARTCharAvailable(uint32_t base)
Determines if there are any characters in the receive FIFO.
Definition: uart.h:276
#define UART_FIFO_TX2_8
Transmit interrupt at 1/4 Full.
Definition: uart.h:112
void UARTConfigSetExpClk(uint32_t base, uint32_t UARTClkFreq, uint32_t baudFreq, uint32_t config)
Sets the configuration of a UART.
Definition: uart.c:43
#define __STATIC_INLINE
Definition: cmsis_gcc.h:47
__STATIC_INLINE void UARTEnableDMA(uint32_t base, uint32_t dmaFlags)
Enable UART DMA operation.
Definition: uart.h:574
__STATIC_INLINE void UARTClearRxError(uint32_t base)
Clears all reported receiver errors.
Definition: uart.h:642
__STATIC_INLINE uint32_t UARTGetRxError(uint32_t base)
Gets current receiver errors.
Definition: uart.h:622
__STATIC_INLINE void UARTEnableRTS(uint32_t base)
Enable RTS flow control.
Definition: uart.h:676
__STATIC_INLINE void UARTEnableCTS(uint32_t base)
Enable CTS flow control.
Definition: uart.h:660
__STATIC_INLINE void UARTDisableRTS(uint32_t base)
Disable RTS flow control.
Definition: uart.h:708