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

How do I interface external IO pins when app_button is used?

I would like to support app_button, however I need to configure a pin as NOPULL and trigger on a low to high transition without debouncing.

I don't see a way this can co-exist with the app_button modile. I tried using nrf_drv_gpiote but was confused when it would not let me register new event handlers.

What is the recommended way of interfacing external interrupts with an application already using app_button?

-- Is this sufficient if I use the gpiote merge fix to use both app_gpiote and nrf_drv_gpiote?

	APP_GPIOTE_INIT(2);
	app_gpiote_user_register(&userid, (1<<16), 0, evt_hdl);
	app_gpiote_user_enable(userid);
Parents
  • You can configure pin with different trigger level and different pulls with app_buttons static app_button_cfg_t buttons[] = { {BSP_BUTTON_0, APP_BUTTON_ACTIVE_HIGH, NRF_GPIO_PIN_NOPULL, button0_event_handler}, {BSP_BUTTON_1, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULL, button1_event_handler}, };

    Else your solution should work well if you use the merge fix.

  • Yes, override before calling the app_button_init function. If you have energy to experiment more, then you can even reduce debounce_time for that specific pin in app_button.c->gpiote_event_handler replace

    err_code = app_timer_start(m_detection_delay_timer_id, m_detection_delay, NULL);
    

    with

      if(external_pin) err_code = app_timer_start(m_detection_delay_timer_id, 5, NULL);
      else err_code = app_timer_start(m_detection_delay_timer_id, m_detection_delay, NULL);
    

    Then you interrupt needs to stay active just for 5 ticks ...

Reply
  • Yes, override before calling the app_button_init function. If you have energy to experiment more, then you can even reduce debounce_time for that specific pin in app_button.c->gpiote_event_handler replace

    err_code = app_timer_start(m_detection_delay_timer_id, m_detection_delay, NULL);
    

    with

      if(external_pin) err_code = app_timer_start(m_detection_delay_timer_id, 5, NULL);
      else err_code = app_timer_start(m_detection_delay_timer_id, m_detection_delay, NULL);
    

    Then you interrupt needs to stay active just for 5 ticks ...

Children
No Data
Related