|
|
@@ -1312,135 +1312,193 @@ typedef struct
|
|
|
|
|
|
|
|
|
/**
|
|
|
- \brief Enable External Interrupt
|
|
|
- \details Enables a device-specific interrupt in the NVIC interrupt controller.
|
|
|
- \param [in] IRQn External interrupt number. Value cannot be negative.
|
|
|
+ \brief Enable Interrupt
|
|
|
+ \details Enables a device specific interrupt in the NVIC interrupt controller.
|
|
|
+ \param [in] IRQn Device specific interrupt number.
|
|
|
+ \note IRQn must not be nagative.
|
|
|
*/
|
|
|
__STATIC_INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
|
|
|
{
|
|
|
- NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
+ {
|
|
|
+ NVIC->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
- \brief Disable External Interrupt
|
|
|
- \details Disables a device-specific interrupt in the NVIC interrupt controller.
|
|
|
- \param [in] IRQn External interrupt number. Value cannot be negative.
|
|
|
+ \brief Disable Interrupt
|
|
|
+ \details Disables a device specific interrupt in the NVIC interrupt controller.
|
|
|
+ \param [in] IRQn Device specific interrupt number.
|
|
|
+ \note IRQn must not be nagative.
|
|
|
*/
|
|
|
__STATIC_INLINE void NVIC_DisableIRQ(IRQn_Type IRQn)
|
|
|
{
|
|
|
- NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
+ {
|
|
|
+ NVIC->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
\brief Get Pending Interrupt
|
|
|
- \details Reads the pending register in the NVIC and returns the pending bit for the specified interrupt.
|
|
|
- \param [in] IRQn Interrupt number.
|
|
|
+ \details Reads the NVIC pending register and returns the pending bit for the specified device specific interrupt.
|
|
|
+ \param [in] IRQn Device specific interrupt number.
|
|
|
\return 0 Interrupt status is not pending.
|
|
|
\return 1 Interrupt status is pending.
|
|
|
+ \note IRQn must not be nagative.
|
|
|
*/
|
|
|
__STATIC_INLINE uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn)
|
|
|
{
|
|
|
- return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
+ {
|
|
|
+ return((uint32_t)(((NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return(0U);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
\brief Set Pending Interrupt
|
|
|
- \details Sets the pending bit of an external interrupt.
|
|
|
- \param [in] IRQn Interrupt number. Value cannot be negative.
|
|
|
+ \details Sets the pending bit of a device specific interrupt in the NVIC pending register.
|
|
|
+ \param [in] IRQn Device specific interrupt number.
|
|
|
+ \note IRQn must not be nagative.
|
|
|
*/
|
|
|
__STATIC_INLINE void NVIC_SetPendingIRQ(IRQn_Type IRQn)
|
|
|
{
|
|
|
- NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
+ {
|
|
|
+ NVIC->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
\brief Clear Pending Interrupt
|
|
|
- \details Clears the pending bit of an external interrupt.
|
|
|
- \param [in] IRQn External interrupt number. Value cannot be negative.
|
|
|
+ \details Clears the pending bit of a device specific interrupt in the NVIC pending register.
|
|
|
+ \param [in] IRQn Device specific interrupt number.
|
|
|
+ \note IRQn must not be nagative.
|
|
|
*/
|
|
|
__STATIC_INLINE void NVIC_ClearPendingIRQ(IRQn_Type IRQn)
|
|
|
{
|
|
|
- NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
+ {
|
|
|
+ NVIC->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
\brief Get Active Interrupt
|
|
|
- \details Reads the active register in NVIC and returns the active bit.
|
|
|
- \param [in] IRQn Interrupt number.
|
|
|
+ \details Reads the active register in the NVIC and returns the active bit for the device specific interrupt.
|
|
|
+ \param [in] IRQn Device specific interrupt number.
|
|
|
\return 0 Interrupt status is not active.
|
|
|
\return 1 Interrupt status is active.
|
|
|
+ \note IRQn must not be nagative.
|
|
|
*/
|
|
|
__STATIC_INLINE uint32_t NVIC_GetActive(IRQn_Type IRQn)
|
|
|
{
|
|
|
- return ((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
+ {
|
|
|
+ return((uint32_t)(((NVIC->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return(0U);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
|
|
|
/**
|
|
|
\brief Get Interrupt Target State
|
|
|
- \details Reads the interrupt target field from the NVIC Interrupt Controller.
|
|
|
- \param [in] IRQn External interrupt number. Value cannot be negative.
|
|
|
+ \details Reads the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt.
|
|
|
+ \param [in] IRQn Device specific interrupt number.
|
|
|
\return 0 if interrupt is assigned to Secure
|
|
|
\return 1 if interrupt is assigned to Non Secure
|
|
|
+ \note IRQn must not be nagative.
|
|
|
*/
|
|
|
__STATIC_INLINE uint32_t NVIC_GetTargetState(IRQn_Type IRQn)
|
|
|
{
|
|
|
- return ((uint32_t)(((NVIC->ITNS[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
+ {
|
|
|
+ return((uint32_t)(((NVIC->ITNS[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return(0U);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
\brief Set Interrupt Target State
|
|
|
- \details Sets the interrupt target field in the NVIC.
|
|
|
- \param [in] IRQn External interrupt number. Value cannot be negative.
|
|
|
+ \details Sets the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt.
|
|
|
+ \param [in] IRQn Device specific interrupt number.
|
|
|
\return 0 if interrupt is assigned to Secure
|
|
|
1 if interrupt is assigned to Non Secure
|
|
|
+ \note IRQn must not be nagative.
|
|
|
*/
|
|
|
__STATIC_INLINE uint32_t NVIC_SetTargetState(IRQn_Type IRQn)
|
|
|
{
|
|
|
- NVIC->ITNS[(((uint32_t)(int32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)));
|
|
|
- return ((uint32_t)(((NVIC->ITNS[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
+ {
|
|
|
+ NVIC->ITNS[(((uint32_t)(int32_t)IRQn) >> 5UL)] |= ((uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)));
|
|
|
+ return((uint32_t)(((NVIC->ITNS[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return(0U);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
\brief Clear Interrupt Target State
|
|
|
- \details Clears the interrupt target field in the NVIC.
|
|
|
- \param [in] IRQn External interrupt number. Value cannot be negative.
|
|
|
+ \details Clears the interrupt target field in the NVIC and returns the interrupt target bit for the device specific interrupt.
|
|
|
+ \param [in] IRQn Device specific interrupt number.
|
|
|
\return 0 if interrupt is assigned to Secure
|
|
|
1 if interrupt is assigned to Non Secure
|
|
|
+ \note IRQn must not be nagative.
|
|
|
*/
|
|
|
__STATIC_INLINE uint32_t NVIC_ClearTargetState(IRQn_Type IRQn)
|
|
|
{
|
|
|
- NVIC->ITNS[(((uint32_t)(int32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)));
|
|
|
- return ((uint32_t)(((NVIC->ITNS[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
+ {
|
|
|
+ NVIC->ITNS[(((uint32_t)(int32_t)IRQn) >> 5UL)] &= ~((uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL)));
|
|
|
+ return((uint32_t)(((NVIC->ITNS[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return(0U);
|
|
|
+ }
|
|
|
}
|
|
|
#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
|
|
|
|
|
|
|
|
|
/**
|
|
|
\brief Set Interrupt Priority
|
|
|
- \details Sets the priority of an interrupt.
|
|
|
- \note The priority cannot be set for every core interrupt.
|
|
|
+ \details Sets the priority of a device specific interrupt or a processor exception.
|
|
|
+ The interrupt number can be positive to specify a device specific interrupt,
|
|
|
+ or negative to specify a processor exception.
|
|
|
\param [in] IRQn Interrupt number.
|
|
|
\param [in] priority Priority to set.
|
|
|
+ \note The priority cannot be set for every processor exception.
|
|
|
*/
|
|
|
__STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
|
|
|
{
|
|
|
- if ((int32_t)(IRQn) < 0)
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
{
|
|
|
- SCB->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
|
|
|
+ NVIC->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
|
|
|
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- NVIC->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
|
|
|
+ SCB->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
|
|
|
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
|
|
|
}
|
|
|
}
|
|
|
@@ -1448,9 +1506,9 @@ __STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
|
|
|
|
|
|
/**
|
|
|
\brief Get Interrupt Priority
|
|
|
- \details Reads the priority of an interrupt.
|
|
|
- The interrupt number can be positive to specify an external (device specific) interrupt,
|
|
|
- or negative to specify an internal (core) interrupt.
|
|
|
+ \details Reads the priority of a device specific interrupt or a processor exception.
|
|
|
+ The interrupt number can be positive to specify a device specific interrupt,
|
|
|
+ or negative to specify a processor exception.
|
|
|
\param [in] IRQn Interrupt number.
|
|
|
\return Interrupt Priority.
|
|
|
Value is aligned automatically to the implemented priority bits of the microcontroller.
|
|
|
@@ -1458,13 +1516,13 @@ __STATIC_INLINE void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority)
|
|
|
__STATIC_INLINE uint32_t NVIC_GetPriority(IRQn_Type IRQn)
|
|
|
{
|
|
|
|
|
|
- if ((int32_t)(IRQn) < 0)
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
{
|
|
|
- return((uint32_t)(((SCB->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
|
|
|
+ return((uint32_t)(((NVIC->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- return((uint32_t)(((NVIC->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
|
|
|
+ return((uint32_t)(((SCB->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1489,92 +1547,122 @@ __STATIC_INLINE void NVIC_SystemReset(void)
|
|
|
|
|
|
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
|
|
|
/**
|
|
|
- \brief Enable External Interrupt (non-secure)
|
|
|
- \details Enables a device-specific interrupt in the non-secure NVIC when in secure state.
|
|
|
- \param [in] IRQn External interrupt number. Value cannot be negative.
|
|
|
+ \brief Enable Interrupt (non-secure)
|
|
|
+ \details Enables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state.
|
|
|
+ \param [in] IRQn Device specific interrupt number.
|
|
|
+ \note IRQn must not be nagative.
|
|
|
*/
|
|
|
__STATIC_INLINE void TZ_NVIC_EnableIRQ_NS(IRQn_Type IRQn)
|
|
|
{
|
|
|
- NVIC_NS->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
+ {
|
|
|
+ NVIC_NS->ISER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
- \brief Disable External Interrupt (non-secure)
|
|
|
- \details Disables a device-specific interrupt in the non-secure NVIC when in secure state.
|
|
|
- \param [in] IRQn External interrupt number. Value cannot be negative.
|
|
|
+ \brief Disable Interrupt (non-secure)
|
|
|
+ \details Disables a device specific interrupt in the non-secure NVIC interrupt controller when in secure state.
|
|
|
+ \param [in] IRQn Device specific interrupt number.
|
|
|
+ \note IRQn must not be nagative.
|
|
|
*/
|
|
|
__STATIC_INLINE void TZ_NVIC_DisableIRQ_NS(IRQn_Type IRQn)
|
|
|
{
|
|
|
- NVIC_NS->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
+ {
|
|
|
+ NVIC_NS->ICER[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
\brief Get Pending Interrupt (non-secure)
|
|
|
- \details Reads the pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified interrupt.
|
|
|
- \param [in] IRQn Interrupt number.
|
|
|
+ \details Reads the NVIC pending register in the non-secure NVIC when in secure state and returns the pending bit for the specified device specific interrupt.
|
|
|
+ \param [in] IRQn Device specific interrupt number.
|
|
|
\return 0 Interrupt status is not pending.
|
|
|
\return 1 Interrupt status is pending.
|
|
|
+ \note IRQn must not be nagative.
|
|
|
*/
|
|
|
__STATIC_INLINE uint32_t TZ_NVIC_GetPendingIRQ_NS(IRQn_Type IRQn)
|
|
|
{
|
|
|
- return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
+ {
|
|
|
+ return((uint32_t)(((NVIC_NS->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
\brief Set Pending Interrupt (non-secure)
|
|
|
- \details Sets the pending bit of an non-secure external interrupt when in secure state.
|
|
|
- \param [in] IRQn Interrupt number. Value cannot be negative.
|
|
|
+ \details Sets the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state.
|
|
|
+ \param [in] IRQn Device specific interrupt number.
|
|
|
+ \note IRQn must not be nagative.
|
|
|
*/
|
|
|
__STATIC_INLINE void TZ_NVIC_SetPendingIRQ_NS(IRQn_Type IRQn)
|
|
|
{
|
|
|
- NVIC_NS->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
+ {
|
|
|
+ NVIC_NS->ISPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
\brief Clear Pending Interrupt (non-secure)
|
|
|
- \details Clears the pending bit of an non-secure external interrupt when in secure state.
|
|
|
- \param [in] IRQn External interrupt number. Value cannot be negative.
|
|
|
+ \details Clears the pending bit of a device specific interrupt in the non-secure NVIC pending register when in secure state.
|
|
|
+ \param [in] IRQn Device specific interrupt number.
|
|
|
+ \note IRQn must not be nagative.
|
|
|
*/
|
|
|
__STATIC_INLINE void TZ_NVIC_ClearPendingIRQ_NS(IRQn_Type IRQn)
|
|
|
{
|
|
|
- NVIC_NS->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
+ {
|
|
|
+ NVIC_NS->ICPR[(((uint32_t)(int32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
\brief Get Active Interrupt (non-secure)
|
|
|
- \details Reads the active register in non-secure NVIC when in secure state and returns the active bit.
|
|
|
- \param [in] IRQn Interrupt number.
|
|
|
+ \details Reads the active register in non-secure NVIC when in secure state and returns the active bit for the device specific interrupt.
|
|
|
+ \param [in] IRQn Device specific interrupt number.
|
|
|
\return 0 Interrupt status is not active.
|
|
|
\return 1 Interrupt status is active.
|
|
|
+ \note IRQn must not be nagative.
|
|
|
*/
|
|
|
__STATIC_INLINE uint32_t TZ_NVIC_GetActive_NS(IRQn_Type IRQn)
|
|
|
{
|
|
|
- return ((uint32_t)(((NVIC_NS->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
+ {
|
|
|
+ return((uint32_t)(((NVIC_NS->IABR[(((uint32_t)(int32_t)IRQn) >> 5UL)] & (1UL << (((uint32_t)(int32_t)IRQn) & 0x1FUL))) != 0UL) ? 1UL : 0UL));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return(0U);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
\brief Set Interrupt Priority (non-secure)
|
|
|
- \details Sets the priority of an non-secure interrupt when in secure state.
|
|
|
- \note The priority cannot be set for every core interrupt.
|
|
|
+ \details Sets the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state.
|
|
|
+ The interrupt number can be positive to specify a device specific interrupt,
|
|
|
+ or negative to specify a processor exception.
|
|
|
\param [in] IRQn Interrupt number.
|
|
|
\param [in] priority Priority to set.
|
|
|
+ \note The priority cannot be set for every non-secure processor exception.
|
|
|
*/
|
|
|
__STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority)
|
|
|
{
|
|
|
- if ((int32_t)(IRQn) < 0)
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
{
|
|
|
- SCB_NS->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB_NS->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
|
|
|
+ NVIC_NS->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC_NS->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
|
|
|
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- NVIC_NS->IPR[_IP_IDX(IRQn)] = ((uint32_t)(NVIC_NS->IPR[_IP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
|
|
|
+ SCB_NS->SHPR[_SHP_IDX(IRQn)] = ((uint32_t)(SCB_NS->SHPR[_SHP_IDX(IRQn)] & ~(0xFFUL << _BIT_SHIFT(IRQn))) |
|
|
|
(((priority << (8U - __NVIC_PRIO_BITS)) & (uint32_t)0xFFUL) << _BIT_SHIFT(IRQn)));
|
|
|
}
|
|
|
}
|
|
|
@@ -1582,22 +1670,22 @@ __STATIC_INLINE void TZ_NVIC_SetPriority_NS(IRQn_Type IRQn, uint32_t priority)
|
|
|
|
|
|
/**
|
|
|
\brief Get Interrupt Priority (non-secure)
|
|
|
- \details Reads the priority of an non-secure interrupt when in secure state.
|
|
|
- The interrupt number can be positive to specify an external (device specific) interrupt,
|
|
|
- or negative to specify an internal (core) interrupt.
|
|
|
+ \details Reads the priority of a non-secure device specific interrupt or a non-secure processor exception when in secure state.
|
|
|
+ The interrupt number can be positive to specify a device specific interrupt,
|
|
|
+ or negative to specify a processor exception.
|
|
|
\param [in] IRQn Interrupt number.
|
|
|
\return Interrupt Priority. Value is aligned automatically to the implemented priority bits of the microcontroller.
|
|
|
*/
|
|
|
__STATIC_INLINE uint32_t TZ_NVIC_GetPriority_NS(IRQn_Type IRQn)
|
|
|
{
|
|
|
|
|
|
- if ((int32_t)(IRQn) < 0)
|
|
|
+ if ((int32_t)(IRQn) >= 0)
|
|
|
{
|
|
|
- return((uint32_t)(((SCB_NS->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
|
|
|
+ return((uint32_t)(((NVIC_NS->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- return((uint32_t)(((NVIC_NS->IPR[ _IP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
|
|
|
+ return((uint32_t)(((SCB_NS->SHPR[_SHP_IDX(IRQn)] >> _BIT_SHIFT(IRQn) ) & (uint32_t)0xFFUL) >> (8U - __NVIC_PRIO_BITS)));
|
|
|
}
|
|
|
}
|
|
|
#endif /* defined (__ARM_FEATURE_CMSE) &&(__ARM_FEATURE_CMSE == 3U) */
|