Intel 386 Computer Hardware User Manual


 
Intel386™ EX EMBEDDED MICROPROCESSOR USER’S MANUAL
7-18
}
/*************************** Function InitSIO *******************************
Parameters:
Unit Unit number of the serial port. 0 for SIO port 0, 1 for SIO
port 1.
Mode Defines parity, number of data bits, number of stop bits...
Reference Serial Line Control register for various options
ModemCntrl Defines the operation of the modem control lines
BaudRate Specifies baud rate. The baud divisor value is calculated
based on clocking source and clock frequency. The clocking
frequency is set by calling the InitializeLibrary function.
ClockRate Specifies the serial port clocking rate, for internal clocking
= CLK2 for external = COMCLK
Returns: Error Codes
E_INVAILD_DEVICE -- Unit number specifies a non-existing device
E_OK -- Initialized OK, No error.
Assumptions:
SIOCFG Has already been configured for Clocking source and Modem control
source
REMAPCFG register has Expanded I/O space access enabled (ESE bit set).
The processor Port pin are initialized separately.
Real/Protected Mode
No changes required.
--------------------------------------------------------------------------*/
int InitSIO(int Unit,
BYTE Mode,
BYTE ModemCntrl,
DWORD BaudRate,
DWORD BaudClkIn)
{
WORD SIOPortBase;
WORD BaudDivisor;
// Check for valid unit
if(Unit > 1)
return E_INVALID_DEVICE;
// Set Port base based on serial port used
SIOPortBase = (Unit ? SIO1_BASE : SIO0_BASE);
// Initialized Serial Port registers
// Calculate the baud divisor value, based on baud clocking
BaudDivisor = (WORD)(BaudClkIn / (16*BaudRate));
// Turn on access to baud divisor register
_SetEXRegByte(SIOPortBase + LCR, 0x80);
// Set the baud rate divisor register, High byte first