You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by we...@apache.org on 2022/02/01 00:08:51 UTC

[mynewt-core] 01/02: hal: Modify hal_system_restart

This is an automated email from the ASF dual-hosted git repository.

wes3 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 24398ce000466f9de64563d5817ac75e8d89bec1
Author: Will San Filippo <wi...@juul.com>
AuthorDate: Wed Jan 26 13:45:30 2022 -0800

    hal: Modify hal_system_restart
    
    Two changes to the code: clear ICPR register (to
    clear any pending interrupts) and also leave global
    interrupts enabled when calling hal_system_start.
    The idea behind this change is that the cortex-M
    has global interrupts enabled on reset and that
    this should be the state when the system is
    restarted.
---
 hw/mcu/dialog/da1469x/src/hal_system_start.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/hw/mcu/dialog/da1469x/src/hal_system_start.c b/hw/mcu/dialog/da1469x/src/hal_system_start.c
index 2445f9c..1937a7d 100644
--- a/hw/mcu/dialog/da1469x/src/hal_system_start.c
+++ b/hw/mcu/dialog/da1469x/src/hal_system_start.c
@@ -62,19 +62,24 @@ hal_system_start(void *img_start)
 void
 hal_system_restart(void *img_start)
 {
-    uint32_t primask __attribute__((unused));
     int i;
 
     /*
-     * Disable interrupts, and leave them disabled.
-     * They get re-enabled when system starts coming back again.
+     * NOTE: on reset, PRIMASK should have global interrupts enabled so
+     * the code disables interrupts, clears the interrupt enable bits,
+     * clears any pending interrupts, then enables global interrupts
+     * so processor looks like state it would be in if it reset.
      */
-    __HAL_DISABLE_INTERRUPTS(primask);
-
+    __disable_irq();
     for (i = 0; i < sizeof(NVIC->ICER) / sizeof(NVIC->ICER[0]); i++) {
         NVIC->ICER[i] = 0xffffffff;
     }
 
+    for (i = 0; i < sizeof(NVIC->ICPR) / sizeof(NVIC->ICPR[0]); i++) {
+        NVIC->ICPR[i] = 0xffffffff;
+    }
+    __enable_irq();
+
     hal_system_start(img_start);
 }