IoT Home Alarm System
Dependents: IoTBurglar_and_Fire_AlarmSystem
BusIn.h@0:2f388b030837, 2016-04-29 (annotated)
- Committer:
- kbrahmbhatt6
- Date:
- Fri Apr 29 06:59:59 2016 +0000
- Revision:
- 0:2f388b030837
1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kbrahmbhatt6 | 0:2f388b030837 | 1 | /* mbed Microcontroller Library |
kbrahmbhatt6 | 0:2f388b030837 | 2 | * Copyright (c) 2006-2013 ARM Limited |
kbrahmbhatt6 | 0:2f388b030837 | 3 | * |
kbrahmbhatt6 | 0:2f388b030837 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
kbrahmbhatt6 | 0:2f388b030837 | 5 | * you may not use this file except in compliance with the License. |
kbrahmbhatt6 | 0:2f388b030837 | 6 | * You may obtain a copy of the License at |
kbrahmbhatt6 | 0:2f388b030837 | 7 | * |
kbrahmbhatt6 | 0:2f388b030837 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
kbrahmbhatt6 | 0:2f388b030837 | 9 | * |
kbrahmbhatt6 | 0:2f388b030837 | 10 | * Unless required by applicable law or agreed to in writing, software |
kbrahmbhatt6 | 0:2f388b030837 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
kbrahmbhatt6 | 0:2f388b030837 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kbrahmbhatt6 | 0:2f388b030837 | 13 | * See the License for the specific language governing permissions and |
kbrahmbhatt6 | 0:2f388b030837 | 14 | * limitations under the License. |
kbrahmbhatt6 | 0:2f388b030837 | 15 | */ |
kbrahmbhatt6 | 0:2f388b030837 | 16 | #ifndef MBED_BUSIN_H |
kbrahmbhatt6 | 0:2f388b030837 | 17 | #define MBED_BUSIN_H |
kbrahmbhatt6 | 0:2f388b030837 | 18 | |
kbrahmbhatt6 | 0:2f388b030837 | 19 | #include "platform.h" |
kbrahmbhatt6 | 0:2f388b030837 | 20 | #include "DigitalIn.h" |
kbrahmbhatt6 | 0:2f388b030837 | 21 | |
kbrahmbhatt6 | 0:2f388b030837 | 22 | namespace mbed { |
kbrahmbhatt6 | 0:2f388b030837 | 23 | |
kbrahmbhatt6 | 0:2f388b030837 | 24 | /** A digital input bus, used for reading the state of a collection of pins |
kbrahmbhatt6 | 0:2f388b030837 | 25 | */ |
kbrahmbhatt6 | 0:2f388b030837 | 26 | class BusIn { |
kbrahmbhatt6 | 0:2f388b030837 | 27 | |
kbrahmbhatt6 | 0:2f388b030837 | 28 | public: |
kbrahmbhatt6 | 0:2f388b030837 | 29 | /* Group: Configuration Methods */ |
kbrahmbhatt6 | 0:2f388b030837 | 30 | |
kbrahmbhatt6 | 0:2f388b030837 | 31 | /** Create an BusIn, connected to the specified pins |
kbrahmbhatt6 | 0:2f388b030837 | 32 | * |
kbrahmbhatt6 | 0:2f388b030837 | 33 | * @param <n> DigitalIn pin to connect to bus bit <n> (p5-p30, NC) |
kbrahmbhatt6 | 0:2f388b030837 | 34 | * |
kbrahmbhatt6 | 0:2f388b030837 | 35 | * @note |
kbrahmbhatt6 | 0:2f388b030837 | 36 | * It is only required to specify as many pin variables as is required |
kbrahmbhatt6 | 0:2f388b030837 | 37 | * for the bus; the rest will default to NC (not connected) |
kbrahmbhatt6 | 0:2f388b030837 | 38 | */ |
kbrahmbhatt6 | 0:2f388b030837 | 39 | BusIn(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC, |
kbrahmbhatt6 | 0:2f388b030837 | 40 | PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC, |
kbrahmbhatt6 | 0:2f388b030837 | 41 | PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC, |
kbrahmbhatt6 | 0:2f388b030837 | 42 | PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC); |
kbrahmbhatt6 | 0:2f388b030837 | 43 | |
kbrahmbhatt6 | 0:2f388b030837 | 44 | BusIn(PinName pins[16]); |
kbrahmbhatt6 | 0:2f388b030837 | 45 | |
kbrahmbhatt6 | 0:2f388b030837 | 46 | virtual ~BusIn(); |
kbrahmbhatt6 | 0:2f388b030837 | 47 | |
kbrahmbhatt6 | 0:2f388b030837 | 48 | /** Read the value of the input bus |
kbrahmbhatt6 | 0:2f388b030837 | 49 | * |
kbrahmbhatt6 | 0:2f388b030837 | 50 | * @returns |
kbrahmbhatt6 | 0:2f388b030837 | 51 | * An integer with each bit corresponding to the value read from the associated DigitalIn pin |
kbrahmbhatt6 | 0:2f388b030837 | 52 | */ |
kbrahmbhatt6 | 0:2f388b030837 | 53 | int read(); |
kbrahmbhatt6 | 0:2f388b030837 | 54 | |
kbrahmbhatt6 | 0:2f388b030837 | 55 | /** Set the input pin mode |
kbrahmbhatt6 | 0:2f388b030837 | 56 | * |
kbrahmbhatt6 | 0:2f388b030837 | 57 | * @param mode PullUp, PullDown, PullNone |
kbrahmbhatt6 | 0:2f388b030837 | 58 | */ |
kbrahmbhatt6 | 0:2f388b030837 | 59 | void mode(PinMode pull); |
kbrahmbhatt6 | 0:2f388b030837 | 60 | |
kbrahmbhatt6 | 0:2f388b030837 | 61 | #ifdef MBED_OPERATORS |
kbrahmbhatt6 | 0:2f388b030837 | 62 | /** A shorthand for read() |
kbrahmbhatt6 | 0:2f388b030837 | 63 | */ |
kbrahmbhatt6 | 0:2f388b030837 | 64 | operator int(); |
kbrahmbhatt6 | 0:2f388b030837 | 65 | #endif |
kbrahmbhatt6 | 0:2f388b030837 | 66 | |
kbrahmbhatt6 | 0:2f388b030837 | 67 | protected: |
kbrahmbhatt6 | 0:2f388b030837 | 68 | DigitalIn* _pin[16]; |
kbrahmbhatt6 | 0:2f388b030837 | 69 | }; |
kbrahmbhatt6 | 0:2f388b030837 | 70 | |
kbrahmbhatt6 | 0:2f388b030837 | 71 | } // namespace mbed |
kbrahmbhatt6 | 0:2f388b030837 | 72 | |
kbrahmbhatt6 | 0:2f388b030837 | 73 | #endif |