summaryrefslogtreecommitdiff
path: root/software/avr.lib/ds1820.h
diff options
context:
space:
mode:
Diffstat (limited to 'software/avr.lib/ds1820.h')
-rw-r--r--software/avr.lib/ds1820.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/software/avr.lib/ds1820.h b/software/avr.lib/ds1820.h
new file mode 100644
index 0000000..4c29d07
--- /dev/null
+++ b/software/avr.lib/ds1820.h
@@ -0,0 +1,61 @@
+/*
+ * spreadspace avr utils - usb-1wire example
+ *
+ *
+ * Copyright (C) 2013 Bernhard Tittelbach <xro@realraum.at>
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __DS1820__
+#define __DS1820__
+
+#include <stdint.h>
+
+#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