summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Halbert <halbert@halwitz.org>2019-05-07 00:25:22 -0400
committerDan Halbert <halbert@halwitz.org>2019-05-07 00:25:22 -0400
commitf59dadbb4f1154b1942152fc1d50443d244ece66 (patch)
tree5b41e7ab3a8b95e9ddebd6151efe8d42d8de56ed
parent03f9048778ecad2bbd7d07d01f3b64153a36c177 (diff)
avoid double float arithmetic in FrequencyIn
-rw-r--r--ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c5
-rw-r--r--ports/atmel-samd/timer_handler.c2
2 files changed, 6 insertions, 1 deletions
diff --git a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
index fa5d08a3f..d34049946 100644
--- a/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
+++ b/ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c
@@ -103,7 +103,10 @@ void frequencyin_interrupt_handler(uint8_t index) {
// record a new event count.
if (current_ms - self->last_ms >= self->capture_period) {
float new_factor = self->last_us + (1000 - current_us);
- self->factor = (current_ms - self->last_ms) + (new_factor / 1000);
+ // ms difference will not need 64 bits. If we use 64 bits,
+ // double-precision float routines are required, and we don't
+ // want to include them because they're very large.
+ self->factor = (uint32_t) (current_ms - self->last_ms) + (new_factor / 1000);
self->last_ms = current_ms;
self->last_us = current_us;
diff --git a/ports/atmel-samd/timer_handler.c b/ports/atmel-samd/timer_handler.c
index 61ab3e6d7..5d6de3093 100644
--- a/ports/atmel-samd/timer_handler.c
+++ b/ports/atmel-samd/timer_handler.c
@@ -48,7 +48,9 @@ void shared_timer_handler(bool is_tc, uint8_t index) {
uint8_t handler = tc_handler[index];
switch(handler) {
case TC_HANDLER_PULSEOUT:
+ #if CIRCUITPY_PULSEIO
pulseout_interrupt_handler(index);
+ #endif
break;
case TC_HANDLER_PEW:
#if CIRCUITPY_PEW