mbed

Dependents:   DHTSensor_Test K64F_eCompass_OneNET_JW

Committer:
mbotkinl
Date:
Wed Feb 25 20:22:22 2015 +0000
Revision:
0:2cc6bb4d7fea
Working code to read Temperature and Humidity readings

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbotkinl 0:2cc6bb4d7fea 1 /* mbed Microcontroller Library
mbotkinl 0:2cc6bb4d7fea 2 * Copyright (c) 2006-2013 ARM Limited
mbotkinl 0:2cc6bb4d7fea 3 *
mbotkinl 0:2cc6bb4d7fea 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbotkinl 0:2cc6bb4d7fea 5 * you may not use this file except in compliance with the License.
mbotkinl 0:2cc6bb4d7fea 6 * You may obtain a copy of the License at
mbotkinl 0:2cc6bb4d7fea 7 *
mbotkinl 0:2cc6bb4d7fea 8 * http://www.apache.org/licenses/LICENSE-2.0
mbotkinl 0:2cc6bb4d7fea 9 *
mbotkinl 0:2cc6bb4d7fea 10 * Unless required by applicable law or agreed to in writing, software
mbotkinl 0:2cc6bb4d7fea 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbotkinl 0:2cc6bb4d7fea 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbotkinl 0:2cc6bb4d7fea 13 * See the License for the specific language governing permissions and
mbotkinl 0:2cc6bb4d7fea 14 * limitations under the License.
mbotkinl 0:2cc6bb4d7fea 15 */
mbotkinl 0:2cc6bb4d7fea 16 #ifndef MBED_BUSOUT_H
mbotkinl 0:2cc6bb4d7fea 17 #define MBED_BUSOUT_H
mbotkinl 0:2cc6bb4d7fea 18
mbotkinl 0:2cc6bb4d7fea 19 #include "DigitalOut.h"
mbotkinl 0:2cc6bb4d7fea 20
mbotkinl 0:2cc6bb4d7fea 21 namespace mbed {
mbotkinl 0:2cc6bb4d7fea 22
mbotkinl 0:2cc6bb4d7fea 23 /** A digital output bus, used for setting the state of a collection of pins
mbotkinl 0:2cc6bb4d7fea 24 */
mbotkinl 0:2cc6bb4d7fea 25 class BusOut {
mbotkinl 0:2cc6bb4d7fea 26
mbotkinl 0:2cc6bb4d7fea 27 public:
mbotkinl 0:2cc6bb4d7fea 28
mbotkinl 0:2cc6bb4d7fea 29 /** Create an BusOut, connected to the specified pins
mbotkinl 0:2cc6bb4d7fea 30 *
mbotkinl 0:2cc6bb4d7fea 31 * @param p<n> DigitalOut pin to connect to bus bit <n> (p5-p30, NC)
mbotkinl 0:2cc6bb4d7fea 32 *
mbotkinl 0:2cc6bb4d7fea 33 * @note
mbotkinl 0:2cc6bb4d7fea 34 * It is only required to specify as many pin variables as is required
mbotkinl 0:2cc6bb4d7fea 35 * for the bus; the rest will default to NC (not connected)
mbotkinl 0:2cc6bb4d7fea 36 */
mbotkinl 0:2cc6bb4d7fea 37 BusOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
mbotkinl 0:2cc6bb4d7fea 38 PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
mbotkinl 0:2cc6bb4d7fea 39 PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
mbotkinl 0:2cc6bb4d7fea 40 PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC);
mbotkinl 0:2cc6bb4d7fea 41
mbotkinl 0:2cc6bb4d7fea 42 BusOut(PinName pins[16]);
mbotkinl 0:2cc6bb4d7fea 43
mbotkinl 0:2cc6bb4d7fea 44 virtual ~BusOut();
mbotkinl 0:2cc6bb4d7fea 45
mbotkinl 0:2cc6bb4d7fea 46 /** Write the value to the output bus
mbotkinl 0:2cc6bb4d7fea 47 *
mbotkinl 0:2cc6bb4d7fea 48 * @param value An integer specifying a bit to write for every corresponding DigitalOut pin
mbotkinl 0:2cc6bb4d7fea 49 */
mbotkinl 0:2cc6bb4d7fea 50 void write(int value);
mbotkinl 0:2cc6bb4d7fea 51
mbotkinl 0:2cc6bb4d7fea 52 /** Read the value currently output on the bus
mbotkinl 0:2cc6bb4d7fea 53 *
mbotkinl 0:2cc6bb4d7fea 54 * @returns
mbotkinl 0:2cc6bb4d7fea 55 * An integer with each bit corresponding to associated DigitalOut pin setting
mbotkinl 0:2cc6bb4d7fea 56 */
mbotkinl 0:2cc6bb4d7fea 57 int read();
mbotkinl 0:2cc6bb4d7fea 58
mbotkinl 0:2cc6bb4d7fea 59 #ifdef MBED_OPERATORS
mbotkinl 0:2cc6bb4d7fea 60 /** A shorthand for write()
mbotkinl 0:2cc6bb4d7fea 61 */
mbotkinl 0:2cc6bb4d7fea 62 BusOut& operator= (int v);
mbotkinl 0:2cc6bb4d7fea 63 BusOut& operator= (BusOut& rhs);
mbotkinl 0:2cc6bb4d7fea 64
mbotkinl 0:2cc6bb4d7fea 65 /** A shorthand for read()
mbotkinl 0:2cc6bb4d7fea 66 */
mbotkinl 0:2cc6bb4d7fea 67 operator int();
mbotkinl 0:2cc6bb4d7fea 68 #endif
mbotkinl 0:2cc6bb4d7fea 69
mbotkinl 0:2cc6bb4d7fea 70 protected:
mbotkinl 0:2cc6bb4d7fea 71 DigitalOut* _pin[16];
mbotkinl 0:2cc6bb4d7fea 72
mbotkinl 0:2cc6bb4d7fea 73 /* disallow copy constructor and assignment operators */
mbotkinl 0:2cc6bb4d7fea 74 private:
mbotkinl 0:2cc6bb4d7fea 75 BusOut(const BusOut&);
mbotkinl 0:2cc6bb4d7fea 76 BusOut & operator = (const BusOut&);
mbotkinl 0:2cc6bb4d7fea 77 };
mbotkinl 0:2cc6bb4d7fea 78
mbotkinl 0:2cc6bb4d7fea 79 } // namespace mbed
mbotkinl 0:2cc6bb4d7fea 80
mbotkinl 0:2cc6bb4d7fea 81 #endif