- removed assert

- improved checks

git-svn-id: http://moon:8086/svn/mips@188 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2021-11-22 20:42:02 +00:00
parent 6227db4062
commit 91f53947d0
2 changed files with 31 additions and 26 deletions
+14 -13
View File
@@ -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
View File
@@ -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;
}
}