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_BUSOUT_H
ethaderu 3:78f223d34f36 17 #define MBED_BUSOUT_H
ethaderu 3:78f223d34f36 18
ethaderu 3:78f223d34f36 19 #include "DigitalOut.h"
ethaderu 3:78f223d34f36 20
ethaderu 3:78f223d34f36 21 namespace mbed {
ethaderu 3:78f223d34f36 22
ethaderu 3:78f223d34f36 23 /** A digital output bus, used for setting the state of a collection of pins
ethaderu 3:78f223d34f36 24 */
ethaderu 3:78f223d34f36 25 class BusOut {
ethaderu 3:78f223d34f36 26
ethaderu 3:78f223d34f36 27 public:
ethaderu 3:78f223d34f36 28
ethaderu 3:78f223d34f36 29 /** Create an BusOut, connected to the specified pins
ethaderu 3:78f223d34f36 30 *
ethaderu 3:78f223d34f36 31 * @param p<n> DigitalOut pin to connect to bus bit <n> (p5-p30, NC)
ethaderu 3:78f223d34f36 32 *
ethaderu 3:78f223d34f36 33 * @note
ethaderu 3:78f223d34f36 34 * It is only required to specify as many pin variables as is required
ethaderu 3:78f223d34f36 35 * for the bus; the rest will default to NC (not connected)
ethaderu 3:78f223d34f36 36 */
ethaderu 3:78f223d34f36 37 BusOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
ethaderu 3:78f223d34f36 38 PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
ethaderu 3:78f223d34f36 39 PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
ethaderu 3:78f223d34f36 40 PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC);
ethaderu 3:78f223d34f36 41
ethaderu 3:78f223d34f36 42 BusOut(PinName pins[16]);
ethaderu 3:78f223d34f36 43
ethaderu 3:78f223d34f36 44 virtual ~BusOut();
ethaderu 3:78f223d34f36 45
ethaderu 3:78f223d34f36 46 /** Write the value to the output bus
ethaderu 3:78f223d34f36 47 *
ethaderu 3:78f223d34f36 48 * @param value An integer specifying a bit to write for every corresponding DigitalOut pin
ethaderu 3:78f223d34f36 49 */
ethaderu 3:78f223d34f36 50 void write(int value);
ethaderu 3:78f223d34f36 51
ethaderu 3:78f223d34f36 52 /** Read the value currently output on the bus
ethaderu 3:78f223d34f36 53 *
ethaderu 3:78f223d34f36 54 * @returns
ethaderu 3:78f223d34f36 55 * An integer with each bit corresponding to associated DigitalOut pin setting
ethaderu 3:78f223d34f36 56 */
ethaderu 3:78f223d34f36 57 int read();
ethaderu 3:78f223d34f36 58
ethaderu 3:78f223d34f36 59 /** Binary mask of bus pins connected to actual pins (not NC pins)
ethaderu 3:78f223d34f36 60 * 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 61 *
ethaderu 3:78f223d34f36 62 * @returns
ethaderu 3:78f223d34f36 63 * Binary mask of connected pins
ethaderu 3:78f223d34f36 64 */
ethaderu 3:78f223d34f36 65 int mask() {
ethaderu 3:78f223d34f36 66 return _nc_mask;
ethaderu 3:78f223d34f36 67 }
ethaderu 3:78f223d34f36 68
ethaderu 3:78f223d34f36 69 #ifdef MBED_OPERATORS
ethaderu 3:78f223d34f36 70 /** A shorthand for write()
ethaderu 3:78f223d34f36 71 */
ethaderu 3:78f223d34f36 72 BusOut& operator= (int v);
ethaderu 3:78f223d34f36 73 BusOut& operator= (BusOut& rhs);
ethaderu 3:78f223d34f36 74
ethaderu 3:78f223d34f36 75 /** Access to particular bit in random-iterator fashion
ethaderu 3:78f223d34f36 76 */
ethaderu 3:78f223d34f36 77 DigitalOut& operator[] (int index);
ethaderu 3:78f223d34f36 78
ethaderu 3:78f223d34f36 79 /** A shorthand for read()
ethaderu 3:78f223d34f36 80 */
ethaderu 3:78f223d34f36 81 operator int();
ethaderu 3:78f223d34f36 82 #endif
ethaderu 3:78f223d34f36 83
ethaderu 3:78f223d34f36 84 protected:
ethaderu 3:78f223d34f36 85 DigitalOut* _pin[16];
ethaderu 3:78f223d34f36 86
ethaderu 3:78f223d34f36 87 /** Mask of bus's NC pins
ethaderu 3:78f223d34f36 88 * If bit[n] is set to 1 - pin is connected
ethaderu 3:78f223d34f36 89 * if bit[n] is cleared - pin is not connected (NC)
ethaderu 3:78f223d34f36 90 */
ethaderu 3:78f223d34f36 91 int _nc_mask;
ethaderu 3:78f223d34f36 92
ethaderu 3:78f223d34f36 93 /* disallow copy constructor and assignment operators */
ethaderu 3:78f223d34f36 94 private:
ethaderu 3:78f223d34f36 95 BusOut(const BusOut&);
ethaderu 3:78f223d34f36 96 BusOut & operator = (const BusOut&);
ethaderu 3:78f223d34f36 97 };
ethaderu 3:78f223d34f36 98
ethaderu 3:78f223d34f36 99 } // namespace mbed
ethaderu 3:78f223d34f36 100
ethaderu 3:78f223d34f36 101 #endif