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  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  You can contact the author at Falk.Brunner@gmx.de
22 
23 *****************************************************************************/
24 
55 #ifndef DS18x20_H_
56 #define DS18x20_H_
57 
58 #include <stdint.h>
59 
64 #define DS1820_CMD_SKIP_ROM 0xCC
65 #define DS1820_CMD_CONVERT_T 0x44
66 #define DS1820_CMD_READ_SCRATCHPAD 0xBE
67 #define DS1820_CMD_WRITE_SCRATCHPAD 0x4E
68 #define DS1820_CMD_COPY_SCRATCHPAD 0x48
69 #define DS1820_CMD_RECALL_E2 0xB8
70 #define DS1820_CMD_READ_POWER_SUPPLY 0xB4
71 
77 #define DS18B20_ID 0x28
78 #define DS18S20_ID 0x10
79 
85 
93 uint8_t ds18x20_convert_t(uint8_t parasitic_power);
94 
95 #define ds18B20_convert_t(x) ds18x20_convert_t(x)
96 #define ds18S20_convert_t(x) ds18x20_convert_t(x)
97 
104 int16_t ds18x20_read_temp(void);
105 
106 
113 int16_t ds18B20_read_temp(void);
114 
121 int16_t ds18S20_read_temp(void);
122 
129 void ds18x20_read_scratchpad(uint8_t *buffer);
130 
131 #define ds18B20_read_scratchpad(x) ds18x20_read_scratchpad(x)
132 #define ds18S20_read_scratchpad(x) ds18x20_read_scratchpad(x)
133 
141 void ds18S20_write_scratchpad(int8_t th, int8_t tl);
142 
151 void ds18B20_write_scratchpad(uint8_t th, uint8_t tl, uint8_t config);
152 
160 void ds18x20_copy_scratchpad(uint8_t parasitic_power);
161 
162 #define ds18B20_copy_scratchpad(x) ds18x20_copy_scratchpad(x);
163 #define ds18S20_copy_scratchpad(x) ds18x20_copy_scratchpad(x);
164 
171 void ds18x20_recall_E2(void);
172 #define ds18B20_recall_E2(x) ds18x20_recall_E2(x)
173 #define ds18S20_recall_E2(x) ds18x20_recall_E2(x)
174 
183 uint8_t ds18x20_read_power_supply(void);
184 
185 #define ds18B20_read_power_supply(x) ds18x20_read_power_supply(x)
186 #define ds18S20_read_power_supply(x) ds18x20_read_power_supply(x)
187 
190 #endif
void ds18B20_write_scratchpad(uint8_t th, uint8_t tl, uint8_t config)
write th, tl and configuration of DS18B20
Definition: ds18x20.c:111
uint8_t ds18x20_convert_t(uint8_t parasitic_power)
start temperature conversion
Definition: ds18x20.c:32
int16_t ds18B20_read_temp(void)
Read temperature from DS18B20 (12 bit resolution)
Definition: ds18x20.c:66
void ds18x20_copy_scratchpad(uint8_t parasitic_power)
copy scratchpad to EEPROM, busy waiting (10ms),
Definition: ds18x20.c:119
void ds18S20_write_scratchpad(int8_t th, int8_t tl)
write th and tl of DS18S20
Definition: ds18x20.c:104
int16_t ds18x20_read_temp(void)
Read temperature from DS18x20.
Definition: ds18x20.c:52
int16_t ds18S20_read_temp(void)
Read temperature from DS18S20 (9 bit resolution)
Definition: ds18x20.c:82
uint8_t ds18x20_read_power_supply(void)
read power supply
Definition: ds18x20.c:140
void ds18x20_recall_E2(void)
copy EEPROM to scratchpad, busy waiting (1ms)
Definition: ds18x20.c:135
void ds18x20_read_scratchpad(uint8_t *buffer)
Read complete scratchpad of DS18x20 (9 bytes)
Definition: ds18x20.c:95