Home Alert System

Dependencies:   PWM_Tone_Library DHT

Committer:
aziz111
Date:
Fri Mar 08 17:15:02 2019 +0000
Revision:
5:569a4894abc1
Parent:
3:78f223d34f36
Final

Who changed what in which revision?

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