While waiting for answers on the SPI on pin 7 thread, i tried sending some data(for starters i used a ps/2 trackball i had around) over serial1, and i noticed it sometimes drops data!
test code:
#include <ps2.h>
/*
* an arduino sketch to interface with a ps/2 mouse.
* Also uses serial protocol to talk back to the host
* and report what it finds.
*/
/*
* Pin 5 is the mouse data pin, pin 6 is the clock pin
* Feel free to use whatever pins are convenient.
*/
PS2 mouse(10, 6);
/*
* initialize the mouse. Reset it, and place it into remote
* mode, so we can get the encoder data on demand.
*/
void mouse_init()
{
mouse.write(0xff); // reset
mouse.read(); // ack byte
mouse.read(); // blank */
mouse.read(); // blank */
mouse.write(0xf0); // remote mode
mouse.read(); // ack
delayMicroseconds(100);
}
void setup()
{
Serial1.begin(250000);
Serial1.println("Setting up the mouse");
mouse_init();
Serial1.println("Starting...");
}
/*
* get a reading from the mouse and report it back to the
* host via the serial line.
*/
void loop()
{
char mstat;
char mx;
char my;
/* get a reading from the mouse */
mouse.write(0xeb); // give me data!
mouse.read(); // ignore ack
mstat = mouse.read();
mx = mouse.read();
my = mouse.read();
/* send the data back up */
Serial1.print(mstat, BIN);
Serial1.print("\tX=");
Serial1.print(mx, DEC);
Serial1.print("\tY=");
Serial1.print(my, DEC);
Serial1.println();
delay(1000); /* twiddle */
}
To see the data i ssh into the yun and do a “cat /dev/ttyATH0”
Am i doing something wrong, or is the oscillator not doing its job very well?