diff --git a/ports/atmel-samd/common-hal/rtc/RTC.c b/ports/atmel-samd/common-hal/rtc/RTC.c index 7651fdef60..203187b4ff 100644 --- a/ports/atmel-samd/common-hal/rtc/RTC.c +++ b/ports/atmel-samd/common-hal/rtc/RTC.c @@ -39,6 +39,7 @@ #include "supervisor/shared/translate.h" // This is the time in seconds since 2000 that the RTC was started. +// TODO: Change the offset to ticks so that it can be a subsecond adjustment. static uint32_t rtc_offset = 0; void common_hal_rtc_get_time(timeutils_struct_time_t *tm) { diff --git a/ports/cxd56/common-hal/pulseio/PulseIn.c b/ports/cxd56/common-hal/pulseio/PulseIn.c index f474c0a105..221fa5b6eb 100644 --- a/ports/cxd56/common-hal/pulseio/PulseIn.c +++ b/ports/cxd56/common-hal/pulseio/PulseIn.c @@ -54,7 +54,7 @@ static int pulsein_interrupt_handler(int irq, FAR void *context, FAR void *arg) // Grab the current time first. struct timeval tv; gettimeofday(&tv, NULL); - uint32_t current_us = tv.tv_sec * 1000000 + tv.tv_usec; + uint64_t current_us = ((uint64_t) tv.tv_sec) * 1000000 + tv.tv_usec; pulseio_pulsein_obj_t *self = pulsein_objects[irq - CXD56_IRQ_EXDEVICE_0]; diff --git a/ports/cxd56/common-hal/pulseio/PulseIn.h b/ports/cxd56/common-hal/pulseio/PulseIn.h index ff31712abc..70d1413b63 100644 --- a/ports/cxd56/common-hal/pulseio/PulseIn.h +++ b/ports/cxd56/common-hal/pulseio/PulseIn.h @@ -38,7 +38,7 @@ typedef struct { uint16_t maxlen; uint16_t start; uint16_t len; - uint32_t last_us; + uint64_t last_us; bool idle_state; bool first_edge; bool paused; diff --git a/supervisor/shared/autoreload.c b/supervisor/shared/autoreload.c index bc818e6b08..1976f66470 100644 --- a/supervisor/shared/autoreload.c +++ b/supervisor/shared/autoreload.c @@ -71,6 +71,9 @@ inline bool autoreload_is_enabled() { } void autoreload_start() { + // Enable ticks if we haven't been tracking an autoreload delay. We check + // our current state so that we only turn ticks on once. Multiple starts + // can occur before we reload and then turn ticks off. if (autoreload_delay_ms == 0) { supervisor_enable_tick(); }