PIR grove sensor that sends the sensed data to Thingspeak.com through the wifi module ESP 8266

Dependencies:   mbed

Committer:
skrawool
Date:
Mon Dec 05 16:39:27 2016 +0000
Revision:
0:3954a906acc2
PIR grove sensor that sends the sensed data to thingspeak through the wifi module ESP 8266

Who changed what in which revision?

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