wes3 commented on a change in pull request #1299: [RFC] [NRF52] Remove uint64_t
div in watchdog init
URL: https://github.com/apache/mynewt-core/pull/1299#discussion_r205850387
##########
File path: hw/mcu/nordic/nrf52xxx/src/hal_watchdog.c
##########
@@ -44,13 +44,20 @@ 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 >= 1048576) {
+ /* watchdog with more than 17 minutes? */
+ assert(0);
+ } else {
+ uint32_t e = expire_msecs, rtc = 32768, d = 1000;
+ while (e >= 131072) {
+ e /= 2;
+ rtc /= 2;
+ d /= 2;
Review comment:
Thanks Fabio but not really warranted.
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services