22
22
#include "soc/rtc_cntl_reg.h"
23
23
#include "soc/sens_reg.h"
24
24
25
- #define RTC_TOUCH_INUM 13
26
-
27
25
static uint16_t __touchSleepCycles = 0x1000 ;
28
26
static uint16_t __touchMeasureCycles = 0x1000 ;
29
27
30
28
typedef void (* voidFuncPtr )(void );
31
29
static voidFuncPtr __touchInterruptHandlers [10 ] = {0 ,};
30
+ static intr_handle_t touch_intr_handle = NULL ;
32
31
33
32
void IRAM_ATTR __touchISR (void * arg )
34
33
{
@@ -66,6 +65,7 @@ void __touchInit()
66
65
if (initialized ){
67
66
return ;
68
67
}
68
+ initialized = true;
69
69
SET_PERI_REG_BITS (RTC_IO_TOUCH_CFG_REG , RTC_IO_TOUCH_XPD_BIAS , 1 , RTC_IO_TOUCH_XPD_BIAS_S );
70
70
SET_PERI_REG_MASK (SENS_SAR_TOUCH_CTRL2_REG , SENS_TOUCH_MEAS_EN_CLR );
71
71
//clear touch enable
@@ -74,11 +74,7 @@ void __touchInit()
74
74
75
75
__touchSetCycles (__touchMeasureCycles , __touchSleepCycles );
76
76
77
- ESP_INTR_DISABLE (RTC_TOUCH_INUM );
78
- intr_matrix_set (xPortGetCoreID (), ETS_RTC_CORE_INTR_SOURCE , RTC_TOUCH_INUM );
79
- xt_set_interrupt_handler (RTC_TOUCH_INUM , & __touchISR , NULL );
80
- ESP_INTR_ENABLE (RTC_TOUCH_INUM );
81
- initialized = true;
77
+ esp_intr_alloc (ETS_RTC_CORE_INTR_SOURCE , (int )ESP_INTR_FLAG_IRAM , __touchISR , NULL , & touch_intr_handle );
82
78
}
83
79
84
80
uint16_t __touchRead (uint8_t pin )
0 commit comments