Guo Wenxue
2022-04-18 dc4b04335bd8086487dfcd332082b324e3bbdf3c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/********************************************************************************
 *      Copyright:  (C) 2020 LingYun IoT System Studio
 *                  All rights reserved.
 *
 *       Filename:  ds18b20.h
 *    Description:  This head file is get temperature by DS18B20 on RaspberryPi
 *
 *        Version:  1.0.0(2020年04月15日)
 *         Author:  Guo Wenxue <guowenxue@gmail.com>
 *      ChangeLog:  1, Release initial version on "2020年04月15日 23时37分38秒"
 *
 ********************************************************************************/
 
#ifndef  _DS18B20_H_
#define  _DS18B20_H_
 
#include <stdint.h>
 
/*  description: get temperature by DS18B20 on RaspberryPi
 * return value: 0: Successfully   <0: Failure
 * output value: $temp: temperature value saved in two bytes:
 *                     byte[0]: fractional part, two digits after
 *                     byte[1]: integer part
 */
int ds18b20_get_temperature(uint16_t *temp);
 
#define temper_integer(x)   (((x)>>8) & 0xFF)
#define temper_fract(x)     ( (x)     & 0xFF)
 
#endif   /* ----- #ifndef _DS18B20_H_  ----- */