mbed(SerialHalfDuplex入り)
Fork of mbed by
BusOut.h@64:e3affc9e7238, 2013-08-05 (annotated)
- Committer:
- bogdanm
- Date:
- Mon Aug 05 12:28:09 2013 +0300
- Revision:
- 64:e3affc9e7238
- Parent:
- 59:0883845fe643
- Child:
- 65:5798e58a58b1
New build system structure, new target (LPC1347), bug fixes (I2C read/write errors, LPC11U24 memory map and others)
Who changed what in which revision?
User | Revision | Line number | New 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. |
simon.ford@mbed.co.uk | 0:82220227f4fa | 15 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 16 | #ifndef MBED_BUSOUT_H |
simon.ford@mbed.co.uk | 0:82220227f4fa | 17 | #define MBED_BUSOUT_H |
simon.ford@mbed.co.uk | 0:82220227f4fa | 18 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 19 | #include "DigitalOut.h" |
simon.ford@mbed.co.uk | 0:82220227f4fa | 20 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 21 | namespace mbed { |
simon.ford@mbed.co.uk | 0:82220227f4fa | 22 | |
emilmont | 43:e2ed12d17f06 | 23 | /** A digital output bus, used for setting the state of a collection of pins |
simon.ford@mbed.co.uk | 0:82220227f4fa | 24 | */ |
emilmont | 44:24d45a770a51 | 25 | class BusOut { |
simon.ford@mbed.co.uk | 0:82220227f4fa | 26 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 27 | public: |
simon.ford@mbed.co.uk | 0:82220227f4fa | 28 | |
emilmont | 43:e2ed12d17f06 | 29 | /** Create an BusOut, connected to the specified pins |
emilmont | 43:e2ed12d17f06 | 30 | * |
emilmont | 43:e2ed12d17f06 | 31 | * @param p<n> DigitalOut pin to connect to bus bit <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 | BusOut(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); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 41 | |
emilmont | 44:24d45a770a51 | 42 | BusOut(PinName pins[16]); |
simon.ford@mbed.co.uk | 5:62573be585e9 | 43 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 44 | virtual ~BusOut(); |
emilmont | 44:24d45a770a51 | 45 | |
emilmont | 43:e2ed12d17f06 | 46 | /** Write the value to the output bus |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 47 | * |
emilmont | 43:e2ed12d17f06 | 48 | * @param value An integer specifying a bit to write for every corresponding DigitalOut pin |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 49 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 50 | void write(int value); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 51 | |
emilmont | 43:e2ed12d17f06 | 52 | /** Read the value currently output on the bus |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 53 | * |
emilmont | 43:e2ed12d17f06 | 54 | * @returns |
emilmont | 43:e2ed12d17f06 | 55 | * An integer with each bit corresponding to associated DigitalOut pin setting |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 56 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 57 | int read(); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 58 | |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 59 | #ifdef MBED_OPERATORS |
emilmont | 43:e2ed12d17f06 | 60 | /** A shorthand for write() |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 61 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 62 | BusOut& operator= (int v); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 63 | BusOut& operator= (BusOut& rhs); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 64 | |
emilmont | 43:e2ed12d17f06 | 65 | /** A shorthand for read() |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 66 | */ |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 67 | operator int(); |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 68 | #endif |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 69 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 70 | protected: |
rolf.meyer@arm.com | 11:1c1ebd0324fa | 71 | DigitalOut* _pin[16]; |
simon.ford@mbed.co.uk | 0:82220227f4fa | 72 | }; |
simon.ford@mbed.co.uk | 0:82220227f4fa | 73 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 74 | } // namespace mbed |
simon.ford@mbed.co.uk | 0:82220227f4fa | 75 | |
simon.ford@mbed.co.uk | 1:6b7f447ca868 | 76 | #endif |