1 /* mbed Microcontroller Library
2 * Copyright (c) 2006-2013 ARM Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #ifndef MBED_BUSINOUT_H
17 #define MBED_BUSINOUT_H
19 #include "DigitalInOut.h"
23 /** A digital input output bus, used for setting the state of a collection of pins
29 /** Create an BusInOut, connected to the specified pins
31 * @param p<n> DigitalInOut pin to connect to bus bit p<n> (p5-p30, NC)
34 * It is only required to specify as many pin variables as is required
35 * for the bus; the rest will default to NC (not connected)
37 BusInOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
38 PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
39 PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
40 PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC);
42 BusInOut(PinName pins[16]);
46 /* Group: Access Methods */
48 /** Write the value to the output bus
50 * @param value An integer specifying a bit to write for every corresponding DigitalInOut pin
52 void write(int value);
54 /** Read the value currently output on the bus
57 * An integer with each bit corresponding to associated DigitalInOut pin setting
69 /** Set the input pin mode
71 * @param mode PullUp, PullDown, PullNone
73 void mode(PinMode pull);
75 /** Binary mask of bus pins connected to actual pins (not NC pins)
76 * If bus pin is in NC state make corresponding bit will be cleared (set to 0), else bit will be set to 1
79 * Binary mask of connected pins
86 /** A shorthand for write()
88 BusInOut& operator= (int v);
89 BusInOut& operator= (BusInOut& rhs);
91 /** Access to particular bit in random-iterator fashion
93 DigitalInOut& operator[] (int index);
95 /** A shorthand for read()
101 DigitalInOut* _pin[16];
103 /** Mask of bus's NC pins
104 * If bit[n] is set to 1 - pin is connected
105 * if bit[n] is cleared - pin is not connected (NC)
109 /* disallow copy constructor and assignment operators */
111 BusInOut(const BusInOut&);
112 BusInOut & operator = (const BusInOut&);