Avago ADNS6010 mouse chip library This class referred to ADNS5020EN library http://mbed.org/users/IPAB/programs/ADNS5020EN/5zwdp

Committer:
nucho
Date:
Mon Nov 21 16:00:51 2011 +0000
Revision:
1:ac87e825b0d7
Parent:
0:efc16a3c5ce4

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nucho 0:efc16a3c5ce4 1 /**************************
nucho 0:efc16a3c5ce4 2 This class referred to ADNS5020EN library
nucho 0:efc16a3c5ce4 3 http://mbed.org/users/IPAB/programs/ADNS5020EN/5zwdp
nucho 0:efc16a3c5ce4 4 **************************/
nucho 0:efc16a3c5ce4 5
nucho 0:efc16a3c5ce4 6 #ifndef _ADNS6010_H_
nucho 0:efc16a3c5ce4 7 #define _ADNS6010_H_
nucho 0:efc16a3c5ce4 8
nucho 0:efc16a3c5ce4 9 #define REGISTER_PRODUCTID 0x00
nucho 0:efc16a3c5ce4 10 #define REGISTER_REVISONID 0x01
nucho 0:efc16a3c5ce4 11 #define REGISTER_MOTION 0x02
nucho 0:efc16a3c5ce4 12 #define REGISTER_DELTAX 0x03
nucho 0:efc16a3c5ce4 13 #define REGISTER_DELTAY 0x04
nucho 0:efc16a3c5ce4 14 #define REGISTER_SQUAL 0x05
nucho 0:efc16a3c5ce4 15 #define REGISTER_CONFIGURATION_BITS 0x0a
nucho 0:efc16a3c5ce4 16
nucho 0:efc16a3c5ce4 17 #define ADNS6010_PRODUCTID 0x1C
nucho 0:efc16a3c5ce4 18 #define ADNS6010_REVISIONID 0x20
nucho 0:efc16a3c5ce4 19
nucho 0:efc16a3c5ce4 20 #define DELAY_TRAD 50
nucho 0:efc16a3c5ce4 21 #define DELAY_TRAD_MOT 75
nucho 0:efc16a3c5ce4 22 #define DELAY_RESET_PULSE 10
nucho 0:efc16a3c5ce4 23
nucho 0:efc16a3c5ce4 24 #include"mbed.h"
nucho 0:efc16a3c5ce4 25
nucho 0:efc16a3c5ce4 26 /** Interface to control a ADNS-6010 Avago mouse
nucho 0:efc16a3c5ce4 27 * chip using a SPI and 3 DigitalOuts
nucho 0:efc16a3c5ce4 28 */
nucho 0:efc16a3c5ce4 29 class ADNS6010 {
nucho 0:efc16a3c5ce4 30 public:
nucho 0:efc16a3c5ce4 31 /** Create the mouse chip control interface. Returns Error if the connection is not established.
nucho 0:efc16a3c5ce4 32 *
nucho 0:efc16a3c5ce4 33 * @param mosi A SPI(mosi) pin, for the spi interface of the mouse chip (SDIO)
nucho 0:efc16a3c5ce4 34 * @param miso A SPI(miso) pin, for the spi interface of the mouse chip (SDIO)
nucho 0:efc16a3c5ce4 35 * @param sclk A SPI(sclk) pin, for the spi interface of the mouse chip (SCLK)
nucho 0:efc16a3c5ce4 36 * @param ncs A DigitalOut, set low for chip select
nucho 0:efc16a3c5ce4 37 * @param reset A DigitalOut, set high for chip reset
nucho 0:efc16a3c5ce4 38 * @param npd A DigitalOut, set high for chip powerdown
nucho 0:efc16a3c5ce4 39 */
nucho 0:efc16a3c5ce4 40 ADNS6010(PinName mosi, PinName miso, PinName sclk, PinName ncs, PinName reset,PinName npd);
nucho 0:efc16a3c5ce4 41
nucho 0:efc16a3c5ce4 42 /** Read the deltaX and deltaY registers and assign to the input variable the counts for the previous read.
nucho 0:efc16a3c5ce4 43 *
nucho 0:efc16a3c5ce4 44 * @param a_dx A pointer to an integer, to return the value of the deltaX register in reading counts
nucho 0:efc16a3c5ce4 45 * @param a_dy A pointer to an integer, to return the value of the deltaY register in reading counts
nucho 0:efc16a3c5ce4 46 */
nucho 0:efc16a3c5ce4 47 void read_deltas(int* a_dx, int* a_dy);
nucho 0:efc16a3c5ce4 48
nucho 0:efc16a3c5ce4 49 /** Read the SQUAL registers
nucho 0:efc16a3c5ce4 50 *
nucho 0:efc16a3c5ce4 51 * @return SQUAL register value an integer
nucho 0:efc16a3c5ce4 52 */
nucho 0:efc16a3c5ce4 53 int read_squal();
nucho 0:efc16a3c5ce4 54
nucho 0:efc16a3c5ce4 55 /** Change the resolution of the mouse chip.
nucho 0:efc16a3c5ce4 56 *
nucho 0:efc16a3c5ce4 57 * @param cpi A int value 400 or 800 or 1600 or 2000
nucho 0:efc16a3c5ce4 58 */
nucho 0:efc16a3c5ce4 59 void changeCPI(int cpi);
nucho 0:efc16a3c5ce4 60
nucho 0:efc16a3c5ce4 61 /** Set new operating frequency to the mouse chip.
nucho 0:efc16a3c5ce4 62 *
nucho 0:efc16a3c5ce4 63 * @param freq A int value between 500000 and 2000000 for the SPI frequency(in MHz)
nucho 0:efc16a3c5ce4 64 */
nucho 0:efc16a3c5ce4 65 void set_freq(int freq);
nucho 0:efc16a3c5ce4 66
nucho 0:efc16a3c5ce4 67 /** Chip Power Down.
nucho 0:efc16a3c5ce4 68 */
nucho 0:efc16a3c5ce4 69 void end();
nucho 0:efc16a3c5ce4 70
nucho 0:efc16a3c5ce4 71 /** Chip Power Up.
nucho 0:efc16a3c5ce4 72 */
nucho 0:efc16a3c5ce4 73 void start();
nucho 0:efc16a3c5ce4 74
nucho 0:efc16a3c5ce4 75 private:
nucho 0:efc16a3c5ce4 76 int cread(unsigned char cregister);
nucho 0:efc16a3c5ce4 77 void cwrite(unsigned char caddress, unsigned char cdata);
nucho 0:efc16a3c5ce4 78 int MChipMotion(int reading);
nucho 0:efc16a3c5ce4 79 void creset();
nucho 0:efc16a3c5ce4 80
nucho 0:efc16a3c5ce4 81 SPI spi_;
nucho 0:efc16a3c5ce4 82 DigitalOut npd_;
nucho 0:efc16a3c5ce4 83 DigitalOut reset_;
nucho 0:efc16a3c5ce4 84 DigitalOut ncs_;
nucho 0:efc16a3c5ce4 85 };
nucho 0:efc16a3c5ce4 86
nucho 0:efc16a3c5ce4 87 #endif