summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucian Copeland <hierophect@gmail.com>2020-03-12 15:03:21 -0400
committerLucian Copeland <hierophect@gmail.com>2020-03-12 15:03:47 -0400
commit0155fab356d5e41681e9d7a18355a70910d5200a (patch)
treeeae68289c0e305c21ebc6beed4c3045380c61bd7
parentead32ea6e63eac21285bc59fc51973a5f1d4a351 (diff)
Revise style on interrupt handler functions
-rw-r--r--ports/stm32f4/common-hal/pulseio/PulseIn.c50
1 files changed, 12 insertions, 38 deletions
diff --git a/ports/stm32f4/common-hal/pulseio/PulseIn.c b/ports/stm32f4/common-hal/pulseio/PulseIn.c
index cf484daf9..8428a2278 100644
--- a/ports/stm32f4/common-hal/pulseio/PulseIn.c
+++ b/ports/stm32f4/common-hal/pulseio/PulseIn.c
@@ -43,6 +43,9 @@ static pulseio_pulsein_obj_t* _objs[STM32_GPIO_PORT_SIZE];
static void assign_EXTI_Interrupt(pulseio_pulsein_obj_t* self, uint8_t num);
static void pulsein_handler(uint8_t num) {
+ // Interrupt register must be cleared manually
+ EXTI->PR = 1 << num;
+
// Grab the current time first.
uint32_t current_us;
uint64_t current_ms;
@@ -260,70 +263,41 @@ static void assign_EXTI_Interrupt(pulseio_pulsein_obj_t* self, uint8_t num) {
void EXTI0_IRQHandler(void)
{
- EXTI->PR = 1 << 0;
pulsein_handler(0);
}
void EXTI1_IRQHandler(void)
{
- EXTI->PR = 1 << 1;
pulsein_handler(1);
}
void EXTI2_IRQHandler(void)
{
- EXTI->PR = 1 << 2;
pulsein_handler(2);
}
void EXTI3_IRQHandler(void)
{
- EXTI->PR = 1 << 3;
pulsein_handler(3);
}
void EXTI4_IRQHandler(void)
{
- EXTI->PR = 1 << 4;
pulsein_handler(4);
}
+
void EXTI9_5_IRQHandler(void)
{
uint32_t pending = EXTI->PR;
- if(pending & (1 << 5)) {
- EXTI->PR = 1 << 5;
- pulsein_handler(5);
- } else if (pending & (1 << 6)) {
- EXTI->PR = 1 << 6;
- pulsein_handler(6);
- } else if (pending & (1 << 7)) {
- EXTI->PR = 1 << 7;
- pulsein_handler(7);
- } else if (pending & (1 << 8)) {
- EXTI->PR = 1 << 8;
- pulsein_handler(8);
- } else if (pending & (1 << 9)) {
- EXTI->PR = 1 << 9;
- pulsein_handler(9);
+ for (uint i = 5; i <= 9; i++) {
+ if(pending & (1 << i)) {
+ pulsein_handler(i);
+ }
}
}
void EXTI15_10_IRQHandler(void)
{
uint32_t pending = EXTI->PR;
- if(pending & (1 << 10)) {
- EXTI->PR = 1 << 10;
- pulsein_handler(10);
- } else if (pending & (1 << 11)) {
- EXTI->PR = 1 << 11;
- pulsein_handler(11);
- } else if (pending & (1 << 12)) {
- EXTI->PR = 1 << 12;
- pulsein_handler(12);
- } else if (pending & (1 << 13)) {
- EXTI->PR = 1 << 13;
- pulsein_handler(13);
- } else if (pending & (1 << 14)) {
- EXTI->PR = 1 << 14;
- pulsein_handler(14);
- } else if (pending & (1 << 15)) {
- EXTI->PR = 1 << 15;
- pulsein_handler(15);
+ for (uint i = 10; i <= 15; i++) {
+ if(pending & (1 << i)) {
+ pulsein_handler(i);
+ }
}
}