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.
ADNS5020EN.h
00001 #ifndef ADNS5020EN_H 00002 #define ADNS5020EN_H 00003 00004 #include "mbed.h" 00005 00006 /** Interface to control a ADNS-5020-EN Avago mouse 00007 * chip using a SPI and 2 DigitalOuts 00008 */ 00009 00010 class ADNS5020EN { 00011 public: 00012 00013 /** Create the mouse chip control interface. Returns Error if the connection is not established. 00014 * 00015 * @param mosi A SPI(mosi) pin, for the spi interface of the mouse chip (SDIO) 00016 * @param miso A SPI(miso) pin, for the spi interface of the mouse chip (SDIO) 00017 * @param sclk A SPI(sclk) pin, for the spi interface of the mouse chip (SCLK) 00018 * @param cs A DigitalOut, set low for chip select 00019 * @param cr A DigitalOut, set los for chip reset 00020 * @param freq A float value between 1.0 and 0.1 for the SPI frequency(in MHz) 00021 */ 00022 ADNS5020EN(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName cr, float freq); 00023 00024 00025 /** Read the deltaX and deltaY registers and assign to the input variable the counts for the previous read. 00026 * 00027 * @param a_dx A pointer to an integer, to return the value of the deltaX register in reading counts 00028 * @param a_dy A pointer to an integer, to return the value of the deltaY register in reading counts 00029 */ 00030 void read_deltas(int* a_dx, int* a_dy); 00031 00032 /** Same as the read_deltas() function but the return is the movement in mm according to the working resolution. 00033 * 00034 * @param a_dx A pointer to a float, to return the value of the deltaX register in mm 00035 * @param a_dy A pointer to a float, to return the value of the deltaY register in mm 00036 * @see read_deltas() 00037 * @see changeCPI() 00038 */ 00039 void read_deltas_mm(float* dx, float* dy); 00040 00041 00042 /** Chip Power Down. 00043 */ 00044 void end(); 00045 00046 00047 /** Set new operating frequency to the mouse chip. 00048 * 00049 * @param freq A float value between 1.0 and 0.1 for the SPI frequency(in MHz) 00050 */ 00051 void set_freq(float freq); 00052 00053 00054 /** Get the false readings of the mouse chip. 00055 * 00056 * @return The false readings 00057 */ 00058 int falser(); 00059 00060 00061 /** Change the resolution of the mouse chip. 00062 * 00063 * @param cpi A bool value where 0 is 500cpi (default) and 1 is 1000cpi 00064 * @return The mouse control register value 00065 */ 00066 int changeCPI(bool cpi); 00067 00068 protected: 00069 00070 void creset(); 00071 int cread(int cregister); 00072 void cwrite(int caddress, int cdata); 00073 int MChipMotion(int reading); 00074 float counts_to_mm(int counts); 00075 00076 SPI _spi; 00077 DigitalOut _cs; 00078 DigitalOut _cr; 00079 int _false_readings; 00080 int _cpi; 00081 00082 }; 00083 00084 #endif // ADNS5020EN_H
Generated on Mon Aug 1 2022 10:22:01 by
1.7.2