Firmware SDK
twr_cy8cmbr3102.h
1 #ifndef _TWR_CY8CMBR3102_H
2 #define _TWR_CY8CMBR3102_H
3 
4 #include <twr_i2c.h>
5 #include <twr_scheduler.h>
6 
10 
12 
13 typedef enum
14 {
17 
20 
22 
24 
26 
28 
29 typedef enum
30 {
31  TWR_CY8CMBR3102_STATE_ERROR = -1,
32  TWR_CY8CMBR3102_STATE_INITIALIZE = 0,
33  TWR_CY8CMBR3102_STATE_CALC_CONFIG_CRC = 1,
34  TWR_CY8CMBR3102_STATE_SELF_RESET = 2,
35  TWR_CY8CMBR3102_STATE_READ = 3
36 
37 } twr_cy8cmbr3102_state_t;
38 
39 struct twr_cy8cmbr3102_t
40 {
41  twr_i2c_channel_t _i2c_channel;
42  uint8_t _i2c_address;
43  twr_scheduler_task_id_t _task_id_task;
44  void (*_event_handler)(twr_cy8cmbr3102_t *, twr_cy8cmbr3102_event_t, void *);
45  void *_event_param;
46  twr_cy8cmbr3102_state_t _state;
47  twr_tick_t _scan_interval;
48  int _error_cnt;
49 };
50 
52 
57 
58 bool twr_cy8cmbr3102_init(twr_cy8cmbr3102_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address);
59 
64 
65 void twr_cy8cmbr3102_set_event_handler(twr_cy8cmbr3102_t *self, void (*event_handler)(twr_cy8cmbr3102_t *, twr_cy8cmbr3102_event_t, void *), void *event_param);
66 
70 
72 
78 
79 bool twr_cy8cmbr3102_get_proximity(twr_cy8cmbr3102_t *self, uint16_t value);
80 
86 
87 bool twr_cy8cmbr3102_is_touch(twr_cy8cmbr3102_t *self, bool *is_touch);
88 
90 
91 #endif // _TWR_CY8CMBR3102_H
twr_cy8cmbr3102_event_t
Callback events.
bool twr_cy8cmbr3102_is_touch(twr_cy8cmbr3102_t *self, bool *is_touch)
Is touch.
bool twr_cy8cmbr3102_get_proximity(twr_cy8cmbr3102_t *self, uint16_t value)
Get proximity (Capacitive sensor difference count signal.)
void twr_cy8cmbr3102_set_scan_interval(twr_cy8cmbr3102_t *self, twr_tick_t scan_interval)
Set scan interval.
void twr_cy8cmbr3102_set_event_handler(twr_cy8cmbr3102_t *self, void(*event_handler)(twr_cy8cmbr3102_t *, twr_cy8cmbr3102_event_t, void *), void *event_param)
Set callback function.
bool twr_cy8cmbr3102_init(twr_cy8cmbr3102_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize CY8CMBR3102.
struct twr_cy8cmbr3102_t twr_cy8cmbr3102_t
TCA9534A instance.
@ TWR_CY8CMBR3102_EVENT_TOUCH
Update event.
@ TWR_CY8CMBR3102_EVENT_ERROR
Error event.
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