- removed assert
- improved checks git-svn-id: http://moon:8086/svn/mips@188 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
+14
-13
@@ -8,7 +8,7 @@
|
||||
#include <string.h>
|
||||
#include "console.h"
|
||||
|
||||
extern con_if_t con_if;
|
||||
extern const con_if_t con_if;
|
||||
|
||||
// Funcs
|
||||
con_if_entry_t const* con_getInterface(int file)
|
||||
@@ -94,24 +94,25 @@ void con_flush(int fd)
|
||||
|
||||
int con_readchar(con_if_entry_t const *pIF)
|
||||
{
|
||||
int c;
|
||||
assert(pIF);
|
||||
|
||||
// busy read
|
||||
do
|
||||
int c = -1;
|
||||
if (pIF)
|
||||
{
|
||||
c = pIF->readchar(pIF->pInst);
|
||||
|
||||
} while(c < 0);
|
||||
|
||||
// busy read
|
||||
do
|
||||
{
|
||||
c = pIF->readchar(pIF->pInst);
|
||||
|
||||
} while(c < 0);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
void con_writechar(con_if_entry_t const *pIF, char c)
|
||||
{
|
||||
assert(pIF);
|
||||
|
||||
pIF->writechar(pIF->pInst, c);
|
||||
if (pIF)
|
||||
{
|
||||
pIF->writechar(pIF->pInst, c);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
|
||||
+17
-13
@@ -12,28 +12,32 @@
|
||||
// ------------------------------------
|
||||
void UART_setbaud(void const *pInst, uint32_t baudrate)
|
||||
{
|
||||
uart_if_t *pReg = (uart_if_t*)pInst;
|
||||
|
||||
*pReg->pBAUD = UART_CALC_BAUD(baudrate);
|
||||
if (pInst)
|
||||
{
|
||||
uart_if_t *pReg = (uart_if_t*)pInst;
|
||||
*pReg->pBAUD = UART_CALC_BAUD(baudrate);
|
||||
}
|
||||
}
|
||||
|
||||
int UART_readchar(void const *pInst)
|
||||
{
|
||||
uart_if_t *pReg = (uart_if_t*)pInst;
|
||||
|
||||
if (SYS_UART_BIT_RX_AVAIL & *pReg->pCTRL)
|
||||
if (pInst)
|
||||
{
|
||||
return (*pReg->pDATA & 0xFF);
|
||||
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)
|
||||
{
|
||||
uart_if_t *pReg = (uart_if_t*)pInst;
|
||||
|
||||
while((SYS_UART_BIT_TX_HALFFULL & *pReg->pCTRL) != 0);
|
||||
|
||||
*pReg->pDATA = (uint32_t)c;
|
||||
if (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