Skip to content

Commit

Permalink
STM32U5: Only try and invalidate cache if enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarske authored and danielinux committed Jun 25, 2024
1 parent a92c1b9 commit 1967cc2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions hal/stm32u5.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,15 +540,20 @@ void hal_cache_disable(void)

void hal_cache_invalidate(void)
{
/* Check if no ongoing operation */
/* only try and invalidate cache if enabled */
if ((ICACHE_CR & ICACHE_CR_CEN) == 0)
return;

/* If cache invalidate not in progress, start it */
if ((ICACHE_SR & ICACHE_SR_BUSYF) == 0) {
/* Launch cache invalidation */
/* Start invalidate */
ICACHE_CR |= ICACHE_CR_CACHEINV;
}

/* If cache invalidate is active, wait for busy end flag */
if (ICACHE_SR & ICACHE_SR_BUSYF) {
while ((ICACHE_SR & ICACHE_SR_BSYENDF) == 0);
}
/* Clear BSYENDF */
/* Clear busy end flag */
ICACHE_SR |= ICACHE_SR_BSYENDF;
}

0 comments on commit 1967cc2

Please sign in to comment.