OneWire Temperature library for interfacing DS18B20

Dependents:   DallasTemperature project1

Committer:
Wimpie
Date:
Sun Apr 17 17:27:20 2011 +0000
Revision:
0:ad90c2e86a63
improved 1W search function

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Wimpie 0:ad90c2e86a63 1 /*
Wimpie 0:ad90c2e86a63 2 * OneWireCRC. This is a port to mbed of Jim Studt's Adruino One Wire
Wimpie 0:ad90c2e86a63 3 * library.
Wimpie 0:ad90c2e86a63 4 *
Wimpie 0:ad90c2e86a63 5 * Copyright (C) <2009> Petras Saduikis <petras@petras.co.uk>
Wimpie 0:ad90c2e86a63 6 * Added Wim
Wimpie 0:ad90c2e86a63 7 * This file is part of OneWireCRC.
Wimpie 0:ad90c2e86a63 8 *
Wimpie 0:ad90c2e86a63 9 * OneWireCRC is free software: you can redistribute it and/or modify
Wimpie 0:ad90c2e86a63 10 * it under the terms of the GNU General Public License as published by
Wimpie 0:ad90c2e86a63 11 * the Free Software Foundation, either version 3 of the License, or
Wimpie 0:ad90c2e86a63 12 * (at your option) any later version.
Wimpie 0:ad90c2e86a63 13 *
Wimpie 0:ad90c2e86a63 14 * OneWireCRC is distributed in the hope that it will be useful,
Wimpie 0:ad90c2e86a63 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Wimpie 0:ad90c2e86a63 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Wimpie 0:ad90c2e86a63 17 * GNU General Public License for more details.
Wimpie 0:ad90c2e86a63 18 *
Wimpie 0:ad90c2e86a63 19 * You should have received a copy of the GNU General Public License
Wimpie 0:ad90c2e86a63 20 * along with OneWireCRC. If not, see <http://www.gnu.org/licenses/>.
Wimpie 0:ad90c2e86a63 21 */
Wimpie 0:ad90c2e86a63 22
Wimpie 0:ad90c2e86a63 23 #ifndef _ONEWIREDEFS_H
Wimpie 0:ad90c2e86a63 24 #define _ONEWIREDEFS_H
Wimpie 0:ad90c2e86a63 25
Wimpie 0:ad90c2e86a63 26 // device ids
Wimpie 0:ad90c2e86a63 27 #define DS18B20_ID 0x28
Wimpie 0:ad90c2e86a63 28 #define DS18S20_ID 0x10
Wimpie 0:ad90c2e86a63 29
Wimpie 0:ad90c2e86a63 30 #define ALARM_CONFIG_SIZE 3
Wimpie 0:ad90c2e86a63 31 #define THERMOM_SCRATCHPAD_SIZE 9
Wimpie 0:ad90c2e86a63 32 #define THERMOM_CRC_BYTE 8
Wimpie 0:ad90c2e86a63 33 #define ADDRESS_SIZE 8
Wimpie 0:ad90c2e86a63 34 #define ADDRESS_CRC_BYTE 7
Wimpie 0:ad90c2e86a63 35
Wimpie 0:ad90c2e86a63 36 // One Wire command codes
Wimpie 0:ad90c2e86a63 37 #define OVERDRIVE_SKIP 0x3C
Wimpie 0:ad90c2e86a63 38 // ROM commands
Wimpie 0:ad90c2e86a63 39 #define SEARCH_ROM 0xF0
Wimpie 0:ad90c2e86a63 40 #define READ_ROM 0x33
Wimpie 0:ad90c2e86a63 41 #define MATCH_ROM 0x55
Wimpie 0:ad90c2e86a63 42 #define SKIP_ROM 0xCC
Wimpie 0:ad90c2e86a63 43 #define OVERDRIVESKIP_ROM 0x3C
Wimpie 0:ad90c2e86a63 44 #define OVERDRIVEMATCH_ROM 0x69
Wimpie 0:ad90c2e86a63 45 #define ALARM_SEARCH 0xEC
Wimpie 0:ad90c2e86a63 46 // Functions Commnds
Wimpie 0:ad90c2e86a63 47 #define CONVERT 0x44
Wimpie 0:ad90c2e86a63 48 #define RECALLE2 0xB8
Wimpie 0:ad90c2e86a63 49 #define READPOWERSUPPLY 0xB4
Wimpie 0:ad90c2e86a63 50
Wimpie 0:ad90c2e86a63 51 // temperature read resolutions
Wimpie 0:ad90c2e86a63 52 enum eResolution {nineBit = 0, tenBit, elevenBit, twelveBit};
Wimpie 0:ad90c2e86a63 53 const int CONVERSION_TIME[] = {94, 188, 375, 750}; // milli-seconds
Wimpie 0:ad90c2e86a63 54
Wimpie 0:ad90c2e86a63 55 // DS18B20/DS18S20 related
Wimpie 0:ad90c2e86a63 56 #define DS18X20_WRITESCRATCH 0x4E
Wimpie 0:ad90c2e86a63 57 #define DS18X20_READSCRATCH 0xBE
Wimpie 0:ad90c2e86a63 58 #define DS18X20_COPYSCRATCH 0x48
Wimpie 0:ad90c2e86a63 59 #define TEMPERATURE_LSB 0
Wimpie 0:ad90c2e86a63 60 #define TEMPERATURE_MSB 1
Wimpie 0:ad90c2e86a63 61 #define HIGH_ALARM_BYTE 2
Wimpie 0:ad90c2e86a63 62 #define LOW_ALARM_BYTE 3
Wimpie 0:ad90c2e86a63 63 #define CONFIG_REG_BYTE 4
Wimpie 0:ad90c2e86a63 64 #define CONFIG_READ_END 5
Wimpie 0:ad90c2e86a63 65 #define COUNT_REMAIN_BYTE 6
Wimpie 0:ad90c2e86a63 66 #define COUNT_PER_DEG_BYTE 7
Wimpie 0:ad90c2e86a63 67
Wimpie 0:ad90c2e86a63 68 #endif