Auto search for All DS18B20 sensors on data bus

Dependencies:   mbed

Committer:
umairaftab
Date:
Sun Apr 13 10:06:52 2014 +0000
Revision:
0:a2a81f538133
Multiple Sensors Functionality Added to Peter Sudensikis Library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
umairaftab 0:a2a81f538133 1 /*
umairaftab 0:a2a81f538133 2 * OneWireThermometer. Base class for Maxim One-Wire Thermometers.
umairaftab 0:a2a81f538133 3 * Uses the OneWireCRC library.
umairaftab 0:a2a81f538133 4 *
umairaftab 0:a2a81f538133 5 * Copyright (C) <2010> Petras Saduikis <petras@petras.co.uk>
umairaftab 0:a2a81f538133 6 *
umairaftab 0:a2a81f538133 7 * This file is part of OneWireThermometer.
umairaftab 0:a2a81f538133 8 *
umairaftab 0:a2a81f538133 9 * OneWireThermometer is free software: you can redistribute it and/or modify
umairaftab 0:a2a81f538133 10 * it under the terms of the GNU General Public License as published by
umairaftab 0:a2a81f538133 11 * the Free Software Foundation, either version 3 of the License, or
umairaftab 0:a2a81f538133 12 * (at your option) any later version.
umairaftab 0:a2a81f538133 13 *
umairaftab 0:a2a81f538133 14 * OneWireThermometer is distributed in the hope that it will be useful,
umairaftab 0:a2a81f538133 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
umairaftab 0:a2a81f538133 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
umairaftab 0:a2a81f538133 17 * GNU General Public License for more details.
umairaftab 0:a2a81f538133 18 *
umairaftab 0:a2a81f538133 19 * You should have received a copy of the GNU General Public License
umairaftab 0:a2a81f538133 20 * along with OneWireThermometer. If not, see <http://www.gnu.org/licenses/>.
umairaftab 0:a2a81f538133 21 */
umairaftab 0:a2a81f538133 22
umairaftab 0:a2a81f538133 23 #ifndef SNATCH59_ONEWIRETHERMOMETER_H
umairaftab 0:a2a81f538133 24 #define SNATCH59_ONEWIRETHERMOMETER_H
umairaftab 0:a2a81f538133 25
umairaftab 0:a2a81f538133 26 #include <mbed.h>
umairaftab 0:a2a81f538133 27 #include "OneWireCRC.h"
umairaftab 0:a2a81f538133 28 #include "OneWireDefs.h"
umairaftab 0:a2a81f538133 29
umairaftab 0:a2a81f538133 30 typedef unsigned char BYTE; // something a byte wide
umairaftab 0:a2a81f538133 31 typedef unsigned char DEVADDRESS[8]; // stores the address of one device
umairaftab 0:a2a81f538133 32
umairaftab 0:a2a81f538133 33 class OneWireThermometer
umairaftab 0:a2a81f538133 34 {
umairaftab 0:a2a81f538133 35 public:
umairaftab 0:a2a81f538133 36 OneWireThermometer(PinName pin, int device_id);
umairaftab 0:a2a81f538133 37
umairaftab 0:a2a81f538133 38 bool initialize();
umairaftab 0:a2a81f538133 39 float readTemperature(int device);
umairaftab 0:a2a81f538133 40 virtual void setResolution(eResolution resln) = 0;
umairaftab 0:a2a81f538133 41 int getDeviceCount();
umairaftab 0:a2a81f538133 42
umairaftab 0:a2a81f538133 43 protected:
umairaftab 0:a2a81f538133 44 OneWireCRC oneWire;
umairaftab 0:a2a81f538133 45 const int deviceId;
umairaftab 0:a2a81f538133 46
umairaftab 0:a2a81f538133 47 eResolution resolution;
umairaftab 0:a2a81f538133 48 BYTE address[8];
umairaftab 0:a2a81f538133 49 DEVADDRESS devices[10];
umairaftab 0:a2a81f538133 50 int deviceCount;
umairaftab 0:a2a81f538133 51
umairaftab 0:a2a81f538133 52 void resetAndAddress();
umairaftab 0:a2a81f538133 53 bool readAndValidateData(BYTE* data);
umairaftab 0:a2a81f538133 54 virtual float calculateTemperature(BYTE* data) = 0; // device specific
umairaftab 0:a2a81f538133 55 };
umairaftab 0:a2a81f538133 56
umairaftab 0:a2a81f538133 57 #endif