- 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 <string.h>
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
|
|
||||||
extern con_if_t con_if;
|
extern const con_if_t con_if;
|
||||||
|
|
||||||
// Funcs
|
// Funcs
|
||||||
con_if_entry_t const* con_getInterface(int file)
|
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 con_readchar(con_if_entry_t const *pIF)
|
||||||
{
|
{
|
||||||
int c;
|
int c = -1;
|
||||||
assert(pIF);
|
if (pIF)
|
||||||
|
|
||||||
// busy read
|
|
||||||
do
|
|
||||||
{
|
{
|
||||||
c = pIF->readchar(pIF->pInst);
|
// busy read
|
||||||
|
do
|
||||||
} while(c < 0);
|
{
|
||||||
|
c = pIF->readchar(pIF->pInst);
|
||||||
|
|
||||||
|
} while(c < 0);
|
||||||
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void con_writechar(con_if_entry_t const *pIF, char c)
|
void con_writechar(con_if_entry_t const *pIF, char c)
|
||||||
{
|
{
|
||||||
assert(pIF);
|
if (pIF)
|
||||||
|
{
|
||||||
pIF->writechar(pIF->pInst, c);
|
pIF->writechar(pIF->pInst, c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------------
|
||||||
|
|||||||
+17
-13
@@ -12,28 +12,32 @@
|
|||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
void UART_setbaud(void const *pInst, uint32_t baudrate)
|
void UART_setbaud(void const *pInst, uint32_t baudrate)
|
||||||
{
|
{
|
||||||
uart_if_t *pReg = (uart_if_t*)pInst;
|
if (pInst)
|
||||||
|
{
|
||||||
*pReg->pBAUD = UART_CALC_BAUD(baudrate);
|
uart_if_t *pReg = (uart_if_t*)pInst;
|
||||||
|
*pReg->pBAUD = UART_CALC_BAUD(baudrate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int UART_readchar(void const *pInst)
|
int UART_readchar(void const *pInst)
|
||||||
{
|
{
|
||||||
uart_if_t *pReg = (uart_if_t*)pInst;
|
if (pInst)
|
||||||
|
|
||||||
if (SYS_UART_BIT_RX_AVAIL & *pReg->pCTRL)
|
|
||||||
{
|
{
|
||||||
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UART_writechar(void const *pInst, char c)
|
void UART_writechar(void const *pInst, char c)
|
||||||
{
|
{
|
||||||
uart_if_t *pReg = (uart_if_t*)pInst;
|
if (pInst)
|
||||||
|
{
|
||||||
while((SYS_UART_BIT_TX_HALFFULL & *pReg->pCTRL) != 0);
|
uart_if_t *pReg = (uart_if_t*)pInst;
|
||||||
|
while((SYS_UART_BIT_TX_HALFFULL & *pReg->pCTRL) != 0);
|
||||||
*pReg->pDATA = (uint32_t)c;
|
*pReg->pDATA = (uint32_t)c;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user