|
Simone: a game of visual memory and speed
|
Interrupt service routines for the STM32F4 platform. More...
#include "port_system.h"#include "stm32f4_system.h"#include "port_button.h"#include "stm32f4_button.h"#include "port_keyboard.h"#include "stm32f4_keyboard.h"#include "port_simone.h"Functions | |
| void | _check_column_interrupt (uint8_t column_index) |
| Check and handle the column interrupt for a given column index. This function is called from the EXTI IRQHandlers for each column. More... | |
| void | SysTick_Handler (void) |
| Interrupt service routine for the System tick timer (SysTick). More... | |
| void | EXTI15_10_IRQHandler (void) |
| This function handles Px10-Px15 global interrupts. More... | |
| void | EXTI4_IRQHandler (void) |
| This function handles EXTI line 4 interrupt. More... | |
| void | EXTI9_5_IRQHandler (void) |
| This function handles EXTI lines [9:5] interrupts. More... | |
| void | TIM5_IRQHandler (void) |
| Interrupt service routine for the TIM5 timer. More... | |
| void | TIM3_IRQHandler (void) |
| Interrupt service routine for the TIM3 timer. More... | |
Interrupt service routines for the STM32F4 platform.
| void _check_column_interrupt | ( | uint8_t | column_index | ) |
Check and handle the column interrupt for a given column index. This function is called from the EXTI IRQHandlers for each column.
TODO alumnos ✅ 1. Get the GPIO port and pin for the given column index from the keyboard struct
✅ 2. Read the GPIO pin state using thestm32f4_system_gpio_read()function
✅ 3. If the pin state is HIGH, it means a key in that column has been pressed. In this case, set theflag_key_pressedfield totrue. Otherwise, the key has been released and thus, set it tofalseand store the index of the column that provoked the interrupt in thecol_idx_interrupt.
✅ 4. Clear the interrupt pending flag for the column pin by writing '1' to the corresponding bit in thePRregister
| column_index | Index of the column to check |
| void EXTI15_10_IRQHandler | ( | void | ) |
This function handles Px10-Px15 global interrupts.
First, this function identifies the line/ pin which has raised the interruption. Then, perform the desired action. Before leaving it cleans the interrupt pending register.
TODO alumnos VERSION 1
✅ 1. Retrieve the values of the GPIO of the user button. Use the PORT_USER_BUTTON_ID index to get the port and pin from the
buttons_arr
✅ 2. If the value is HIGH means that the button as been released, therefore set the fieldflag_pressedtofalse
✅ 3. If the value is LOW means that the button as been pressed, therefore set the fieldflag_pressedtotrue
✅ 4. Clean the corresponding bit of thePRregister
💡 Recommendation: use the macro BIT_POS_TO_MASK
💡 To clean an interrupt in the Pending Register (PR) we must write '1' in the corresponding bit. Look at the example in section "Ejemplo de interrupción externa" of the reference book. You can also find this out by consulting the reference manual STM32F446xx Advanced ARM-based 32-bit MCUs (See section "10.3.6 Pending register (EXTI_PR)")
TODO alumnos VERSION 2
✅ 1. Check if the interrupt has been generated by the column (column PORT_KEYBOARD_COL_1) of the keyboard. To do so, call the function
_check_column_interrupt()with the right column index parameter
*
TODO alumnos VERSION 4
✅ 1. Call the function
port_system_systick_resume()to resume the systick timer at the beginning of the ISR
| void EXTI4_IRQHandler | ( | void | ) |
This function handles EXTI line 4 interrupt.
This function is called when a column line (column PORT_KEYBOARD_COL_2) generates an interrupt. It checks if the corresponding GPIO pin is high, indicating that a key in that column has been pressed and released. If a key press is detected, it updates the keyboard state accordingly.
TODO alumnos
✅ 1. Call the function
_check_column_interrupt()with the right column index parameter for this ISR (i.e., PORT_KEYBOARD_COL_2)
TODO alumnos VERSION 4
✅ 1. Call the function
port_system_systick_resume()to resume the systick timer at the beginning of the ISR
| void EXTI9_5_IRQHandler | ( | void | ) |
This function handles EXTI lines [9:5] interrupts.
This function is called when column lines (columns PORT_KEYBOARD_COL_0 and PORT_KEYBOARD_COL_3) generate interrupts. It checks which GPIO pin triggered the interrupt and calls the corresponding handler to process the key press event.
TODO alumnos
✅ 1. For each column (i.e., PORT_KEYBOARD_COL_0 and PORT_KEYBOARD_COL_3), check if the corresponding EXTI line triggered the interrupt by checking the
PRregister. If it did, call the function_check_column_interrupt()with the right column index parameter
TODO alumnos VERSION 4
✅ 1. Call the function
port_system_systick_resume()to resume the systick timer at the beginning of the ISR
| void SysTick_Handler | ( | void | ) |
Interrupt service routine for the System tick timer (SysTick).
TODO alumnos:
✅ 1. Increment the System tick counter
msTicksin 1 count. To do so, use the functionport_system_get_millis()andport_system_set_millis().
msTicks must be declared volatile! Just because it is modified by a call of an ISR, in order to avoid race conditions . Added to the definition after static. | void TIM3_IRQHandler | ( | void | ) |
Interrupt service routine for the TIM3 timer.
This timer controls the different timing events of the Simone game. When the interrupt occurs it means that: a) the time of a color ON has passed, b) the time of the color OFF has passed, c) the time of waiting to a player keyboard pressed has passed.
TODO alumnos
✅ 1. Clear the interrupt flag UIF in the status register SR.
✅ 2. Call the functionport_simone_set_timer_status()to set the flag that indicates that the time has expired.
| void TIM5_IRQHandler | ( | void | ) |
Interrupt service routine for the TIM5 timer.
This timer controls the duration of the row excitation in the keyboard. When the timer interrupt occurs, it indicates that the duration of the row excitation has expired and a new row can be excited.
TODO alumnos
✅ 1. Clear the interrupt flag UIF in the status register SR.
✅ 2. Set the flag that indicates that the row timeout has occurred.