Use MPU9250 with nRF51822

Dependencies:   eMPL_MPU

Fork of Seeed_Tiny_BLE_Flash by Darren Huang

Committer:
yihui
Date:
Thu Dec 10 08:00:18 2015 +0000
Revision:
5:9b240c1d5251
get 9dof data from mpu9250

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 5:9b240c1d5251 1 /* mbed Microcontroller Library
yihui 5:9b240c1d5251 2 * Copyright (c) 2006-2013 ARM Limited
yihui 5:9b240c1d5251 3 *
yihui 5:9b240c1d5251 4 * Licensed under the Apache License, Version 2.0 (the "License");
yihui 5:9b240c1d5251 5 * you may not use this file except in compliance with the License.
yihui 5:9b240c1d5251 6 * You may obtain a copy of the License at
yihui 5:9b240c1d5251 7 *
yihui 5:9b240c1d5251 8 * http://www.apache.org/licenses/LICENSE-2.0
yihui 5:9b240c1d5251 9 *
yihui 5:9b240c1d5251 10 * Unless required by applicable law or agreed to in writing, software
yihui 5:9b240c1d5251 11 * distributed under the License is distributed on an "AS IS" BASIS,
yihui 5:9b240c1d5251 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
yihui 5:9b240c1d5251 13 * See the License for the specific language governing permissions and
yihui 5:9b240c1d5251 14 * limitations under the License.
yihui 5:9b240c1d5251 15 */
yihui 5:9b240c1d5251 16 #ifndef MBED_BUSINOUT_H
yihui 5:9b240c1d5251 17 #define MBED_BUSINOUT_H
yihui 5:9b240c1d5251 18
yihui 5:9b240c1d5251 19 #include "DigitalInOut.h"
yihui 5:9b240c1d5251 20
yihui 5:9b240c1d5251 21 namespace mbed {
yihui 5:9b240c1d5251 22
yihui 5:9b240c1d5251 23 /** A digital input output bus, used for setting the state of a collection of pins
yihui 5:9b240c1d5251 24 */
yihui 5:9b240c1d5251 25 class BusInOut {
yihui 5:9b240c1d5251 26
yihui 5:9b240c1d5251 27 public:
yihui 5:9b240c1d5251 28
yihui 5:9b240c1d5251 29 /** Create an BusInOut, connected to the specified pins
yihui 5:9b240c1d5251 30 *
yihui 5:9b240c1d5251 31 * @param p<n> DigitalInOut pin to connect to bus bit p<n> (p5-p30, NC)
yihui 5:9b240c1d5251 32 *
yihui 5:9b240c1d5251 33 * @note
yihui 5:9b240c1d5251 34 * It is only required to specify as many pin variables as is required
yihui 5:9b240c1d5251 35 * for the bus; the rest will default to NC (not connected)
yihui 5:9b240c1d5251 36 */
yihui 5:9b240c1d5251 37 BusInOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
yihui 5:9b240c1d5251 38 PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
yihui 5:9b240c1d5251 39 PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
yihui 5:9b240c1d5251 40 PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC);
yihui 5:9b240c1d5251 41
yihui 5:9b240c1d5251 42 BusInOut(PinName pins[16]);
yihui 5:9b240c1d5251 43
yihui 5:9b240c1d5251 44 virtual ~BusInOut();
yihui 5:9b240c1d5251 45
yihui 5:9b240c1d5251 46 /* Group: Access Methods */
yihui 5:9b240c1d5251 47
yihui 5:9b240c1d5251 48 /** Write the value to the output bus
yihui 5:9b240c1d5251 49 *
yihui 5:9b240c1d5251 50 * @param value An integer specifying a bit to write for every corresponding DigitalInOut pin
yihui 5:9b240c1d5251 51 */
yihui 5:9b240c1d5251 52 void write(int value);
yihui 5:9b240c1d5251 53
yihui 5:9b240c1d5251 54 /** Read the value currently output on the bus
yihui 5:9b240c1d5251 55 *
yihui 5:9b240c1d5251 56 * @returns
yihui 5:9b240c1d5251 57 * An integer with each bit corresponding to associated DigitalInOut pin setting
yihui 5:9b240c1d5251 58 */
yihui 5:9b240c1d5251 59 int read();
yihui 5:9b240c1d5251 60
yihui 5:9b240c1d5251 61 /** Set as an output
yihui 5:9b240c1d5251 62 */
yihui 5:9b240c1d5251 63 void output();
yihui 5:9b240c1d5251 64
yihui 5:9b240c1d5251 65 /** Set as an input
yihui 5:9b240c1d5251 66 */
yihui 5:9b240c1d5251 67 void input();
yihui 5:9b240c1d5251 68
yihui 5:9b240c1d5251 69 /** Set the input pin mode
yihui 5:9b240c1d5251 70 *
yihui 5:9b240c1d5251 71 * @param mode PullUp, PullDown, PullNone
yihui 5:9b240c1d5251 72 */
yihui 5:9b240c1d5251 73 void mode(PinMode pull);
yihui 5:9b240c1d5251 74
yihui 5:9b240c1d5251 75 /** Binary mask of bus pins connected to actual pins (not NC pins)
yihui 5:9b240c1d5251 76 * If bus pin is in NC state make corresponding bit will be cleared (set to 0), else bit will be set to 1
yihui 5:9b240c1d5251 77 *
yihui 5:9b240c1d5251 78 * @returns
yihui 5:9b240c1d5251 79 * Binary mask of connected pins
yihui 5:9b240c1d5251 80 */
yihui 5:9b240c1d5251 81 int mask() {
yihui 5:9b240c1d5251 82 return _nc_mask;
yihui 5:9b240c1d5251 83 }
yihui 5:9b240c1d5251 84
yihui 5:9b240c1d5251 85 #ifdef MBED_OPERATORS
yihui 5:9b240c1d5251 86 /** A shorthand for write()
yihui 5:9b240c1d5251 87 */
yihui 5:9b240c1d5251 88 BusInOut& operator= (int v);
yihui 5:9b240c1d5251 89 BusInOut& operator= (BusInOut& rhs);
yihui 5:9b240c1d5251 90
yihui 5:9b240c1d5251 91 /** Access to particular bit in random-iterator fashion
yihui 5:9b240c1d5251 92 */
yihui 5:9b240c1d5251 93 DigitalInOut& operator[] (int index);
yihui 5:9b240c1d5251 94
yihui 5:9b240c1d5251 95 /** A shorthand for read()
yihui 5:9b240c1d5251 96 */
yihui 5:9b240c1d5251 97 operator int();
yihui 5:9b240c1d5251 98 #endif
yihui 5:9b240c1d5251 99
yihui 5:9b240c1d5251 100 protected:
yihui 5:9b240c1d5251 101 DigitalInOut* _pin[16];
yihui 5:9b240c1d5251 102
yihui 5:9b240c1d5251 103 /** Mask of bus's NC pins
yihui 5:9b240c1d5251 104 * If bit[n] is set to 1 - pin is connected
yihui 5:9b240c1d5251 105 * if bit[n] is cleared - pin is not connected (NC)
yihui 5:9b240c1d5251 106 */
yihui 5:9b240c1d5251 107 int _nc_mask;
yihui 5:9b240c1d5251 108
yihui 5:9b240c1d5251 109 /* disallow copy constructor and assignment operators */
yihui 5:9b240c1d5251 110 private:
yihui 5:9b240c1d5251 111 BusInOut(const BusInOut&);
yihui 5:9b240c1d5251 112 BusInOut & operator = (const BusInOut&);
yihui 5:9b240c1d5251 113 };
yihui 5:9b240c1d5251 114
yihui 5:9b240c1d5251 115 } // namespace mbed
yihui 5:9b240c1d5251 116
yihui 5:9b240c1d5251 117 #endif