You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/07/30 11:31:51 UTC

[GitHub] utzig closed pull request #1299: [RFC] [NRF52] Remove uint64_t div in watchdog init

utzig closed pull request #1299: [RFC] [NRF52] Remove uint64_t div in watchdog init
URL: https://github.com/apache/mynewt-core/pull/1299
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c b/hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c
index 6248dbec4d..cfbaff6363 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c
@@ -44,13 +44,14 @@ nrf52_wdt_irq_handler(void)
 int
 hal_watchdog_init(uint32_t expire_msecs)
 {
-    uint64_t expiration;
-
     NRF_WDT->CONFIG = WDT_CONFIG_SLEEP_Msk;
 
-    /* Convert msec timeout to counts of a 32768 crystal */
-    expiration = ((uint64_t)expire_msecs * 32768) / 1000;
-    NRF_WDT->CRV = (uint32_t)expiration;
+    if (expire_msecs >= 44739243) {
+        /* maximum allowed time is near 12.5 hours! */
+        assert(0);
+    } else {
+        NRF_WDT->CRV = (expire_msecs * 32) + ((expire_msecs * 96) / 125);
+    }
 
     NVIC_SetVector(WDT_IRQn, (uint32_t) nrf52_wdt_irq_handler);
     NVIC_SetPriority(WDT_IRQn, (1 << __NVIC_PRIO_BITS) - 1);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services