SPKT

Dependencies:   F746_GUI SD_PlayerSkeleton F746_SAI_IO

Committer:
phungductung
Date:
Tue Jun 04 21:37:21 2019 +0000
Revision:
0:8ede47d38d10
SPKT

Who changed what in which revision?

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