A copy of very incomplete program for forum

Dependencies:   mbed SDFileSystem

Committer:
roselea
Date:
Sat Mar 17 14:15:20 2012 +0000
Revision:
0:bfcb5b67b1d6

        

Who changed what in which revision?

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