diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-08-07 13:37:27 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-08-07 13:37:27 +0000 |
commit | 68ea680d84c9de5f17618321a8360dab67203677 (patch) | |
tree | 03e7e6fd60ee62e075b0e602b5e93cec3e54109f /os/halnew | |
parent | 636f02da9083ed4ee8b5d2ca5662f70cb2af4909 (diff) | |
download | ChibiOS-68ea680d84c9de5f17618321a8360dab67203677.tar.gz ChibiOS-68ea680d84c9de5f17618321a8360dab67203677.tar.bz2 ChibiOS-68ea680d84c9de5f17618321a8360dab67203677.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6098 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/halnew')
-rw-r--r-- | os/halnew/platforms/STM32F30x/platform.mk | 6 | ||||
-rw-r--r-- | os/halnew/platforms/common/ARMCMx/nvic.c | 57 | ||||
-rw-r--r-- | os/halnew/platforms/common/ARMCMx/nvic.h | 43 |
3 files changed, 104 insertions, 2 deletions
diff --git a/os/halnew/platforms/STM32F30x/platform.mk b/os/halnew/platforms/STM32F30x/platform.mk index 5fd4ced5d..d45dbdb83 100644 --- a/os/halnew/platforms/STM32F30x/platform.mk +++ b/os/halnew/platforms/STM32F30x/platform.mk @@ -1,5 +1,6 @@ # List of all the STM32F30x platform files.
-PLATFORMSRC = ${CHIBIOS}/os/halnew/platforms/STM32F30x/stm32_dma.c \
+PLATFORMSRC = ${CHIBIOS}/os/halnew/platforms/common/ARMCMx/nvic.c \
+ ${CHIBIOS}/os/halnew/platforms/STM32F30x/stm32_dma.c \
${CHIBIOS}/os/halnew/platforms/STM32F30x/hal_lld.c \
${CHIBIOS}/os/halnew/platforms/STM32F30x/adc_lld.c \
${CHIBIOS}/os/halnew/platforms/STM32F30x/ext_lld_isr.c \
@@ -18,7 +19,8 @@ PLATFORMSRC = ${CHIBIOS}/os/halnew/platforms/STM32F30x/stm32_dma.c \ ${CHIBIOS}/os/halnew/platforms/STM32/USBv1/usb_lld.c
# Required include directories
-PLATFORMINC = ${CHIBIOS}/os/halnew/platforms/STM32F30x \
+PLATFORMINC = ${CHIBIOS}/os/halnew/platforms/common/ARMCMx \
+ ${CHIBIOS}/os/halnew/platforms/STM32F30x \
${CHIBIOS}/os/halnew/platforms/STM32 \
${CHIBIOS}/os/halnew/platforms/STM32/GPIOv2 \
${CHIBIOS}/os/halnew/platforms/STM32/I2Cv2 \
diff --git a/os/halnew/platforms/common/ARMCMx/nvic.c b/os/halnew/platforms/common/ARMCMx/nvic.c new file mode 100644 index 000000000..a5872f90f --- /dev/null +++ b/os/halnew/platforms/common/ARMCMx/nvic.c @@ -0,0 +1,57 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
+ 2011,2012,2013 Giovanni Di Sirio.
+
+ This file is part of ChibiOS/RT.
+
+ ChibiOS/RT is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/RT is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file common/ARMCMx/nvic.c
+ * @brief Cortex-Mx NVIC support code.
+ *
+ * @addtogroup COMMON_ARMCMx_NVIC
+ * @{
+ */
+
+#include "hal.h"
+
+/**
+ * @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
+ */
+void nvicEnableVector(uint32_t n, uint32_t prio) {
+
+ NVIC->IP[n] = prio << (8 - __NVIC_PRIO_BITS);
+ NVIC->ICPR[n >> 5] = 1 << (n & 0x1F);
+ NVIC->ISER[n >> 5] = 1 << (n & 0x1F);
+}
+
+/**
+ * @brief Disables an interrupt handler.
+ * @note The parameters are not tested for correctness.
+ *
+ * @param[in] n the interrupt number
+ */
+void nvicDisableVector(uint32_t n) {
+
+ NVIC->ICER[n >> 5] = 1 << (n & 0x1F);
+ NVIC->IP[n] = 0;
+}
+
+/** @} */
diff --git a/os/halnew/platforms/common/ARMCMx/nvic.h b/os/halnew/platforms/common/ARMCMx/nvic.h new file mode 100644 index 000000000..b4ade1623 --- /dev/null +++ b/os/halnew/platforms/common/ARMCMx/nvic.h @@ -0,0 +1,43 @@ +/*
+ ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010,
+ 2011,2012,2013 Giovanni Di Sirio.
+
+ This file is part of ChibiOS/RT.
+
+ ChibiOS/RT is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ ChibiOS/RT is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * @file common/ARMCMx/nvic.h
+ * @brief Cortex-Mx NVIC support macros and structures.
+ *
+ * @addtogroup COMMON_ARMCMx_NVIC
+ * @{
+ */
+
+#ifndef _NVIC_H_
+#define _NVIC_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void nvicEnableVector(uint32_t n, uint32_t prio);
+ void nvicDisableVector(uint32_t n);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _NVIC_H_ */
+
+/** @} */
|