21 #define UART_TIMEOUT_MS 100
23 #define _UART_CFG( IDX, UART, IRQ ) \
24 BF_INIT(SuartFifo ## IDX, SUART_FIFORX_CAP) \
25 static SUART_Descriptor SUARTD ## IDX = { \
27 .rxfifo = &SuartFifo ## IDX, \
30 SUART_Descriptor* UART_DESCR_PTR(IDX) = &SUARTD ## IDX; \
31 void IRQ_HANDLER(IRQ) { \
32 queueChar(UART_DESCR_PTR(IDX)); \
35 #define UART_CFG( IDX, UART, IRQ ) _UART_CFG( IDX, UART, IRQ )
46 assert((baudrate & 0xFFF00000 ) == 0);
47 desc->dev->
RATE = ( ( baudrate << 12 ) +
48 ( WISHBONE_FREQ >> 8 ) ) /
49 ( WISHBONE_FREQ >> 7 );
93 bfRead(desc->rxfifo,(uint8_t*) c);
103 c = desc->dev->
RXDATA & 0xFF;
static bool bfEmpty(ByteFifo *const bf)
Returns whether or not the byte-fifo is empty.
const volatile unsigned int RXDATA
Receive register.
const volatile unsigned int STATUS
Status Register.
static void __irqEnable()
Enabled IRQ's on a global level.
bool bfWrite(ByteFifo *const bf, uint8_t b)
Writes a byte to the byte-fifo.
#define E_SUART_TIMEOUT
Receive / Transmission timeout.
static void __irqDisable()
Disables IRQ's on a global level.
static bool suartTxReady(SUART_Descriptor *desc)
Returns whether or not the TX buffer is empty.
White Rabbit Simple UART Driver.
#define SUART_STATUS_RX_RDY
Uart has rx data ready.
volatile unsigned int RATE
Data rate register.
void suartInit(SUART_Descriptor *desc, unsigned int baudrate)
Initializes the simple UART.
void irqMaskSet(int irq, bool set)
Set/clear the interrupt mask for the specified IRQ.
static uint32_t timeOutInit(uint32_t msec)
Initializes a timeout with the specified no of msecs.
static bool timeOut(uint32_t to)
Checks whether or not the timeout has expired.
Manages the global system error.
bool suartRx(SUART_Descriptor *desc, char *c)
Receives a character.
volatile unsigned int TXDATA
Transmit register.
bool bfRead(ByteFifo *const bf, uint8_t *const b)
Reads a byte from the byte-fifo.
bool errSet(uint32_t code, const char *error, const char *name)
Sets an error.
#define ERROR(CODE,...)
Expands an error code to an error code with a description (if ERROR_W_DESCR is declared).
bool suartTx(SUART_Descriptor *desc, char c)
Transmits a character.