-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGFDS18B20.h
68 lines (55 loc) · 1.98 KB
/
GFDS18B20.h
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef DS18B20_h
#define DS18B20_h
// tw
// Port and pins definition:
// [Ground] ----x x x----------------- [+5v]
// |
// |
// |
// Digital pin
#include <inttypes.h>
#define FALSE 0
#define TRUE 1
class DS18B20
{
private:
volatile uint8_t * _OWPORTDIR; // was uint16_t but got error with new IDE-0009
volatile uint8_t * _OWPORTREN; // was uint16_t but got error with new IDE-0009
volatile uint8_t * _OWPORTIN; // was uint16_t but got error with new IDE-0009
volatile uint8_t * _OWPORTOUT; // was uint16_t but got error with new IDE-0009
uint8_t _OWPORTPIN;
//uint16_t ReadDS1820(void); // moved to public
//int reset(); // moved to Public
void write_bit(int bit);
int read_bit();
//void write_byte(uint8_t byte); moved to Public
//uint8_t read_byte();//
unsigned char ROM_NO[8];
uint8_t LastDiscrepancy;
uint8_t LastFamilyDiscrepancy;
uint8_t LastDeviceFlag;
//unit8_t ii;
public:
DS18B20( uint8_t pin); // 1-wire pin
int32_t GetData(void); // temp (integer)
int32_t GetData10(void); // temp*10 (integer)
float GetDataf(void); // temp (float)
void reset_search(void);
uint8_t search(uint8_t *newAddr);
int reset();
// Issue a 1-Wire rom select command, you do the reset first.
void select( uint8_t rom[8]);
// Write a byte. If 'power' is one then the wire is held high at
// the end for parasitically powered devices. You are responsible
// for eventually depowering it by calling depower() or doing
// another read or write.
//void write(uint8_t v, uint8_t power = 0);
void write_byte(uint8_t byte);
void resolution(uint8_t byte); //choix de la resolution 9,10,11,12
uint16_t ReadDS1820(void);
uint8_t read_byte();//
// Compute a Dallas Semiconductor 8 bit CRC, these are used in the
// ROM and scratchpad registers.
//static uint8_t crc8( uint8_t *addr, uint8_t len);
};
#endif