#ifndef __UART_REGISTERS_H__
#define __UART_REGISTERS_H__

#include <stdint.h>
#include "platform.h"

namespace UART
{
	static const uint32_t BaseAddress = (KS8695PX_IO_BASE + KS8695PX_UART_OFFSET);
	
	enum Registers
	{
		RX	= 0x0000,		// 0x00	- Receive data (ro) 
		TX	= 0x0004,		// 0x04	- Transmit data (wo)
		FCR	= 0x0008,		// 0x08	- Fifo Control (r/w)
		LCR = 0x000C,		// 0x0c	- Line Control (r/w)
		MCR	= 0x0010,		// 0x10	- Modem Control (r/w)
		LSR	= 0x0014,		// 0x14	- Line Status (r/w) 
		MSR = 0x0018,		// 0x18	- Modem Status (r/w) 
		BD	= 0x001C,		// 0x1c	- Baud Rate (r/w) 
		SR	= 0x0020		// 0x20	- Status (r/w)
	};
	
	inline volatile uint32_t *regAddress(Registers reg)
	{
	    return reinterpret_cast<volatile uint32_t*>(BaseAddress + reg);
	}
	
	inline uint32_t regRead(Registers reg)
	{
	    return *regAddress(reg);
	}
	
	inline void regWrite(Registers reg, uint32_t value)
	{
	    *regAddress(reg) = value;
	}

}
#endif // __UART_REGISTERS_H__
