First Publish

Dependencies:   BridgeDriver2 FrontPanelButtons MAX31855 MCP23017 SDFileSystem TextLCD mbed

Committer:
mehatfie
Date:
Mon Nov 10 22:56:20 2014 +0000
Revision:
0:20e78c9d2ea9
First Commit of Falcon Wing

Who changed what in which revision?

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