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

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

commit ffbe8b8aeb203278aa0708b18f131d047ebf5f87
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Fri Oct 4 12:39:29 2024 +0200

    hw/mcu/apollo: Move NVIC_Relocate to hal_system_init
    
    NVIC_Relocate call was placed in Ambiq generated file.
    Now it is moved to hal_system_init function that
    is way it's done in mynewt
    
    hal_bsp_deinit() disable NVIC interrupts as well.
    
    Signed-off-by: Jerzy Kasenberg <[email protected]>
---
 hw/bsp/apollo2_evb/src/hal_bsp.c             | 2 ++
 hw/bsp/apollo2_evb/src/system_apollo2.c      | 2 --
 hw/bsp/apollo3_evb/src/hal_bsp.c             | 2 ++
 hw/bsp/apollo3_evb/src/system_apollo3.c      | 2 --
 hw/mcu/ambiq/apollo2/include/mcu/cortex_m4.h | 1 +
 hw/mcu/ambiq/apollo2/src/hal_system.c        | 1 +
 hw/mcu/ambiq/apollo3/include/mcu/cortex_m4.h | 1 +
 hw/mcu/ambiq/apollo3/src/hal_system.c        | 1 +
 8 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/hw/bsp/apollo2_evb/src/hal_bsp.c b/hw/bsp/apollo2_evb/src/hal_bsp.c
index 3c29955c7..a349e8a19 100644
--- a/hw/bsp/apollo2_evb/src/hal_bsp.c
+++ b/hw/bsp/apollo2_evb/src/hal_bsp.c
@@ -24,6 +24,7 @@
 #include <bsp/bsp.h>
 #include <hal/hal_spi.h>
 #include <mcu/hal_apollo2.h>
+#include "mynewt_cm.h"
 
 #if MYNEWT_VAL(UART_0)
 #include "uart/uart.h"
@@ -184,6 +185,7 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 int
diff --git a/hw/bsp/apollo2_evb/src/system_apollo2.c 
b/hw/bsp/apollo2_evb/src/system_apollo2.c
index 034a4d3b0..56b72d073 100644
--- a/hw/bsp/apollo2_evb/src/system_apollo2.c
+++ b/hw/bsp/apollo2_evb/src/system_apollo2.c
@@ -109,7 +109,5 @@ SystemInit(void)
     CLKGEN->CLKKEY = 0;                 // Disable write to CCTRL
 
     SystemCoreClockUpdate();
-
-    NVIC_Relocate();
 }
 
diff --git a/hw/bsp/apollo3_evb/src/hal_bsp.c b/hw/bsp/apollo3_evb/src/hal_bsp.c
index d49ac016c..78fa1bcf8 100644
--- a/hw/bsp/apollo3_evb/src/hal_bsp.c
+++ b/hw/bsp/apollo3_evb/src/hal_bsp.c
@@ -22,6 +22,7 @@
 #include <assert.h>
 
 #include "os/mynewt.h"
+#include "mynewt_cm.h"
 
 #include "flash_map/flash_map.h"
 
@@ -70,6 +71,7 @@ hal_bsp_init(void)
 void
 hal_bsp_deinit(void)
 {
+    Cortex_DisableAll();
 }
 
 int
diff --git a/hw/bsp/apollo3_evb/src/system_apollo3.c 
b/hw/bsp/apollo3_evb/src/system_apollo3.c
index 2ae2b45e8..89965ef42 100644
--- a/hw/bsp/apollo3_evb/src/system_apollo3.c
+++ b/hw/bsp/apollo3_evb/src/system_apollo3.c
@@ -112,7 +112,5 @@ SystemInit(void)
     CLKGEN->CLKKEY = 0;                 // Disable write to CCTRL
 
     SystemCoreClockUpdate();
-
-    NVIC_Relocate();
 }
 
diff --git a/hw/mcu/ambiq/apollo2/include/mcu/cortex_m4.h 
b/hw/mcu/ambiq/apollo2/include/mcu/cortex_m4.h
index d9779873d..b1cfb8c03 100644
--- a/hw/mcu/ambiq/apollo2/include/mcu/cortex_m4.h
+++ b/hw/mcu/ambiq/apollo2/include/mcu/cortex_m4.h
@@ -21,6 +21,7 @@
 #define __MCU_CORTEX_M4_H__
 
 #include "mcu/apollo2.h"
+#include "mynewt_cm.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/hw/mcu/ambiq/apollo2/src/hal_system.c 
b/hw/mcu/ambiq/apollo2/src/hal_system.c
index 43058d81b..31e05a4b3 100644
--- a/hw/mcu/ambiq/apollo2/src/hal_system.c
+++ b/hw/mcu/ambiq/apollo2/src/hal_system.c
@@ -28,6 +28,7 @@ am_hal_mcuctrl_device_t adevinfo;
 void
 hal_system_init(void)
 {
+    NVIC_Relocate();
 }
 
 void
diff --git a/hw/mcu/ambiq/apollo3/include/mcu/cortex_m4.h 
b/hw/mcu/ambiq/apollo3/include/mcu/cortex_m4.h
index d006e34d1..4b1d638df 100644
--- a/hw/mcu/ambiq/apollo3/include/mcu/cortex_m4.h
+++ b/hw/mcu/ambiq/apollo3/include/mcu/cortex_m4.h
@@ -21,6 +21,7 @@
 #define __MCU_CORTEX_M4_H__
 
 #include "mcu/apollo3.h"
+#include "mynewt_cm.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/hw/mcu/ambiq/apollo3/src/hal_system.c 
b/hw/mcu/ambiq/apollo3/src/hal_system.c
index 770f030d6..e811c69ef 100644
--- a/hw/mcu/ambiq/apollo3/src/hal_system.c
+++ b/hw/mcu/ambiq/apollo3/src/hal_system.c
@@ -26,6 +26,7 @@
 void
 hal_system_init(void)
 {
+    NVIC_Relocate();
 }
 
 void

Reply via email to