From be76990656840614230e406f88a8d99c1d81cc6a Mon Sep 17 00:00:00 2001 From: Bernhard Tittelbach Date: Sun, 4 Aug 2013 03:12:29 +0000 Subject: ds1820 onewire lib git-svn-id: https://svn.spreadspace.org/avr/trunk@214 aa12f405-d877-488e-9caf-2d797e2a1cc7 --- lib/ds1820.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 lib/ds1820.h (limited to 'lib/ds1820.h') diff --git a/lib/ds1820.h b/lib/ds1820.h new file mode 100644 index 0000000..4c29d07 --- /dev/null +++ b/lib/ds1820.h @@ -0,0 +1,61 @@ +/* + * spreadspace avr utils - usb-1wire example + * + * + * Copyright (C) 2013 Bernhard Tittelbach + * based on code from: + * http://www.pjrc.com/teensy/td_libs_OneWire.html + * + * This file is part of spreadspace avr utils. + * + * spreadspace avr utils is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * spreadspace avr utils is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with spreadspace avr utils. If not, see . + */ + +#ifndef __DS1820__ +#define __DS1820__ + +#include + +#define DS1820_FAMILY_ID 0x10 +#define DS1820_START_CONVERSION 0x44 +#define DS1820_READ_SCRATCHPAD 0xbe +#define DS1820_WRITE_SCRATCHPAD 0x4e +#define DS1820_ERROR -1000 // Return code. Outside temperature range. +#define DS1820_RESOLUTION_9BITS 0x00 +#define DS1820_RESOLUTION_10BITS 0x20 +#define DS1820_RESOLUTION_11BITS 0x40 +#define DS1820_RESOLUTION_12BITS 0x60 +#define DS1820_TCONV_MS_9BITS 96 +#define DS1820_TCONV_MS_10BITS 195 +#define DS1820_TCONV_MS_11BITS 390 +#define DS1820_TCONV_MS_12BITS 800 + +#define DS2890_FAMILY_ID 0x2c +#define DS2890_WRITE_CONTROL_REGISTER 0X55 +#define DS2890_RELEASE_CODE 0x96 +#define DS2890_WRITE_POSITION 0x0f + +#ifndef MAX_OWI_DEVICES +#define MAX_OWI_DEVICES 8 +#endif + +uint8_t ds1820_discover(void); +void ds1820_set_resolution(uint8_t d, uint8_t bits); +void ds1820_start_measuring(uint8_t d); +uint16_t ds1820_get_conversion_time_ms(uint8_t bits); +void ds1820_wait_conversion_time(uint8_t bits); +int16_t ds1820_read_temperature(uint8_t d); +float ds1820_raw_temp_to_celsius(int16_t t); + +#endif \ No newline at end of file -- cgit v1.2.3