photodiode.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef _PHOTODIODE_H__
  2. #define _PHOTODIODE_H__
  3. #include <stdint.h>
  4. #include <stdbool.h>
  5. #include "define.h"
  6. #include "nrf_drv_gpiote.h"
  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif
  10. #define PHOTODIODE_CHECK_ENBALE nrf_drv_gpiote_in_event_enable(PHOTODIODE_PIN,true);
  11. #define PHOTODIODE_CHECK_DISABLE nrf_drv_gpiote_in_event_enable(PHOTODIODE_PIN,false);
  12. typedef enum
  13. {
  14. PHOTODIODE_QUEUE_TIME=0,
  15. PHOTODIODE_QUEUE_CHANGE=1,
  16. }PHOTODIODE_QUEUE_TYPE;
  17. typedef void (*photodiode_finish_func)(bool stat);
  18. //光敏状态
  19. typedef enum
  20. {
  21. PHOTODIODE_STAT_NULL = (uint8_t)0,
  22. PHOTODIODE_STAT_BRIGHT = (uint8_t)1,
  23. PHOTODIODE_STAT_DARK = (uint8_t)2,
  24. PHOTODIODE_STAT_LAST = PHOTODIODE_STAT_DARK,
  25. }PHOTODIODE_STAT;
  26. typedef struct
  27. {
  28. PHOTODIODE_STAT photodiode_stat; //当前光敏状态
  29. photodiode_finish_func finish_func; //光敏检测完成回调
  30. uint8_t dark_count; //未检测到光的次数
  31. uint8_t bright_count; //检测到光的次数
  32. }PHOTODIODE_STRUCT_t;
  33. void User_photodiode(void);
  34. void photodiode_timers_init(void);
  35. void Set_Photodiode_Queue(PHOTODIODE_QUEUE_TYPE type);
  36. void photodiode_check_init(nrf_drv_gpiote_in_config_t *config,nrfx_gpiote_evt_handler_t evt_handler);
  37. void set_photodiode_finish_func(photodiode_finish_func func);
  38. extern PHOTODIODE_STRUCT_t photodiode_struct;
  39. #endif //_PHOTODIODE_H__