续前一篇文章。
3、nrfx_gpiote_in_event_enable
void nrfx_gpiote_in_event_enable(nrfx_gpiote_pin_t pin, bool int_enable) { NRFX_ASSERT(nrf_gpio_pin_present_check(pin)); NRFX_ASSERT(pin_in_use_by_gpiote(pin)); if (pin_in_use_by_port(pin)) { nrf_gpiote_polarity_t polarity = port_handler_polarity_get(channel_port_get(pin) - GPIOTE_CH_NUM); nrf_gpio_pin_sense_t sense; if (polarity == NRF_GPIOTE_POLARITY_TOGGLE) { /* read current pin state and set for next sense to oposit */ sense = (nrf_gpio_pin_read(pin)) ? NRF_GPIO_PIN_SENSE_LOW : NRF_GPIO_PIN_SENSE_HIGH; } else { sense = (polarity == NRF_GPIOTE_POLARITY_LOTOHI) ? NRF_GPIO_PIN_SENSE_HIGH : NRF_GPIO_PIN_SENSE_LOW; } nrf_gpio_cfg_sense_set(pin, sense); } else if (pin_in_use_by_te(pin)) { int32_t channel = (int32_t)channel_port_get(pin); nrf_gpiote_events_t event = TE_IDX_TO_EVENT_ADDR((uint32_t)channel); nrf_gpiote_event_enable((uint32_t)channel); nrf_gpiote_event_clear(event); if (int_enable) { nrfx_gpiote_evt_handler_t handler = channel_handler_get((uint32_t)channel_port_get(pin)); // Enable the interrupt only if event handler was provided. if (handler) { nrf_gpiote_int_enable(1 << channel); } } } }
![图片[1]-7、nRF52xx蓝牙学习(nrf_gpiote.c库函数学习)-ELink墨水屏电子纸社区-FPGA CPLD-ChipDebug](http://chipdebug.com/wp-content/uploads/2025/11/20251112115049119-21762919449.png?v=1762919449)
一、函数概述
nrfx_gpiote_in_event_enable 函数的主要功能是为指定的 GPIO 引脚启用 GPIOTE(通用外设中断和事件)输入事件。
该函数会根据引脚的使用情况(是由端口处理还是由定时器事件处理)来配置相应的引脚感应和事件中断。&nb





没有回复内容