Button handling implementation for eval-powrms project.
More...
#include <stdbool.h>
#include <stdint.h>
#include "powrms_gpios.h"
#include "parameters.h"
#include "no_os_gpio.h"
#include "no_os_error.h"
#include "no_os_delay.h"
#include "no_os_irq.h"
#include "maxim_gpio_irq.h"
#include "example.h"
#include "no_os_print_log.h"
Button handling implementation for eval-powrms project.
- Author
- Robert Budai (rober.nosp@m.t.bu.nosp@m.dai@a.nosp@m.nalo.nosp@m.g.com)
Copyright 2025(c) Analog Devices, Inc.
SPDX-License-Identifier: BSD-3-Clause
◆ BTN_BACK_FLAG
| #define BTN_BACK_FLAG (1 << 1) |
◆ BTN_BACK_PIN
◆ BTN_ENTER_FLAG
| #define BTN_ENTER_FLAG (1 << 2) |
◆ BTN_ENTER_PIN
◆ BTN_GPIO_PORT
◆ BTN_NEXT_FLAG
| #define BTN_NEXT_FLAG (1 << 0) |
◆ BTN_NEXT_PIN
◆ BTN_ON_OFF_HOLD_MS
| #define BTN_ON_OFF_HOLD_MS 250 |
◆ BTN_ON_OFF_PIN
| #define BTN_ON_OFF_PIN 14 |
◆ buttons_init()
| int buttons_init |
( |
void | | ) |
|
Initialize button GPIO pins.
Initialize interrupt-based button handling.
Configures GPIO pins 0.16, 0.17, and 0.18 as input pins with pull-up resistors for button functionality (NEXT, BACK, ENTER).
- Returns
- 0 on success, negative error code on failure
◆ buttons_read()
| int buttons_read |
( |
void | | ) |
|
Read button states with debouncing.
Read button states using interrupt flags.
Reads the current state of all buttons and applies debouncing logic to prevent false triggers from mechanical switch bounce.
- Returns
- Button press code:
- 0: No button pressed
- 1: NEXT button pressed (GPIO 0.17)
- 2: BACK button pressed (GPIO 0.16)
- 3: ENTER button pressed (GPIO 0.18)
- 4: ON_OFF latch held LOW for > 250 ms (GPIO 0.14)
◆ configure_gpios_upon_shutdown()
| int configure_gpios_upon_shutdown |
( |
| ) |
|
Configure GPIOs upon system shutdown.
Safely powers down the system by disabling power rails and setting control signals to their safe states. Finally, triggers a system reset.
- Returns
- 0 on success, negative error code on failure
◆ configure_gpios_upon_startup()
| void configure_gpios_upon_startup |
( |
void | | ) |
|
Configure GPIOs upon system startup.
Sets up necessary GPIO pins for system operation, including enabling power rails and setting initial states for control signals.