When I try to send character 'X', I get 0x18.
This is my SendSerial function. ex. SendSerial(0,'X');
Code: Select all
void SendSerial(uint8 COM, uint8 data)
{
if(COM>SerialComAmount-1)
{
if(SerialComAmount==0)cerror("No Serial Hardware in System.");
else cerror("Can't use unregistered serial port!");
return;
}
uint16 SerAddr=SerialPort[COM];
while(!(inb(SerAddr+5)&0x20));
outb(SerAddr,data);
}
InitSerial():
Code: Select all
bool InitSerial()
{
for(uint8 i=0;i<4;i++)
{
uint16 val=*((uint16*)(0x0400+i*2));
if(!val)continue;
SerialPort[i]=val;
SerialComAmount++;
InitPort(val);
}
printf("\nSerial Ports:%d\n",SerialComAmount);
if(SerialComAmount)return true;
else return false;
}
Code: Select all
void SetBaud(uint16 portaddr,uint8 divisor)
{
outb(portaddr+3,0x80);
outb(portaddr,divisor);
outb(portaddr+1,0);//I will not use divisors bigger than 255
}
void InitPort(uint8 portaddr)
{
outb(portaddr+1,0x00);
SetBaud(portaddr,3);
outb(portaddr,0x03);//0000 0011
outb(portaddr+2,0xC7);
outb(portaddr+4,0x0B);
}