arch: arm: add macro definition for vector key write permit value

This commit adds a macro definition for the Vector Key value of
AIRCR register that permits the accompanying writes. The macro
is then used instead of the hard-coded numerical value.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
Ioannis Glaropoulos 2018-07-09 11:47:18 +02:00 committed by Anas Nashif
parent 97d5f60afb
commit 28acaeadc9

View file

@ -34,6 +34,10 @@ extern "C" {
extern volatile irq_offload_routine_t offload_routine;
#endif
/* Writes to the AIRCR must be accompanied by a write of the value 0x05FA
* to the Vector Key field, otherwise the writes are ignored.
*/
#define AIRCR_VECT_KEY_PERMIT_WRITE 0x05FAUL
/**
*
* @brief Find out if running in an ISR context
@ -124,7 +128,8 @@ static ALWAYS_INLINE void _ExcSetup(void)
SCB->AIRCR =
(SCB->AIRCR & (~(SCB_AIRCR_VECTKEY_Msk)))
| SCB_AIRCR_BFHFNMINS_Msk
| ((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) & SCB_AIRCR_VECTKEY_Msk);
| ((AIRCR_VECT_KEY_PERMIT_WRITE << SCB_AIRCR_VECTKEY_Pos) &
SCB_AIRCR_VECTKEY_Msk);
/* Note: Fault conditions that would generate a SecureFault
* in a PE with the Main Extension instead generate a
* SecureHardFault in a PE without the Main Extension.