Nordic Semiconductor nRF5 AirFuel SDK  version 2.2.0

Functions

void common_hal_buttons_init (uint32_t button_press_duration_ms, uint8_t app_timer_prescaler)
 Initialize button functionality. Used only for starting DFU. More...
 

Detailed Description

Function Documentation

void common_hal_buttons_init ( uint32_t  button_press_duration_ms,
uint8_t  app_timer_prescaler 
)

Initialize button functionality. Used only for starting DFU.

Parameters
button_press_duration_msHow many milliseconds does the button need to be held down for DFU mode to start
app_timer_prescalerWhat prescaler is the app_timer module set up to use?

Definition at line 40 of file common_hal_buttons.c.

41 {
42  m_button_press_duration_ms = button_press_duration_ms;
43  m_app_timer_prescaler = app_timer_prescaler;
44  nrf_gpio_cfg_input(DFU_BUTTON_PIN, NRF_GPIO_PIN_PULLUP);
45  nrf_gpiote_event_configure(GPIOTE_CHANNEL_NUMBER_BUTTON_PRESS, DFU_BUTTON_PIN, NRF_GPIOTE_POLARITY_HITOLO);
46  nrf_gpiote_event_configure(GPIOTE_CHANNEL_NUMBER_BUTTON_RELEASE, DFU_BUTTON_PIN, NRF_GPIOTE_POLARITY_LOTOHI);
47 
48  NRF_GPIOTE->INTENCLR = GPIOTE_IRQ_INTENCLR_ALL_VAL;
49  NRF_GPIOTE->INTENSET = GPIOTE_IRQ_ENABLE_VAL;
50  NVIC_ClearPendingIRQ(GPIOTE_IRQn);
51  NVIC_SetPriority(GPIOTE_IRQn, APP_IRQ_PRIORITY_LOW);
52  NVIC_EnableIRQ(GPIOTE_IRQn);
53 }
#define GPIOTE_CHANNEL_NUMBER_BUTTON_PRESS
#define GPIOTE_IRQ_INTENCLR_ALL_VAL
#define GPIOTE_IRQ_ENABLE_VAL
#define DFU_BUTTON_PIN
#define GPIOTE_CHANNEL_NUMBER_BUTTON_RELEASE
static uint8_t m_app_timer_prescaler
static uint32_t m_button_press_duration_ms