Firmware SDK
twr_pyq1648.h
1 #ifndef _TWR_PYQ1648_H
2 #define _TWR_PYQ1648_H
3 
4 #include <twr_tick.h>
5 #include <twr_gpio.h>
6 #include <twr_scheduler.h>
7 
11 
13 
14 typedef enum
15 {
18 
21 
23 
25 
26 typedef enum
27 {
30 
33 
36 
39 
41 
43 
44 typedef struct twr_pyq1648_t twr_pyq1648_t;
45 
47 
48 typedef enum
49 {
50  TWR_PYQ1648_STATE_ERROR = -1,
51  TWR_PYQ1648_STATE_INITIALIZE = 0,
52  TWR_PYQ1648_STATE_IGNORE = 1,
53  TWR_PYQ1648_STATE_CHECK = 2
54 
55 } twr_pyq1648_state_t;
56 
57 struct twr_pyq1648_t
58 {
59  twr_gpio_channel_t _gpio_channel_serin;
60  twr_gpio_channel_t _gpio_channel_dl;
61  void (*_event_handler)(twr_pyq1648_t *, twr_pyq1648_event_t, void *);
62  void *_event_param;
63  twr_pyq1648_state_t _state;
64  uint32_t _config;
65  uint8_t _sensitivity;
66  twr_tick_t _blank_period;
67  twr_tick_t _aware_time;
68  twr_tick_t _ignore_untill;
69  twr_scheduler_task_id_t _task_id;
70 };
71 
73 
78 
79 void twr_pyq1648_init(twr_pyq1648_t *self, twr_gpio_channel_t gpio_channel_serin, twr_gpio_channel_t gpio_channel_dl);
80 
85 
86 void twr_pyq1648_set_event_handler(twr_pyq1648_t *self, void (*event_handler)(twr_pyq1648_t *, twr_pyq1648_event_t, void *), void *event_param);
87 
91 
93 
97 
98 void twr_pyq1648_set_blank_period(twr_pyq1648_t *self, twr_tick_t blank_period);
99 
101 
102 #endif // _TWR_PYQ1648_H
twr_gpio_channel_t
GPIO channels.
Definition: twr_gpio.h:13
struct twr_pyq1648_t twr_pyq1648_t
PYQ1648 instance.
Definition: twr_pyq1648.h:44
void twr_pyq1648_set_sensitivity(twr_pyq1648_t *self, twr_pyq1648_sensitivity_t sensitivity)
Set PYQ1648 sensitivity.
Definition: twr_pyq1648.c:68
void twr_pyq1648_set_blank_period(twr_pyq1648_t *self, twr_tick_t blank_period)
Set blank period (for how long alarm events will be ignored)
Definition: twr_pyq1648.c:78
void twr_pyq1648_init(twr_pyq1648_t *self, twr_gpio_channel_t gpio_channel_serin, twr_gpio_channel_t gpio_channel_dl)
Initialize PYQ1648 driver.
Definition: twr_pyq1648.c:37
twr_pyq1648_sensitivity_t
Possible sensitivities.
Definition: twr_pyq1648.h:27
void twr_pyq1648_set_event_handler(twr_pyq1648_t *self, void(*event_handler)(twr_pyq1648_t *, twr_pyq1648_event_t, void *), void *event_param)
Set callback function.
Definition: twr_pyq1648.c:59
twr_pyq1648_event_t
Callback events.
Definition: twr_pyq1648.h:15
@ TWR_PYQ1648_SENSITIVITY_HIGH
High sensitivity.
Definition: twr_pyq1648.h:35
@ TWR_PYQ1648_SENSITIVITY_VERY_HIGH
Very high sensitivity.
Definition: twr_pyq1648.h:38
@ TWR_PYQ1648_SENSITIVITY_LOW
Low sensitivity.
Definition: twr_pyq1648.h:29
@ TWR_PYQ1648_SENSITIVITY_MEDIUM
Medium sensitivity.
Definition: twr_pyq1648.h:32
@ TWR_PYQ1648_EVENT_ERROR
Error event.
Definition: twr_pyq1648.h:17
@ TWR_PYQ1648_EVENT_MOTION
Update event.
Definition: twr_pyq1648.h:20
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