]> granicus.if.org Git - esp-idf/commitdiff
rtc_wdt: fix overflow issue with setting wdt interval
authorMahavir Jain <mahavir@espressif.com>
Fri, 24 Aug 2018 12:28:22 +0000 (17:58 +0530)
committerMahavir Jain <mahavir@espressif.com>
Fri, 24 Aug 2018 12:36:39 +0000 (18:06 +0530)
Signed-off-by: Mahavir Jain <mahavir@espressif.com>
components/soc/esp32/rtc_wdt.c

index 8daa352f3a4a9178e540963e7252c3d985a9ba31..5fea2fd55c688eea0e27c9e17a15f3e8b642b347 100644 (file)
@@ -73,7 +73,7 @@ esp_err_t rtc_wdt_set_time(rtc_wdt_stage_t stage, unsigned int timeout_ms)
     if (stage > 3) {
         return ESP_ERR_INVALID_ARG;
     }
-    uint32_t timeout = rtc_clk_slow_freq_get_hz() * timeout_ms / 1000;
+    uint32_t timeout = (uint32_t) ((uint64_t) rtc_clk_slow_freq_get_hz() * timeout_ms / 1000);
     if (stage == RTC_WDT_STAGE0) {
         WRITE_PERI_REG(RTC_CNTL_WDTCONFIG1_REG, timeout);
     } else if (stage == RTC_WDT_STAGE1) {