ジャパンオープン用のメインプログラム

Dependencies:   mbed AQM1602 HMC6352 PID

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers adns_9800.h Source File

adns_9800.h

Go to the documentation of this file.
00001 /**
00002  * @author Alexander Entinger, MSc / LXRobotics
00003  * @brief this class acts as interface for accessing the adns-9800 sensor - based on https://github.com/mrjohnk/ADNS-9800
00004  * @file adns_9800.h
00005  */
00006  
00007 #ifndef ADNS_9800_H_
00008 #define ADNS_9800_H_
00009 
00010 #include "mbed.h"
00011 
00012 class adns_9800
00013 {
00014 public:
00015     /**
00016      * @brief Constructor
00017      */
00018     adns_9800(PinName mosi, PinName miso, PinName sclk, PinName ncs);
00019     
00020     /**
00021      * @brief Destructor
00022      */
00023     ~adns_9800();
00024 
00025     /**
00026      * @brief returns true if a motion has occured since the last readout
00027      */
00028     bool new_motion_data_available();
00029     
00030     /**
00031      * @brief retrieves the latest delta values
00032      */
00033     void get_delta_x_y(int16_t &delta_x, int16_t &delta_y);
00034         
00035 private:
00036     SPI m_spi;
00037     DigitalOut m_ncs_pin;
00038     
00039     /**
00040      * @brief start and stop communication with the sensor by clearing/setting the ncs pin
00041      */
00042     void com_begin();
00043     void com_end();
00044     /**
00045      * @brief provide read/write access to a adns register
00046      */
00047     uint8_t read_reg(uint8_t const address);
00048     void write_reg(uint8_t const address, uint8_t const data);
00049     /**
00050      * @brief upload the firmware
00051      */
00052     void upload_firmware();
00053     /**
00054      * @brief starts the sensor up
00055      */
00056     void startup();
00057 };
00058 
00059 #endif