intro
in order to learn how this mouse normally functions i am going to sniff the serial bus. this will allow me to see all of the commands that the pc uses to interact with the mouse and hopefully tell me how to control the mouse cursor position. the rest of the buttons will remain intact so i only need to emulate the X,Y sensor information
Process
Low Level
- Wait for falling edge - this signals the beginning of a transfer and loads the next bit to read
- Wait for rising edge
- *Shift current SDIO bit into addr variable
- Repeat 8 times
- Only need to wait for rising edge for data transfers
- Remember the first bit of addr is the command type
- Wait for rising edge
- Shift current SDIO bit into data variable
- Repeat 8 times
High Level
- Determine if it's a Read or Write - determined by the first bit in any transfer
- Save 1st byte addr and 2nd byte _data_
- Echo if the command is a Read or Write to RS232 port
- Echo addr and data to RS232 port
- If known convert addr to register name
Sniffer Application
Main
for(;;){
waitForFallingEdge();
addr = readByte();
data = readbyte();
commandEcho(addr, data);
}
uint8_t readByte()
dataByte = 0;
for(x=7;x>=0;x--){
waitForRisingEdge();
dataByte |= ( mSDIO << x );
}
return dataByte;
void commandEcho(uint8_t addr, uint8_t data);
if(lookupCommand(addr)); //if true this function prints out the command name i.e. deltaX
else{ puts(itoh8(addr); }
puts(itoh8(data));
puts("\r\n");
AVR interrupt INT0
Monitoring
SCK is done through the pin change interrupt. This will be used to determine if the clock is currently a falling edge or rising edge.
SIGNAL(SIG_OVERFLOW0){
#ifdef DEBUG
puts("pin0 interrupt\r\n", 16);
#endif
/* the pin state just changed. if it is now high
the change must have been a rising edge... */
if(MOUSE_SCK){ clk_state = MOUSE_SCK_RISING; }
else { clk_state = MOUSE_SCK_FALLING; }
}
--
ChristopherPepe - 23 Aug 2006