Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
ADNS6010.h
00001 /************************** 00002 This class referred to ADNS5020EN library 00003 http://mbed.org/users/IPAB/programs/ADNS5020EN/5zwdp 00004 **************************/ 00005 00006 #ifndef _ADNS6010_H_ 00007 #define _ADNS6010_H_ 00008 00009 #define REGISTER_PRODUCTID 0x00 00010 #define REGISTER_REVISONID 0x01 00011 #define REGISTER_MOTION 0x02 00012 #define REGISTER_DELTAX 0x03 00013 #define REGISTER_DELTAY 0x04 00014 #define REGISTER_SQUAL 0x05 00015 #define REGISTER_CONFIGURATION_BITS 0x0a 00016 00017 #define ADNS6010_PRODUCTID 0x1C 00018 #define ADNS6010_REVISIONID 0x20 00019 00020 #define DELAY_TRAD 50 00021 #define DELAY_TRAD_MOT 75 00022 #define DELAY_RESET_PULSE 10 00023 00024 #include"mbed.h" 00025 00026 /** Interface to control a ADNS-6010 Avago mouse 00027 * chip using a SPI and 3 DigitalOuts 00028 */ 00029 class ADNS6010 { 00030 public: 00031 /** Create the mouse chip control interface. Returns Error if the connection is not established. 00032 * 00033 * @param mosi A SPI(mosi) pin, for the spi interface of the mouse chip (SDIO) 00034 * @param miso A SPI(miso) pin, for the spi interface of the mouse chip (SDIO) 00035 * @param sclk A SPI(sclk) pin, for the spi interface of the mouse chip (SCLK) 00036 * @param ncs A DigitalOut, set low for chip select 00037 * @param reset A DigitalOut, set high for chip reset 00038 * @param npd A DigitalOut, set high for chip powerdown 00039 */ 00040 ADNS6010(PinName mosi, PinName miso, PinName sclk, PinName ncs, PinName reset,PinName npd); 00041 00042 /** Read the deltaX and deltaY registers and assign to the input variable the counts for the previous read. 00043 * 00044 * @param a_dx A pointer to an integer, to return the value of the deltaX register in reading counts 00045 * @param a_dy A pointer to an integer, to return the value of the deltaY register in reading counts 00046 */ 00047 void read_deltas(int* a_dx, int* a_dy); 00048 00049 /** Read the SQUAL registers 00050 * 00051 * @return SQUAL register value an integer 00052 */ 00053 int read_squal(); 00054 00055 /** Change the resolution of the mouse chip. 00056 * 00057 * @param cpi A int value 400 or 800 or 1600 or 2000 00058 */ 00059 void changeCPI(int cpi); 00060 00061 /** Set new operating frequency to the mouse chip. 00062 * 00063 * @param freq A int value between 500000 and 2000000 for the SPI frequency(in MHz) 00064 */ 00065 void set_freq(int freq); 00066 00067 /** Chip Power Down. 00068 */ 00069 void end(); 00070 00071 /** Chip Power Up. 00072 */ 00073 void start(); 00074 00075 private: 00076 int cread(unsigned char cregister); 00077 void cwrite(unsigned char caddress, unsigned char cdata); 00078 int MChipMotion(int reading); 00079 void creset(); 00080 00081 SPI spi_; 00082 DigitalOut npd_; 00083 DigitalOut reset_; 00084 DigitalOut ncs_; 00085 }; 00086 00087 #endif
Generated on Wed Jul 13 2022 17:51:04 by
1.7.2