Wim De Roeve / DS18B20

Dependents:   DallasTemperature project1

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers OneWireDefs.h Source File

OneWireDefs.h

00001 /*
00002 * OneWireCRC. This is a port to mbed of Jim Studt's Adruino One Wire
00003 * library.
00004 *
00005 * Copyright (C) <2009> Petras Saduikis <petras@petras.co.uk>
00006 * Added Wim
00007  * This file is part of OneWireCRC.
00008 *
00009 * OneWireCRC is free software: you can redistribute it and/or modify
00010 * it under the terms of the GNU General Public License as published by
00011 * the Free Software Foundation, either version 3 of the License, or
00012 * (at your option) any later version.
00013 * 
00014 * OneWireCRC is distributed in the hope that it will be useful,
00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 * GNU General Public License for more details.
00018 *
00019 * You should have received a copy of the GNU General Public License
00020 * along with OneWireCRC.  If not, see <http://www.gnu.org/licenses/>.
00021 */
00022 
00023 #ifndef _ONEWIREDEFS_H
00024 #define _ONEWIREDEFS_H
00025 
00026 // device ids
00027 #define DS18B20_ID        0x28
00028 #define DS18S20_ID        0x10
00029 
00030 #define ALARM_CONFIG_SIZE 3
00031 #define THERMOM_SCRATCHPAD_SIZE    9
00032 #define THERMOM_CRC_BYTE  8
00033 #define ADDRESS_SIZE      8
00034 #define ADDRESS_CRC_BYTE  7
00035 
00036 // One Wire command codes
00037 #define OVERDRIVE_SKIP    0x3C
00038 // ROM commands
00039 #define SEARCH_ROM         0xF0
00040 #define READ_ROM           0x33
00041 #define MATCH_ROM          0x55
00042 #define SKIP_ROM           0xCC
00043 #define OVERDRIVESKIP_ROM  0x3C
00044 #define OVERDRIVEMATCH_ROM 0x69
00045 #define ALARM_SEARCH       0xEC
00046 // Functions Commnds
00047 #define CONVERT            0x44
00048 #define RECALLE2           0xB8
00049 #define READPOWERSUPPLY    0xB4
00050 
00051 // temperature read resolutions
00052 enum eResolution {nineBit = 0, tenBit, elevenBit, twelveBit};
00053 const int CONVERSION_TIME[] = {94, 188, 375, 750};    // milli-seconds
00054 
00055 // DS18B20/DS18S20 related
00056 #define DS18X20_WRITESCRATCH      0x4E
00057 #define DS18X20_READSCRATCH       0xBE
00058 #define DS18X20_COPYSCRATCH       0x48
00059 #define TEMPERATURE_LSB    0
00060 #define TEMPERATURE_MSB    1
00061 #define HIGH_ALARM_BYTE    2
00062 #define LOW_ALARM_BYTE     3
00063 #define CONFIG_REG_BYTE    4
00064 #define CONFIG_READ_END    5
00065 #define COUNT_REMAIN_BYTE  6
00066 #define COUNT_PER_DEG_BYTE 7
00067 
00068 #endif