Skip to content

Commit 1967cc2

Browse files
dgarskedanielinux
authored andcommitted
STM32U5: Only try and invalidate cache if enabled.
1 parent a92c1b9 commit 1967cc2

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

hal/stm32u5.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,15 +540,20 @@ void hal_cache_disable(void)
540540

541541
void hal_cache_invalidate(void)
542542
{
543-
/* Check if no ongoing operation */
543+
/* only try and invalidate cache if enabled */
544+
if ((ICACHE_CR & ICACHE_CR_CEN) == 0)
545+
return;
546+
547+
/* If cache invalidate not in progress, start it */
544548
if ((ICACHE_SR & ICACHE_SR_BUSYF) == 0) {
545-
/* Launch cache invalidation */
549+
/* Start invalidate */
546550
ICACHE_CR |= ICACHE_CR_CACHEINV;
547551
}
548552

553+
/* If cache invalidate is active, wait for busy end flag */
549554
if (ICACHE_SR & ICACHE_SR_BUSYF) {
550555
while ((ICACHE_SR & ICACHE_SR_BSYENDF) == 0);
551556
}
552-
/* Clear BSYENDF */
557+
/* Clear busy end flag */
553558
ICACHE_SR |= ICACHE_SR_BSYENDF;
554559
}

0 commit comments

Comments
 (0)