From 11e716fc01279f46672b849f24b76415baeda15f Mon Sep 17 00:00:00 2001 From: Rocco Marco Guglielmi Date: Sun, 17 Sep 2017 17:08:12 +0000 Subject: Improved AIC to work with both secure and non secure mode. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@10621 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/ports/SAMA/SAMA5D2x/aic.c | 10 ++++++++++ os/hal/ports/SAMA/SAMA5D2x/aic.h | 10 +++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/os/hal/ports/SAMA/SAMA5D2x/aic.c b/os/hal/ports/SAMA/SAMA5D2x/aic.c index a63b533c3..9c0ef2a57 100644 --- a/os/hal/ports/SAMA/SAMA5D2x/aic.c +++ b/os/hal/ports/SAMA/SAMA5D2x/aic.c @@ -82,7 +82,17 @@ */ void aicInit(void) { +#if SAMA_HAL_IS_SECURE Aic *aic = SAIC; + /* Redirect interrupts */ + uint32_t aicredir = SFR_AICREDIR_AICREDIRKEY(AIC_REDIR_KEY); + SFR->SFR_AICREDIR = (aicredir ^ SFR->SFR_SN1); +#else + Aic *aic = AIC; + /* Redirect interrupts */ + uint32_t aicredir = SFR_AICREDIR_AICREDIRKEY(AIC_REDIR_KEY); + SFR->SFR_AICREDIR = (aicredir ^ SFR->SFR_SN1) | SFR_AICREDIR_NSAIC; +#endif unsigned i; /* Disable all interrupts */ diff --git a/os/hal/ports/SAMA/SAMA5D2x/aic.h b/os/hal/ports/SAMA/SAMA5D2x/aic.h index 92a924b31..defee9d30 100644 --- a/os/hal/ports/SAMA/SAMA5D2x/aic.h +++ b/os/hal/ports/SAMA/SAMA5D2x/aic.h @@ -29,6 +29,11 @@ /* Driver constants. */ /*===========================================================================*/ +/** + * @brief AIC unique redirect key. + */ +#define AIC_REDIR_KEY 0x5B6C0E26U + /*===========================================================================*/ /* Driver pre-compile time settings. */ /*===========================================================================*/ @@ -47,10 +52,9 @@ /** * @brief Acknowledge the current interrupt. - * */ -#define aicAckInt() { \ - SAIC->AIC_EOICR = AIC_EOICR_ENDIT; \ +#define aicAckInt() { \ + SAIC->AIC_EOICR = AIC_EOICR_ENDIT; \ } /*===========================================================================*/ -- cgit v1.2.3