Firmware SDK
twr_zssc3123.h
1 #ifndef _TWR_ZSSC3123_H
2 #define _TWR_ZSSC3123_H
3 
4 #include <twr_i2c.h>
5 #include <twr_scheduler.h>
6 
10 
12 
13 typedef enum
14 {
17 
20 
22 
24 
25 typedef struct twr_zssc3123_t twr_zssc3123_t;
26 
28 
29 typedef enum
30 {
31  TWR_ZSSC3123_STATE_ERROR = -1,
32  TWR_ZSSC3123_STATE_INITIALIZE = 0,
33  TWR_ZSSC3123_STATE_MEASURE = 1,
34  TWR_ZSSC3123_STATE_READ = 2
35 
36 } twr_zssc3123_state_t;
37 
38 struct twr_zssc3123_t
39 {
40  twr_i2c_channel_t _i2c_channel;
41  uint8_t _i2c_address;
42  twr_scheduler_task_id_t _task_id;
43  void (*_event_handler)(twr_zssc3123_t *, twr_zssc3123_event_t, void *);
44  void *_event_param;
45  twr_zssc3123_state_t _state;
46  twr_tick_t _update_interval;
47  bool _valid;
48  bool _measurement_active;
49  twr_tick_t _next_update_start;
50  uint16_t _raw;
51  twr_tick_t _data_fetch_delay;
52 };
53 
55 
60 
61 bool twr_zssc3123_init(twr_zssc3123_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address);
62 
65 
67 
71 
73 
78 
79 void twr_zssc3123_set_event_handler(twr_zssc3123_t *self, void (*event_handler)(twr_zssc3123_t *, twr_zssc3123_event_t, void *), void *event_param);
80 
84 
86 
91 
93 
99 
100 bool twr_zssc3123_get_raw_cap_data(twr_zssc3123_t *self, uint16_t *raw);
101 
104 
106 
109 
111 
118 
119 bool twr_zssc3123_eeprom_read(twr_zssc3123_t *self, uint8_t address, uint16_t *word);
120 
127 
128 bool twr_zssc3123_eeprom_write(twr_zssc3123_t *self, uint8_t address, uint16_t word);
129 
134 
136 
138 
139 #endif // _TWR_ZSSC3123_H
twr_i2c_channel_t
I2C channels.
Definition: twr_i2c.h:16
size_t twr_scheduler_task_id_t
Task ID assigned by scheduler.
Definition: twr_scheduler.h:22
uint64_t twr_tick_t
Timestamp data type.
Definition: twr_tick.h:16
bool twr_zssc3123_deinit(twr_zssc3123_t *self)
Deitialize ZSSC3123.
Definition: twr_zssc3123.c:28
void twr_zssc3123_set_event_handler(twr_zssc3123_t *self, void(*event_handler)(twr_zssc3123_t *, twr_zssc3123_event_t, void *), void *event_param)
Set callback function.
Definition: twr_zssc3123.c:42
bool twr_zssc3123_get_raw_cap_data(twr_zssc3123_t *self, uint16_t *raw)
Get capacitance data as raw value.
Definition: twr_zssc3123.c:79
bool twr_zssc3123_eeprom_read(twr_zssc3123_t *self, uint8_t address, uint16_t *word)
Write to eeprom, work only with command mode.
Definition: twr_zssc3123.c:111
bool twr_zssc3123_end_cm(twr_zssc3123_t *self)
Ends Command Mode.
Definition: twr_zssc3123.c:101
void twr_zssc3123_set_update_interval(twr_zssc3123_t *self, twr_tick_t interval)
Set scan interval.
Definition: twr_zssc3123.c:48
bool twr_zssc3123_measure(twr_zssc3123_t *self)
Start measurement manually.
Definition: twr_zssc3123.c:65
struct twr_zssc3123_t twr_zssc3123_t
ZSSC3123 instance.
Definition: twr_zssc3123.h:25
bool twr_zssc3123_unlock_eeprom(twr_zssc3123_t *self)
Unlock eerpom, work only with command mode.
Definition: twr_zssc3123.c:166
twr_zssc3123_event_t
Callback events.
Definition: twr_zssc3123.h:14
void twr_zssc3123_set_data_fetch_delay(twr_zssc3123_t *self, twr_tick_t interval)
Set data fetch delay.
Definition: twr_zssc3123.c:37
bool twr_zssc3123_init(twr_zssc3123_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize ZSSC3123.
Definition: twr_zssc3123.c:8
bool twr_zssc3123_start_cm(twr_zssc3123_t *self)
Start Command Mode.
Definition: twr_zssc3123.c:91
bool twr_zssc3123_eeprom_write(twr_zssc3123_t *self, uint8_t address, uint16_t word)
Read from eeprm, work only with command mode.
Definition: twr_zssc3123.c:150
@ TWR_ZSSC3123_EVENT_ERROR
Error event.
Definition: twr_zssc3123.h:16
@ TWR_ZSSC3123_EVENT_UPDATE
Update event.
Definition: twr_zssc3123.h:19