PS/2 I/O
Posted: Fri May 02, 2014 11:30 am
I am currently implementing PS/2 support for my OS. What is wrong with this code? getCurrentScanCodeSet() always returns ACKs (0xFA). sendByteToPort() and receiveByteFromPort() doesn't cause the problem. PS2DataPort = 0x60.
PS2Test() returns true. (seems like it works correctly)
Where should I send PS/2 commands and receive answers?
Code: Select all
uint8_t getCurrentScanCodeSet()
{
sendByteToPort(PS2DataPort, 0xF0);
sendByteToPort(PS2DataPort, 0x00);
uint8_t receivedByteFromPS2DataPort = receiveByteFromPort(PS2DataPort);
printf("Received 0x%x from 0x60.\n", receivedByteFromPS2DataPort);
if(receivedByteFromPS2DataPort == 0xFE)
{
printf("RESEND: aborting...\n");
return 4;
}
receivedByteFromPS2DataPort = receiveByteFromPort(PS2DataPort);
printf("Received 0x%x from 0x60.\n", receivedByteFromPS2DataPort);
return receivedByteFromPS2DataPort;
}
Code: Select all
bool PS2Test()
{
sendByteToPort(PS2DataPort, 0xEE);
uint8_t receivedByteFromPS2DataPort = receiveByteFromPort(PS2DataPort);
if(receivedByteFromPS2DataPort == 0xEE) return true;
else return false;
}