upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
ds18b20_defs.h
1 /*
2  * Author: Jon Trulson <jtrulson@ics.com>
3  * Copyright (c) 2017 Intel Corporation.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining
6  * a copy of this software and associated documentation files (the
7  * "Software"), to deal in the Software without restriction, including
8  * without limitation the rights to use, copy, modify, merge, publish,
9  * distribute, sublicense, and/or sell copies of the Software, and to
10  * permit persons to whom the Software is furnished to do so, subject to
11  * the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 #pragma once
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 // The family code for these devices. We handle all of them that
31 // are found on the bus.
32 #define DS18B20_FAMILY_CODE 0x28
33 
34  // commands
35  typedef enum {
36  DS18B20_CMD_CONVERT = 0x44, // start a temp conversion
37  DS18B20_CMD_WRITE_SCRATCHPAD = 0x4e,
38  DS18B20_CMD_READ_SCRATCHPAD = 0xbe,
39  DS18B20_CMD_COPY_SCRATCHPAD = 0x48, // copy scratchpad to EEPROM
40  DS18B20_CMD_RECALL_EEPROM = 0xb8, // copy EEPROM to scratchpad
41  DS18B20_CMD_READ_POWER_SUPPLY = 0xb4 // parasitically powered?
42  } DS18B20_CMD_T;
43 
44  // config register (scratchpad[4])
45  typedef enum {
46  DS18B20_CFG_RESOLUTION_R0 = 0x20,
47  DS18B20_CFG_RESOLUTION_R1 = 0x40,
48  _DS18B20_CFG_RESOLUTION_MASK = 3,
49  _DS18B20_CFG_RESOLUTION_SHIFT = 5
50 
51  // all other bits reserved and non-writable
52  } DS18B20_CFG_BITS_T;
53 
54  typedef enum {
55  DS18B20_RESOLUTION_9BITS = 0, // 93.75ms (tconv/8)
56  DS18B20_RESOLUTION_10BITS = 1, // 187.5 (tconv/4)
57  DS18B20_RESOLUTION_11BITS = 2, // 375ms (tconv/2)
58  DS18B20_RESOLUTION_12BITS = 3 // 750ms (tconv)
59  } DS18B20_RESOLUTIONS_T;
60 
61 #ifdef __cplusplus
62 }
63 #endif