...

Dependents:   2doejemplo Labo_TRSE_Drone

Fork of mbed by mbed official

Committer:
emilmont
Date:
Mon Feb 18 11:12:58 2013 +0000
Revision:
59:0883845fe643
Parent:
55:d722ed6a4237
Child:
65:5798e58a58b1
Add pinmap NC terminators for LPC1768 CAN.
Update the license from MIT to Apache v2.
Make the semihost code target independent using opportune defines for the UID and MAC.

Who changed what in which revision?

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