![]() |
no-OS
|
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"Macros | |
| #define | BTN_ON_OFF_HOLD_MS 250 |
| #define | BTN_NEXT_FLAG (1 << 0) |
| #define | BTN_BACK_FLAG (1 << 1) |
| #define | BTN_ENTER_FLAG (1 << 2) |
| #define | BTN_ON_OFF_PIN 14 |
| #define | BTN_BACK_PIN 17 |
| #define | BTN_NEXT_PIN 16 |
| #define | BTN_ENTER_PIN 18 |
| #define | BTN_GPIO_PORT 0 |
Functions | |
| int | buttons_init (void) |
| Initialize button GPIO pins. | |
| int | buttons_read (void) |
| Read button states with debouncing. | |
| void | configure_gpios_upon_startup () |
| Configure GPIOs upon system startup. | |
| int | configure_gpios_upon_shutdown () |
| Configure GPIOs upon system shutdown. | |
Button handling implementation for eval-powrms project.
Copyright 2025(c) Analog Devices, Inc.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES, INC. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
| #define BTN_BACK_FLAG (1 << 1) |
| #define BTN_BACK_PIN 17 |
| #define BTN_ENTER_FLAG (1 << 2) |
| #define BTN_ENTER_PIN 18 |
| #define BTN_GPIO_PORT 0 |
| #define BTN_NEXT_FLAG (1 << 0) |
| #define BTN_NEXT_PIN 16 |
| #define BTN_ON_OFF_HOLD_MS 250 |
| #define BTN_ON_OFF_PIN 14 |
| 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).
| 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.
| 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.
| 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.