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_BUSINOUT_H
einsteingustavo 0:0dee8840a1c0 17 #define MBED_BUSINOUT_H
einsteingustavo 0:0dee8840a1c0 18
einsteingustavo 0:0dee8840a1c0 19 #include "DigitalInOut.h"
einsteingustavo 0:0dee8840a1c0 20
einsteingustavo 0:0dee8840a1c0 21 namespace mbed {
einsteingustavo 0:0dee8840a1c0 22
einsteingustavo 0:0dee8840a1c0 23 /** A digital input output bus, used for setting the state of a collection of pins
einsteingustavo 0:0dee8840a1c0 24 */
einsteingustavo 0:0dee8840a1c0 25 class BusInOut {
einsteingustavo 0:0dee8840a1c0 26
einsteingustavo 0:0dee8840a1c0 27 public:
einsteingustavo 0:0dee8840a1c0 28
einsteingustavo 0:0dee8840a1c0 29 /** Create an BusInOut, connected to the specified pins
einsteingustavo 0:0dee8840a1c0 30 *
einsteingustavo 0:0dee8840a1c0 31 * @param p<n> DigitalInOut pin to connect to bus bit p<n> (p5-p30, NC)
einsteingustavo 0:0dee8840a1c0 32 *
einsteingustavo 0:0dee8840a1c0 33 * @note
einsteingustavo 0:0dee8840a1c0 34 * It is only required to specify as many pin variables as is required
einsteingustavo 0:0dee8840a1c0 35 * for the bus; the rest will default to NC (not connected)
einsteingustavo 0:0dee8840a1c0 36 */
einsteingustavo 0:0dee8840a1c0 37 BusInOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
einsteingustavo 0:0dee8840a1c0 38 PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
einsteingustavo 0:0dee8840a1c0 39 PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
einsteingustavo 0:0dee8840a1c0 40 PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC);
einsteingustavo 0:0dee8840a1c0 41
einsteingustavo 0:0dee8840a1c0 42 BusInOut(PinName pins[16]);
einsteingustavo 0:0dee8840a1c0 43
einsteingustavo 0:0dee8840a1c0 44 virtual ~BusInOut();
einsteingustavo 0:0dee8840a1c0 45
einsteingustavo 0:0dee8840a1c0 46 /* Group: Access Methods */
einsteingustavo 0:0dee8840a1c0 47
einsteingustavo 0:0dee8840a1c0 48 /** Write the value to the output bus
einsteingustavo 0:0dee8840a1c0 49 *
einsteingustavo 0:0dee8840a1c0 50 * @param value An integer specifying a bit to write for every corresponding DigitalInOut pin
einsteingustavo 0:0dee8840a1c0 51 */
einsteingustavo 0:0dee8840a1c0 52 void write(int value);
einsteingustavo 0:0dee8840a1c0 53
einsteingustavo 0:0dee8840a1c0 54 /** Read the value currently output on the bus
einsteingustavo 0:0dee8840a1c0 55 *
einsteingustavo 0:0dee8840a1c0 56 * @returns
einsteingustavo 0:0dee8840a1c0 57 * An integer with each bit corresponding to associated DigitalInOut pin setting
einsteingustavo 0:0dee8840a1c0 58 */
einsteingustavo 0:0dee8840a1c0 59 int read();
einsteingustavo 0:0dee8840a1c0 60
einsteingustavo 0:0dee8840a1c0 61 /** Set as an output
einsteingustavo 0:0dee8840a1c0 62 */
einsteingustavo 0:0dee8840a1c0 63 void output();
einsteingustavo 0:0dee8840a1c0 64
einsteingustavo 0:0dee8840a1c0 65 /** Set as an input
einsteingustavo 0:0dee8840a1c0 66 */
einsteingustavo 0:0dee8840a1c0 67 void input();
einsteingustavo 0:0dee8840a1c0 68
einsteingustavo 0:0dee8840a1c0 69 /** Set the input pin mode
einsteingustavo 0:0dee8840a1c0 70 *
einsteingustavo 0:0dee8840a1c0 71 * @param mode PullUp, PullDown, PullNone
einsteingustavo 0:0dee8840a1c0 72 */
einsteingustavo 0:0dee8840a1c0 73 void mode(PinMode pull);
einsteingustavo 0:0dee8840a1c0 74
einsteingustavo 0:0dee8840a1c0 75 /** Binary mask of bus pins connected to actual pins (not NC pins)
einsteingustavo 0:0dee8840a1c0 76 * 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 77 *
einsteingustavo 0:0dee8840a1c0 78 * @returns
einsteingustavo 0:0dee8840a1c0 79 * Binary mask of connected pins
einsteingustavo 0:0dee8840a1c0 80 */
einsteingustavo 0:0dee8840a1c0 81 int mask() {
einsteingustavo 0:0dee8840a1c0 82 return _nc_mask;
einsteingustavo 0:0dee8840a1c0 83 }
einsteingustavo 0:0dee8840a1c0 84
einsteingustavo 0:0dee8840a1c0 85 #ifdef MBED_OPERATORS
einsteingustavo 0:0dee8840a1c0 86 /** A shorthand for write()
einsteingustavo 0:0dee8840a1c0 87 */
einsteingustavo 0:0dee8840a1c0 88 BusInOut& operator= (int v);
einsteingustavo 0:0dee8840a1c0 89 BusInOut& operator= (BusInOut& rhs);
einsteingustavo 0:0dee8840a1c0 90
einsteingustavo 0:0dee8840a1c0 91 /** Access to particular bit in random-iterator fashion
einsteingustavo 0:0dee8840a1c0 92 */
einsteingustavo 0:0dee8840a1c0 93 DigitalInOut& operator[] (int index);
einsteingustavo 0:0dee8840a1c0 94
einsteingustavo 0:0dee8840a1c0 95 /** A shorthand for read()
einsteingustavo 0:0dee8840a1c0 96 */
einsteingustavo 0:0dee8840a1c0 97 operator int();
einsteingustavo 0:0dee8840a1c0 98 #endif
einsteingustavo 0:0dee8840a1c0 99
einsteingustavo 0:0dee8840a1c0 100 protected:
einsteingustavo 0:0dee8840a1c0 101 DigitalInOut* _pin[16];
einsteingustavo 0:0dee8840a1c0 102
einsteingustavo 0:0dee8840a1c0 103 /** Mask of bus's NC pins
einsteingustavo 0:0dee8840a1c0 104 * If bit[n] is set to 1 - pin is connected
einsteingustavo 0:0dee8840a1c0 105 * if bit[n] is cleared - pin is not connected (NC)
einsteingustavo 0:0dee8840a1c0 106 */
einsteingustavo 0:0dee8840a1c0 107 int _nc_mask;
einsteingustavo 0:0dee8840a1c0 108
einsteingustavo 0:0dee8840a1c0 109 /* disallow copy constructor and assignment operators */
einsteingustavo 0:0dee8840a1c0 110 private:
einsteingustavo 0:0dee8840a1c0 111 BusInOut(const BusInOut&);
einsteingustavo 0:0dee8840a1c0 112 BusInOut & operator = (const BusInOut&);
einsteingustavo 0:0dee8840a1c0 113 };
einsteingustavo 0:0dee8840a1c0 114
einsteingustavo 0:0dee8840a1c0 115 } // namespace mbed
einsteingustavo 0:0dee8840a1c0 116
einsteingustavo 0:0dee8840a1c0 117 #endif
einsteingustavo 0:0dee8840a1c0 118