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

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


The following commit(s) were added to refs/heads/master by this push:
     new ed0201c74 nvic: Add NVIC_ConfigVector
ed0201c74 is described below

commit ed0201c741f918ca91304ae3f46645f020ed0353
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Wed Jul 8 07:51:19 2026 +0200

    nvic: Add NVIC_ConfigVector
    
    Almost all NVIC vector configurations follow
    pattern:
    
    NVIC_SetPriority(irq, 2)
    NVIC_SetVector(irq, (uint32_t)isr);
    NVIC_EnableIRQ(irq);
    
    Now there is one function that does those things
    NVIC_ConfigVector(irq, isr, 2, true);
    
    Cast to uint32_t is done inside.
    
    Signed-off-by: Jerzy Kasenberg <[email protected]>
---
 hw/cmsis-core/include/mynewt_nvic.h |  4 ++++
 hw/cmsis-core/src/cmsis_nvic.c      | 13 ++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/hw/cmsis-core/include/mynewt_nvic.h 
b/hw/cmsis-core/include/mynewt_nvic.h
index cd58ca953..ba8373a04 100644
--- a/hw/cmsis-core/include/mynewt_nvic.h
+++ b/hw/cmsis-core/include/mynewt_nvic.h
@@ -20,12 +20,16 @@
 #ifndef MYNEWT_NVIC_H
 #define MYNEWT_NVIC_H
 
+#include <stdbool.h>
+#include <stdint.h>
 #include <mcu/cmsis_nvic.h>
 #include <os/util.h>
 
 void NVIC_Relocate(void);
 void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
 uint32_t NVIC_GetVector(IRQn_Type IRQn);
+void NVIC_ConfigVector(IRQn_Type IRQn, void (*vector)(void), uint8_t priority,
+                       bool enable);
 
 static inline void
 NVIC_DisableAll(void)
diff --git a/hw/cmsis-core/src/cmsis_nvic.c b/hw/cmsis-core/src/cmsis_nvic.c
index a9b48009a..73fd4e74d 100644
--- a/hw/cmsis-core/src/cmsis_nvic.c
+++ b/hw/cmsis-core/src/cmsis_nvic.c
@@ -3,7 +3,8 @@
  *
  * CMSIS-style functionality to support dynamic vectors
  */
-#include "mcu/cmsis_nvic.h"
+
+#include <mynewt_nvic.h>
 
 #ifndef __CORTEX_M
     #error "Macro __CORTEX_M not defined; must define cortex-m type!"
@@ -19,6 +20,16 @@
 extern char __isr_vector[];
 extern char __vector_tbl_reloc__[];
 
+void
+NVIC_ConfigVector(IRQn_Type IRQn, void (*vector)(void), uint8_t priority, bool 
enable)
+{
+    NVIC_SetPriority(IRQn, priority);
+    NVIC_SetVector(IRQn, (uint32_t)vector);
+    if (enable) {
+        NVIC_EnableIRQ(IRQn);
+    }
+}
+
 void
 NVIC_Relocate(void)
 {

Reply via email to