shock_switch.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef SHOCK_SWITH_H__
  2. #define SHOCK_SWITH_H__
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include "boards.h"
  6. #include "nrf_drv_gpiote.h"
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #define SHOCK_CHECKOUT_INTERVAL 700
  11. typedef enum
  12. {
  13. SHOCK_SW_QUEUE_TIME=0,
  14. SHOCK_SW_QUEUE_INT=1,
  15. }SHOCK_SW_QUEUE_TYPE;
  16. typedef void (*shock_act_func)(bool stat);
  17. typedef enum
  18. {
  19. SHOCK_STAT_NULL = (uint8_t)0,
  20. SHOCK_STAT_STATIC = (uint8_t)1,
  21. SHOCK_STAT_SHOCK = (uint8_t)2,
  22. SHOCK_STAT_LAST = SHOCK_STAT_SHOCK,
  23. }shock_stat_e;
  24. typedef struct
  25. {
  26. bool shock_int_stat; //震动中断触发开启状态
  27. bool shock_check_stat; //震动检测状态
  28. shock_stat_e shock_stat; //当前震动状态
  29. uint8_t shock_stat_count; //震动触发次数
  30. shock_act_func shock_act; //震动状态触发
  31. }shock_struct_s;
  32. void shock_sw_timers_init(void);
  33. void Set_Shock_SW_Queue(SHOCK_SW_QUEUE_TYPE type);
  34. void shock_sw_event_enable(void);
  35. void shock_sw_event_disable(void);
  36. void shock_sw_int_init(nrf_drv_gpiote_in_config_t *config,nrfx_gpiote_evt_handler_t evt_handler);
  37. void shock_event_pro(void);
  38. bool get_shock_stat(void);
  39. void set_Shock_act_func(shock_act_func func);
  40. extern bool shock_stat;
  41. #ifdef __cplusplus
  42. }
  43. #endif
  44. #endif // SHOCK_BL_2030_H__
  45. /** @} */