diff --git a/components/driver/include/driver/touch_pad.h b/components/driver/include/driver/touch_pad.h index b8dc6e753..4f78b2351 100644 --- a/components/driver/include/driver/touch_pad.h +++ b/components/driver/include/driver/touch_pad.h @@ -19,6 +19,7 @@ extern "C" { #endif #include "esp_intr.h" #include "esp_err.h" +#include "esp_intr_alloc.h" #define TOUCH_PAD_SLEEP_CYCLE_CONFIG (0x1000)//The Time is 150Khz,the Max value is 0xffff #define TOUCH_PAD_MEASURE_CYCLE_CONFIG (0xffff)//The Time is 8Mhz,the Max value is 0xffff typedef enum { @@ -34,6 +35,9 @@ typedef enum { TOUCH_PAD_NUM9, /*!< Touch pad channel 0 is GPIO32*/ TOUCH_PAD_MAX, } touch_pad_t; + +typedef intr_handle_t touch_isr_handle_t; + /** * @brief Initialize touch module. * @@ -79,44 +83,40 @@ esp_err_t touch_pad_read(touch_pad_t touch_num, uint16_t * touch_value); /** * @brief register TouchPad interrupt handler, the handler is an ISR. * The handler will be attached to the same CPU core that this function is running on. - * @note - * Users should know that which CPU is running and then pick a INUM that is not used by system. - * We can find the information of INUM and interrupt level in soc.h. * - * @param touch_intr_num Touch interrupt number,check the info in soc.h, and please see the core-isa.h for more details * @param fn Interrupt handler function. - * - * @note - * Note that the handler function MUST be defined with attribution of "IRAM_ATTR". - * * @param arg Parameter for handler function + * @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred) + * ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info. + * @param handle Pointer to return handle. If non-NULL, a handle for the interrupt will + * be returned here. * * @return * - ESP_OK Success ; * - ESP_ERR_INVALID_ARG GPIO error */ -esp_err_t touch_pad_isr_handler_register(uint32_t touch_intr_num, void(*fn)(void*), void *arg); +esp_err_t touch_pad_isr_handler_register(void(*fn)(void *), void *arg, int intr_alloc_flags, touch_isr_handle_t *handle); /** * *************** ATTENTION ********************/ /** *@attention -*Touch button is through the body's capacitive characteristics, -*there is a charge discharge circuit inside the. When the hands touch, -*the charge and discharge time will be slow. -*Because of the different hardware, each pad needs to be calibrated at the factory. -*We use touch_pad_read to determine factory parament. -*/ + *Touch button is through the body's capacitive characteristics, + *there is a charge discharge circuit inside the. When the hands touch, + *the charge and discharge time will be slow. + *Because of the different hardware, each pad needs to be calibrated at the factory. + *We use touch_pad_read to determine factory parameters. + */ /** - *----------EXAMPLE TO CONIFGURE GPIO AS OUTPUT ------------ * + *----------EXAMPLE TO CONFIGURE GPIO AS OUTPUT ------------ * * @code{c} * touch_pad_init(); * void taskA(void* arg) * { * for(;;){ * vtaskDelay(20/portTICK_PERIOD_MS); - * ets_printf("tocuch pad value %u\n",touch_pad_read(0));//Take the touched status and untouched status value + * ets_printf("touch pad value %u\n",touch_pad_read(0));//Take the touched status and untouched status value * } * } * @endcode @@ -124,22 +124,17 @@ esp_err_t touch_pad_isr_handler_register(uint32_t touch_intr_num, void(*fn)(void /** *----------EXAMPLE TO SET ISR HANDLER ---------------------- * @code{c} - * //the first parameter is INUM, you can pick one form interrupt level 1/2 which is not used by the system. - * touch_pad_isr_handler_register(19,rtc_intr,NULL); //hook the isr handler for TouchPad interrupt + * touch_pad_isr_handler_register(rtc_intr,NULL, 0, NULL) //hook the isr handler for TouchPad interrupt * @endcode - * @note - * 1. user should arrange the INUMs that used, better not to use a same INUM for different interrupt. - * 2. do not pick the INUM that already occupied by the system. - * 3. refer to soc.h to check which INUMs that can be used. */ /** *----------EXAMPLE TO USE TOUCH_PAD------------ * * @code{c} * touch_pad_init();//only init one time * touch_pad_config(0,300);//set the intr threshold,use touch_pad_read to determine this threshold - * touch_pad_isr_handler_register(19,rtc_intr,NULL) + * touch_pad_isr_handler_register(rtc_intr,NULL, 0, NULL) * #include "esp_attr.h" - * void IRAM_ATTR rtc_intr(void * arg) + * void rtc_intr(void * arg) * { * uint32_t pad_intr = READ_PERI_REG(SARADC_SAR_TOUCH_CTRL2_REG) & 0x3ff; * uint8_t i = 0; diff --git a/components/driver/rtc_module.c b/components/driver/rtc_module.c index 5da738b45..ab6112d4f 100644 --- a/components/driver/rtc_module.c +++ b/components/driver/rtc_module.c @@ -264,15 +264,10 @@ esp_err_t rtc_gpio_pulldown_dis(gpio_num_t gpio_num) /*--------------------------------------------------------------- Touch Pad ---------------------------------------------------------------*/ -esp_err_t touch_pad_isr_handler_register(uint32_t touch_intr_num, void(*fn)(void *), void *arg) +esp_err_t touch_pad_isr_handler_register(void(*fn)(void *), void *arg, int intr_alloc_flags, touch_isr_handle_t *handle) { RTC_MODULE_CHECK(fn, "Touch_Pad ISR null", ESP_ERR_INVALID_ARG); - ESP_INTR_DISABLE(touch_intr_num); - intr_matrix_set(xPortGetCoreID(), ETS_RTC_CORE_INTR_SOURCE, touch_intr_num); - xt_set_interrupt_handler(touch_intr_num, fn, arg); - ESP_INTR_ENABLE(touch_intr_num); - - return ESP_OK; + return esp_intr_alloc(ETS_RTC_CORE_INTR_SOURCE, intr_alloc_flags, fn, arg, handle); } static esp_err_t touch_pad_get_io_num(touch_pad_t touch_num, gpio_num_t *gpio_num) diff --git a/components/esp32/lib b/components/esp32/lib index 5902a2229..3a412c08a 160000 --- a/components/esp32/lib +++ b/components/esp32/lib @@ -1 +1 @@ -Subproject commit 5902a2229e5371aeea45c09e63ea5e233b58750f +Subproject commit 3a412c08af1ace47a58d1f8722a8fed5b8d3b944 diff --git a/tools/unit-test-app/sdkconfig b/tools/unit-test-app/sdkconfig index 9e5be636d..1b9db9951 100644 --- a/tools/unit-test-app/sdkconfig +++ b/tools/unit-test-app/sdkconfig @@ -93,6 +93,11 @@ CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2048 CONFIG_MAIN_TASK_STACK_SIZE=4096 CONFIG_NEWLIB_STDOUT_ADDCR=y +CONFIG_CONSOLE_UART_DEFAULT=y +# CONFIG_CONSOLE_UART_CUSTOM is not set +# CONFIG_CONSOLE_UART_NONE is not set +CONFIG_CONSOLE_UART_NUM=0 +CONFIG_CONSOLE_UART_BAUDRATE=115200 CONFIG_ULP_COPROC_ENABLED=y CONFIG_ULP_COPROC_RESERVE_MEM=512 # CONFIG_ESP32_PANIC_PRINT_HALT is not set