logi loader fork from jpiat
Fork of mbed-src by
api/BusIn.h@565:5ad6216dec17, 2015-06-09 (annotated)
- Committer:
- fragment
- Date:
- Tue Jun 09 21:25:28 2015 +0000
- Revision:
- 565:5ad6216dec17
- Parent:
- 455:8bc3a354916d
updated header - disable rtc, correct osc freq. Turn on led at startup
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 13:0645d8841f51 | 1 | /* mbed Microcontroller Library |
bogdanm | 13:0645d8841f51 | 2 | * Copyright (c) 2006-2013 ARM Limited |
bogdanm | 13:0645d8841f51 | 3 | * |
bogdanm | 13:0645d8841f51 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
bogdanm | 13:0645d8841f51 | 5 | * you may not use this file except in compliance with the License. |
bogdanm | 13:0645d8841f51 | 6 | * You may obtain a copy of the License at |
bogdanm | 13:0645d8841f51 | 7 | * |
bogdanm | 13:0645d8841f51 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
bogdanm | 13:0645d8841f51 | 9 | * |
bogdanm | 13:0645d8841f51 | 10 | * Unless required by applicable law or agreed to in writing, software |
bogdanm | 13:0645d8841f51 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
bogdanm | 13:0645d8841f51 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
bogdanm | 13:0645d8841f51 | 13 | * See the License for the specific language governing permissions and |
bogdanm | 13:0645d8841f51 | 14 | * limitations under the License. |
bogdanm | 13:0645d8841f51 | 15 | */ |
bogdanm | 13:0645d8841f51 | 16 | #ifndef MBED_BUSIN_H |
bogdanm | 13:0645d8841f51 | 17 | #define MBED_BUSIN_H |
bogdanm | 13:0645d8841f51 | 18 | |
bogdanm | 13:0645d8841f51 | 19 | #include "platform.h" |
bogdanm | 13:0645d8841f51 | 20 | #include "DigitalIn.h" |
bogdanm | 13:0645d8841f51 | 21 | |
bogdanm | 13:0645d8841f51 | 22 | namespace mbed { |
bogdanm | 13:0645d8841f51 | 23 | |
bogdanm | 13:0645d8841f51 | 24 | /** A digital input bus, used for reading the state of a collection of pins |
bogdanm | 13:0645d8841f51 | 25 | */ |
bogdanm | 13:0645d8841f51 | 26 | class BusIn { |
bogdanm | 13:0645d8841f51 | 27 | |
bogdanm | 13:0645d8841f51 | 28 | public: |
bogdanm | 13:0645d8841f51 | 29 | /* Group: Configuration Methods */ |
bogdanm | 13:0645d8841f51 | 30 | |
bogdanm | 13:0645d8841f51 | 31 | /** Create an BusIn, connected to the specified pins |
bogdanm | 13:0645d8841f51 | 32 | * |
bogdanm | 13:0645d8841f51 | 33 | * @param <n> DigitalIn pin to connect to bus bit <n> (p5-p30, NC) |
bogdanm | 13:0645d8841f51 | 34 | * |
bogdanm | 13:0645d8841f51 | 35 | * @note |
bogdanm | 13:0645d8841f51 | 36 | * It is only required to specify as many pin variables as is required |
bogdanm | 13:0645d8841f51 | 37 | * for the bus; the rest will default to NC (not connected) |
bogdanm | 13:0645d8841f51 | 38 | */ |
bogdanm | 13:0645d8841f51 | 39 | BusIn(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC, |
bogdanm | 13:0645d8841f51 | 40 | PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC, |
bogdanm | 13:0645d8841f51 | 41 | PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC, |
bogdanm | 13:0645d8841f51 | 42 | PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC); |
bogdanm | 13:0645d8841f51 | 43 | |
bogdanm | 13:0645d8841f51 | 44 | BusIn(PinName pins[16]); |
bogdanm | 13:0645d8841f51 | 45 | |
bogdanm | 13:0645d8841f51 | 46 | virtual ~BusIn(); |
bogdanm | 13:0645d8841f51 | 47 | |
bogdanm | 13:0645d8841f51 | 48 | /** Read the value of the input bus |
bogdanm | 13:0645d8841f51 | 49 | * |
bogdanm | 13:0645d8841f51 | 50 | * @returns |
bogdanm | 13:0645d8841f51 | 51 | * An integer with each bit corresponding to the value read from the associated DigitalIn pin |
bogdanm | 13:0645d8841f51 | 52 | */ |
bogdanm | 13:0645d8841f51 | 53 | int read(); |
mbed_official | 212:34d62c0b2af6 | 54 | |
mbed_official | 160:6870f452afa4 | 55 | /** Set the input pin mode |
mbed_official | 160:6870f452afa4 | 56 | * |
mbed_official | 160:6870f452afa4 | 57 | * @param mode PullUp, PullDown, PullNone |
mbed_official | 160:6870f452afa4 | 58 | */ |
mbed_official | 160:6870f452afa4 | 59 | void mode(PinMode pull); |
mbed_official | 212:34d62c0b2af6 | 60 | |
mbed_official | 455:8bc3a354916d | 61 | /** Binary mask of bus pins connected to actual pins (not NC pins) |
mbed_official | 455:8bc3a354916d | 62 | * If bus pin is in NC state make corresponding bit will be cleared (set to 0), else bit will be set to 1 |
mbed_official | 455:8bc3a354916d | 63 | * |
mbed_official | 455:8bc3a354916d | 64 | * @returns |
mbed_official | 455:8bc3a354916d | 65 | * Binary mask of connected pins |
mbed_official | 455:8bc3a354916d | 66 | */ |
mbed_official | 455:8bc3a354916d | 67 | int mask() { |
mbed_official | 455:8bc3a354916d | 68 | return _nc_mask; |
mbed_official | 455:8bc3a354916d | 69 | } |
mbed_official | 455:8bc3a354916d | 70 | |
bogdanm | 13:0645d8841f51 | 71 | #ifdef MBED_OPERATORS |
bogdanm | 13:0645d8841f51 | 72 | /** A shorthand for read() |
bogdanm | 13:0645d8841f51 | 73 | */ |
bogdanm | 13:0645d8841f51 | 74 | operator int(); |
mbed_official | 455:8bc3a354916d | 75 | |
mbed_official | 455:8bc3a354916d | 76 | /** Access to particular bit in random-iterator fashion |
mbed_official | 455:8bc3a354916d | 77 | */ |
mbed_official | 455:8bc3a354916d | 78 | DigitalIn & operator[] (int index); |
bogdanm | 13:0645d8841f51 | 79 | #endif |
bogdanm | 13:0645d8841f51 | 80 | |
bogdanm | 13:0645d8841f51 | 81 | protected: |
bogdanm | 13:0645d8841f51 | 82 | DigitalIn* _pin[16]; |
mbed_official | 212:34d62c0b2af6 | 83 | |
mbed_official | 455:8bc3a354916d | 84 | /** Mask of bus's NC pins |
mbed_official | 455:8bc3a354916d | 85 | * If bit[n] is set to 1 - pin is connected |
mbed_official | 455:8bc3a354916d | 86 | * if bit[n] is cleared - pin is not connected (NC) |
mbed_official | 455:8bc3a354916d | 87 | */ |
mbed_official | 455:8bc3a354916d | 88 | int _nc_mask; |
mbed_official | 455:8bc3a354916d | 89 | |
mbed_official | 212:34d62c0b2af6 | 90 | /* disallow copy constructor and assignment operators */ |
mbed_official | 212:34d62c0b2af6 | 91 | private: |
mbed_official | 212:34d62c0b2af6 | 92 | BusIn(const BusIn&); |
mbed_official | 212:34d62c0b2af6 | 93 | BusIn & operator = (const BusIn&); |
bogdanm | 13:0645d8841f51 | 94 | }; |
bogdanm | 13:0645d8841f51 | 95 | |
bogdanm | 13:0645d8841f51 | 96 | } // namespace mbed |
bogdanm | 13:0645d8841f51 | 97 | |
bogdanm | 13:0645d8841f51 | 98 | #endif |