From 5805e10f74104e3de60470c38d6643d2bdb00fe0 Mon Sep 17 00:00:00 2001 From: Stephane D'Alu Date: Sat, 9 Jul 2016 23:57:48 +0200 Subject: NRF52832 implementation --- os/hal/ports/NRF5/LLD/hal_st_lld.c | 302 +++++++++++++++++++++++++++++++++++++ 1 file changed, 302 insertions(+) create mode 100644 os/hal/ports/NRF5/LLD/hal_st_lld.c (limited to 'os/hal/ports/NRF5/LLD/hal_st_lld.c') diff --git a/os/hal/ports/NRF5/LLD/hal_st_lld.c b/os/hal/ports/NRF5/LLD/hal_st_lld.c new file mode 100644 index 0000000..3a988a8 --- /dev/null +++ b/os/hal/ports/NRF5/LLD/hal_st_lld.c @@ -0,0 +1,302 @@ +/* + ChibiOS - Copyright (C) 2015 Fabio Utzig + 2016 Stephane D'Alu + + 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 st_lld.c + * @brief NRF51822 ST subsystem low level driver source. + * + * @addtogroup ST + * @{ + */ + +#include "hal.h" + +#if (OSAL_ST_MODE != OSAL_ST_MODE_NONE) || defined(__DOXYGEN__) + +/*===========================================================================*/ +/* Driver local definitions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver exported variables. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local types. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local variables and types. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver local functions. */ +/*===========================================================================*/ + +/*===========================================================================*/ +/* Driver interrupt handlers. */ +/*===========================================================================*/ + +#if (OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC) || defined(__DOXYGEN__) +#if NRF51_ST_USE_RTC0 == TRUE +/** + * @brief System Timer vector (RTC0) + * @details This interrupt is used for system tick in periodic mode + * if selected with NRF51_ST_USE_RTC0 + * + * @isr + */ +OSAL_IRQ_HANDLER(Vector6C) { + + OSAL_IRQ_PROLOGUE(); + + NRF_RTC0->EVENTS_TICK = 0; + (void)NRF_RTC0->EVENTS_TICK; + + osalSysLockFromISR(); + osalOsTimerHandlerI(); + osalSysUnlockFromISR(); + + OSAL_IRQ_EPILOGUE(); +} +#endif + +#if NRF51_ST_USE_RTC1 == TRUE +/** + * @brief System Timer vector (RTC1) + * @details This interrupt is used for system tick in periodic mode + * if selected with NRF51_ST_USE_RTC1 + * + * @isr + */ +OSAL_IRQ_HANDLER(Vector84) { + + OSAL_IRQ_PROLOGUE(); + + NRF_RTC1->EVENTS_TICK = 0; + (void)NRF_RTC1->EVENTS_TICK; + + osalSysLockFromISR(); + osalOsTimerHandlerI(); + osalSysUnlockFromISR(); + + OSAL_IRQ_EPILOGUE(); +} +#endif + +#if NRF51_ST_USE_TIMER0 == TRUE +/** + * @brief System Timer vector. (TIMER0) + * @details This interrupt is used for system tick in periodic mode + * if selected with NRF51_ST_USE_TIMER0 + * + * @isr + */ +OSAL_IRQ_HANDLER(Vector60) { + + OSAL_IRQ_PROLOGUE(); + + /* Clear timer compare event */ + if (NRF_TIMER0->EVENTS_COMPARE[0] != 0) { + NRF_TIMER0->EVENTS_COMPARE[0] = 0; + (void)NRF_TIMER0->EVENTS_COMPARE[0]; + + osalSysLockFromISR(); + osalOsTimerHandlerI(); + osalSysUnlockFromISR(); + } + + OSAL_IRQ_EPILOGUE(); +} +#endif +#endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */ + +#if (OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING) || defined(__DOXYGEN__) +#if NRF51_ST_USE_RTC0 == TRUE +/** + * @brief System Timer vector (RTC0) + * @details This interrupt is used for freerunning mode (tick-less) + * if selected with NRF51_ST_USE_RTC0 + * + * @isr + */ +OSAL_IRQ_HANDLER(Vector6C) { + + OSAL_IRQ_PROLOGUE(); + + if (NRF_RTC0->EVENTS_COMPARE[0]) { + NRF_RTC0->EVENTS_COMPARE[0] = 0; + (void)NRF_RTC0->EVENTS_COMPARE[0]; + + osalSysLockFromISR(); + osalOsTimerHandlerI(); + osalSysUnlockFromISR(); + } + +#if OSAL_ST_RESOLUTION == 16 + if (NRF_RTC0->EVENTS_COMPARE[1]) { + NRF_RTC0->EVENTS_COMPARE[1] = 0; + (void)NRF_RTC0->EVENTS_COMPARE[1]; + NRF_RTC0->TASKS_CLEAR = 1; + } +#endif + + OSAL_IRQ_EPILOGUE(); +} +#endif + +#if NRF51_ST_USE_RTC1 == TRUE +/** + * @brief System Timer vector (RTC1) + * @details This interrupt is used for freerunning mode (tick-less) + * if selected with NRF51_ST_USE_RTC1 + * + * @isr + */ +OSAL_IRQ_HANDLER(Vector84) { + + OSAL_IRQ_PROLOGUE(); + + if (NRF_RTC1->EVENTS_COMPARE[0]) { + NRF_RTC1->EVENTS_COMPARE[0] = 0; + (void)NRF_RTC1->EVENTS_COMPARE[0]; + + osalSysLockFromISR(); + osalOsTimerHandlerI(); + osalSysUnlockFromISR(); + } + +#if OSAL_ST_RESOLUTION == 16 + if (NRF_RTC1->EVENTS_COMPARE[1]) { + NRF_RTC1->EVENTS_COMPARE[1] = 0; + (void)NRF_RTC1->EVENTS_COMPARE[1]; + NRF_RTC1->TASKS_CLEAR = 1; + } +#endif + + OSAL_IRQ_EPILOGUE(); +} +#endif +#endif /* OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING */ + +/*===========================================================================*/ +/* Driver exported functions. */ +/*===========================================================================*/ + +/** + * @brief Low level ST driver initialization. + * + * @notapi + */ +void st_lld_init(void) { +#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING + +#if NRF51_ST_USE_RTC0 == TRUE + /* Using RTC with prescaler */ + NRF_RTC0->TASKS_STOP = 1; + NRF_RTC0->PRESCALER = (NRF51_LFCLK_FREQUENCY / OSAL_ST_FREQUENCY) - 1; + NRF_RTC0->EVTENCLR = RTC_EVTENSET_COMPARE0_Msk; + NRF_RTC0->EVENTS_COMPARE[0] = 0; + NRF_RTC0->INTENSET = RTC_INTENSET_COMPARE0_Msk; +#if OSAL_ST_RESOLUTION == 16 + NRF_RTC0->CC[1] = 0x10000; /* 2^16 */ + NRF_RTC0->EVENTS_COMPARE[1] = 0; + NRF_RTC0->EVTENSET = RTC_EVTENSET_COMPARE0_Msk; + NRF_RTC0->INTENSET = RTC_INTENSET_COMPARE1_Msk; +#endif + NRF_RTC0->TASKS_CLEAR = 1; + + /* Start timer */ + nvicEnableVector(RTC0_IRQn, NRF51_ST_PRIORITY); + NRF_RTC0->TASKS_START = 1; +#endif /* NRF51_ST_USE_RTC0 == TRUE */ + +#if NRF51_ST_USE_RTC1 == TRUE + /* Using RTC with prescaler */ + NRF_RTC1->TASKS_STOP = 1; + NRF_RTC1->PRESCALER = (NRF51_LFCLK_FREQUENCY / OSAL_ST_FREQUENCY) - 1; + NRF_RTC1->EVTENCLR = RTC_EVTENSET_COMPARE0_Msk; + NRF_RTC1->EVENTS_COMPARE[0] = 0; + NRF_RTC1->INTENSET = RTC_INTENSET_COMPARE0_Msk; +#if OSAL_ST_RESOLUTION == 16 + NRF_RTC1->CC[1] = 0x10000; /* 2^16 */ + NRF_RTC1->EVENTS_COMPARE[1] = 0; + NRF_RTC1->EVTENSET = RTC_EVTENSET_COMPARE0_Msk; + NRF_RTC1->INTENSET = RTC_INTENSET_COMPARE1_Msk; +#endif + NRF_RTC1->TASKS_CLEAR = 1; + + /* Start timer */ + nvicEnableVector(RTC1_IRQn, NRF51_ST_PRIORITY); + NRF_RTC1->TASKS_START = 1; +#endif /* NRF51_ST_USE_RTC1 == TRUE */ + +#endif /* OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING */ + +#if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC + +#if NRF51_ST_USE_RTC0 == TRUE + /* Using RTC with prescaler */ + NRF_RTC0->TASKS_STOP = 1; + NRF_RTC0->PRESCALER = (NRF51_LFCLK_FREQUENCY / OSAL_ST_FREQUENCY) - 1; + NRF_RTC0->INTENSET = RTC_INTENSET_TICK_Msk; + + /* Start timer */ + nvicEnableVector(RTC0_IRQn, NRF51_ST_PRIORITY); + NRF_RTC0->TASKS_START = 1; +#endif /* NRF51_ST_USE_RTC0 == TRUE */ + +#if NRF51_ST_USE_RTC1 == TRUE + /* Using RTC with prescaler */ + NRF_RTC1->TASKS_STOP = 1; + NRF_RTC1->PRESCALER = (NRF51_LFCLK_FREQUENCY / OSAL_ST_FREQUENCY) - 1; + NRF_RTC1->INTENSET = RTC_INTENSET_TICK_Msk; + + /* Start timer */ + nvicEnableVector(RTC1_IRQn, NRF51_ST_PRIORITY); + NRF_RTC1->TASKS_START = 1; +#endif /* NRF51_ST_USE_RTC1 == TRUE */ + +#if NRF51_ST_USE_TIMER0 == TRUE + NRF_TIMER0->TASKS_CLEAR = 1; + + /* + * Using 32-bit mode with prescaler 16 configures this + * timer with a 1MHz clock. + */ + NRF_TIMER0->BITMODE = 3; + NRF_TIMER0->PRESCALER = 4; + + /* + * Configure timer 0 compare capture 0 to generate interrupt + * and clear timer value when event is generated. + */ + NRF_TIMER0->CC[0] = (1000000 / OSAL_ST_FREQUENCY) - 1; + NRF_TIMER0->SHORTS = 1; + NRF_TIMER0->INTENSET = 0x10000; + + /* Start timer */ + nvicEnableVector(TIMER0_IRQn, NRF51_ST_PRIORITY); + NRF_TIMER0->TASKS_START = 1; +#endif /* NRF51_ST_USE_TIMER0 == TRUE */ + +#endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */ +} + +#endif /* OSAL_ST_MODE != OSAL_ST_MODE_NONE */ + +/** @} */ -- cgit v1.2.3 From 1908537785516004f2014ccb2d6db31a2fe56173 Mon Sep 17 00:00:00 2001 From: Stephane D'Alu Date: Sun, 10 Jul 2016 00:23:12 +0200 Subject: use constantes --- os/hal/ports/NRF5/LLD/hal_st_lld.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os/hal/ports/NRF5/LLD/hal_st_lld.c') diff --git a/os/hal/ports/NRF5/LLD/hal_st_lld.c b/os/hal/ports/NRF5/LLD/hal_st_lld.c index 3a988a8..a2c1a8f 100644 --- a/os/hal/ports/NRF5/LLD/hal_st_lld.c +++ b/os/hal/ports/NRF5/LLD/hal_st_lld.c @@ -278,7 +278,7 @@ void st_lld_init(void) { * Using 32-bit mode with prescaler 16 configures this * timer with a 1MHz clock. */ - NRF_TIMER0->BITMODE = 3; + NRF_TIMER0->BITMODE = TIMER_BITMODE_BITMODE_32Bit; NRF_TIMER0->PRESCALER = 4; /* @@ -287,7 +287,7 @@ void st_lld_init(void) { */ NRF_TIMER0->CC[0] = (1000000 / OSAL_ST_FREQUENCY) - 1; NRF_TIMER0->SHORTS = 1; - NRF_TIMER0->INTENSET = 0x10000; + NRF_TIMER0->INTENSET = TIMER_INTENSET_COMPARE0_Msk; /* Start timer */ nvicEnableVector(TIMER0_IRQn, NRF51_ST_PRIORITY); -- cgit v1.2.3 From 5259158d1727f3703bc90f88d50938eada316f67 Mon Sep 17 00:00:00 2001 From: Stephane D'Alu Date: Sun, 10 Jul 2016 10:48:04 +0200 Subject: renamed NRF51_* to NRF5_* --- os/hal/ports/NRF5/LLD/hal_st_lld.c | 62 +++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 31 deletions(-) (limited to 'os/hal/ports/NRF5/LLD/hal_st_lld.c') diff --git a/os/hal/ports/NRF5/LLD/hal_st_lld.c b/os/hal/ports/NRF5/LLD/hal_st_lld.c index a2c1a8f..931f1a7 100644 --- a/os/hal/ports/NRF5/LLD/hal_st_lld.c +++ b/os/hal/ports/NRF5/LLD/hal_st_lld.c @@ -16,8 +16,8 @@ */ /** - * @file st_lld.c - * @brief NRF51822 ST subsystem low level driver source. + * @file NRF5/LLD/hal_st_lld.c + * @brief NRF5 ST subsystem low level driver source. * * @addtogroup ST * @{ @@ -52,11 +52,11 @@ /*===========================================================================*/ #if (OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC) || defined(__DOXYGEN__) -#if NRF51_ST_USE_RTC0 == TRUE +#if NRF5_ST_USE_RTC0 == TRUE /** * @brief System Timer vector (RTC0) * @details This interrupt is used for system tick in periodic mode - * if selected with NRF51_ST_USE_RTC0 + * if selected with NRF5_ST_USE_RTC0 * * @isr */ @@ -75,11 +75,11 @@ OSAL_IRQ_HANDLER(Vector6C) { } #endif -#if NRF51_ST_USE_RTC1 == TRUE +#if NRF5_ST_USE_RTC1 == TRUE /** * @brief System Timer vector (RTC1) * @details This interrupt is used for system tick in periodic mode - * if selected with NRF51_ST_USE_RTC1 + * if selected with NRF5_ST_USE_RTC1 * * @isr */ @@ -98,11 +98,11 @@ OSAL_IRQ_HANDLER(Vector84) { } #endif -#if NRF51_ST_USE_TIMER0 == TRUE +#if NRF5_ST_USE_TIMER0 == TRUE /** * @brief System Timer vector. (TIMER0) * @details This interrupt is used for system tick in periodic mode - * if selected with NRF51_ST_USE_TIMER0 + * if selected with NRF5_ST_USE_TIMER0 * * @isr */ @@ -126,11 +126,11 @@ OSAL_IRQ_HANDLER(Vector60) { #endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */ #if (OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING) || defined(__DOXYGEN__) -#if NRF51_ST_USE_RTC0 == TRUE +#if NRF5_ST_USE_RTC0 == TRUE /** * @brief System Timer vector (RTC0) * @details This interrupt is used for freerunning mode (tick-less) - * if selected with NRF51_ST_USE_RTC0 + * if selected with NRF5_ST_USE_RTC0 * * @isr */ @@ -159,11 +159,11 @@ OSAL_IRQ_HANDLER(Vector6C) { } #endif -#if NRF51_ST_USE_RTC1 == TRUE +#if NRF5_ST_USE_RTC1 == TRUE /** * @brief System Timer vector (RTC1) * @details This interrupt is used for freerunning mode (tick-less) - * if selected with NRF51_ST_USE_RTC1 + * if selected with NRF5_ST_USE_RTC1 * * @isr */ @@ -205,10 +205,10 @@ OSAL_IRQ_HANDLER(Vector84) { void st_lld_init(void) { #if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING -#if NRF51_ST_USE_RTC0 == TRUE +#if NRF5_ST_USE_RTC0 == TRUE /* Using RTC with prescaler */ NRF_RTC0->TASKS_STOP = 1; - NRF_RTC0->PRESCALER = (NRF51_LFCLK_FREQUENCY / OSAL_ST_FREQUENCY) - 1; + NRF_RTC0->PRESCALER = (NRF5_LFCLK_FREQUENCY / OSAL_ST_FREQUENCY) - 1; NRF_RTC0->EVTENCLR = RTC_EVTENSET_COMPARE0_Msk; NRF_RTC0->EVENTS_COMPARE[0] = 0; NRF_RTC0->INTENSET = RTC_INTENSET_COMPARE0_Msk; @@ -221,14 +221,14 @@ void st_lld_init(void) { NRF_RTC0->TASKS_CLEAR = 1; /* Start timer */ - nvicEnableVector(RTC0_IRQn, NRF51_ST_PRIORITY); + nvicEnableVector(RTC0_IRQn, NRF5_ST_PRIORITY); NRF_RTC0->TASKS_START = 1; -#endif /* NRF51_ST_USE_RTC0 == TRUE */ +#endif /* NRF5_ST_USE_RTC0 == TRUE */ -#if NRF51_ST_USE_RTC1 == TRUE +#if NRF5_ST_USE_RTC1 == TRUE /* Using RTC with prescaler */ NRF_RTC1->TASKS_STOP = 1; - NRF_RTC1->PRESCALER = (NRF51_LFCLK_FREQUENCY / OSAL_ST_FREQUENCY) - 1; + NRF_RTC1->PRESCALER = (NRF5_LFCLK_FREQUENCY / OSAL_ST_FREQUENCY) - 1; NRF_RTC1->EVTENCLR = RTC_EVTENSET_COMPARE0_Msk; NRF_RTC1->EVENTS_COMPARE[0] = 0; NRF_RTC1->INTENSET = RTC_INTENSET_COMPARE0_Msk; @@ -241,37 +241,37 @@ void st_lld_init(void) { NRF_RTC1->TASKS_CLEAR = 1; /* Start timer */ - nvicEnableVector(RTC1_IRQn, NRF51_ST_PRIORITY); + nvicEnableVector(RTC1_IRQn, NRF5_ST_PRIORITY); NRF_RTC1->TASKS_START = 1; -#endif /* NRF51_ST_USE_RTC1 == TRUE */ +#endif /* NRF5_ST_USE_RTC1 == TRUE */ #endif /* OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING */ #if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC -#if NRF51_ST_USE_RTC0 == TRUE +#if NRF5_ST_USE_RTC0 == TRUE /* Using RTC with prescaler */ NRF_RTC0->TASKS_STOP = 1; - NRF_RTC0->PRESCALER = (NRF51_LFCLK_FREQUENCY / OSAL_ST_FREQUENCY) - 1; + NRF_RTC0->PRESCALER = (NRF5_LFCLK_FREQUENCY / OSAL_ST_FREQUENCY) - 1; NRF_RTC0->INTENSET = RTC_INTENSET_TICK_Msk; /* Start timer */ - nvicEnableVector(RTC0_IRQn, NRF51_ST_PRIORITY); + nvicEnableVector(RTC0_IRQn, NRF5_ST_PRIORITY); NRF_RTC0->TASKS_START = 1; -#endif /* NRF51_ST_USE_RTC0 == TRUE */ +#endif /* NRF5_ST_USE_RTC0 == TRUE */ -#if NRF51_ST_USE_RTC1 == TRUE +#if NRF5_ST_USE_RTC1 == TRUE /* Using RTC with prescaler */ NRF_RTC1->TASKS_STOP = 1; - NRF_RTC1->PRESCALER = (NRF51_LFCLK_FREQUENCY / OSAL_ST_FREQUENCY) - 1; + NRF_RTC1->PRESCALER = (NRF5_LFCLK_FREQUENCY / OSAL_ST_FREQUENCY) - 1; NRF_RTC1->INTENSET = RTC_INTENSET_TICK_Msk; /* Start timer */ - nvicEnableVector(RTC1_IRQn, NRF51_ST_PRIORITY); + nvicEnableVector(RTC1_IRQn, NRF5_ST_PRIORITY); NRF_RTC1->TASKS_START = 1; -#endif /* NRF51_ST_USE_RTC1 == TRUE */ +#endif /* NRF5_ST_USE_RTC1 == TRUE */ -#if NRF51_ST_USE_TIMER0 == TRUE +#if NRF5_ST_USE_TIMER0 == TRUE NRF_TIMER0->TASKS_CLEAR = 1; /* @@ -290,9 +290,9 @@ void st_lld_init(void) { NRF_TIMER0->INTENSET = TIMER_INTENSET_COMPARE0_Msk; /* Start timer */ - nvicEnableVector(TIMER0_IRQn, NRF51_ST_PRIORITY); + nvicEnableVector(TIMER0_IRQn, NRF5_ST_PRIORITY); NRF_TIMER0->TASKS_START = 1; -#endif /* NRF51_ST_USE_TIMER0 == TRUE */ +#endif /* NRF5_ST_USE_TIMER0 == TRUE */ #endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */ } -- cgit v1.2.3 From 6423c3dabeba4e4ed9217d71873653bc8af9ae4e Mon Sep 17 00:00:00 2001 From: Stephane D'Alu Date: Sun, 10 Jul 2016 12:04:39 +0200 Subject: moved rng to LLD directory. removed rng power control (doesn't exist in nrf52, wasn't documented in nrf51) renamed peripheral to start at 0 --- os/hal/ports/NRF5/LLD/hal_st_lld.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os/hal/ports/NRF5/LLD/hal_st_lld.c') diff --git a/os/hal/ports/NRF5/LLD/hal_st_lld.c b/os/hal/ports/NRF5/LLD/hal_st_lld.c index 931f1a7..c78b4bb 100644 --- a/os/hal/ports/NRF5/LLD/hal_st_lld.c +++ b/os/hal/ports/NRF5/LLD/hal_st_lld.c @@ -275,8 +275,8 @@ void st_lld_init(void) { NRF_TIMER0->TASKS_CLEAR = 1; /* - * Using 32-bit mode with prescaler 16 configures this - * timer with a 1MHz clock. + * Using 32-bit mode with prescaler 1/16 configures this + * timer with a 1MHz clock, reducing power consumption. */ NRF_TIMER0->BITMODE = TIMER_BITMODE_BITMODE_32Bit; NRF_TIMER0->PRESCALER = 4; -- cgit v1.2.3 From 539338100fffb76e152be37228c4040fa072ba92 Mon Sep 17 00:00:00 2001 From: Stephane D'Alu Date: Mon, 11 Jul 2016 22:11:27 +0200 Subject: deal with write buffer --- os/hal/ports/NRF5/LLD/hal_st_lld.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'os/hal/ports/NRF5/LLD/hal_st_lld.c') diff --git a/os/hal/ports/NRF5/LLD/hal_st_lld.c b/os/hal/ports/NRF5/LLD/hal_st_lld.c index c78b4bb..8e42029 100644 --- a/os/hal/ports/NRF5/LLD/hal_st_lld.c +++ b/os/hal/ports/NRF5/LLD/hal_st_lld.c @@ -65,8 +65,10 @@ OSAL_IRQ_HANDLER(Vector6C) { OSAL_IRQ_PROLOGUE(); NRF_RTC0->EVENTS_TICK = 0; +#if CORTEX_MODEL >= 4 (void)NRF_RTC0->EVENTS_TICK; - +#endif + osalSysLockFromISR(); osalOsTimerHandlerI(); osalSysUnlockFromISR(); @@ -88,8 +90,10 @@ OSAL_IRQ_HANDLER(Vector84) { OSAL_IRQ_PROLOGUE(); NRF_RTC1->EVENTS_TICK = 0; +#if CORTEX_MODEL >= 4 (void)NRF_RTC1->EVENTS_TICK; - +#endif + osalSysLockFromISR(); osalOsTimerHandlerI(); osalSysUnlockFromISR(); @@ -113,8 +117,10 @@ OSAL_IRQ_HANDLER(Vector60) { /* Clear timer compare event */ if (NRF_TIMER0->EVENTS_COMPARE[0] != 0) { NRF_TIMER0->EVENTS_COMPARE[0] = 0; +#if CORTEX_MODEL >= 4 (void)NRF_TIMER0->EVENTS_COMPARE[0]; - +#endif + osalSysLockFromISR(); osalOsTimerHandlerI(); osalSysUnlockFromISR(); @@ -140,8 +146,10 @@ OSAL_IRQ_HANDLER(Vector6C) { if (NRF_RTC0->EVENTS_COMPARE[0]) { NRF_RTC0->EVENTS_COMPARE[0] = 0; +#if CORTEX_MODEL >= 4 (void)NRF_RTC0->EVENTS_COMPARE[0]; - +#endif + osalSysLockFromISR(); osalOsTimerHandlerI(); osalSysUnlockFromISR(); @@ -150,7 +158,9 @@ OSAL_IRQ_HANDLER(Vector6C) { #if OSAL_ST_RESOLUTION == 16 if (NRF_RTC0->EVENTS_COMPARE[1]) { NRF_RTC0->EVENTS_COMPARE[1] = 0; +#if CORTEX_MODEL >= 4 (void)NRF_RTC0->EVENTS_COMPARE[1]; +#endif NRF_RTC0->TASKS_CLEAR = 1; } #endif @@ -173,8 +183,10 @@ OSAL_IRQ_HANDLER(Vector84) { if (NRF_RTC1->EVENTS_COMPARE[0]) { NRF_RTC1->EVENTS_COMPARE[0] = 0; +#if CORTEX_MODEL >= 4 (void)NRF_RTC1->EVENTS_COMPARE[0]; - +#endif + osalSysLockFromISR(); osalOsTimerHandlerI(); osalSysUnlockFromISR(); @@ -183,7 +195,9 @@ OSAL_IRQ_HANDLER(Vector84) { #if OSAL_ST_RESOLUTION == 16 if (NRF_RTC1->EVENTS_COMPARE[1]) { NRF_RTC1->EVENTS_COMPARE[1] = 0; +#if CORTEX_MODEL >= 4 (void)NRF_RTC1->EVENTS_COMPARE[1]; +#endif NRF_RTC1->TASKS_CLEAR = 1; } #endif @@ -211,10 +225,16 @@ void st_lld_init(void) { NRF_RTC0->PRESCALER = (NRF5_LFCLK_FREQUENCY / OSAL_ST_FREQUENCY) - 1; NRF_RTC0->EVTENCLR = RTC_EVTENSET_COMPARE0_Msk; NRF_RTC0->EVENTS_COMPARE[0] = 0; +#if CORTEX_MODEL >= 4 + (void)NRF_RTC0->EVENTS_COMPARE[0]; +#endif NRF_RTC0->INTENSET = RTC_INTENSET_COMPARE0_Msk; #if OSAL_ST_RESOLUTION == 16 NRF_RTC0->CC[1] = 0x10000; /* 2^16 */ NRF_RTC0->EVENTS_COMPARE[1] = 0; +#if CORTEX_MODEL >= 4 + (void)NRF_RTC0->EVENTS_COMPARE[1]; +#endif NRF_RTC0->EVTENSET = RTC_EVTENSET_COMPARE0_Msk; NRF_RTC0->INTENSET = RTC_INTENSET_COMPARE1_Msk; #endif @@ -231,10 +251,16 @@ void st_lld_init(void) { NRF_RTC1->PRESCALER = (NRF5_LFCLK_FREQUENCY / OSAL_ST_FREQUENCY) - 1; NRF_RTC1->EVTENCLR = RTC_EVTENSET_COMPARE0_Msk; NRF_RTC1->EVENTS_COMPARE[0] = 0; +#if CORTEX_MODEL >= 4 + (void)NRF_RTC1->EVENTS_COMPARE[0]; +#endif NRF_RTC1->INTENSET = RTC_INTENSET_COMPARE0_Msk; #if OSAL_ST_RESOLUTION == 16 NRF_RTC1->CC[1] = 0x10000; /* 2^16 */ NRF_RTC1->EVENTS_COMPARE[1] = 0; +#if CORTEX_MODEL >= 4 + NRF_RTC1->EVENTS_COMPARE[1]; +#endif NRF_RTC1->EVTENSET = RTC_EVTENSET_COMPARE0_Msk; NRF_RTC1->INTENSET = RTC_INTENSET_COMPARE1_Msk; #endif -- cgit v1.2.3