Simone: a game of visual memory and speed
port_button.h File Reference

Header for the portable functions to interact with the HW of the buttons. The functions must be implemented in the platform-specific code. More...

#include <stdint.h>
#include <stdbool.h>

Macros

#define PORT_USER_BUTTON_ID
 
#define PORT_USER_BUTTON_DEBOUNCE_TIME_MS
 

Functions

void port_button_init (uint8_t button_id)
 Configure the HW specifications of a given button. More...
 
bool port_button_get_pressed (uint8_t button_id)
 Return the status of the button (pressed or not). More...
 

Detailed Description

Header for the portable functions to interact with the HW of the buttons. The functions must be implemented in the platform-specific code.

Author
Sistemas Digitales II
Date
2026-01-01

Macro Definition Documentation

◆ PORT_USER_BUTTON_DEBOUNCE_TIME_MS

#define PORT_USER_BUTTON_DEBOUNCE_TIME_MS

Button debounce time in milliseconds

◆ PORT_USER_BUTTON_ID

#define PORT_USER_BUTTON_ID

User button identifier that represents the button to start and config the game

Function Documentation

◆ port_button_get_pressed()

bool port_button_get_pressed ( uint8_t  button_id)

Return the status of the button (pressed or not).

TODO alumnos:

✅ 1. Return the value of the field flag_pressed. Call the function _stm32f4_button_get() to get the button struct.

Parameters
button_idButton ID. This index is used to get the correct button status struct.
Returns
true If the button has been pressed
false If the button has not been pressed

◆ port_button_init()

void port_button_init ( uint8_t  button_id)

Configure the HW specifications of a given button.

Assuming we are using an STM32F4-based platform, this function must call the following functions:

TODO alumnos: ✅ 1. Retrieve the button configuration struct calling _stm32f4_button_get()
✅ 2. Call function stm32f4_system_gpio_config() with the right arguments to configure the button as input and no pull up neither pull down connection
✅ 3. Call function stm32f4_system_gpio_config_exti() with the right arguments to configure interruption mode in both rising and falling edges, and enable the interrupt request
✅ 4. Call function stm32f4_system_gpio_exti_enable() with the right parameters to enable the interrupt line and set the priority level to 1 and the subpriority level to 0

Parameters
button_idButton ID. This index is used to select the element of the buttons_arr[] array