added more UART low-level functions
Committed on the Free edition of March Hare Software CVSNT Server. Upgrade to CVS Suite for more features and support: http://march-hare.com/cvsnt/ git-svn-id: http://moon:8086/svn/vhdl/trunk@512 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
@@ -150,27 +150,88 @@ void DCACHE_invalidate_at(UINT32* pPtr)
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
char readchar(void)
|
||||
int UART0_readchar(void)
|
||||
{
|
||||
volatile UINT32 *pUART_stat = (UINT32*)sys_uart_stat;
|
||||
volatile UINT32 *pUART_data = (UINT32*)sys_uart_data;
|
||||
volatile UINT32 *pUART_stat = (UINT32*)sys_uart0_stat;
|
||||
volatile UINT32 *pUART_data = (UINT32*)sys_uart0_data;
|
||||
|
||||
while(!(0x10 & *pUART_stat));
|
||||
if (0x10 & *pUART_stat)
|
||||
return (*pUART_data & 0xFF);
|
||||
|
||||
return (char)*pUART_data;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void writechar(char c)
|
||||
void UART0_writechar(char c)
|
||||
{
|
||||
volatile UINT32 *pUART_stat = (UINT32*)sys_uart_stat;
|
||||
volatile UINT32 *pUART_data = (UINT32*)sys_uart_data;
|
||||
volatile UINT32 *pUART_stat = (UINT32*)sys_uart0_stat;
|
||||
volatile UINT32 *pUART_data = (UINT32*)sys_uart0_data;
|
||||
|
||||
while((0x01 & *pUART_stat) != 0);
|
||||
|
||||
*pUART_data = (UINT32)c;
|
||||
}
|
||||
|
||||
void _putchar(char c)
|
||||
int UART1_readchar(void)
|
||||
{
|
||||
volatile UINT32 *pUART_stat = (UINT32*)sys_uart1_stat;
|
||||
volatile UINT32 *pUART_data = (UINT32*)sys_uart1_data;
|
||||
|
||||
if (0x10 & *pUART_stat)
|
||||
return (*pUART_data & 0xFF);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void UART1_writechar(char c)
|
||||
{
|
||||
volatile UINT32 *pUART_stat = (UINT32*)sys_uart1_stat;
|
||||
volatile UINT32 *pUART_data = (UINT32*)sys_uart1_data;
|
||||
|
||||
while((0x01 & *pUART_stat) != 0);
|
||||
|
||||
*pUART_data = (UINT32)c;
|
||||
}
|
||||
|
||||
int UART2_readchar(void)
|
||||
{
|
||||
volatile UINT32 *pUART_stat = (UINT32*)sys_uart2_stat;
|
||||
volatile UINT32 *pUART_data = (UINT32*)sys_uart2_data;
|
||||
|
||||
if (0x10 & *pUART_stat)
|
||||
return (*pUART_data & 0xFF);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void UART2_writechar(char c)
|
||||
{
|
||||
volatile UINT32 *pUART_stat = (UINT32*)sys_uart2_stat;
|
||||
volatile UINT32 *pUART_data = (UINT32*)sys_uart2_data;
|
||||
|
||||
while((0x01 & *pUART_stat) != 0);
|
||||
|
||||
*pUART_data = (UINT32)c;
|
||||
}
|
||||
|
||||
char readchar(void)
|
||||
{
|
||||
int c;
|
||||
|
||||
do
|
||||
{
|
||||
c = UART0_readchar();
|
||||
|
||||
} while(c < 0);
|
||||
|
||||
return (char)c;
|
||||
}
|
||||
|
||||
void writechar(char c)
|
||||
{
|
||||
UART0_writechar(c);
|
||||
}
|
||||
|
||||
void _ser_putchar(char c)
|
||||
{
|
||||
if (c == 0x0A)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user