aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/NRF5/NRF51822
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/ports/NRF5/NRF51822')
-rw-r--r--os/hal/ports/NRF5/NRF51822/hal_ext_lld_isr.h79
-rw-r--r--os/hal/ports/NRF5/NRF51822/hal_lld.c2
-rw-r--r--os/hal/ports/NRF5/NRF51822/hal_lld.h2
-rw-r--r--os/hal/ports/NRF5/NRF51822/nrf51_isr.c (renamed from os/hal/ports/NRF5/NRF51822/hal_ext_lld_isr.c)56
-rw-r--r--os/hal/ports/NRF5/NRF51822/nrf51_isr.h44
-rw-r--r--os/hal/ports/NRF5/NRF51822/platform.mk3
6 files changed, 69 insertions, 117 deletions
diff --git a/os/hal/ports/NRF5/NRF51822/hal_ext_lld_isr.h b/os/hal/ports/NRF5/NRF51822/hal_ext_lld_isr.h
deleted file mode 100644
index d606866..0000000
--- a/os/hal/ports/NRF5/NRF51822/hal_ext_lld_isr.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- Copyright (C) 2015 Stephen Caudle
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-/**
- * @file NRF51x22/ext_lld_isr.h
- * @brief NRF51x22 EXT subsystem low level driver ISR header.
- *
- * @addtogroup EXT
- * @{
- */
-
-#ifndef HAL_EXT_LLD_ISR_H
-#define HAL_EXT_LLD_ISR_H
-
-#if HAL_USE_EXT || defined(__DOXYGEN__)
-
-/*===========================================================================*/
-/* Driver constants. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Driver pre-compile time settings. */
-/*===========================================================================*/
-
-/**
- * @name Configuration options
- * @{
- */
-/**
- * @brief GPIOTE interrupt priority level setting.
- */
-#if !defined(NRF5_EXT_GPIOTE_IRQ_PRIORITY) || defined(__DOXYGEN__)
-#define NRF5_EXT_GPIOTE_IRQ_PRIORITY 3
-#endif
-/** @} */
-
-/*===========================================================================*/
-/* Derived constants and error checks. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Driver data structures and types. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* Driver macros. */
-/*===========================================================================*/
-
-/*===========================================================================*/
-/* External declarations. */
-/*===========================================================================*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
- void ext_lld_exti_irq_enable(void);
- void ext_lld_exti_irq_disable(void);
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* HAL_USE_EXT */
-
-#endif /* HAL_EXT_LLD_ISR_H */
-
-/** @} */
diff --git a/os/hal/ports/NRF5/NRF51822/hal_lld.c b/os/hal/ports/NRF5/NRF51822/hal_lld.c
index f33fdda..412cfea 100644
--- a/os/hal/ports/NRF5/NRF51822/hal_lld.c
+++ b/os/hal/ports/NRF5/NRF51822/hal_lld.c
@@ -80,6 +80,8 @@ void hal_lld_init(void)
(NRF5_SYSTEM_TICKS == NRF5_SYSTEM_TICKS_AS_RTC)
NRF_CLOCK->TASKS_LFCLKSTART = 1;
#endif
+
+ irqInit();
}
/**
diff --git a/os/hal/ports/NRF5/NRF51822/hal_lld.h b/os/hal/ports/NRF5/NRF51822/hal_lld.h
index a1d2460..178bb42 100644
--- a/os/hal/ports/NRF5/NRF51822/hal_lld.h
+++ b/os/hal/ports/NRF5/NRF51822/hal_lld.h
@@ -94,7 +94,7 @@
/*===========================================================================*/
#include "nvic.h"
-
+#include "nrf51_isr.h"
#ifdef __cplusplus
extern "C" {
diff --git a/os/hal/ports/NRF5/NRF51822/hal_ext_lld_isr.c b/os/hal/ports/NRF5/NRF51822/nrf51_isr.c
index ca8e24d..9a2bd94 100644
--- a/os/hal/ports/NRF5/NRF51822/hal_ext_lld_isr.c
+++ b/os/hal/ports/NRF5/NRF51822/nrf51_isr.c
@@ -1,4 +1,5 @@
/*
+ Copyright (C) 2018 Konstantin Oblaukhov
Copyright (C) 2015 Stephen Caudle
Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,19 +16,15 @@
*/
/**
- * @file NRF51x22/ext_lld_isr.h
- * @brief NRF51x22 EXT subsystem low level driver ISR code.
+ * @file NRF51822/nrf51_isr.c
+ * @brief NRF51822 ISR handler code.
*
- * @addtogroup EXT
+ * @addtogroup NRF51822_ISR
* @{
*/
#include "hal.h"
-#if HAL_USE_EXT || defined(__DOXYGEN__)
-
-#include "hal_ext_lld_isr.h"
-
/*===========================================================================*/
/* Driver local definitions. */
/*===========================================================================*/
@@ -49,33 +46,21 @@
/*===========================================================================*/
/**
- * @brief EXTI[0]...EXTI[1] interrupt handler.
+ * @brief GPIOTE interrupt handler.
*
* @isr
*/
OSAL_IRQ_HANDLER(Vector58) {
OSAL_IRQ_PROLOGUE();
-
- if (NRF_GPIOTE->EVENTS_IN[0])
+
+ for (int ch = 0; ch < NRF5_GPIOTE_NUM_CHANNELS; ch++)
{
- NRF_GPIOTE->EVENTS_IN[0] = 0;
- EXTD1.config->channels[0].cb(&EXTD1, 0);
- }
- if (NRF_GPIOTE->EVENTS_IN[1])
- {
- NRF_GPIOTE->EVENTS_IN[1] = 0;
- EXTD1.config->channels[1].cb(&EXTD1, 1);
- }
- if (NRF_GPIOTE->EVENTS_IN[2])
- {
- NRF_GPIOTE->EVENTS_IN[2] = 0;
- EXTD1.config->channels[2].cb(&EXTD1, 2);
- }
- if (NRF_GPIOTE->EVENTS_IN[3])
- {
- NRF_GPIOTE->EVENTS_IN[3] = 0;
- EXTD1.config->channels[3].cb(&EXTD1, 3);
+ if (NRF_GPIOTE->EVENTS_IN[ch])
+ {
+ NRF_GPIOTE->EVENTS_IN[ch] = 0;
+ _pal_isr_code(ch);
+ }
}
OSAL_IRQ_EPILOGUE();
@@ -84,27 +69,28 @@ OSAL_IRQ_HANDLER(Vector58) {
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
-
/**
- * @brief Enables EXTI IRQ sources.
+ * @brief Enables IRQ sources.
*
* @notapi
*/
-void ext_lld_exti_irq_enable(void) {
+void irqInit(void) {
- nvicEnableVector(GPIOTE_IRQn, NRF5_EXT_GPIOTE_IRQ_PRIORITY);
+#if HAL_USE_PAL
+ nvicEnableVector(GPIOTE_IRQn, NRF5_IRQ_GPIOTE_PRIORITY);
+#endif
}
/**
- * @brief Disables EXTI IRQ sources.
+ * @brief Disables IRQ sources.
*
* @notapi
*/
-void ext_lld_exti_irq_disable(void) {
+void irqDeinit(void) {
+#if HAL_USE_PAL
nvicDisableVector(GPIOTE_IRQn);
+#endif
}
-#endif /* HAL_USE_EXT */
-
/** @} */
diff --git a/os/hal/ports/NRF5/NRF51822/nrf51_isr.h b/os/hal/ports/NRF5/NRF51822/nrf51_isr.h
new file mode 100644
index 0000000..832d2c3
--- /dev/null
+++ b/os/hal/ports/NRF5/NRF51822/nrf51_isr.h
@@ -0,0 +1,44 @@
+/*
+ Copyright (C) 2018 Konstantin Oblaukhov
+ Copyright (C) 2015 Stephen Caudle
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file NRF51822/nrf51_isr.h
+ * @brief NRF51822 ISR handler header.
+ *
+ * @addtogroup NRF51822_ISR
+ * @{
+ */
+
+#ifndef NRF51_ISR_H
+#define NRF51_ISR_H
+
+#if !defined(NRF5_IRQ_GPIOTE_PRIORITY) || defined(__DOXYGEN__)
+#define NRF5_IRQ_GPIOTE_PRIORITY 3
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void irqInit(void);
+ void irqDeinit(void);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* NRF51_ISR_H */
+
+/** @} */
diff --git a/os/hal/ports/NRF5/NRF51822/platform.mk b/os/hal/ports/NRF5/NRF51822/platform.mk
index 298a85c..711a625 100644
--- a/os/hal/ports/NRF5/NRF51822/platform.mk
+++ b/os/hal/ports/NRF5/NRF51822/platform.mk
@@ -1,6 +1,6 @@
PLATFORMSRC_CONTRIB := ${CHIBIOS}/os/hal/ports/common/ARMCMx/nvic.c \
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_lld.c \
- ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/hal_ext_lld_isr.c \
+ ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/NRF51822/nrf51_isr.c \
${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/TIMERv1/hal_st_lld.c
PLATFORMINC_CONTRIB := ${CHIBIOS}/os/hal/ports/common/ARMCMx \
@@ -21,7 +21,6 @@ endif
include ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/GPIOv1/driver.mk
include ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/UARTv1/driver.mk
include ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/SPIv1/driver.mk
-include ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/GPIOTEv1/driver.mk
include ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/TWIv1/driver.mk
include ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/ADCv1/driver.mk
include ${CHIBIOS_CONTRIB}/os/hal/ports/NRF5/LLD/TIMERv1/driver.mk