Mangue Baja Box

Dependencies:   mbed

Committer:
einsteingustavo
Date:
Mon Jul 29 20:38:00 2019 +0000
Revision:
0:0dee8840a1c0
Mangue Baja Box

Who changed what in which revision?

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