This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to handle GPIO interrupts while it is configures to SENSE low

Hi all: All of the example code is using GPIOTE to demonstrate how to handle GPIO interrupt. However, it just can configured HiTOLow/LowToHi/Toggle. If I want to trigger the interrupt by sense Low/High, how can I implement the function. For example, we can register a event handler by calling the function of nrf_drv_gpiote_in_init(). How can I register a event handler to handle GPIO interrupts while it sense LOW/HIGH?

Thanks...

Parents
  • I try to use external interrupt from pin.

    Use example \examples\peripheral\pin_change_int

    but doesn't work. I can't receive handler in_pin_handler()

    my code:

    void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
    HAL_GPIO_EXTI_Callback();
    }
    
    static void gpio_init2(void)
    
    {
    ret_code_t err_code;
    
    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);
    
    //    nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
    
    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
    in_config.pull = NRF_GPIO_PIN_NOPULL;
    
    err_code = nrf_drv_gpiote_in_init(INT1, &in_config, in_pin_handler);
    APP_ERROR_CHECK(err_code);
    
    nrf_drv_gpiote_in_event_enable(INT1, true);
    }
    

    where is my wrong?

Reply
  • I try to use external interrupt from pin.

    Use example \examples\peripheral\pin_change_int

    but doesn't work. I can't receive handler in_pin_handler()

    my code:

    void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
    HAL_GPIO_EXTI_Callback();
    }
    
    static void gpio_init2(void)
    
    {
    ret_code_t err_code;
    
    err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);
    
    //    nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
    
    nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
    in_config.pull = NRF_GPIO_PIN_NOPULL;
    
    err_code = nrf_drv_gpiote_in_init(INT1, &in_config, in_pin_handler);
    APP_ERROR_CHECK(err_code);
    
    nrf_drv_gpiote_in_event_enable(INT1, true);
    }
    

    where is my wrong?

Children
Related