Add flag to disable the cache for testing.

This commit is contained in:
iabdalkader 2020-11-15 18:29:12 +02:00
parent 69cb030c44
commit 2b267bc2f2

View File

@ -66,23 +66,27 @@ void HAL_MspInit(void)
#endif #endif
/* Enable I/D cache */ /* Enable I/D cache */
#if defined(MCU_SERIES_F7) ||\ #if defined(MCU_SERIES_F7) || defined(MCU_SERIES_H7)
defined(MCU_SERIES_H7) #ifdef OMV_DISABLE_CACHE
if (SCB->CCR & (uint32_t)SCB_CCR_IC_Msk) { // Disable caches for testing.
/* Disable and Invalidate I-Cache */ SCB_DisableICache();
SCB_DisableICache(); SCB_DisableDCache();
#else
// Enable caches if not enabled, or clean and invalidate.
if (!(SCB->CCR & (uint32_t)SCB_CCR_IC_Msk)) {
SCB_EnableICache();
} else {
SCB_InvalidateICache(); SCB_InvalidateICache();
__ISB(); __DSB(); __DMB();
} }
if (SCB->CCR & (uint32_t)SCB_CCR_DC_Msk) { if (!(SCB->CCR & (uint32_t)SCB_CCR_DC_Msk)) {
/* Disable, Clean and Invalidate D-Cache */ SCB_EnableDCache();
SCB_DisableDCache(); } else {
SCB_CleanInvalidateDCache(); SCB_CleanInvalidateDCache();
__ISB(); __DSB(); __DMB();
} }
#endif
// Enable the CPU Caches
SCB_EnableICache();
SCB_EnableDCache();
#endif #endif
/* Config Systick */ /* Config Systick */