Software SPI allows non-standard SPI pins to be used for interfacing with SPI devices

Dependencies:   SWSPI

Fork of SWSPI by Dave Van Wagner

Committer:
Throwbot
Date:
Thu May 08 19:10:37 2014 +0000
Revision:
1:98a9d6fc60ae
Parent:
SWSPI.h@0:6a500a08c7fd
Child:
2:4612564007c0
good version, just intergrated mouse sensor, has shell, has rc

Who changed what in which revision?

UserRevisionLine numberNew 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"
davervw 0:6a500a08c7fd 7
Throwbot 1:98a9d6fc60ae 8 #define ADNS5090_WRITE_VAL (0x80)
Throwbot 1:98a9d6fc60ae 9 #define ADNS5090_MOTION_ST_REG (0x02)
Throwbot 1:98a9d6fc60ae 10 #define ADNS5090_MOTION_BURST_REG (0x63)
Throwbot 1:98a9d6fc60ae 11 #define ADNS5090_RESET_REG (0x3a)
Throwbot 1:98a9d6fc60ae 12 #define ADNS5090_RESET_VAL (0x5a)
Throwbot 1:98a9d6fc60ae 13 #define ADNS5090_MOUSE_CTRL_REG (0x0d)
Throwbot 1:98a9d6fc60ae 14 #define ADNS5090_POWERDOWN_VAL (0x02)
Throwbot 1:98a9d6fc60ae 15
Throwbot 1:98a9d6fc60ae 16
Throwbot 1:98a9d6fc60ae 17 class ADNS5090
davervw 0:6a500a08c7fd 18 {
davervw 0:6a500a08c7fd 19 private:
Throwbot 1:98a9d6fc60ae 20
Throwbot 1:98a9d6fc60ae 21 SWSPI spi;
Throwbot 1:98a9d6fc60ae 22 DigitalOut ncs;
davervw 0:6a500a08c7fd 23
davervw 0:6a500a08c7fd 24 public:
Throwbot 1:98a9d6fc60ae 25
Throwbot 1:98a9d6fc60ae 26 ADNS5090(PinName mosi_pin, PinName miso_pin, PinName sclk_pin, PinName ncs_pin, float pxPerMM_);
davervw 0:6a500a08c7fd 27
Throwbot 1:98a9d6fc60ae 28 int8_t dx_px, dy_px;
Throwbot 1:98a9d6fc60ae 29 uint8_t sq; //surface quality, higher better, ~30 is good, 0= no surface
Throwbot 1:98a9d6fc60ae 30 float pxPerMM;
davervw 0:6a500a08c7fd 31
Throwbot 1:98a9d6fc60ae 32 float dx();
Throwbot 1:98a9d6fc60ae 33 float dy();
davervw 0:6a500a08c7fd 34
Throwbot 1:98a9d6fc60ae 35 bool updateMotion();
Throwbot 1:98a9d6fc60ae 36 void reset();
Throwbot 1:98a9d6fc60ae 37 void powerDown();
Throwbot 1:98a9d6fc60ae 38 void setDPI();
davervw 0:6a500a08c7fd 39 };
davervw 0:6a500a08c7fd 40
Throwbot 1:98a9d6fc60ae 41 #endif