ジャパンオープン用のメインプログラム
Dependencies: mbed AQM1602 HMC6352 PID
lib/adns_9800/adns_9800.h@38:67bc78f3c0ab, 2016-03-27 (annotated)
- Committer:
- lilac0112_1
- Date:
- Sun Mar 27 13:04:39 2016 +0000
- Revision:
- 38:67bc78f3c0ab
- Parent:
- 0:ea35c18c85fc
JapanSoccerOpen2016 CatPot Program(main)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lilac0112_1 | 0:ea35c18c85fc | 1 | /** |
lilac0112_1 | 0:ea35c18c85fc | 2 | * @author Alexander Entinger, MSc / LXRobotics |
lilac0112_1 | 0:ea35c18c85fc | 3 | * @brief this class acts as interface for accessing the adns-9800 sensor - based on https://github.com/mrjohnk/ADNS-9800 |
lilac0112_1 | 0:ea35c18c85fc | 4 | * @file adns_9800.h |
lilac0112_1 | 0:ea35c18c85fc | 5 | */ |
lilac0112_1 | 0:ea35c18c85fc | 6 | |
lilac0112_1 | 0:ea35c18c85fc | 7 | #ifndef ADNS_9800_H_ |
lilac0112_1 | 0:ea35c18c85fc | 8 | #define ADNS_9800_H_ |
lilac0112_1 | 0:ea35c18c85fc | 9 | |
lilac0112_1 | 0:ea35c18c85fc | 10 | #include "mbed.h" |
lilac0112_1 | 0:ea35c18c85fc | 11 | |
lilac0112_1 | 0:ea35c18c85fc | 12 | class adns_9800 |
lilac0112_1 | 0:ea35c18c85fc | 13 | { |
lilac0112_1 | 0:ea35c18c85fc | 14 | public: |
lilac0112_1 | 0:ea35c18c85fc | 15 | /** |
lilac0112_1 | 0:ea35c18c85fc | 16 | * @brief Constructor |
lilac0112_1 | 0:ea35c18c85fc | 17 | */ |
lilac0112_1 | 0:ea35c18c85fc | 18 | adns_9800(PinName mosi, PinName miso, PinName sclk, PinName ncs); |
lilac0112_1 | 0:ea35c18c85fc | 19 | |
lilac0112_1 | 0:ea35c18c85fc | 20 | /** |
lilac0112_1 | 0:ea35c18c85fc | 21 | * @brief Destructor |
lilac0112_1 | 0:ea35c18c85fc | 22 | */ |
lilac0112_1 | 0:ea35c18c85fc | 23 | ~adns_9800(); |
lilac0112_1 | 0:ea35c18c85fc | 24 | |
lilac0112_1 | 0:ea35c18c85fc | 25 | /** |
lilac0112_1 | 0:ea35c18c85fc | 26 | * @brief returns true if a motion has occured since the last readout |
lilac0112_1 | 0:ea35c18c85fc | 27 | */ |
lilac0112_1 | 0:ea35c18c85fc | 28 | bool new_motion_data_available(); |
lilac0112_1 | 0:ea35c18c85fc | 29 | |
lilac0112_1 | 0:ea35c18c85fc | 30 | /** |
lilac0112_1 | 0:ea35c18c85fc | 31 | * @brief retrieves the latest delta values |
lilac0112_1 | 0:ea35c18c85fc | 32 | */ |
lilac0112_1 | 0:ea35c18c85fc | 33 | void get_delta_x_y(int16_t &delta_x, int16_t &delta_y); |
lilac0112_1 | 0:ea35c18c85fc | 34 | |
lilac0112_1 | 0:ea35c18c85fc | 35 | private: |
lilac0112_1 | 0:ea35c18c85fc | 36 | SPI m_spi; |
lilac0112_1 | 0:ea35c18c85fc | 37 | DigitalOut m_ncs_pin; |
lilac0112_1 | 0:ea35c18c85fc | 38 | |
lilac0112_1 | 0:ea35c18c85fc | 39 | /** |
lilac0112_1 | 0:ea35c18c85fc | 40 | * @brief start and stop communication with the sensor by clearing/setting the ncs pin |
lilac0112_1 | 0:ea35c18c85fc | 41 | */ |
lilac0112_1 | 0:ea35c18c85fc | 42 | void com_begin(); |
lilac0112_1 | 0:ea35c18c85fc | 43 | void com_end(); |
lilac0112_1 | 0:ea35c18c85fc | 44 | /** |
lilac0112_1 | 0:ea35c18c85fc | 45 | * @brief provide read/write access to a adns register |
lilac0112_1 | 0:ea35c18c85fc | 46 | */ |
lilac0112_1 | 0:ea35c18c85fc | 47 | uint8_t read_reg(uint8_t const address); |
lilac0112_1 | 0:ea35c18c85fc | 48 | void write_reg(uint8_t const address, uint8_t const data); |
lilac0112_1 | 0:ea35c18c85fc | 49 | /** |
lilac0112_1 | 0:ea35c18c85fc | 50 | * @brief upload the firmware |
lilac0112_1 | 0:ea35c18c85fc | 51 | */ |
lilac0112_1 | 0:ea35c18c85fc | 52 | void upload_firmware(); |
lilac0112_1 | 0:ea35c18c85fc | 53 | /** |
lilac0112_1 | 0:ea35c18c85fc | 54 | * @brief starts the sensor up |
lilac0112_1 | 0:ea35c18c85fc | 55 | */ |
lilac0112_1 | 0:ea35c18c85fc | 56 | void startup(); |
lilac0112_1 | 0:ea35c18c85fc | 57 | }; |
lilac0112_1 | 0:ea35c18c85fc | 58 | |
lilac0112_1 | 0:ea35c18c85fc | 59 | #endif |