You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by we...@apache.org on 2016/11/18 23:24:10 UTC

incubator-mynewt-core git commit: No jira ticket for this commit: remove references to nordic SDK from hal_watchdog for nrf51 and nrf52.

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/1_0_0_b1_dev e2211c8f6 -> d859a482a


No jira ticket for this commit: remove references to nordic SDK
from hal_watchdog for nrf51 and nrf52.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/d859a482
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d859a482
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d859a482

Branch: refs/heads/1_0_0_b1_dev
Commit: d859a482a489eb444e63a8bfe5d8595529efbf12
Parents: e2211c8
Author: William San Filippo <wi...@runtime.io>
Authored: Fri Nov 18 15:23:11 2016 -0800
Committer: William San Filippo <wi...@runtime.io>
Committed: Fri Nov 18 15:23:11 2016 -0800

----------------------------------------------------------------------
 hw/mcu/nordic/nrf51xxx/src/hal_watchdog.c | 37 +++++++++++++-------------
 hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c | 37 +++++++++++++-------------
 2 files changed, 38 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d859a482/hw/mcu/nordic/nrf51xxx/src/hal_watchdog.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf51xxx/src/hal_watchdog.c b/hw/mcu/nordic/nrf51xxx/src/hal_watchdog.c
index 29357a4..527712f 100644
--- a/hw/mcu/nordic/nrf51xxx/src/hal_watchdog.c
+++ b/hw/mcu/nordic/nrf51xxx/src/hal_watchdog.c
@@ -17,15 +17,11 @@
  * under the License.
  */
 
+#include <assert.h>
 #include "hal/hal_watchdog.h"
 #include "bsp/cmsis_nvic.h"
-
-#include <assert.h>
-
-#include "app_util_platform.h"
-#include "nrf.h"
-#include "nrf_drv_common.h"
-#include "nrf_wdt.h"
+#include "nrf51.h"
+#include "nrf51_bitfields.h"
 
 static void
 nrf51_hal_wdt_default_handler(void)
@@ -37,8 +33,8 @@ nrf51_hal_wdt_default_handler(void)
 static void
 nrf51_wdt_irq_handler(void)
 {
-    if (nrf_wdt_int_enable_check(NRF_WDT_INT_TIMEOUT_MASK) == true) {
-        nrf_wdt_event_clear(NRF_WDT_EVENT_TIMEOUT);
+    if (NRF_WDT->INTENSET & WDT_INTENSET_TIMEOUT_Msk) {
+        NRF_WDT->EVENTS_TIMEOUT = 0;
         nrf51_hal_wdt_default_handler();
     }
 }
@@ -46,14 +42,19 @@ nrf51_wdt_irq_handler(void)
 int
 hal_watchdog_init(uint32_t expire_msecs)
 {
-    NVIC_SetVector(WDT_IRQn, (uint32_t) nrf51_wdt_irq_handler);
+    uint64_t expiration;
+
+    NRF_WDT->CONFIG = WDT_CONFIG_SLEEP_Msk;
 
-    nrf_wdt_behaviour_set(NRF_WDT_BEHAVIOUR_RUN_SLEEP);
+    /* Convert msec timeout to counts of a 32768 crystal */
+    expiration = ((uint64_t)expire_msecs * 32768) / 1000;
+    NRF_WDT->CRV = (uint32_t)expiration;
 
-    /* Program in timeout in msecs */
-    nrf_wdt_reload_value_set((expire_msecs * 32768ULL) / 1000);
-    nrf_drv_common_irq_enable(WDT_IRQn, APP_IRQ_PRIORITY_HIGH);
-    nrf_wdt_reload_request_enable(NRF_WDT_RR0);
+    NVIC_SetVector(WDT_IRQn, (uint32_t) nrf51_wdt_irq_handler);
+    NVIC_SetPriority(WDT_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
+    NVIC_ClearPendingIRQ(WDT_IRQn);
+    NVIC_EnableIRQ(WDT_IRQn);
+    NRF_WDT->RREN |= 0x1;
 
     return (0);
 }
@@ -61,13 +62,13 @@ hal_watchdog_init(uint32_t expire_msecs)
 void
 hal_watchdog_enable(void)
 {
-    nrf_wdt_int_enable(NRF_WDT_INT_TIMEOUT_MASK);
-    nrf_wdt_task_trigger(NRF_WDT_TASK_START);
+    NRF_WDT->INTENSET = WDT_INTENSET_TIMEOUT_Msk;
+    NRF_WDT->TASKS_START = 1;
 }
 
 void
 hal_watchdog_tickle(void)
 {
-    nrf_wdt_reload_request_set(NRF_WDT_RR0);
+    NRF_WDT->RR[0] = WDT_RR_RR_Reload;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d859a482/hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c
----------------------------------------------------------------------
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c b/hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c
index 7068bcb..90ed8f2 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c
@@ -17,15 +17,11 @@
  * under the License.
  */
 
+#include <assert.h>
 #include "hal/hal_watchdog.h"
 #include "bsp/cmsis_nvic.h"
-
-#include <assert.h>
-
-#include "app_util_platform.h"
-#include "nrf.h"
-#include "nrf_drv_common.h"
-#include "nrf_wdt.h"
+#include "nrf52.h"
+#include "nrf52_bitfields.h"
 
 static void
 nrf52_hal_wdt_default_handler(void)
@@ -37,8 +33,8 @@ nrf52_hal_wdt_default_handler(void)
 static void
 nrf52_wdt_irq_handler(void)
 {
-    if (nrf_wdt_int_enable_check(NRF_WDT_INT_TIMEOUT_MASK) == true) {
-        nrf_wdt_event_clear(NRF_WDT_EVENT_TIMEOUT);
+    if (NRF_WDT->INTENSET & WDT_INTENSET_TIMEOUT_Msk) {
+        NRF_WDT->EVENTS_TIMEOUT = 0;
         nrf52_hal_wdt_default_handler();
     }
 }
@@ -46,14 +42,19 @@ nrf52_wdt_irq_handler(void)
 int
 hal_watchdog_init(uint32_t expire_msecs)
 {
-    NVIC_SetVector(WDT_IRQn, (uint32_t) nrf52_wdt_irq_handler);
+    uint64_t expiration;
+
+    NRF_WDT->CONFIG = WDT_CONFIG_SLEEP_Msk;
 
-    nrf_wdt_behaviour_set(NRF_WDT_BEHAVIOUR_RUN_SLEEP);
+    /* Convert msec timeout to counts of a 32768 crystal */
+    expiration = ((uint64_t)expire_msecs * 32768) / 1000;
+    NRF_WDT->CRV = (uint32_t)expiration;
 
-    /* Program in timeout in msecs */
-    nrf_wdt_reload_value_set((expire_msecs * 32768ULL) / 1000);
-    nrf_drv_common_irq_enable(WDT_IRQn, APP_IRQ_PRIORITY_HIGH);
-    nrf_wdt_reload_request_enable(NRF_WDT_RR0);
+    NVIC_SetVector(WDT_IRQn, (uint32_t) nrf52_wdt_irq_handler);
+    NVIC_SetPriority(WDT_IRQn, (1 << __NVIC_PRIO_BITS) - 1);
+    NVIC_ClearPendingIRQ(WDT_IRQn);
+    NVIC_EnableIRQ(WDT_IRQn);
+    NRF_WDT->RREN |= 0x1;
 
     return (0);
 }
@@ -61,13 +62,13 @@ hal_watchdog_init(uint32_t expire_msecs)
 void
 hal_watchdog_enable(void)
 {
-    nrf_wdt_int_enable(NRF_WDT_INT_TIMEOUT_MASK);
-    nrf_wdt_task_trigger(NRF_WDT_TASK_START);
+    NRF_WDT->INTENSET = WDT_INTENSET_TIMEOUT_Msk;
+    NRF_WDT->TASKS_START = 1;
 }
 
 void
 hal_watchdog_tickle(void)
 {
-    nrf_wdt_reload_request_set(NRF_WDT_RR0);
+    NRF_WDT->RR[0] = WDT_RR_RR_Reload;
 }