Library for Programmable Resolution 1-Wire Digital ThermometerDS18B20

Dependents:   DS18B20_HGC

Committer:
kriedel
Date:
Thu Feb 03 12:10:20 2011 +0000
Revision:
0:21c0c97a5d7c

        

Who changed what in which revision?

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