aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-11-07 08:41:42 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-11-07 08:41:42 +0000
commit4d059c02e9659a1b4b030fef5537267ad2694e08 (patch)
tree1af30264b0ce2a6e2c89eb81d59bcbf4ca3ad220 /os
parent6750ea84066ad5f23553d2a8c5e3e61049522df6 (diff)
downloadChibiOS-4d059c02e9659a1b4b030fef5537267ad2694e08.tar.gz
ChibiOS-4d059c02e9659a1b4b030fef5537267ad2694e08.tar.bz2
ChibiOS-4d059c02e9659a1b4b030fef5537267ad2694e08.zip
Fixed bug #654.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8439 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/ports/common/ARMCMx/nvic.c26
-rw-r--r--os/hal/ports/common/ARMCMx/nvic.h2
2 files changed, 20 insertions, 8 deletions
diff --git a/os/hal/ports/common/ARMCMx/nvic.c b/os/hal/ports/common/ARMCMx/nvic.c
index c8f1f21af..605640d8b 100644
--- a/os/hal/ports/common/ARMCMx/nvic.c
+++ b/os/hal/ports/common/ARMCMx/nvic.c
@@ -56,9 +56,14 @@
*/
void nvicEnableVector(uint32_t n, uint32_t prio) {
- NVIC->IP[n] = NVIC_PRIORITY_MASK(prio);
- NVIC->ICPR[n >> 5] = 1 << (n & 0x1F);
- NVIC->ISER[n >> 5] = 1 << (n & 0x1F);
+#if defined(__CORE_CM0_H_GENERIC)
+ NVIC->IP[_IP_IDX(n)] = (NVIC->IP[_IP_IDX(n)] & ~(0xFFU << _BIT_SHIFT(n))) |
+ (NVIC_PRIORITY_MASK(prio) << _BIT_SHIFT(n));
+#else
+ NVIC->IP[n] = NVIC_PRIORITY_MASK(prio);
+#endif
+ NVIC->ICPR[n >> 5U] = 1U << (n & 0x1FU);
+ NVIC->ISER[n >> 5U] = 1U << (n & 0x1FU);
}
/**
@@ -68,8 +73,12 @@ void nvicEnableVector(uint32_t n, uint32_t prio) {
*/
void nvicDisableVector(uint32_t n) {
- NVIC->ICER[n >> 5] = 1 << (n & 0x1F);
- NVIC->IP[n] = 0;
+ NVIC->ICER[n >> 5U] = 1U << (n & 0x1FU);
+#if defined(__CORE_CM0_H_GENERIC)
+ NVIC->IP[_IP_IDX(n)] = NVIC->IP[_IP_IDX(n)] & ~(0xFFU << _BIT_SHIFT(n));
+#else
+ NVIC->IP[n] = 0U;
+#endif
}
/**
@@ -80,9 +89,12 @@ void nvicDisableVector(uint32_t n) {
*/
void nvicSetSystemHandlerPriority(uint32_t handler, uint32_t prio) {
- osalDbgCheck(handler <= 12);
+ osalDbgCheck(handler <= 12U);
-#if defined(__CORE_CM7_H_GENERIC)
+#if defined(__CORE_CM0_H_GENERIC)
+ SCB->SHP[_SHP_IDX(handler)] = (SCB->SHP[_SHP_IDX(handler)] & ~(0xFFU << _BIT_SHIFT(handler))) |
+ (NVIC_PRIORITY_MASK(prio) << _BIT_SHIFT(handler));
+#elif defined(__CORE_CM7_H_GENERIC)
SCB->SHPR[handler] = NVIC_PRIORITY_MASK(prio);
#else
SCB->SHP[handler] = NVIC_PRIORITY_MASK(prio);
diff --git a/os/hal/ports/common/ARMCMx/nvic.h b/os/hal/ports/common/ARMCMx/nvic.h
index 636cba3b1..868843b73 100644
--- a/os/hal/ports/common/ARMCMx/nvic.h
+++ b/os/hal/ports/common/ARMCMx/nvic.h
@@ -66,7 +66,7 @@
/**
* @brief Priority level to priority mask conversion macro.
*/
-#define NVIC_PRIORITY_MASK(prio) ((prio) << (8 - __NVIC_PRIO_BITS))
+#define NVIC_PRIORITY_MASK(prio) ((prio) << (8U - (unsigned)__NVIC_PRIO_BITS))
/*===========================================================================*/
/* External declarations. */