Urbanite: Parking aid system
|
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_PARKING_BUTTON_ID |
#define | PORT_PARKING_BUTTON_DEBOUNCE_TIME_MS |
Functions | |
void | port_button_init (uint32_t button_id) |
Configure the HW specifications of a given button. More... | |
bool | port_button_get_pressed (uint32_t button_id) |
Return the status of the button (pressed or not). More... | |
bool | port_button_get_value (uint32_t button_id) |
Get the value of the GPIO connected to the button. More... | |
void | port_button_set_pressed (uint32_t button_id, bool pressed) |
Set the status of the button (pressed or not). More... | |
bool | port_button_get_pending_interrupt (uint32_t button_id) |
Get the status of the interrupt line connected to the button. More... | |
void | port_button_clear_pending_interrupt (uint32_t button_id) |
Clear the pending interrupt of the button. More... | |
void | port_button_disable_interrupts (uint32_t button_id) |
Disable the interrupts of the button. More... | |
Header for the portable functions to interact with the HW of the buttons. The functions must be implemented in the platform-specific code.
#define PORT_PARKING_BUTTON_DEBOUNCE_TIME_MS |
Button debounce time in milliseconds
#define PORT_PARKING_BUTTON_ID |
User button identifier that represents the rear button (activation of the parking aid system)
void port_button_clear_pending_interrupt | ( | uint32_t | button_id | ) |
Clear the pending interrupt of the button.
This function is used to clear the pending interrupt of the button. It is called from the ISR to avoid unwanted interrupts.
TODO alumnos:
✅ 1. Get the button configuration struct calling
_stm32f4_button_get()
✅ 2. Get the pin of the button
✅ 3. Clear the corresponding bit of the PR register of the EXTI peripheral associated with the button pin
button_id | Button ID. This index is used to get the correct button struct of the buttons_arr[] array. |
void port_button_disable_interrupts | ( | uint32_t | button_id | ) |
Disable the interrupts of the button.
This function is used to disable the interrupts of the button. It is used in the unit tests to avoid unwanted interrupts.
TODO alumnos:
✅ 1. Get the button configuration struct calling
_stm32f4_button_get()
✅ 2. Get the pin of the button
✅ 3. Disable the EXTI line associated with the button pin by calling the functionstm32f4_system_gpio_exti_disable()
button_id | Button ID. This index is used to get the correct button struct of the buttons_arr[] array. |
bool port_button_get_pending_interrupt | ( | uint32_t | button_id | ) |
Get the status of the interrupt line connected to the button.
This function is used to check if the interrupt line of the button is pending. It is called from the ISR to check if the button has been pressed.
TODO alumnos:
✅ 1. Get the button configuration struct calling
_stm32f4_button_get()
✅ 2. Get the pin of the button
✅ 3. Read the value of the PR register of the EXTI peripheral associated with the button pin
✅ 4. Return the value.
button_id | Button ID. This index is used to get the correct button struct of the buttons_arr[] array. |
bool port_button_get_pressed | ( | uint32_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.
button_id | Button ID. This index is used to get the correct button status struct. |
bool port_button_get_value | ( | uint32_t | button_id | ) |
Get the value of the GPIO connected to the button.
TODO alumnos:
✅ 1. Call function
stm32f4_system_gpio_read()
with the right arguments to get the value of the button. Call the function_stm32f4_button_get()
to get the button struct.
button_id | Button ID. This index is used to select the element of the buttons_arr[] array |
void port_button_init | ( | uint32_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 functionstm32f4_system_gpio_config()
with the right arguments to configure the button as input and no pull up neither pull down connection
✅ 3. Call functionstm32f4_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 functionstm32f4_system_gpio_exti_enable()
with the right parameters to enable the interrupt line and set the priority level to1
and the subpriority level to0
button_id | Button ID. This index is used to select the element of the buttons_arr[] array |
void port_button_set_pressed | ( | uint32_t | button_id, |
bool | pressed | ||
) |
Set the status of the button (pressed or not).
This function is used to force the status of the button. It is used to simulate the button press in the tests.
TODO alumnos:
✅ 1. Set the value of the field
flag_pressed
. Call the function_stm32f4_button_get()
to get the button struct.
button_id | Button ID. This index is used to get the correct button struct of the buttons_arr[] array. |
pressed | Status of the button. |