OneWire + DS18X20 Library
Basic functions for OneWire operations + specific DS18x20 operations
 All Functions Groups Pages
ds18x20.h
1 /*****************************************************************************
2 
3  DS18x20 library
4 
5  Copyright (C) 2016 Falk Brunner
6 
7 *****************************************************************************/
8 
9 /*
10 * ----------------------------------------------------------------------------
11 * "THE BEER-WARE LICENSE" (Revision 42):
12 * <Falk.Brunner@gmx.de> wrote this file. As long as you retain this notice you
13 * can do whatever you want with this stuff. If we meet some day, and you think
14 * this stuff is worth it, you can buy me a beer in return. Falk Brunner
15 * ----------------------------------------------------------------------------
16 */
17 
48 #ifndef DS18x20_H_
49 #define DS18x20_H_
50 
51 #include <stdint.h>
52 
57 #define DS18x20_CMD_SKIP_ROM 0xCC
58 #define DS18x20_CMD_CONVERT_T 0x44
59 #define DS18x20_CMD_READ_SCRATCHPAD 0xBE
60 #define DS18x20_CMD_WRITE_SCRATCHPAD 0x4E
61 #define DS18x20_CMD_COPY_SCRATCHPAD 0x48
62 #define DS18x20_CMD_RECALL_E2 0xB8
63 #define DS18x20_CMD_READ_POWER_SUPPLY 0xB4
64 
70 #define DS18B20_ID 0x28
71 #define DS18S20_ID 0x10
72 
78 
84 void ds18x20_convert_t(uint8_t parasitic_power);
85 
86 #define ds18B20_convert_t(x) ds18x20_convert_t(x)
87 #define ds18S20_convert_t(x) ds18x20_convert_t(x)
88 
97 uint8_t ds18B20_read_temp(int16_t *temperature);
98 
107 uint8_t ds18S20_read_temp(int16_t *temperature);
108 
115 void ds18x20_read_scratchpad(uint8_t *buffer);
116 
117 #define ds18B20_read_scratchpad(x) ds18x20_read_scratchpad(x)
118 #define ds18S20_read_scratchpad(x) ds18x20_read_scratchpad(x)
119 
127 void ds18S20_write_scratchpad(int8_t tl, int8_t th);
128 
137 void ds18B20_write_scratchpad(int8_t tl, int8_t th, uint8_t adc_resolution);
138 
146 void ds18x20_copy_scratchpad(uint8_t parasitic_power);
147 
148 #define ds18B20_copy_scratchpad(x) ds18x20_copy_scratchpad(x);
149 #define ds18S20_copy_scratchpad(x) ds18x20_copy_scratchpad(x);
150 
157 void ds18x20_recall_E2(void);
158 #define ds18B20_recall_E2(x) ds18x20_recall_E2(x)
159 #define ds18S20_recall_E2(x) ds18x20_recall_E2(x)
160 
169 uint8_t ds18x20_read_power_supply(void);
170 
171 #define ds18B20_read_power_supply(x) ds18x20_read_power_supply(x)
172 #define ds18S20_read_power_supply(x) ds18x20_read_power_supply(x)
173 
176 #endif
void ds18x20_convert_t(uint8_t parasitic_power)
start temperature conversion
Definition: ds18x20.cpp:25
void ds18B20_write_scratchpad(int8_t tl, int8_t th, uint8_t adc_resolution)
write tl, th and configuration of DS18B20
Definition: ds18x20.cpp:96
uint8_t ds18S20_read_temp(int16_t *temperature)
Read temperature from DS18S20 (9 bit + enhanced resolution, effective 12 bits)
Definition: ds18x20.cpp:59
void ds18S20_write_scratchpad(int8_t tl, int8_t th)
write tl and th of DS18S20
Definition: ds18x20.cpp:89
void ds18x20_copy_scratchpad(uint8_t parasitic_power)
copy scratchpad to EEPROM, busy waiting (10ms),
Definition: ds18x20.cpp:111
uint8_t ds18B20_read_temp(int16_t *temperature)
Read temperature from DS18B20 (9-12 bit resolution)
Definition: ds18x20.cpp:37
uint8_t ds18x20_read_power_supply(void)
read power supply
Definition: ds18x20.cpp:130
void ds18x20_recall_E2(void)
copy EEPROM to scratchpad, busy waiting (1ms)
Definition: ds18x20.cpp:125
void ds18x20_read_scratchpad(uint8_t *buffer)
Read complete scratchpad of DS18x20 (9 bytes)
Definition: ds18x20.cpp:80