fork of Sam Grove's library
Fork of ADIS16488 by
Adis16488.h@3:4420cf0e0b74, 2017-01-10 (annotated)
- Committer:
- raprism
- Date:
- Tue Jan 10 22:22:51 2017 +0100
- Revision:
- 3:4420cf0e0b74
- Parent:
- 2:e2e5e40668bf
- added ADIS16485 as correct model type
- removed redundant SPI writes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sam_grove | 0:e9a81060a092 | 1 | /** |
sam_grove | 0:e9a81060a092 | 2 | * @file Adis16488.h |
sam_grove | 0:e9a81060a092 | 3 | * @brief Device driver - ADIS16488 IMU |
sam_grove | 0:e9a81060a092 | 4 | * @author sam grove |
sam_grove | 0:e9a81060a092 | 5 | * @version 1.0 |
sam_grove | 0:e9a81060a092 | 6 | * @see http://www.analog.com/static/imported-files/data_sheets/ADIS16488.pdf |
sam_grove | 0:e9a81060a092 | 7 | * |
sam_grove | 0:e9a81060a092 | 8 | * Copyright (c) 2013 |
sam_grove | 0:e9a81060a092 | 9 | * |
sam_grove | 0:e9a81060a092 | 10 | * Licensed under the Apache License, Version 2.0 (the "License"); |
sam_grove | 0:e9a81060a092 | 11 | * you may not use this file except in compliance with the License. |
sam_grove | 0:e9a81060a092 | 12 | * You may obtain a copy of the License at |
sam_grove | 0:e9a81060a092 | 13 | * |
sam_grove | 0:e9a81060a092 | 14 | * http://www.apache.org/licenses/LICENSE-2.0 |
sam_grove | 0:e9a81060a092 | 15 | * |
sam_grove | 0:e9a81060a092 | 16 | * Unless required by applicable law or agreed to in writing, software |
sam_grove | 0:e9a81060a092 | 17 | * distributed under the License is distributed on an "AS IS" BASIS, |
sam_grove | 0:e9a81060a092 | 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
sam_grove | 0:e9a81060a092 | 19 | * See the License for the specific language governing permissions and |
sam_grove | 0:e9a81060a092 | 20 | * limitations under the License. |
sam_grove | 0:e9a81060a092 | 21 | */ |
sam_grove | 0:e9a81060a092 | 22 | |
sam_grove | 0:e9a81060a092 | 23 | #ifndef ADIS16488_H |
sam_grove | 0:e9a81060a092 | 24 | #define ADIS16488_H |
sam_grove | 0:e9a81060a092 | 25 | |
sam_grove | 0:e9a81060a092 | 26 | #include "LogUtil.h" |
sam_grove | 0:e9a81060a092 | 27 | #include "mbed.h" |
sam_grove | 0:e9a81060a092 | 28 | |
sam_grove | 0:e9a81060a092 | 29 | /** Using the Analog Devices ADIS16488/PCBZ |
sam_grove | 0:e9a81060a092 | 30 | * |
sam_grove | 0:e9a81060a092 | 31 | * Example: |
sam_grove | 0:e9a81060a092 | 32 | * @code |
sam_grove | 2:e2e5e40668bf | 33 | * #include "mbed.h" |
sam_grove | 2:e2e5e40668bf | 34 | * |
sam_grove | 2:e2e5e40668bf | 35 | * int main() |
sam_grove | 2:e2e5e40668bf | 36 | * { |
sam_grove | 2:e2e5e40668bf | 37 | * } |
sam_grove | 0:e9a81060a092 | 38 | * @endcode |
sam_grove | 0:e9a81060a092 | 39 | */ |
sam_grove | 0:e9a81060a092 | 40 | |
sam_grove | 0:e9a81060a092 | 41 | /** |
sam_grove | 0:e9a81060a092 | 42 | * @class Adis16488 |
sam_grove | 0:e9a81060a092 | 43 | * @brief API abstraction for the ADIS16488 IMU |
sam_grove | 0:e9a81060a092 | 44 | */ |
sam_grove | 0:e9a81060a092 | 45 | class Adis16488 |
sam_grove | 0:e9a81060a092 | 46 | { |
sam_grove | 0:e9a81060a092 | 47 | public: |
sam_grove | 0:e9a81060a092 | 48 | |
sam_grove | 0:e9a81060a092 | 49 | struct{ uint16_t data[6]; } gyro, accel, magn, deltang, deltvel; |
sam_grove | 0:e9a81060a092 | 50 | |
sam_grove | 0:e9a81060a092 | 51 | /** Create the Adis16488 object |
sam_grove | 0:e9a81060a092 | 52 | * @param spi - A defined SPI object |
sam_grove | 0:e9a81060a092 | 53 | * @param cs - A defined DigitalOut object |
sam_grove | 0:e9a81060a092 | 54 | * @param rst - A defined DigitalOut object |
sam_grove | 0:e9a81060a092 | 55 | * @param dr - A defined InterruptIn object |
sam_grove | 0:e9a81060a092 | 56 | */ |
sam_grove | 0:e9a81060a092 | 57 | Adis16488(SPI &spi, DigitalOut &cs, DigitalOut &rst, InterruptIn &dr); |
sam_grove | 0:e9a81060a092 | 58 | |
sam_grove | 0:e9a81060a092 | 59 | /** Clear state vars and initilize the dependant objects |
sam_grove | 0:e9a81060a092 | 60 | */ |
sam_grove | 0:e9a81060a092 | 61 | void init(void); |
sam_grove | 0:e9a81060a092 | 62 | |
sam_grove | 0:e9a81060a092 | 63 | /** Read from a register (exposed for debugging reasons) |
sam_grove | 0:e9a81060a092 | 64 | * @param reg - The register to be written |
sam_grove | 0:e9a81060a092 | 65 | * @param data - Data read from the device is stored here |
sam_grove | 0:e9a81060a092 | 66 | */ |
sam_grove | 0:e9a81060a092 | 67 | void readRegister(uint16_t const reg, uint16_t &data); |
sam_grove | 0:e9a81060a092 | 68 | |
sam_grove | 0:e9a81060a092 | 69 | /** Write to a register (exposed for debugging reasons) |
sam_grove | 0:e9a81060a092 | 70 | * @param reg - The register to be written |
sam_grove | 0:e9a81060a092 | 71 | */ |
sam_grove | 0:e9a81060a092 | 72 | void writeRegister(uint16_t const reg); |
sam_grove | 0:e9a81060a092 | 73 | |
sam_grove | 0:e9a81060a092 | 74 | /** Allow the IC to run and collect user input |
sam_grove | 0:e9a81060a092 | 75 | */ |
sam_grove | 0:e9a81060a092 | 76 | void enable(void); |
sam_grove | 0:e9a81060a092 | 77 | |
sam_grove | 0:e9a81060a092 | 78 | /** Stop the IC and put into low power mode |
sam_grove | 0:e9a81060a092 | 79 | */ |
sam_grove | 0:e9a81060a092 | 80 | void disable(void); |
sam_grove | 0:e9a81060a092 | 81 | |
sam_grove | 0:e9a81060a092 | 82 | private: |
sam_grove | 0:e9a81060a092 | 83 | SPI *_spi; |
sam_grove | 0:e9a81060a092 | 84 | DigitalOut *_cs; |
sam_grove | 0:e9a81060a092 | 85 | DigitalOut *_rst; |
sam_grove | 0:e9a81060a092 | 86 | InterruptIn *_dr; |
sam_grove | 0:e9a81060a092 | 87 | |
sam_grove | 0:e9a81060a092 | 88 | void drHandler(void); |
sam_grove | 0:e9a81060a092 | 89 | }; |
sam_grove | 0:e9a81060a092 | 90 | |
sam_grove | 0:e9a81060a092 | 91 | #endif |
sam_grove | 0:e9a81060a092 | 92 |