Skip to content

Commit e4c217e

Browse files
Niklas Hausermeriac
authored andcommitted
Backport virtual NVIC mechanism from CMSIS 5
1 parent 23904e7 commit e4c217e

File tree

1 file changed

+39
-10
lines changed

1 file changed

+39
-10
lines changed

hal/targets/cmsis/core_cm4.h

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1502,6 +1502,35 @@ typedef struct
15021502
@{
15031503
*/
15041504

1505+
#ifdef CMSIS_NVIC_VIRTUAL
1506+
#ifndef CMSIS_NVIC_VIRTUAL_HEADER_FILE
1507+
#define CMSIS_NVIC_VIRTUAL_HEADER_FILE "cmsis_nvic_virtual.h"
1508+
#endif
1509+
#include CMSIS_NVIC_VIRTUAL_HEADER_FILE
1510+
#else
1511+
#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping
1512+
#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping
1513+
#define NVIC_EnableIRQ __NVIC_EnableIRQ
1514+
#define NVIC_DisableIRQ __NVIC_DisableIRQ
1515+
#define NVIC_GetPendingIRQ __NVIC_GetPendingIRQ
1516+
#define NVIC_SetPendingIRQ __NVIC_SetPendingIRQ
1517+
#define NVIC_ClearPendingIRQ __NVIC_ClearPendingIRQ
1518+
#define NVIC_GetActive __NVIC_GetActive
1519+
#define NVIC_SetPriority __NVIC_SetPriority
1520+
#define NVIC_GetPriority __NVIC_GetPriority
1521+
#endif /* CMSIS_NVIC_VIRTUAL */
1522+
1523+
#ifdef CMSIS_VECTAB_VIRTUAL
1524+
#ifndef CMSIS_VECTAB_VIRTUAL_HEADER_FILE
1525+
#define CMSIS_VECTAB_VIRTUAL_HEADER_FILE "cmsis_vectab_virtual.h"
1526+
#endif
1527+
#include CMSIS_VECTAB_VIRTUAL_HEADER_FILE
1528+
#else
1529+
#define NVIC_SetVector __NVIC_SetVector
1530+
#define NVIC_GetVector __NVIC_GetVector
1531+
#endif /* CMSIS_VECTAB_VIRTUAL */
1532+
1533+
15051534
/** \brief Set Priority Grouping
15061535
15071536
The function sets the priority grouping field using the required unlock sequence.
@@ -1512,7 +1541,7 @@ typedef struct
15121541
15131542
\param [in] PriorityGroup Priority grouping field.
15141543
*/
1515-
__STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
1544+
__STATIC_INLINE void __NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
15161545
{
15171546
uint32_t reg_value;
15181547
uint32_t PriorityGroupTmp = (PriorityGroup & (uint32_t)0x07UL); /* only values 0..7 are used */
@@ -1532,7 +1561,7 @@ __STATIC_INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
15321561
15331562
\return Priority grouping field (SCB->AIRCR [10:8] PRIGROUP field).
15341563
*/
1535-
__STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void)
1564+
__STATIC_INLINE uint32_t __NVIC_GetPriorityGrouping(void)
15361565
{
15371566
return ((uint32_t)((SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) >> SCB_AIRCR_PRIGROUP_Pos));
15381567
}
@@ -1544,7 +1573,7 @@ __STATIC_INLINE uint32_t NVIC_GetPriorityGrouping(void)
15441573
15451574
\param [in] IRQn External interrupt number. Value cannot be negative.
15461575
*/
1547-
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
1576+
__STATIC_INLINE void __NVIC_EnableIRQ(IRQn_Type IRQn)
15481577
{
15491578
NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
15501579
}
@@ -1556,7 +1585,7 @@ __STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
15561585
15571586
\param [in] IRQn External interrupt number. Value cannot be negative.
15581587
*/
1559-
__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
1588+
__STATIC_INLINE void __NVIC_DisableIRQ(IRQn_Type IRQn)
15601589
{
15611590
NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
15621591
}
@@ -1572,7 +1601,7 @@ __STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
15721601
\return 0 Interrupt status is not pending.
15731602
\return 1 Interrupt status is pending.
15741603
*/
1575-
__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
1604+
__STATIC_INLINE uint32_t __NVIC_GetPendingIRQ(IRQn_Type IRQn)
15761605
{
15771606
return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
15781607
}
@@ -1584,7 +1613,7 @@ __STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
15841613
15851614
\param [in] IRQn Interrupt number. Value cannot be negative.
15861615
*/
1587-
__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
1616+
__STATIC_INLINE void __NVIC_SetPendingIRQ(IRQn_Type IRQn)
15881617
{
15891618
NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
15901619
}
@@ -1596,7 +1625,7 @@ __STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
15961625
15971626
\param [in] IRQn External interrupt number. Value cannot be negative.
15981627
*/
1599-
__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
1628+
__STATIC_INLINE void __NVIC_ClearPendingIRQ(IRQn_Type IRQn)
16001629
{
16011630
NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
16021631
}
@@ -1611,7 +1640,7 @@ __STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
16111640
\return 0 Interrupt status is not active.
16121641
\return 1 Interrupt status is active.
16131642
*/
1614-
__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
1643+
__STATIC_INLINE uint32_t __NVIC_GetActive(IRQn_Type IRQn)
16151644
{
16161645
return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
16171646
}
@@ -1626,7 +1655,7 @@ __STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
16261655
\param [in] IRQn Interrupt number.
16271656
\param [in] priority Priority to set.
16281657
*/
1629-
__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
1658+
__STATIC_INLINE void __NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
16301659
{
16311660
if((int32_t)IRQn < 0) {
16321661
SCB->SHP[(((uint32_t)(int32_t)IRQn) & 0xFUL)-4UL] = (uint8_t)((priority << (8 - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL);
@@ -1648,7 +1677,7 @@ __STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
16481677
\return Interrupt Priority. Value is aligned automatically to the implemented
16491678
priority bits of the microcontroller.
16501679
*/
1651-
__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
1680+
__STATIC_INLINE uint32_t __NVIC_GetPriority(IRQn_Type IRQn)
16521681
{
16531682

16541683
if((int32_t)IRQn < 0) {

0 commit comments

Comments
 (0)