Skip to content

Commit 685e0b4

Browse files
committed
lib: dk_buttons_and_lets: Remove DK_LIBRARY_BUTTON_NO_ISR
The nRF54L15PDK is no longer supported. Signed-off-by: Carles Cufi <[email protected]>
1 parent 5cf5619 commit 685e0b4

File tree

2 files changed

+21
-50
lines changed

2 files changed

+21
-50
lines changed

lib/dk_buttons_and_leds/Kconfig

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,36 +12,12 @@ if DK_LIBRARY
1212

1313
config DK_LIBRARY_BUTTON_SCAN_INTERVAL
1414
int "Scanning interval of buttons in milliseconds"
15-
default 50 if DK_LIBRARY_BUTTON_NO_ISR
1615
default 10
1716

1817
config DK_LIBRARY_DYNAMIC_BUTTON_HANDLERS
1918
bool "Enable the runtime assignable button handler API"
2019
default y
2120

22-
config DK_LIBRARY_BUTTON_NO_ISR
23-
bool "Poll buttons unconditionally (no interrupts) [EXPERIMENTAL]"
24-
# Workaround for buttons on nRF54L15 PDK in revision 0.2.x.
25-
default y if BOARD_NRF54L15PDK_NRF54L15_CPUAPP && (BOARD_REVISION = "0.2.0" || BOARD_REVISION = "0.2.1")
26-
select EXPERIMENTAL
27-
help
28-
With this option disabled, the module periodically scans all the
29-
available buttons until no button is pressed. If no button is
30-
pressed, the module uses GPIO interrupts to detect the first button
31-
press. On the first button press, the module switches back to
32-
periodically scanning buttons.
33-
34-
Enable this option to avoid relying on GPIO interrupts at all and
35-
to unconditionally scan all buttons periodically. Please note that
36-
the constant scanning activity increases the overall power
37-
consumption of the system.
38-
39-
For example, in case the application uses Button 3 or 4, the option
40-
must be set for the nRF54L15 PDK (PCA10156) revisions
41-
v0.2.0 AA0-ES2, v0.2.0 AA0-ES3, and v0.2.1 AB0-ES5.
42-
These versions of the PDK have Buttons 3 and 4 connected to
43-
the GPIO port which does not support interrupts.
44-
4521
module = DK_LIBRARY
4622
module-str = DK library
4723
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"

lib/dk_buttons_and_leds/dk_buttons_and_leds.c

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,7 @@ static void buttons_scan_fn(struct k_work *work)
129129
static bool initial_run = true;
130130
uint32_t button_scan;
131131

132-
__ASSERT_NO_MSG(!IS_ENABLED(CONFIG_DK_LIBRARY_BUTTON_NO_ISR) || !irq_enabled);
133-
134-
if (!IS_ENABLED(CONFIG_DK_LIBRARY_BUTTON_NO_ISR) && irq_enabled) {
132+
if (irq_enabled) {
135133
/* Disable GPIO interrupts for edge triggered devices.
136134
* Devices that are configured with active high interrupts are already disabled.
137135
*/
@@ -159,7 +157,7 @@ static void buttons_scan_fn(struct k_work *work)
159157

160158
last_button_scan = button_scan;
161159

162-
if (IS_ENABLED(CONFIG_DK_LIBRARY_BUTTON_NO_ISR) || (button_scan != 0)) {
160+
if (button_scan != 0) {
163161
k_work_reschedule(&buttons_scan,
164162
K_MSEC(CONFIG_DK_LIBRARY_BUTTON_SCAN_INTERVAL));
165163
} else {
@@ -238,6 +236,7 @@ static void button_pressed(const struct device *gpio_dev, struct gpio_callback *
238236

239237
int dk_buttons_init(button_handler_t button_handler)
240238
{
239+
uint32_t pin_mask = 0;
241240
int err;
242241

243242
button_handler_cb = button_handler;
@@ -259,31 +258,27 @@ int dk_buttons_init(button_handler_t button_handler)
259258
}
260259
}
261260

262-
if (!IS_ENABLED(CONFIG_DK_LIBRARY_BUTTON_NO_ISR)) {
263-
uint32_t pin_mask = 0;
264-
265-
for (size_t i = 0; i < ARRAY_SIZE(buttons); i++) {
266-
/* Module starts in scanning mode and will switch to
267-
* callback mode if no button is pressed.
268-
*/
269-
err = gpio_pin_interrupt_configure_dt(&buttons[i],
270-
GPIO_INT_DISABLE);
271-
if (err) {
272-
LOG_ERR("Cannot disable callbacks()");
273-
return err;
274-
}
275-
276-
pin_mask |= BIT(buttons[i].pin);
261+
for (size_t i = 0; i < ARRAY_SIZE(buttons); i++) {
262+
/* Module starts in scanning mode and will switch to
263+
* callback mode if no button is pressed.
264+
*/
265+
err = gpio_pin_interrupt_configure_dt(&buttons[i],
266+
GPIO_INT_DISABLE);
267+
if (err) {
268+
LOG_ERR("Cannot disable callbacks()");
269+
return err;
277270
}
278271

279-
gpio_init_callback(&gpio_cb, button_pressed, pin_mask);
272+
pin_mask |= BIT(buttons[i].pin);
273+
}
280274

281-
for (size_t i = 0; i < ARRAY_SIZE(buttons); i++) {
282-
err = gpio_add_callback(buttons[i].port, &gpio_cb);
283-
if (err) {
284-
LOG_ERR("Cannot add callback");
285-
return err;
286-
}
275+
gpio_init_callback(&gpio_cb, button_pressed, pin_mask);
276+
277+
for (size_t i = 0; i < ARRAY_SIZE(buttons); i++) {
278+
err = gpio_add_callback(buttons[i].port, &gpio_cb);
279+
if (err) {
280+
LOG_ERR("Cannot add callback");
281+
return err;
287282
}
288283
}
289284

0 commit comments

Comments
 (0)