fix nrf51822 i2c & spi conflict

Dependencies:   BLE_API eMPL_MPU6050 nRF51822

Fork of Seeed_Tiny_BLE_Flash by Darren Huang

Committer:
yihui
Date:
Tue Nov 17 07:48:56 2015 +0000
Revision:
5:b8c02645e6af
fix i2c & spi conflict

Who changed what in which revision?

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