#include <config.h>
#include <stdint.h>
#include <util.h>
#include <machine/io.h>
#include <plat/machine/devices.h>
#define URXD 0x00
#define UTXD 0x40
#define UCR1 0x80
#define UCR2 0x84
#define UCR3 0x88
#define UCR4 0x8c
#define UFCR 0x90
#define USR1 0x94
#define USR2 0x98
#define UESC 0x9c
#define UTIM 0xa0
#define UBIR 0xa4
#define UBMR 0xa8
#define UBRC 0xac
#define ONEMS 0xb0
#define UTS 0xb4
#define UART_REG(x) ((volatile uint32_t *)(UART_PPTR + (x)))
#define UART_SR2_TXFIFO_EMPTY 14
#define UART_SR2_RXFIFO_RDR 0
#if defined(CONFIG_DEBUG_BUILD) || defined(CONFIG_PRINTING)
void
putDebugChar(unsigned char c)
{
while (!(*UART_REG(USR2) & BIT(UART_SR2_TXFIFO_EMPTY)));
*UART_REG(UTXD) = c;
}
#endif
#ifdef CONFIG_DEBUG_BUILD
unsigned char
getDebugChar(void)
{
while (!(*UART_REG(USR2) & BIT(UART_SR2_RXFIFO_RDR)));
return *UART_REG(URXD);
}
#endif