Now supports DS18B20 and DS18S20 Maxim/Dallas one-wire thermometer devices. Also supports DS18S20 in 9, 10, 11, and 12 bit resolution modes. 'Use Address' mode now checks if the correct device type is present, and informs the user which device to use. Correct temperature conversion times now used in non-parasitic mode. The device should be placed at least 6 inches (15 cm) from the mbed board in order to accurately read ambient temperature.

Dependencies:   mbed

Committer:
snatch59
Date:
Sun Jan 03 11:57:31 2010 +0000
Revision:
0:01a6a40578c9

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
snatch59 0:01a6a40578c9 1 /*
snatch59 0:01a6a40578c9 2 * OneWireCRC. This is a port to mbed of Jim Studt's Adruino One Wire
snatch59 0:01a6a40578c9 3 * library.
snatch59 0:01a6a40578c9 4 *
snatch59 0:01a6a40578c9 5 * Copyright (C) <2009> Petras Saduikis <petras@petras.co.uk>
snatch59 0:01a6a40578c9 6 *
snatch59 0:01a6a40578c9 7 * This file is part of OneWireCRC.
snatch59 0:01a6a40578c9 8 *
snatch59 0:01a6a40578c9 9 * OneWireCRC 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 * OneWireCRC 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 OneWireCRC. If not, see <http://www.gnu.org/licenses/>.
snatch59 0:01a6a40578c9 21 */
snatch59 0:01a6a40578c9 22
snatch59 0:01a6a40578c9 23 #ifndef SNATCH59_ONEWIREDEFS_H
snatch59 0:01a6a40578c9 24 #define SNATCH59_ONEWIREDEFS_H
snatch59 0:01a6a40578c9 25
snatch59 0:01a6a40578c9 26 // device ids
snatch59 0:01a6a40578c9 27 #define DS18B20_ID 0x28
snatch59 0:01a6a40578c9 28 #define DS18S20_ID 0x10
snatch59 0:01a6a40578c9 29
snatch59 0:01a6a40578c9 30 #define ALARM_CONFIG_SIZE 3
snatch59 0:01a6a40578c9 31 #define THERMOM_SCRATCHPAD_SIZE 9
snatch59 0:01a6a40578c9 32 #define THERMOM_CRC_BYTE 8
snatch59 0:01a6a40578c9 33 #define ADDRESS_SIZE 8
snatch59 0:01a6a40578c9 34 #define ADDRESS_CRC_BYTE 7
snatch59 0:01a6a40578c9 35
snatch59 0:01a6a40578c9 36 // One Wire command codes
snatch59 0:01a6a40578c9 37 #define OVERDRIVE_SKIP 0x3C
snatch59 0:01a6a40578c9 38 // ROM commands
snatch59 0:01a6a40578c9 39 #define SEARCH_ROM 0xF0
snatch59 0:01a6a40578c9 40 #define READ_ROM 0x33
snatch59 0:01a6a40578c9 41 #define MATCH_ROM 0x55
snatch59 0:01a6a40578c9 42 #define SKIP_ROM 0xCC
snatch59 0:01a6a40578c9 43 #define ALARM_SEARCH 0xEC
snatch59 0:01a6a40578c9 44 // Functions Commnds
snatch59 0:01a6a40578c9 45 #define CONVERT 0x44
snatch59 0:01a6a40578c9 46 #define WRITESCRATCH 0x4E
snatch59 0:01a6a40578c9 47 #define READSCRATCH 0xBE
snatch59 0:01a6a40578c9 48 #define COPYSCRATCH 0x48
snatch59 0:01a6a40578c9 49 #define RECALLE2 0xB8
snatch59 0:01a6a40578c9 50 #define READPOWERSUPPLY 0xB4
snatch59 0:01a6a40578c9 51
snatch59 0:01a6a40578c9 52 // temperature read resolutions
snatch59 0:01a6a40578c9 53 enum eResolution {nineBit = 0, tenBit, elevenBit, twelveBit};
snatch59 0:01a6a40578c9 54 const int CONVERSION_TIME[] = {94, 188, 375, 750}; // milli-seconds
snatch59 0:01a6a40578c9 55
snatch59 0:01a6a40578c9 56 // DS18B20/DS18S20 related
snatch59 0:01a6a40578c9 57 #define TEMPERATURE_LSB 0
snatch59 0:01a6a40578c9 58 #define TEMPERATURE_MSB 1
snatch59 0:01a6a40578c9 59 #define HIGH_ALARM_BYTE 2
snatch59 0:01a6a40578c9 60 #define LOW_ALARM_BYTE 3
snatch59 0:01a6a40578c9 61 #define CONFIG_REG_BYTE 4
snatch59 0:01a6a40578c9 62 #define CONFIG_READ_END 5
snatch59 0:01a6a40578c9 63 #define COUNT_REMAIN_BYTE 6
snatch59 0:01a6a40578c9 64 #define COUNT_PER_DEG_BYTE 7
snatch59 0:01a6a40578c9 65
snatch59 0:01a6a40578c9 66 #endif