Skip to content

Commit 79af576

Browse files
committed
stm32 spi - IRQ management
Disable IRQ when transfer is finished. Also clear pending IRQ after they have been disabled.
1 parent 64a037c commit 79af576

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

targets/TARGET_STM/stm_spi_api.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,8 @@ static int spi_master_start_asynch_transfer(spi_t *obj, transfer_type_t transfer
434434

435435
// enable the interrupt
436436
IRQn_Type irq_n = spiobj->spiIRQ;
437-
NVIC_ClearPendingIRQ(irq_n);
438437
NVIC_DisableIRQ(irq_n);
438+
NVIC_ClearPendingIRQ(irq_n);
439439
NVIC_SetPriority(irq_n, 1);
440440
NVIC_EnableIRQ(irq_n);
441441

@@ -545,6 +545,9 @@ uint32_t spi_irq_handler_asynch(spi_t *obj)
545545
// else we're done
546546
event = SPI_EVENT_COMPLETE | SPI_EVENT_INTERNAL_TRANSFER_COMPLETE;
547547
}
548+
// enable the interrupt
549+
NVIC_DisableIRQ(spiobj->spiIRQ);
550+
NVIC_ClearPendingIRQ(spiobj->spiIRQ);
548551
}
549552

550553
if (event) DEBUG_PRINTF("SPI: Event: 0x%x\n", event);

0 commit comments

Comments
 (0)