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

Migration from app_gpiote to nrf_drv_gpiote

With the new nrf_drv_gpiote, how can I know if the handler has been trigged by event "low to high" or "high to low"?

Please, could you provide a configuration exemple? I tried this without success because the init for one pin is done twice:

nrf_drv_gpiote_in_config_t config_low_to_high = GPIOTE_CONFIG_IN_SENSE_LOTOHI(false);		
	err_code = nrf_drv_gpiote_in_init(WATCH_BUTTON_1_PIN_NO, &config_low_to_high, gpiote_event_watch_button_1_low_to_high);
APP_ERROR_CHECK(err_code);

nrf_drv_gpiote_in_config_t config_high_to_low = GPIOTE_CONFIG_IN_SENSE_HITOLO(false);		
	err_code = nrf_drv_gpiote_in_init(WATCH_BUTTON_1_PIN_NO, &config_high_to_low, gpiote_event_watch_button_1_high_to_low);
APP_ERROR_CHECK(err_code);

nrf_drv_gpiote_in_event_enable(WATCH_BUTTON_1_PIN_NO, true);

With app_gptiote, I used to catch button event like this :

static void gpiote_init(void)
{
    uint32_t err_code;
    
    APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS);
    
    uint32_t active_high_states_mask = 0;
    uint32_t active_low_states_mask  = 0;
    
    //Watch button
    nrf_gpio_cfg_input(WATCH_BUTTON_PIN_NO, NRF_GPIO_PIN_PULLUP);  	
    
    active_high_states_mask |= (0x1UL << WATCH_BUTTON_PIN_NO);
    active_low_states_mask  |= (0x1UL << WATCH_BUTTON_PIN_NO);
    
    err_code = app_gpiote_user_register(&m_gpiote_watch_btn_id,
                                active_high_states_mask,
                                active_low_states_mask,
                                gpiote_event_watch_button_handler);
    
    APP_ERROR_CHECK(err_code);
    
    err_code = app_gpiote_user_enable(m_gpiote_watch_btn_id);
    APP_ERROR_CHECK(err_code);
}

static void gpiote_event_watch_button_handler(uint32_t event_pins_low_to_high, uint32_t event_pins_high_to_low)
{        
    //Push
    if(event_pins_high_to_low)
        kernel_setSignal(SIGNAL_BTN_PUSH);	
    
    //Release
    if(event_pins_low_to_high)
        kernel_setSignal(SIGNAL_BTN_RELEASE);	
}
Parents Reply Children
No Data
Related