LPC11U35 ADC Tick & USBSerial
Dependents: SmallDoseMeter_SingleCH_AE_lpc11u35_V1_00
mbed/BusOut.h@1:b1a3be5f48ab, 2018-02-19 (annotated)
- Committer:
- H_Tsunemoto
- Date:
- Mon Feb 19 09:09:52 2018 +0000
- Revision:
- 1:b1a3be5f48ab
- Parent:
- 0:871ab6846b18
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
H_Tsunemoto | 0:871ab6846b18 | 1 | /* mbed Microcontroller Library |
H_Tsunemoto | 0:871ab6846b18 | 2 | * Copyright (c) 2006-2013 ARM Limited |
H_Tsunemoto | 0:871ab6846b18 | 3 | * |
H_Tsunemoto | 0:871ab6846b18 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
H_Tsunemoto | 0:871ab6846b18 | 5 | * you may not use this file except in compliance with the License. |
H_Tsunemoto | 0:871ab6846b18 | 6 | * You may obtain a copy of the License at |
H_Tsunemoto | 0:871ab6846b18 | 7 | * |
H_Tsunemoto | 0:871ab6846b18 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
H_Tsunemoto | 0:871ab6846b18 | 9 | * |
H_Tsunemoto | 0:871ab6846b18 | 10 | * Unless required by applicable law or agreed to in writing, software |
H_Tsunemoto | 0:871ab6846b18 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
H_Tsunemoto | 0:871ab6846b18 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
H_Tsunemoto | 0:871ab6846b18 | 13 | * See the License for the specific language governing permissions and |
H_Tsunemoto | 0:871ab6846b18 | 14 | * limitations under the License. |
H_Tsunemoto | 0:871ab6846b18 | 15 | */ |
H_Tsunemoto | 0:871ab6846b18 | 16 | #ifndef MBED_BUSOUT_H |
H_Tsunemoto | 0:871ab6846b18 | 17 | #define MBED_BUSOUT_H |
H_Tsunemoto | 0:871ab6846b18 | 18 | |
H_Tsunemoto | 0:871ab6846b18 | 19 | #include "DigitalOut.h" |
H_Tsunemoto | 0:871ab6846b18 | 20 | |
H_Tsunemoto | 0:871ab6846b18 | 21 | namespace mbed { |
H_Tsunemoto | 0:871ab6846b18 | 22 | |
H_Tsunemoto | 0:871ab6846b18 | 23 | /** A digital output bus, used for setting the state of a collection of pins |
H_Tsunemoto | 0:871ab6846b18 | 24 | */ |
H_Tsunemoto | 0:871ab6846b18 | 25 | class BusOut { |
H_Tsunemoto | 0:871ab6846b18 | 26 | |
H_Tsunemoto | 0:871ab6846b18 | 27 | public: |
H_Tsunemoto | 0:871ab6846b18 | 28 | |
H_Tsunemoto | 0:871ab6846b18 | 29 | /** Create an BusOut, connected to the specified pins |
H_Tsunemoto | 0:871ab6846b18 | 30 | * |
H_Tsunemoto | 0:871ab6846b18 | 31 | * @param p<n> DigitalOut pin to connect to bus bit <n> (p5-p30, NC) |
H_Tsunemoto | 0:871ab6846b18 | 32 | * |
H_Tsunemoto | 0:871ab6846b18 | 33 | * @note |
H_Tsunemoto | 0:871ab6846b18 | 34 | * It is only required to specify as many pin variables as is required |
H_Tsunemoto | 0:871ab6846b18 | 35 | * for the bus; the rest will default to NC (not connected) |
H_Tsunemoto | 0:871ab6846b18 | 36 | */ |
H_Tsunemoto | 0:871ab6846b18 | 37 | BusOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC, |
H_Tsunemoto | 0:871ab6846b18 | 38 | PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC, |
H_Tsunemoto | 0:871ab6846b18 | 39 | PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC, |
H_Tsunemoto | 0:871ab6846b18 | 40 | PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC); |
H_Tsunemoto | 0:871ab6846b18 | 41 | |
H_Tsunemoto | 0:871ab6846b18 | 42 | BusOut(PinName pins[16]); |
H_Tsunemoto | 0:871ab6846b18 | 43 | |
H_Tsunemoto | 0:871ab6846b18 | 44 | virtual ~BusOut(); |
H_Tsunemoto | 0:871ab6846b18 | 45 | |
H_Tsunemoto | 0:871ab6846b18 | 46 | /** Write the value to the output bus |
H_Tsunemoto | 0:871ab6846b18 | 47 | * |
H_Tsunemoto | 0:871ab6846b18 | 48 | * @param value An integer specifying a bit to write for every corresponding DigitalOut pin |
H_Tsunemoto | 0:871ab6846b18 | 49 | */ |
H_Tsunemoto | 0:871ab6846b18 | 50 | void write(int value); |
H_Tsunemoto | 0:871ab6846b18 | 51 | |
H_Tsunemoto | 0:871ab6846b18 | 52 | /** Read the value currently output on the bus |
H_Tsunemoto | 0:871ab6846b18 | 53 | * |
H_Tsunemoto | 0:871ab6846b18 | 54 | * @returns |
H_Tsunemoto | 0:871ab6846b18 | 55 | * An integer with each bit corresponding to associated DigitalOut pin setting |
H_Tsunemoto | 0:871ab6846b18 | 56 | */ |
H_Tsunemoto | 0:871ab6846b18 | 57 | int read(); |
H_Tsunemoto | 0:871ab6846b18 | 58 | |
H_Tsunemoto | 0:871ab6846b18 | 59 | #ifdef MBED_OPERATORS |
H_Tsunemoto | 0:871ab6846b18 | 60 | /** A shorthand for write() |
H_Tsunemoto | 0:871ab6846b18 | 61 | */ |
H_Tsunemoto | 0:871ab6846b18 | 62 | BusOut& operator= (int v); |
H_Tsunemoto | 0:871ab6846b18 | 63 | BusOut& operator= (BusOut& rhs); |
H_Tsunemoto | 0:871ab6846b18 | 64 | |
H_Tsunemoto | 0:871ab6846b18 | 65 | /** A shorthand for read() |
H_Tsunemoto | 0:871ab6846b18 | 66 | */ |
H_Tsunemoto | 0:871ab6846b18 | 67 | operator int(); |
H_Tsunemoto | 0:871ab6846b18 | 68 | #endif |
H_Tsunemoto | 0:871ab6846b18 | 69 | |
H_Tsunemoto | 0:871ab6846b18 | 70 | protected: |
H_Tsunemoto | 0:871ab6846b18 | 71 | DigitalOut* _pin[16]; |
H_Tsunemoto | 0:871ab6846b18 | 72 | |
H_Tsunemoto | 0:871ab6846b18 | 73 | /* disallow copy constructor and assignment operators */ |
H_Tsunemoto | 0:871ab6846b18 | 74 | private: |
H_Tsunemoto | 0:871ab6846b18 | 75 | BusOut(const BusOut&); |
H_Tsunemoto | 0:871ab6846b18 | 76 | BusOut & operator = (const BusOut&); |
H_Tsunemoto | 0:871ab6846b18 | 77 | }; |
H_Tsunemoto | 0:871ab6846b18 | 78 | |
H_Tsunemoto | 0:871ab6846b18 | 79 | } // namespace mbed |
H_Tsunemoto | 0:871ab6846b18 | 80 | |
H_Tsunemoto | 0:871ab6846b18 | 81 | #endif |