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