2222#include "soc/rtc_cntl_reg.h"
2323#include "soc/sens_reg.h"
2424
25- #define RTC_TOUCH_INUM 13
26-
2725static uint16_t __touchSleepCycles = 0x1000 ;
2826static uint16_t __touchMeasureCycles = 0x1000 ;
2927
3028typedef void (* voidFuncPtr )(void );
3129static voidFuncPtr __touchInterruptHandlers [10 ] = {0 ,};
30+ static intr_handle_t touch_intr_handle = NULL ;
3231
3332void IRAM_ATTR __touchISR (void * arg )
3433{
@@ -66,6 +65,7 @@ void __touchInit()
6665 if (initialized ){
6766 return ;
6867 }
68+ initialized = true;
6969 SET_PERI_REG_BITS (RTC_IO_TOUCH_CFG_REG , RTC_IO_TOUCH_XPD_BIAS , 1 , RTC_IO_TOUCH_XPD_BIAS_S );
7070 SET_PERI_REG_MASK (SENS_SAR_TOUCH_CTRL2_REG , SENS_TOUCH_MEAS_EN_CLR );
7171 //clear touch enable
@@ -74,11 +74,7 @@ void __touchInit()
7474
7575 __touchSetCycles (__touchMeasureCycles , __touchSleepCycles );
7676
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 );
8278}
8379
8480uint16_t __touchRead (uint8_t pin )
0 commit comments