Firmware SDK
twr_ds2484.h
1 #ifndef _TWR_DS2484_H
2 #define _TWR_DS2484_H
3 
4 #include <twr_i2c.h>
5 
9 
11 
12 #define TWR_DS2484_STATUS_1WB (1<<0) // 1-Wire Busy
13 #define TWR_DS2484_STATUS_PPD (1<<1) // Presence Pulse Detect
14 #define TWR_DS2484_STATUS_SD (1<<2) // Short Detected
15 #define TWR_DS2484_STATUS_LL (1<<3) // Logic Level
16 #define TWR_DS2484_STATUS_RST (1<<4) // Device Reset
17 #define TWR_DS2484_STATUS_SBR (1<<5) // Single Bit Result
18 #define TWR_DS2484_STATUS_TSB (1<<6) // Triplet Second Bit
19 #define TWR_DS2484_STATUS_DIR (1<<7) // Branch Direction Taken
20 
22 
23 typedef struct twr_ds2484_t twr_ds2484_t;
24 
26 
27 struct twr_ds2484_t
28 {
29  bool _ready;
30  bool _spu_on;
31  uint8_t _status;
32  uint8_t _srp;
33  twr_i2c_channel_t _i2c_channel;
34  bool (*_set_slpz)(void *, bool);
35  void *_set_slpz_ctx;
36 };
37 
39 
43 
44 bool twr_ds2484_init(twr_ds2484_t *self, twr_i2c_channel_t i2c_channel);
45 
46 void twr_ds2484_set_slpz_handler(twr_ds2484_t *self, bool (*handler)(void *, bool), void *handler_ctx);
47 
50 
52 
55 
57 
60 
61 bool twr_ds2484_reset(twr_ds2484_t *self);
62 
65 
67 
68 bool twr_ds2484_write_byte(twr_ds2484_t *self, const uint8_t byte);
69 
70 bool twr_ds2484_read_byte(twr_ds2484_t *self, uint8_t *byte);
71 
72 bool twr_ds2484_read_bit(twr_ds2484_t *self, uint8_t *bit);
73 
74 bool twr_ds2484_triplet(twr_ds2484_t *self, const uint8_t direction);
75 
76 bool twr_ds2484_is_ready(twr_ds2484_t *self);
77 
78 uint8_t twr_ds2484_status_get(twr_ds2484_t *self);
79 
80 bool twr_ds2484_is_present(twr_ds2484_t *self);
81 
83 
84 #endif // _TWR_TWR_DS2484_H
bool twr_ds2484_reset(twr_ds2484_t *self)
Reset the 1-Wire bus and return the presence of any device.
Definition: twr_ds2484.c:102
bool twr_ds2484_init(twr_ds2484_t *self, twr_i2c_channel_t i2c_channel)
Initialize DS2484.
Definition: twr_ds2484.c:40
void twr_ds2484_enable(twr_ds2484_t *self)
Enable DS2484.
Definition: twr_ds2484.c:59
bool twr_ds2484_busy_wait(twr_ds2484_t *self)
Wait until not busy.
Definition: twr_ds2484.c:125
void twr_ds2484_disable(twr_ds2484_t *self)
Disable DS2484.
Definition: twr_ds2484.c:90
struct twr_ds2484_t twr_ds2484_t
TMP112 instance.
Definition: twr_ds2484.h:23
twr_i2c_channel_t
I2C channels.
Definition: twr_i2c.h:16