[mips]
- libsys multitarget - apps multitarget git-svn-id: http://moon:8086/svn/mips@67 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <board.h>
|
||||
#include "uart.h"
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Globals
|
||||
// ---------------------------------------------------------------------------------
|
||||
uart_if_t uart_if[2] =
|
||||
{
|
||||
{(uint32_t*)SYS_UART0_STAT, (uint32_t*)SYS_UART0_DATA, (uint32_t*)SYS_UART0_BAUD},
|
||||
{(uint32_t*)SYS_UART1_STAT, (uint32_t*)SYS_UART1_DATA, (uint32_t*)SYS_UART1_BAUD}
|
||||
};
|
||||
|
||||
// ------------------------------------
|
||||
// Low-level I/O
|
||||
// ------------------------------------
|
||||
int UART_readchar(void const *pInst)
|
||||
{
|
||||
assert(pInst);
|
||||
|
||||
uart_if_t *pReg = (uart_if_t*)pInst;
|
||||
|
||||
if (SYS_UART_BIT_RX_AVAIL & *pReg->pCTRL)
|
||||
return (*pReg->pDATA & 0xFF);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
void UART_writechar(void const *pInst, char c)
|
||||
{
|
||||
assert(pInst);
|
||||
|
||||
uart_if_t *pReg = (uart_if_t*)pInst;
|
||||
|
||||
while((SYS_UART_BIT_TX_HALFFULL & *pReg->pCTRL) != 0);
|
||||
|
||||
*pReg->pDATA = (uint32_t)c;
|
||||
}
|
||||
Reference in New Issue
Block a user