Software SPI allows non-standard SPI pins to be used for interfacing with SPI devices
Fork of SWSPI by
ADNS5090.h@2:4612564007c0, 2014-06-16 (annotated)
- Committer:
- Throwbot
- Date:
- Mon Jun 16 10:45:10 2014 +0000
- Revision:
- 2:4612564007c0
- Parent:
- 1:98a9d6fc60ae
klhkl
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Throwbot | 1:98a9d6fc60ae | 1 | #ifndef ADNS5090_H |
Throwbot | 1:98a9d6fc60ae | 2 | #define ADNS5090_H |
davervw | 0:6a500a08c7fd | 3 | |
Throwbot | 1:98a9d6fc60ae | 4 | #include "stdint.h" |
Throwbot | 1:98a9d6fc60ae | 5 | #include "mbed.h" |
Throwbot | 1:98a9d6fc60ae | 6 | #include "SWSPI.h" |
Throwbot | 2:4612564007c0 | 7 | #include "rtos.h" |
davervw | 0:6a500a08c7fd | 8 | |
Throwbot | 1:98a9d6fc60ae | 9 | #define ADNS5090_WRITE_VAL (0x80) |
Throwbot | 1:98a9d6fc60ae | 10 | #define ADNS5090_MOTION_ST_REG (0x02) |
Throwbot | 1:98a9d6fc60ae | 11 | #define ADNS5090_MOTION_BURST_REG (0x63) |
Throwbot | 1:98a9d6fc60ae | 12 | #define ADNS5090_RESET_REG (0x3a) |
Throwbot | 1:98a9d6fc60ae | 13 | #define ADNS5090_RESET_VAL (0x5a) |
Throwbot | 1:98a9d6fc60ae | 14 | #define ADNS5090_MOUSE_CTRL_REG (0x0d) |
Throwbot | 1:98a9d6fc60ae | 15 | #define ADNS5090_POWERDOWN_VAL (0x02) |
Throwbot | 1:98a9d6fc60ae | 16 | |
Throwbot | 1:98a9d6fc60ae | 17 | |
Throwbot | 1:98a9d6fc60ae | 18 | class ADNS5090 |
davervw | 0:6a500a08c7fd | 19 | { |
davervw | 0:6a500a08c7fd | 20 | private: |
Throwbot | 1:98a9d6fc60ae | 21 | |
Throwbot | 2:4612564007c0 | 22 | SWSPI& spi; |
Throwbot | 2:4612564007c0 | 23 | Mutex& spi_mutex; |
Throwbot | 1:98a9d6fc60ae | 24 | DigitalOut ncs; |
davervw | 0:6a500a08c7fd | 25 | |
davervw | 0:6a500a08c7fd | 26 | public: |
Throwbot | 1:98a9d6fc60ae | 27 | |
Throwbot | 2:4612564007c0 | 28 | ADNS5090(SWSPI&, Mutex&, PinName ncs_pin, float pxPerMM_); |
davervw | 0:6a500a08c7fd | 29 | |
Throwbot | 1:98a9d6fc60ae | 30 | int8_t dx_px, dy_px; |
Throwbot | 1:98a9d6fc60ae | 31 | uint8_t sq; //surface quality, higher better, ~30 is good, 0= no surface |
Throwbot | 1:98a9d6fc60ae | 32 | float pxPerMM; |
davervw | 0:6a500a08c7fd | 33 | |
Throwbot | 1:98a9d6fc60ae | 34 | float dx(); |
Throwbot | 1:98a9d6fc60ae | 35 | float dy(); |
davervw | 0:6a500a08c7fd | 36 | |
Throwbot | 1:98a9d6fc60ae | 37 | bool updateMotion(); |
Throwbot | 1:98a9d6fc60ae | 38 | void reset(); |
Throwbot | 1:98a9d6fc60ae | 39 | void powerDown(); |
Throwbot | 1:98a9d6fc60ae | 40 | void setDPI(); |
davervw | 0:6a500a08c7fd | 41 | }; |
davervw | 0:6a500a08c7fd | 42 | |
Throwbot | 1:98a9d6fc60ae | 43 | #endif |