Tim Barry / mbed_blinky_offset
Committer:
timbobazza
Date:
Sat Oct 04 09:07:08 2014 +0000
Revision:
0:2173789ea697
First version

Who changed what in which revision?

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