summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2020-04-06 16:03:31 -0700
committerScott Shawcroft <scott@tannewt.org>2020-04-06 16:03:31 -0700
commitc0ba2a839fabb8fca05adaf3450d2465d260cc50 (patch)
tree9a596906458c3637a6c91bb25137c4c0aaab36cd
parente99cf6e441db5f8f3c6378cf0a0ce2b12f1b72cd (diff)
Updates based on feedback from jepler
-rw-r--r--ports/atmel-samd/common-hal/rtc/RTC.c1
-rw-r--r--ports/cxd56/common-hal/pulseio/PulseIn.c2
-rw-r--r--ports/cxd56/common-hal/pulseio/PulseIn.h2
-rw-r--r--supervisor/shared/autoreload.c3
4 files changed, 6 insertions, 2 deletions
diff --git a/ports/atmel-samd/common-hal/rtc/RTC.c b/ports/atmel-samd/common-hal/rtc/RTC.c
index 7651fdef6..203187b4f 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 f474c0a10..221fa5b6e 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 ff31712ab..70d1413b6 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 bc818e6b0..1976f6647 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();
}