SDCard version

Fork of gr-peach-opencv-project-sd-card by the do

Committer:
thedo
Date:
Fri Jul 21 01:26:54 2017 +0000
Revision:
167:2ee3e82cb6f5
gr-peach-opencv-project-sd-card

Who changed what in which revision?

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