Urbanite: Parking aid system
|
Interrupt service routines for the STM32F4 platform. More...
#include "port_system.h"
#include "stm32f4_system.h"
#include "port_button.h"
#include "port_ultrasound.h"
#include "stm32f4_button.h"
#include "stm32f4_ultrasound.h"
Functions | |
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 | TIM2_IRQHandler (void) |
Interrupt service routine for the TIM2 timer. More... | |
void | TIM3_IRQHandler (void) |
Interrupt service routine for the TIM3 timer. More... | |
void | TIM5_IRQHandler (void) |
Interrupt service routine for the TIM5 timer. More... | |
Interrupt service routines for the STM32F4 platform.
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 using the
PORT_PARKING_BUTTON_ID
index to get the port and pin from thebuttons_arr
using its getter functionport_button_get_value()
.
✅ 2. If the value istrue
means that the button as been released, therefore set the fieldflag_pressed
tofalse
✅ 3. If the value isfalse
means that the button as been pressed, therefore set the fieldflag_pressed
totrue
✅ 4. Clean the corresponding bit of thePR
register
💡 Recommendation: use the macroBIT_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 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).
TO-DO alumnos
✅ 1. Increment the System tick counter
msTicks
in 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 TIM2_IRQHandler | ( | void | ) |
Interrupt service routine for the TIM2 timer.
This timer controls the duration of the echo signal of the ultrasound sensor by means of the input capture mode.
The timer can interrupt in two cases:
Ejemplo: captura de entrada (input capture)
of the Libro de Fundamentos
to manage the ISR correctly.TODO alumnos
✅ 1. Check if the UIF flag is set. If so, this means that the ARR register has overflowed. In this case:
nbsp; Increment theecho_overflows
counter. To do this, use the functionsport_ultrasound_set_echo_overflows()
andport_ultrasound_get_echo_overflows()
with the corresponding ultrasound ID and the incremented value.
Remember to clear the UIF flag.
✅ 2. Check if the CCxIF flag is set. If so, this means that the input capture event has occurred. Read the value of the CCRx register to get the current tick. Reading CCRx also clears the CCxIF bit, and it is not necessary to do it later.
If both theecho_init_tick
andecho_end_tick
are 0, this means that the echo signal has not started yet. In this case, update theecho_init_tick
with the current tick.
Otherwise, update theecho_end_tick
with the current tick and set theecho_received
flag totrue
.
💡 Use the port functionsport_ultrasound_get_echo_xxx
andport_ultrasound_set_echo_xxx
.
void TIM3_IRQHandler | ( | void | ) |
Interrupt service routine for the TIM3 timer.
This timer controls the duration of the trigger signal of the ultrasound sensor. When the interrupt occurs it means that the time of the trigger signal has expired and must be lowered.
TODO alumnos
✅ 1. Clear the interrupt flag UIF in the status register SR.
✅ 2. Call the functionport_ultrasound_set_trigger_end()
to set the flag that indicates that the time of the trigger signal has expired.
void TIM5_IRQHandler | ( | void | ) |
Interrupt service routine for the TIM5 timer.
This timer controls the duration of the measurements of the ultrasound sensor. When the interrupt occurs it means that the time of the a measurement has expired and a new measurement can be started.
TODO alumnos
✅ 1. Clear the interrupt flag UIF in the status register SR.
✅ 2. Call the functionport_ultrasound_set_trigger_ready()
to set the flag that indicates that a new measurement can be started.