Remove diff var from timeout
@@ -120,7 +120,7 @@ espi_get_from_mbox_with_timeout_checks(esp_sys_mbox_t* b, void** m, uint32_t tim
espr_t
esp_timeout_add(uint32_t time, esp_timeout_fn fn, void* arg) {
esp_timeout_t* to;
- uint32_t now, diff = 0;
+ uint32_t now;
ESP_ASSERT("fn != NULL", fn != NULL);
@@ -132,14 +132,13 @@ esp_timeout_add(uint32_t time, esp_timeout_fn fn, void* arg) {
esp_core_lock();
now = esp_sys_now(); /* Get current time */
if (first_timeout != NULL) {
- diff = now - last_timeout_time; /* Get difference between current and last processed time */
- }
-
/*
* Since we want timeout value to start from NOW,
* we have to add time when we last processed our timeouts
*/
- to->time = time + diff;
+ time += now - last_timeout_time; /* Add difference between now and last processed time */
+ }
+ to->time = time;
to->arg = arg;
to->fn = fn;
