ICARUS OS (Intelligent Cooperative Architecture for Real-time Unified Systems) 0.1.0
Preemptive Real-Time Operating System for ARM Cortex-M7
Loading...
Searching...
No Matches
button.c File Reference

User button (K1) implementation. More...

#include "bsp/button.h"
#include "bsp/config.h"
#include "stm32h7xx_hal.h"

Go to the source code of this file.

Functions

bool Button_IsPressed (void)
 Read the K1 user button state.
 

Detailed Description

User button (K1) implementation.

Reads the K1 GPIO via HAL_GPIO_ReadPin and inverts the active-low electrical convention so callers see true when the button is held down.

Under HOST_TEST the function is backed by an in-memory state variable that the unit tests can drive via __button_host_set_pressed().

Author
Souham Biswas
Date
2026

Definition in file button.c.

Function Documentation

◆ Button_IsPressed()

bool Button_IsPressed ( void  )

Read the K1 user button state.

Returns
true if the button is currently held down (pin sampled low after the active-low conversion), false otherwise.
Note
Pure read — no debounce, no edge detection. Callers that care about transitions should sample twice with a short delay between reads or maintain their own previous-state flag.
Safe to call from any task context. Does not enter a critical section.

Definition at line 28 of file button.c.

References BSP_KEY_PIN, and BSP_KEY_PORT.