summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZixun LI <[email protected]>2026-07-27 15:55:20 +0200
committerZixun LI <[email protected]>2026-07-27 15:55:20 +0200
commitb3708aebd985a2c21a361903b1ca60d44e457e92 (patch)
tree34b83fd5596210f151e3c72e62c6a3798c4053f1
parentf0a8a1483bd4e89ab3adf40d8c61777a5ddadc7f (diff)
hw/bsp/lpc43: reset peripherals on IAR restart
-rw-r--r--hw/bsp/lpc43/family.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/hw/bsp/lpc43/family.c b/hw/bsp/lpc43/family.c
index 411ea7d58..0f3c62fef 100644
--- a/hw/bsp/lpc43/family.c
+++ b/hw/bsp/lpc43/family.c
@@ -59,6 +59,19 @@ void SystemInit(void);
// Invoked by startup code
void SystemInit(void)
{
+#if defined(__ICCARM__) && !defined(DONT_RESET_ON_RESTART)
+ // A debugger restart resets the M4 core, but can leave LPC43 peripherals and
+ // pending interrupts active. Match the GCC startup sequence, which the IAR
+ // startup lacks, before the C runtime can reuse peripheral DMA memory.
+ __disable_irq();
+ LPC_RGU->RESET_CTRL[0] = 0x10DF1000u;
+ LPC_RGU->RESET_CTRL[1] = 0x01DFF7FFu;
+ for (uint32_t i = 0; i < 8; i++) {
+ NVIC->ICPR[i] = UINT32_MAX;
+ }
+ __enable_irq();
+#endif
+
#ifdef __USE_LPCOPEN
unsigned int *pSCB_VTOR = (unsigned int *) 0xE000ED08;