Kiyoteru Hayama / mbedRobotracer_Edu
Committer:
hayama
Date:
Wed Jun 19 10:00:41 2013 +0000
Revision:
0:da22b0b4395a
mbed robotracer for education ver 1.0

Who changed what in which revision?

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