Skip to content

Commit 309fd89

Browse files
committed
[MBED-OS] Backport virtual NVIC mechanism from CMSIS 5 on CM3
This patch backports the virtual NVIC mechanish from CMSIS 5 for the Cortex M3 architecture in order to support uvisor in this MCU class. Signed-off-by: Vincenzo Frascino <[email protected]>
1 parent 7137cad commit 309fd89

File tree

1 file changed

+38
-10
lines changed

1 file changed

+38
-10
lines changed

hal/targets/cmsis/core_cm3.h

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,34 @@ typedef struct
13371337
@{
13381338
*/
13391339

1340+
#ifdef CMSIS_NVIC_VIRTUAL
1341+
#ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE
1342+
#define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h"
1343+
#endif
1344+
#include CMSIS_NVIC_VIRTUAL_HEADER_FILE
1345+
#else
1346+
#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping
1347+
#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping
1348+
#define NVIC_EnableIRQ __NVIC_EnableIRQ
1349+
#define NVIC_DisableIRQ __NVIC_DisableIRQ
1350+
#define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ
1351+
#define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ
1352+
#define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ
1353+
#define NVIC_GetActive __NVIC_GetActive
1354+
#define NVIC_SetPriority __NVIC_SetPriority
1355+
#define NVIC_GetPriority __NVIC_GetPriority
1356+
#endif /* CMSIS_NVIC_VIRTUAL */
1357+
1358+
#ifdef CMSIS_VECTAB_VIRTUAL
1359+
#ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE
1360+
#define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h"
1361+
#endif
1362+
#include CMSIS_VECTAB_VIRTUAL_HEADER_FILE
1363+
#else
1364+
#define NVIC_SetVector __NVIC_SetVector
1365+
#define NVIC_GetVector __NVIC_GetVector
1366+
#endif /* CMSIS_VECTAB_VIRTUAL */
1367+
13401368
/** \brief Set Priority Grouping
13411369
13421370
The function sets the priority grouping field using the required unlock sequence.
@@ -1347,7 +1375,7 @@ typedef struct
13471375
13481376
\param [in] PriorityGroup Priority grouping field.
13491377
*/
1350-
__STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
1378+
__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
13511379
{
13521380
uint32_t reg_value;
13531381
uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */
@@ -1367,7 +1395,7 @@ __STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
13671395
13681396
\return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field).
13691397
*/
1370-
__STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void)
1398+
__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void)
13711399
{
13721400
return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos));
13731401
}
@@ -1379,7 +1407,7 @@ __STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void)
13791407
13801408
\param [in] IRQn External interrupt number. Value cannot be negative.
13811409
*/
1382-
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
1410+
__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn)
13831411
{
13841412
NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
13851413
}
@@ -1391,7 +1419,7 @@ __STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
13911419
13921420
\param [in] IRQn External interrupt number. Value cannot be negative.
13931421
*/
1394-
__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
1422+
__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn)
13951423
{
13961424
NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
13971425
}
@@ -1407,7 +1435,7 @@ __STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
14071435
\return 0 Interrupt status is not pending.
14081436
\return 1 Interrupt status is pending.
14091437
*/
1410-
__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
1438+
__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn)
14111439
{
14121440
return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
14131441
}
@@ -1419,7 +1447,7 @@ __STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
14191447
14201448
\param [in] IRQn Interrupt number. Value cannot be negative.
14211449
*/
1422-
__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
1450+
__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn)
14231451
{
14241452
NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
14251453
}
@@ -1431,7 +1459,7 @@ __STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
14311459
14321460
\param [in] IRQn External interrupt number. Value cannot be negative.
14331461
*/
1434-
__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
1462+
__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn)
14351463
{
14361464
NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
14371465
}
@@ -1446,7 +1474,7 @@ __STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
14461474
\return 0 Interrupt status is not active.
14471475
\return 1 Interrupt status is active.
14481476
*/
1449-
__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
1477+
__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn)
14501478
{
14511479
return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
14521480
}
@@ -1461,7 +1489,7 @@ __STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
14611489
\param [in] IRQn Interrupt number.
14621490
\param [in] priority Priority to set.
14631491
*/
1464-
__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
1492+
__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
14651493
{
14661494
if((int32_t)IRQn < 0) {
14671495
SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8 - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL);
@@ -1483,7 +1511,7 @@ __STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
14831511
\return Interrupt Priority. Value is aligned automatically to the implemented
14841512
priority bits of the microcontroller.
14851513
*/
1486-
__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
1514+
__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn)
14871515
{
14881516

14891517
if((int32_t)IRQn < 0) {

0 commit comments

Comments
 (0)