Interface to access to Avago ADNS-9500 laser mouse sensors.
Fork of ADNS9500 by
Diff: adns9500.cpp
- Revision:
- 3:898ed1944119
- Parent:
- 2:ee0c13ef1320
- Child:
- 8:97e5df54b8bb
diff -r ee0c13ef1320 -r 898ed1944119 adns9500.cpp --- a/adns9500.cpp Thu Mar 22 15:04:33 2012 +0000 +++ b/adns9500.cpp Thu Mar 22 17:36:49 2012 +0000 @@ -431,7 +431,7 @@ yCpi_ = y_resolution * CPI_CHANGE_UNIT; } - void ADNS9500::captureFrame(uint8_t pixels[NUMBER_OF_PIXELS_PER_FRAME]) + void ADNS9500::captureFrame(uint8_t* pixels) { if (! enabled_) error("ADNS9500::captureFrame : the sensor is not enabled\n"); @@ -445,24 +445,22 @@ LONG_WAIT_US(2*DEFAULT_MAX_FRAME_PERIOD); // check for first pixel reading motion bit - while(true) { + int motion = spiReceive(MOTION); + WAIT_TSRR(); + while(! ADNS9500_IF_FRAME_FIRST_PIXEL(motion)) { int motion = spiReceive(MOTION); - if (ADNS9500_IF_MOTION(motion)) - break; WAIT_TSRR(); } - WAIT_TSRR(); // read pixel values spi_.write(PIXEL_BURST); WAIT_TSRAD(); - for (uint8_t* p = pixels; p != pixels + sizeof(pixels); ++p) { + for (uint8_t* p = pixels; p != pixels + NUMBER_OF_PIXELS_PER_FRAME; ++p) { + *p = spi_.write(0x00); WAIT_TLOAD(); - *p = spi_.write(PIXEL_BURST); } - // burst exit - WAIT_TSCLKNCS(); + // burst exit ncs_.write(1); WAIT_TBEXIT(); }