/* * spreadspace avr utils - usb-1wire example * * * Copyright (C) 2013-2014 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__ #ifdef __cplusplus extern "C" { #endif #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); #ifdef __cplusplus } #endif #endif