#ifndef _PHOTODIODE_H__ #define _PHOTODIODE_H__ #include #include #include "define.h" #include "nrf_drv_gpiote.h" #ifdef __cplusplus extern "C" { #endif #define PHOTODIODE_CHECK_ENBALE nrf_drv_gpiote_in_event_enable(PHOTODIODE_PIN,true); #define PHOTODIODE_CHECK_DISABLE nrf_drv_gpiote_in_event_enable(PHOTODIODE_PIN,false); typedef enum { PHOTODIODE_QUEUE_TIME=0, PHOTODIODE_QUEUE_CHANGE=1, }PHOTODIODE_QUEUE_TYPE; typedef void (*photodiode_finish_func)(bool stat); //光敏状态 typedef enum { PHOTODIODE_STAT_NULL = (uint8_t)0, PHOTODIODE_STAT_BRIGHT = (uint8_t)1, PHOTODIODE_STAT_DARK = (uint8_t)2, PHOTODIODE_STAT_LAST = PHOTODIODE_STAT_DARK, }PHOTODIODE_STAT; typedef struct { PHOTODIODE_STAT photodiode_stat; //当前光敏状态 photodiode_finish_func finish_func; //光敏检测完成回调 uint8_t dark_count; //未检测到光的次数 uint8_t bright_count; //检测到光的次数 }PHOTODIODE_STRUCT_t; void User_photodiode(void); void photodiode_timers_init(void); void Set_Photodiode_Queue(PHOTODIODE_QUEUE_TYPE type); void photodiode_check_init(nrf_drv_gpiote_in_config_t *config,nrfx_gpiote_evt_handler_t evt_handler); void set_photodiode_finish_func(photodiode_finish_func func); extern PHOTODIODE_STRUCT_t photodiode_struct; #endif //_PHOTODIODE_H__