From 23f759922d415d9adaab70424b2c67ff0d9b7181 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Wed, 5 Feb 2014 19:55:42 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6667 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/ports/STM32/LLD/TIMv1/st_lld.c | 2 +- os/hal/ports/common/ARMCMx/nvic.c | 17 ++++++++++++++--- os/hal/ports/common/ARMCMx/nvic.h | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) (limited to 'os') diff --git a/os/hal/ports/STM32/LLD/TIMv1/st_lld.c b/os/hal/ports/STM32/LLD/TIMv1/st_lld.c index a8ef5896d..01aeabf1b 100644 --- a/os/hal/ports/STM32/LLD/TIMv1/st_lld.c +++ b/os/hal/ports/STM32/LLD/TIMv1/st_lld.c @@ -205,7 +205,7 @@ void st_lld_init(void) { SysTick_CTRL_TICKINT_Msk; /* IRQ enabled.*/ - nvicSetSystemHandlerPriority(SysTick_IRQn, STM32_ST_IRQ_PRIORITY); + nvicSetSystemHandlerPriority(HANDLER_SYSTICK, STM32_ST_IRQ_PRIORITY); #endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */ } diff --git a/os/hal/ports/common/ARMCMx/nvic.c b/os/hal/ports/common/ARMCMx/nvic.c index 20bf60035..dbd165a9f 100644 --- a/os/hal/ports/common/ARMCMx/nvic.c +++ b/os/hal/ports/common/ARMCMx/nvic.c @@ -50,10 +50,9 @@ /** * @brief Sets the priority of an interrupt handler and enables it. - * @note The parameters are not tested for correctness. * * @param[in] n the interrupt number - * @param[in] prio the interrupt priority mask + * @param[in] prio the interrupt priority */ void nvicEnableVector(uint32_t n, uint32_t prio) { @@ -64,7 +63,6 @@ void nvicEnableVector(uint32_t n, uint32_t prio) { /** * @brief Disables an interrupt handler. - * @note The parameters are not tested for correctness. * * @param[in] n the interrupt number */ @@ -74,4 +72,17 @@ void nvicDisableVector(uint32_t n) { NVIC->IP[n] = 0; } +/** + * @brief Changes the priority of a system handler. + * + * @param[in] handler the system handler number + * @param[in] prio the system handler priority + */ +void nvicSetSystemHandlerPriority(uint32_t handler, uint32_t prio) { + + osalDbgCheck((handler >= 4) && (handler <= 15)); + + SCB->SHP[handler - 4] = NVIC_PRIORITY_MASK(prio); +} + /** @} */ diff --git a/os/hal/ports/common/ARMCMx/nvic.h b/os/hal/ports/common/ARMCMx/nvic.h index b9fa905b1..807bf230c 100644 --- a/os/hal/ports/common/ARMCMx/nvic.h +++ b/os/hal/ports/common/ARMCMx/nvic.h @@ -29,6 +29,24 @@ /* Driver constants. */ /*===========================================================================*/ +/** + * @name System vectors numbers + * @{ + */ +#define HANDLER_MEM_MANAGE 0 /**< MEM MANAGE vector id. */ +#define HANDLER_BUS_FAULT 1 /**< BUS FAULT vector id. */ +#define HANDLER_USAGE_FAULT 2 /**< USAGE FAULT vector id. */ +#define HANDLER_RESERVED_3 3 +#define HANDLER_RESERVED_4 4 +#define HANDLER_RESERVED_5 5 +#define HANDLER_RESERVED_6 6 +#define HANDLER_SVCALL 7 /**< SVCALL vector id. */ +#define HANDLER_DEBUG_MONITOR 8 /**< DEBUG MONITOR vector id. */ +#define HANDLER_RESERVED_9 9 +#define HANDLER_PENDSV 10 /**< PENDSV vector id. */ +#define HANDLER_SYSTICK 11 /**< SYS TCK vector id. */ +/** @} */ + /*===========================================================================*/ /* Driver pre-compile time settings. */ /*===========================================================================*/ @@ -59,6 +77,7 @@ extern "C" { #endif void nvicEnableVector(uint32_t n, uint32_t prio); void nvicDisableVector(uint32_t n); + void nvicSetSystemHandlerPriority(uint32_t handler, uint32_t prio); #ifdef __cplusplus } #endif -- cgit v1.2.3