no-OS
Loading...
Searching...
No Matches
powrms_gpios.h File Reference

Button handling definitions and declarations. More...

#include "no_os_gpio.h"
Include dependency graph for powrms_gpios.h:

Macros

#define ADC_POWER_STABILIZE_MS   100
 
#define ADC_5V_STABILIZE_MS   50
 

Functions

int buttons_init (void)
 Initialize interrupt-based button handling.
 
int buttons_read (void)
 Read button states using interrupt flags.
 
void configure_gpios_upon_startup (void)
 Configure GPIOs upon system startup.
 
int configure_gpios_upon_shutdown ()
 Configure GPIOs upon system shutdown.
 

Detailed Description

Button handling definitions and declarations.

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

Macro Definition Documentation

◆ ADC_5V_STABILIZE_MS

#define ADC_5V_STABILIZE_MS   50

◆ ADC_POWER_STABILIZE_MS

#define ADC_POWER_STABILIZE_MS   100

Function Documentation

◆ buttons_init()

int buttons_init ( void )

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 and sets up GPIO interrupt handlers for falling edge detection. Uses the Maxim GPIO IRQ interface (max_gpio_irq_ops) for proper interrupt support on the Maxim platform. Also enables the GPIO interrupt controller at the NVIC level for proper interrupt handling.

Returns
0 on success, negative error code on failure

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 using interrupt flags.

Checks for button press events detected by GPIO interrupt handlers. This function clears the interrupt flag when a button press is detected. Call this function regularly to check for button presses.

Returns
Button press code:
  • 0: No button pressed
  • 1: NEXT button pressed (GPIO 0.16)
  • 2: BACK button pressed (GPIO 0.17)
  • 3: ENTER button pressed (GPIO 0.18)
  • 4: ON_OFF latch held LOW for > 250 ms (GPIO 0.14) - triggers shutdown

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.