nRF Connect SDK Bare Metal API 2.0.99
Loading...
Searching...
No Matches
NCS Bare Metal Buttons library

Buttons management module. More...

Data Structures

struct  bm_buttons_config
 Button configuration. More...
 

Macros

#define BM_BUTTONS_DETECTION_DELAY_MIN_US    (2 * k_ticks_to_us_ceil32(MAX(1, BM_TIMER_MIN_TIMEOUT_TICKS)))
 Minimum detection delay in microseconds.
 

Typedefs

typedef void(* bm_buttons_handler_t) (uint8_t pin_number, enum bm_buttons_evt_type action)
 Button event handler type.
 

Enumerations

enum  bm_buttons_evt_type { BM_BUTTONS_RELEASE = 0 , BM_BUTTONS_PRESS = 1 }
 
enum  bm_buttons_active_state { BM_BUTTONS_ACTIVE_LOW = 0 , BM_BUTTONS_ACTIVE_HIGH = 1 }
 
enum  bm_buttons_pin_pull { BM_BUTTONS_PIN_NOPULL = NRF_GPIO_PIN_NOPULL , BM_BUTTONS_PIN_PULLDOWN = NRF_GPIO_PIN_PULLDOWN , BM_BUTTONS_PIN_PULLUP = NRF_GPIO_PIN_PULLUP }
 Enumerator used for selecting the pin to be pulled down or up at the time of pin configuration. More...
 

Functions

int bm_buttons_init (const struct bm_buttons_config *configs, uint8_t num_configs, uint32_t detection_delay)
 Initialize buttons.
 
int bm_buttons_deinit (void)
 Deinitialize buttons.
 
int bm_buttons_enable (void)
 Enable button detection.
 
int bm_buttons_disable (void)
 Disable button detection.
 
bool bm_buttons_is_pressed (uint8_t pin)
 Check if a button is being pressed.
 

Detailed Description

Buttons management module.

The bm_buttons library uses the nrfx_gpiote to detect that a button has been pressed. To handle debouncing, it will start a bm_timer. The button will only be reported as pressed if the corresponding pin is still active when the timer expires. If there is a new GPIOTE event while the timer is running, the timer is restarted.