Appiko
main.c
1 /*
2  * main.c : Application for SensePi devices
3  * Copyright (C) 2019 Appiko
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
30 #include <stdbool.h>
31 #include <stdint.h>
32 #include <stddef.h>
33 #include <string.h>
34 
35 #include "led_sense.h"
36 #include "evt_sd_handler.h"
37 #include "nrf.h"
38 #include "boards.h"
39 
40 #include "log.h"
41 #include "nrf_util.h"
42 #include "hal_gpio.h"
43 #include "ms_timer.h"
44 #include "hal_nop_delay.h"
45 #include "hal_wdt.h"
46 #include "irq_msg_util.h"
47 #include "device_tick.h"
48 #include "pir_sense.h"
49 #include "hal_pin_analog_input.h"
50 #include "aa_aaa_battery_check.h"
51 #include "button_ui.h"
52 #include "nrf_nvic.h"
53 #include "ble.h"
54 #include "nrf_sdm.h"
55 #include "app_error.h"
56 #include "out_pattern_gen.h"
57 #include "led_ui.h"
58 #include "sensepi_ble.h"
59 #include "sensepi_cam_trigger.h"
60 #include "dev_id_fw_ver.h"
61 #include "sensepi_store_config.h"
62 #include "hal_nvmc.h"
63 
64 /* ----- Defines ----- */
65 
68 #define APP_DEVICE_NAME_CHAR 'S','e','n','s','e','P','i'
69 const uint8_t app_device_name[] = { APP_DEVICE_NAME_CHAR };
70 
73 #define APP_UUID_COMPLETE 0x0a, 0xde, 0xfb, 0x07, 0x74, 0x83, 0x66, 0xb0, 0x0d, 0x48, 0xf5, 0x07, 0x50, 0xdc, 0x73, 0x3c
74 
77 #define APP_ADV_DATA { \
78  0x02, BLE_GAP_AD_TYPE_FLAGS, BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE, \
79  sizeof(app_device_name) + 1, BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME, APP_DEVICE_NAME_CHAR, \
80  0x11, BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE, APP_UUID_COMPLETE \
81  }
82 
85 #define APP_SCAN_RSP_DATA { \
86  0x02, BLE_GAP_AD_TYPE_TX_POWER_LEVEL, 0 , \
87  0x11, BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME, \
88  'x', 'x','x', 'x', 'x', 'x' , 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', 'x', \
89  0x04, BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA, 0 , 0 , 0 \
90  }
91 
94 #define WDT_PERIOD_MS 301000
95 
97 #define ENABLE_WDT 1
98 
102 #define PIR_SENSE_INTERVAL_MS 50
103 
104 #define PIR_SENSE_THRESHOLD 600
105 
107 #define SENSE_FAST_TICK_INTERVAL_MS 60
108 
109 #define SENSE_SLOW_TICK_INTERVAL_MS 300000
110 
112 #define ADV_FAST_TICK_INTERVAL_MS 60
113 
114 #define ADV_SLOW_TICK_INTERVAL_MS 1100
115 
117 #define CONN_FAST_TICK_INTERVAL_MS 60
118 
119 #define CONN_SLOW_TICK_INTERVAL_MS 1100
120 
122 #define CONN_TIMEOUT_MS (10*60*1000)
123 
125 typedef enum
126 {
131 }sense_states;
132 
133 /* ----- Global constants in flash ----- */
134 
135 /* ----- Global variables in RAM ----- */
138 
140 static uint32_t conn_count;
141 
142 static sensepi_config_t sensepi_ble_default_config = {
143  .pir_conf.oper_time.day_or_night = 1,
144  .pir_conf.oper_time.threshold = 0b0000000,
145  .pir_conf.amplification = 20,
146  .pir_conf.threshold = 175,
147  .pir_conf.mode = 0x00000000,
148  .pir_conf.intr_trig_timer = 50,
149 
150  .timer_conf.oper_time.day_or_night = 1,
151  .timer_conf.oper_time.threshold = 0b0000000,
152  .timer_conf.mode = 0x00000000,
153  .timer_conf.timer_interval = 50,
154 
155  .trig_conf = PIR_ONLY,
156 };
157 
158 static uint32_t out_pin_array[] = {JACK_FOCUS_PIN, JACK_TRIGGER_PIN};
159 
160 static sensepi_cam_trigger_init_config_t sensepi_cam_trigger_default_config =
161 {
162  .config_sensepi = &sensepi_ble_default_config,
163  .led_sense_analog_in_pin = PIN_TO_ANALOG_INPUT(LED_LIGHT_SENSE),
164  .led_sense_off_val = !(LEDS_ACTIVE_STATE),
165  .led_sense_out_pin = LED_GREEN,
166  .pir_sense_offset_input = PIN_TO_ANALOG_INPUT(PIR_AMP_OFFSET_PIN),
167  .pir_sense_signal_input = PIN_TO_ANALOG_INPUT(PIR_AMP_SIGNAL_PIN),
168  .amp_cs_pin = MCP4012T_CS_PIN,
169  .amp_ud_pin= MCP4012T_UD_PIN,
170  .amp_spi_sck_pin = SPI_SCK_PIN,
171  .signal_out_pin_array = out_pin_array,
172  .signal_pin_num = ARRAY_SIZE(out_pin_array),
173 };
174 
175 
176 /* ----- Function declarations ----- */
177 
178 /* ----- Function definitions ----- */
181  log_printf("WDT reset\n");
182 }
183 
184 void prepare_init_ble_adv()
185 {
186  uint8_t app_adv_data[] = APP_ADV_DATA;
187  uint8_t app_scan_rsp_data[] = APP_SCAN_RSP_DATA;
188 
189  //Add in the firmware version
190  memcpy(&app_scan_rsp_data[23], fw_ver_get(), sizeof(fw_ver_t));
191 
192  //Add the device ID
193  memcpy(&app_scan_rsp_data[5], dev_id_get(), sizeof(dev_id_t));
194 
195  sensepi_ble_adv_data_t app_adv_data_struct =
196  {
197  .adv_data = app_adv_data,
198  .scan_rsp_data = app_scan_rsp_data,
199  .adv_len = ARRAY_SIZE(app_adv_data),
200  .scan_rsp_len = ARRAY_SIZE(app_scan_rsp_data)
201  };
202 
203  sensepi_ble_adv_init(&app_adv_data_struct);
204 }
205 
212 static void ble_evt_handler(ble_evt_t * evt)
213 {
214  log_printf("ble evt %x\n", evt->header.evt_id);
215  switch (evt->header.evt_id)
216  {
217  case BLE_GAP_EVT_CONNECTED:
218  irq_msg_push(MSG_STATE_CHANGE, (void *) CONNECTED);
219  break;
220  case BLE_GAP_EVT_DISCONNECTED:
221  irq_msg_push(MSG_STATE_CHANGE, (void *) SENSING);
222  break;
223  case BLE_GAP_EVT_ADV_SET_TERMINATED:
224  irq_msg_push(MSG_STATE_CHANGE, (void *) SENSING);
225  break;
226  case BLE_GAP_EVT_CONN_PARAM_UPDATE:
227  log_printf("sup time %d s, max intvl %d ms, min intvl %d ms, slave lat %d\n",
228  evt->evt.gap_evt.params.conn_param_update.conn_params.conn_sup_timeout/100,
229  (5*evt->evt.gap_evt.params.conn_param_update.conn_params.max_conn_interval)/4,
230  (5*evt->evt.gap_evt.params.conn_param_update.conn_params.min_conn_interval)/4,
231  evt->evt.gap_evt.params.conn_param_update.conn_params.slave_latency);
232  break;
233  }
234 }
235 
240 static void get_sensepi_config_t(sensepi_config_t *config)
241 {
242  log_printf("Trig mode %d, PIR ope time %08x, PIR mode %08x, PIR amp %d, PIR thres %d, \
243  PIR int trig time %04d, Timer oper %x, Timer mode %x, timer interval %04d \n",
244  config->trig_conf, config->pir_conf.oper_time, config->pir_conf.mode,
245  config->pir_conf.amplification, config->pir_conf.threshold,
246  config->pir_conf.intr_trig_timer,
247  config->timer_conf.oper_time, config->timer_conf.mode, config->timer_conf.timer_interval);
249 }
250 
256 void next_interval_handler(uint32_t interval)
257 {
258  log_printf("in %d\n", interval);
259  button_ui_add_tick(interval);
260  switch(current_state)
261  {
262  case SENSING:
263  {
264  log_printf("Nxt Evt Hndlr : SENSING\n");
265  sensepi_cam_trigger_add_tick(interval);
266  }
267  break;
268  case ADVERTISING:
269  break;
270  case CONNECTED:
271  {
272  conn_count += interval;
273  if(conn_count > MS_TIMER_TICKS_MS(CONN_TIMEOUT_MS))
274  {
276  }
277  }
278  break;
279  }
280 }
281 
287 void state_change_handler(uint32_t new_state)
288 {
289  log_printf("State change %d\n", new_state);
290  if(new_state == current_state)
291  {
292  log_printf("new state same as current state\n");
293  return;
294  }
295  current_state = (sense_states) new_state;
296 
297  switch(current_state)
298  {
299  case SENSING:
300  {
301  sd_softdevice_disable();
302  log_printf("State Change : SENSING\n");
303  device_tick_cfg tick_cfg =
304  {
308  };
309  device_tick_init(&tick_cfg);
310 
311  led_ui_type_stop_all(LED_UI_LOOP_SEQ);
312 
314  }
315  break;
316  case ADVERTISING:
317  {
319  conn_count = 0;
320 
321  device_tick_cfg tick_cfg =
322  {
326  };
327  device_tick_init(&tick_cfg);
328 
329  uint8_t is_sd_enabled;
330  sd_softdevice_is_enabled(&is_sd_enabled);
331  // Would be coming from the SENSING mode
332  if(is_sd_enabled == 0)
333  {
337  prepare_init_ble_adv();
338 
339  sensepi_sysinfo sysinfo;
340  memcpy(&sysinfo.id, dev_id_get(), sizeof(dev_id_t));
341  sysinfo.battery_status = aa_aaa_battery_status();
342  memcpy(&sysinfo.fw_ver, fw_ver_get(), sizeof(fw_ver_t));
343  sensepi_ble_update_sysinfo(&sysinfo);
344 
346  sensepi_config_t * config = sensepi_cam_trigger_get_sensepi_config();
348  }
350 
351  led_ui_type_stop_all(LED_UI_LOOP_SEQ);
352  led_ui_loop_start(LED_SEQ_ORANGE_WAVE, LED_UI_MID_PRIORITY);
353  }
354  break;
355  case CONNECTED:
356  {
357  device_tick_cfg tick_cfg =
358  {
362  };
363  device_tick_init(&tick_cfg);
364 
365  led_ui_type_stop_all(LED_UI_LOOP_SEQ);
366  led_ui_loop_start(LED_SEQ_GREEN_WAVE, LED_UI_MID_PRIORITY);
367  break;
368  }
369  }
370 }
371 
379 {
380  if(act == BUTTON_UI_ACT_CROSS)
381  {
382  switch(step)
383  {
384  case BUTTON_UI_STEP_WAKE:
385  log_printf("fast\n");
387  button_ui_config_wake(false);
388  break;
389  case BUTTON_UI_STEP_PRESS:
390  if(current_state == SENSING)
391  {
392  irq_msg_push(MSG_STATE_CHANGE, (void *) ADVERTISING);
393  }
394  break;
395  case BUTTON_UI_STEP_LONG:
396  {
397  NRF_POWER->GPREGRET = 0xB1;
398  log_printf("Trying to do system reset..!!");
399  uint8_t is_sd_enabled;
400  sd_softdevice_is_enabled(&is_sd_enabled);
401  if(is_sd_enabled == 0)
402  {
403  sd_nvic_SystemReset();
404  }
405  else
406  {
407  NVIC_SystemReset ();
408  }
409  }
410  break;
411  }
412  }
413  else //BUTTON_UI_ACT_RELEASE
414  {
416  log_printf("slow\n");
417  button_ui_config_wake(true);
418  switch(step)
419  {
420  case BUTTON_UI_STEP_WAKE:
421  break;
422  case BUTTON_UI_STEP_PRESS:
423  break;
424  case BUTTON_UI_STEP_LONG:
425  break;
426  }
427  }
428 }
429 
434 void leds_init(void)
435 {
436  hal_gpio_cfg_output(LED_RED, LEDS_ACTIVE_STATE);
437  hal_gpio_cfg_output(LED_GREEN, !LEDS_ACTIVE_STATE);
438  hal_nop_delay_ms(600);
439  hal_gpio_pin_write(LED_RED, !LEDS_ACTIVE_STATE);
440  hal_gpio_pin_write(LED_GREEN, LEDS_ACTIVE_STATE);
441  hal_nop_delay_ms(600);
442  hal_gpio_pin_write(LED_RED, !LEDS_ACTIVE_STATE);
443  hal_gpio_pin_write(LED_GREEN, !LEDS_ACTIVE_STATE);
444 }
445 
451 void boot_pwr_config(void)
452 {
453  log_printf("Reset because of ");
454  if(NRF_POWER->RESETREAS == 0)
455  {
456  log_printf("power on or brownout, ");
457  }
458  if(NRF_POWER->RESETREAS & POWER_RESETREAS_DIF_Msk)
459  {
460  log_printf("entering into debug interface from Sys OFF, ");
461  }
462  if(NRF_POWER->RESETREAS & POWER_RESETREAS_DOG_Msk)
463  {
464  log_printf("watchdog bite, ");
465  }
466  if(NRF_POWER->RESETREAS & POWER_RESETREAS_LOCKUP_Msk)
467  {
468  log_printf("CPU lockup, ");
469  }
470  if(NRF_POWER->RESETREAS & POWER_RESETREAS_OFF_Msk)
471  {
472  log_printf("wake up from SYS OFF by GPIO, ");
473  }
474  if(NRF_POWER->RESETREAS & POWER_RESETREAS_RESETPIN_Msk)
475  {
476  log_printf("pin reset, ");
477  }
478  if(NRF_POWER->RESETREAS & POWER_RESETREAS_SREQ_Msk)
479  {
480  log_printf("software reset, ");
481  }
482  log_printf("\n");
483 
484  //Clear the reset reason
485  NRF_POWER->RESETREAS = (POWER_RESETREAS_DIF_Msk |
486  POWER_RESETREAS_DOG_Msk |
487  POWER_RESETREAS_LOCKUP_Msk |
488  POWER_RESETREAS_OFF_Msk |
489  POWER_RESETREAS_RESETPIN_Msk |
490  POWER_RESETREAS_SREQ_Msk);
491 
492  //Enable the DCDC converter if the board supports it
493 #if DC_DC_CIRCUITRY == true //Defined in the board header file
494  NRF_POWER->DCDCEN = POWER_DCDCEN_DCDCEN_Enabled << POWER_DCDCEN_DCDCEN_Pos;
495 #endif
496  NRF_POWER->TASKS_LOWPWR = 1;
497 }
498 
503 {
505  {
506  sensepi_store_config_write (&sensepi_ble_default_config);
507  }
509 }
510 
514 void slumber(void)
515 {
516  uint8_t is_sd_enabled;
517  sd_softdevice_is_enabled(&is_sd_enabled);
518  // Would in the SENSING mode
519  if(is_sd_enabled == 0)
520  {
521  __WFI();
522  }
523  else
524  {
525  sd_app_evt_wait();
526  }
527 }
528 
532 int main(void)
533 {
534  leds_init();
535 
536  /* Mandatory welcome message */
537  log_init();
538  log_printf("\n\nHello SensePi World!\n");
539  boot_pwr_config();
540 
542  ms_timer_init(APP_IRQ_PRIORITY_LOW);
543 #if ENABLE_WDT == 1
545  hal_wdt_start();
546 #endif
547 
548  button_ui_init(BUTTON_PIN, APP_IRQ_PRIORITY_LOW,
550  led_sense_init(LED_GREEN,
551  PIN_TO_ANALOG_INPUT(LED_LIGHT_SENSE), !LEDS_ACTIVE_STATE);
552 
553  {
554  irq_msg_callbacks cb =
556  irq_msg_init(&cb);
557  }
558  sensepi_cam_trigger_init(&sensepi_cam_trigger_default_config);
559 
560  current_state = ADVERTISING; //So that a state change happens
561  irq_msg_push(MSG_STATE_CHANGE, (void *)SENSING);
562  sensepi_ble_init(ble_evt_handler, get_sensepi_config_t);
564  load_last_config ();
565  while (true)
566  {
567 #if ENABLE_WDT == 1
568  //Since the application demands that CPU wakes up
569  hal_wdt_feed();
570 #endif
572  irq_msg_process();
573  slumber();
574  }
575 }
576 
#define PIR_AMP_OFFSET_PIN
Definition: sensepi_rev2.h:72
void sensepi_cam_trigger_stop()
Function to stop PIR sensing.
bool sensepi_store_config_is_memory_empty(void)
uint8_t aa_aaa_battery_status()
Function to get battery status. It'll convert battery ADC value to 8bit.
When a button press crosses a particular time.
Definition: button_ui.h:44
void sensepi_cam_trigger_add_tick(uint32_t interval)
Function to decide what to decide at current tick.
void sensepi_ble_update_sysinfo(sensepi_sysinfo *sysinfo)
Updates the characteristic that stores the sysinfo.
Definition: sensepi_ble.c:179
fw_ver_t * fw_ver_get(void)
Gets a pointer to the location where the Device ID is stored.
Definition: dev_id_fw_ver.c:35
void boot_pwr_config(void)
Prints the reason for the last reset, enables the internal DC-DC converter if the board supports it a...
Definition: main.c:451
void load_last_config()
function to load previous sensepi configuration present in flash memory
Definition: main.c:502
void hal_wdt_start(void)
Definition: hal_wdt.c:71
#define SPI_SCK_PIN
Definition: sensepi_rev4.h:96
BLE connection established with an app.
Definition: main.c:130
void sensepi_ble_gap_params_init(void)
Generic Access Profile initialization. The device name, and the preferred connection parameters are s...
Definition: sensepi_ble.c:338
void sensepi_store_config_check_fw_ver()
Function to check the major number of firmware if latest major number \ firmware version is greater t...
Fast mode.
Definition: device_tick.h:56
button_ui_action
Definition: button_ui.h:42
#define APP_SCAN_RSP_DATA
Definition: main.c:85
void sensepi_ble_stack_init(void)
Function for initializing the BLE stack by enabling the SoftDevice and the BLE event interrupt.
Definition: sensepi_ble.c:208
sense_states current_state
Definition: main.c:137
void button_ui_init(uint32_t button_pin, uint32_t irq_priority, void(*button_ui_handler)(button_ui_steps step, button_ui_action act))
Initialize the button ui event generator module.
Definition: button_ui.c:66
#define ADV_SLOW_TICK_INTERVAL_MS
Definition: main.c:114
For a long button press.
Definition: button_ui.h:55
void sensepi_ble_adv_start(void)
Function to start advertising.
Definition: sensepi_ble.c:406
void led_ui_loop_start(led_sequences seq, led_ui_priority_t priority)
Start a sequence to play repeatedly.
Definition: led_ui.c:247
void sensepi_ble_service_init(void)
Create the Service and its characteristics for the SensePi device. There is a read-only characteristi...
Definition: sensepi_ble.c:243
#define LEDS_ACTIVE_STATE
Definition: bluey_1v1.h:44
#define SENSE_SLOW_TICK_INTERVAL_MS
Definition: main.c:109
void sensepi_ble_init(void(*ble_sd_evt)(ble_evt_t *evt), void(*config_update)(sensepi_config_t *cfg))
Initialize the handlers to pass the BLE SD events and the configuration received from the mobile app.
Definition: sensepi_ble.c:161
void sensepi_ble_update_config(sensepi_config_t *config)
Updates the characteristic that stores the SensePi config.
Definition: sensepi_ble.c:193
button_ui_steps
Definition: button_ui.h:51
void state_change_handler(uint32_t new_state)
The handler that is called whenever the application transitions to a new state.
Definition: main.c:287
void lfclk_init(lfclk_src_t lfclk_src)
Function to initialize the LF clock.
Definition: hal_clocks.c:23
Use PIR sensor to sense motion based on the set configuration.
Definition: main.c:128
Stucture for passing the configuration for initializing the Device Tick module.
Definition: device_tick.h:64
void led_sense_init(uint32_t led_out_pin, uint32_t led_sense_analog_pin, uint32_t led_off_val)
Initialize the LED light sensing module.
Definition: led_sense.c:27
void button_handler(button_ui_steps step, button_ui_action act)
Handler for all button related events.
Definition: main.c:378
#define ADV_FAST_TICK_INTERVAL_MS
Definition: main.c:112
void sensepi_cam_trigger_init(sensepi_cam_trigger_init_config_t *config_sensepi_cam_trigger)
Function to initiate SensePi_PIR module.
#define APP_DEVICE_NAME_CHAR
Definition: main.c:68
sensepi_config_t * sensepi_store_config_get_last_config()
void sensepi_ble_disconn(void)
Disconnect the current active connection, if already connected.
Definition: sensepi_ble.c:168
#define CONN_SLOW_TICK_INTERVAL_MS
Definition: main.c:119
#define MS_TIMER_TICKS_MS(ms)
Definition: ms_timer.h:64
void button_ui_config_wake(bool set_wake_on)
To enable/disable the button UI GPIOTE IRQ.
Definition: button_ui.c:128
void wdt_prior_reset_callback(void)
Definition: main.c:180
sensepi_config_t * sensepi_cam_trigger_get_sensepi_config()
Function to get the current configuration to send it to mobile app.
void device_tick_init(device_tick_cfg *cfg)
Initializes and starts the Device tick module. Provides a next interval event immediately....
Definition: device_tick.c:52
#define APP_ADV_DATA
Definition: main.c:77
#define PIR_AMP_SIGNAL_PIN
Definition: sensepi_rev2.h:70
#define LED_LIGHT_SENSE
Definition: sensepi_rev3.h:46
void ms_timer_init(uint32_t irq_priority)
Definition: ms_timer.c:111
void led_ui_type_stop_all(led_ui_seq_t type)
Stop all sequence of a particular type.
Definition: led_ui.c:275
dev_id_t * dev_id_get(void)
Gets a pointer to the location where the Device ID is stored.
Definition: dev_id_fw_ver.c:30
Same as previous mode.
Definition: device_tick.h:57
void sensepi_cam_trigger_update(sensepi_config_t *update_config)
Function to update the configuration at every instance when it is changed in the program.
LED_UI_MID_PRIORITY.
Definition: led_ui.h:42
BLE advertising to get connected to an app.
Definition: main.c:129
#define ARRAY_SIZE(arr)
Definition: common_util.h:70
#define CONN_TIMEOUT_MS
Definition: main.c:122
For the moment a button is pressed.
Definition: button_ui.h:56
#define MCP4012T_UD_PIN
Definition: sensepi_rev4.h:94
void device_tick_process(void)
The function to be called whenever the SoC wakes up to see if more than half the time of the current ...
Definition: device_tick.c:89
Trigger only on timer.
Definition: sensepi_ble.h:50
void sensepi_ble_adv_init(sensepi_ble_adv_data_t *sensepi_ble_adv_data)
Function to initializing the advertising.
Definition: sensepi_ble.c:361
void sensepi_store_config_write(sensepi_config_t *latest_config)
Function to write the sensepi_config_t at address location received from get_next_location().
#define CONN_FAST_TICK_INTERVAL_MS
Definition: main.c:117
void irq_msg_init(irq_msg_callbacks *cb_ptr)
Definition: irq_msg_util.c:53
void hal_wdt_feed(void)
Definition: hal_wdt.c:64
void slumber(void)
Definition: main.c:180
void leds_init(void)
Initialize and blink the LEDs momentarily. To be used at the start of the program.
Definition: main.c:434
void irq_msg_process(void)
Definition: irq_msg_util.c:77
#define MCP4012T_CS_PIN
Definition: sensepi_rev4.h:92
void device_tick_switch_mode(device_tick_mode mode)
Switches from the fast to slow mode or vice versa.
Definition: device_tick.c:73
int main(void)
Function for application main entry.
Definition: main.c:90
void button_ui_add_tick(uint32_t ui_ticks)
The ticks that need to be sent to the button UI module for its processing.
Definition: button_ui.c:86
sense_states
Definition: main.c:125
Strcture to configure SensePi_PIR module.
#define WDT_PERIOD_MS
Definition: main.c:94
void hal_wdt_init(uint32_t period_ms, void(*wdt_timeout_handler)(void))
Definition: hal_wdt.c:34
#define SENSE_FAST_TICK_INTERVAL_MS
Definition: main.c:107
void next_interval_handler(uint32_t interval)
The next interval handler is used for providing a periodic tick to be used by the various modules of ...
Definition: main.c:256
void irq_msg_push(irq_msg_types pushed_msg, void *more_data)
Definition: irq_msg_util.c:64
External crystal.
Definition: hal_clocks.h:38
Slow mode.
Definition: device_tick.h:55
void sensepi_cam_trigger_start()
Function to start PIR sensing.