Intel386™ EX EMBEDDED MICROPROCESSOR USER’S MANUAL
11-36
#define SIO_0 0
#define LENGTH 32
char String_Read[LENGTH];
int error;
error = SerialReadStr (SIO_0,
String_Read,
LENGTH);
Real/Protected Mode
No changes required.
*****************************************************************************/
int SerialReadStr(int Unit, char far *str, int count)
{
WORD ReceivePortAddr;
WORD StatusPortAddr;
BYTE Status;
int i;
/* Set Port base, based on serial port used */
ReceivePortAddr = (Unit ? RBR1 : RBR0);
StatusPortAddr = (Unit ? LSR1 : LSR0);
for(i=0; i < count-1; i++)
{
// Status register is cleared after read, so we must save
// it’s value when read
while(!((Status=_GetEXRegByte(StatusPortAddr)) & SIO_RX_BUF_FULL))
if( Status & SIO_ERROR_BITS ) /* Error Bit set then return NULL */
{
str[i+1] = ‘\0’;
return Status & SIO_ERROR_BITS;
}
str[i] = _GetEXRegByte(ReceivePortAddr);
}
str[i] = ‘\0’;
return E_OK;
}/* SerialReadStr */
/*****************************************************************************
SerialReadChar:
Description:
Is a Polled serial port read function that waits forever or