Device driver

Committer:
sam_grove
Date:
Wed Apr 10 04:41:21 2013 +0000
Revision:
0:e9a81060a092
Child:
2:e2e5e40668bf
Initial commit - working in a basic way

Who changed what in which revision?

UserRevisionLine numberNew 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
sam_grove 0:e9a81060a092 30 /** Using the Analog Devices ADIS16488/PCBZ
sam_grove 0:e9a81060a092 31 *
sam_grove 0:e9a81060a092 32 * Example:
sam_grove 0:e9a81060a092 33 * @code
sam_grove 0:e9a81060a092 34
sam_grove 0:e9a81060a092 35 * @endcode
sam_grove 0:e9a81060a092 36 */
sam_grove 0:e9a81060a092 37
sam_grove 0:e9a81060a092 38 /**
sam_grove 0:e9a81060a092 39 * @class Adis16488
sam_grove 0:e9a81060a092 40 * @brief API abstraction for the ADIS16488 IMU
sam_grove 0:e9a81060a092 41 */
sam_grove 0:e9a81060a092 42 class Adis16488
sam_grove 0:e9a81060a092 43 {
sam_grove 0:e9a81060a092 44 public:
sam_grove 0:e9a81060a092 45
sam_grove 0:e9a81060a092 46 struct{ uint16_t data[6]; } gyro, accel, magn, deltang, deltvel;
sam_grove 0:e9a81060a092 47
sam_grove 0:e9a81060a092 48 /** Create the Adis16488 object
sam_grove 0:e9a81060a092 49 * @param spi - A defined SPI object
sam_grove 0:e9a81060a092 50 * @param cs - A defined DigitalOut object
sam_grove 0:e9a81060a092 51 * @param rst - A defined DigitalOut object
sam_grove 0:e9a81060a092 52 * @param dr - A defined InterruptIn object
sam_grove 0:e9a81060a092 53 */
sam_grove 0:e9a81060a092 54 Adis16488(SPI &spi, DigitalOut &cs, DigitalOut &rst, InterruptIn &dr);
sam_grove 0:e9a81060a092 55
sam_grove 0:e9a81060a092 56 /** Clear state vars and initilize the dependant objects
sam_grove 0:e9a81060a092 57 */
sam_grove 0:e9a81060a092 58 void init(void);
sam_grove 0:e9a81060a092 59
sam_grove 0:e9a81060a092 60 /** Read from a register (exposed for debugging reasons)
sam_grove 0:e9a81060a092 61 * @param reg - The register to be written
sam_grove 0:e9a81060a092 62 * @param data - Data read from the device is stored here
sam_grove 0:e9a81060a092 63 */
sam_grove 0:e9a81060a092 64 void readRegister(uint16_t const reg, uint16_t &data);
sam_grove 0:e9a81060a092 65
sam_grove 0:e9a81060a092 66 /** Write to a register (exposed for debugging reasons)
sam_grove 0:e9a81060a092 67 * @param reg - The register to be written
sam_grove 0:e9a81060a092 68 */
sam_grove 0:e9a81060a092 69 void writeRegister(uint16_t const reg);
sam_grove 0:e9a81060a092 70
sam_grove 0:e9a81060a092 71 /** Allow the IC to run and collect user input
sam_grove 0:e9a81060a092 72 */
sam_grove 0:e9a81060a092 73 void enable(void);
sam_grove 0:e9a81060a092 74
sam_grove 0:e9a81060a092 75 /** Stop the IC and put into low power mode
sam_grove 0:e9a81060a092 76 */
sam_grove 0:e9a81060a092 77 void disable(void);
sam_grove 0:e9a81060a092 78
sam_grove 0:e9a81060a092 79 private:
sam_grove 0:e9a81060a092 80 SPI *_spi;
sam_grove 0:e9a81060a092 81 DigitalOut *_cs;
sam_grove 0:e9a81060a092 82 DigitalOut *_rst;
sam_grove 0:e9a81060a092 83 InterruptIn *_dr;
sam_grove 0:e9a81060a092 84
sam_grove 0:e9a81060a092 85 void drHandler(void);
sam_grove 0:e9a81060a092 86 };
sam_grove 0:e9a81060a092 87
sam_grove 0:e9a81060a092 88 #endif
sam_grove 0:e9a81060a092 89