summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsommersoft <sommersoft@gmail.com>2019-02-19 20:18:21 -0600
committersommersoft <sommersoft@gmail.com>2019-02-19 20:18:21 -0600
commit55e7c5a41bf53fc44bfdbedd9f1228241a62132c (patch)
tree57a52336a8e6feb584f2745b81cabc740a7d642f
parentdafc370d22b0598f7330d907e7fbeaa4aa93cc15 (diff)
handle 'set_timer_handler' on this side, vs samd-periphs.
-rw-r--r--ports/atmel-samd/common-hal/audioio/AudioOut.c3
-rw-r--r--ports/atmel-samd/common-hal/pulseio/PWMOut.c3
-rw-r--r--ports/atmel-samd/common-hal/pulseio/PulseOut.c5
-rw-r--r--ports/atmel-samd/timer_handler.c6
-rw-r--r--ports/atmel-samd/timer_handler.h2
5 files changed, 12 insertions, 7 deletions
diff --git a/ports/atmel-samd/common-hal/audioio/AudioOut.c b/ports/atmel-samd/common-hal/audioio/AudioOut.c
index fb9ef00af..a75abd324 100644
--- a/ports/atmel-samd/common-hal/audioio/AudioOut.c
+++ b/ports/atmel-samd/common-hal/audioio/AudioOut.c
@@ -252,7 +252,8 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self,
tc_gclk = 1;
#endif
- turn_on_clocks(true, tc_index, tc_gclk, TC_HANDLER_NO_INTERRUPT);
+ set_timer_handler(true, tc_index, TC_HANDLER_NO_INTERRUPT);
+ turn_on_clocks(true, tc_index, tc_gclk);
// Don't bother setting the period. We set it before you playback anything.
tc_set_enable(t, false);
diff --git a/ports/atmel-samd/common-hal/pulseio/PWMOut.c b/ports/atmel-samd/common-hal/pulseio/PWMOut.c
index dcc236332..19daaa14f 100644
--- a/ports/atmel-samd/common-hal/pulseio/PWMOut.c
+++ b/ports/atmel-samd/common-hal/pulseio/PWMOut.c
@@ -235,8 +235,9 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
}
}
+ set_timer_handler(timer->is_tc, timer->index, TC_HANDLER_NO_INTERRUPT);
// We use the zeroeth clock on either port to go full speed.
- turn_on_clocks(timer->is_tc, timer->index, 0, TC_HANDLER_NO_INTERRUPT);
+ turn_on_clocks(timer->is_tc, timer->index, 0);
if (timer->is_tc) {
tc_periods[timer->index] = top;
diff --git a/ports/atmel-samd/common-hal/pulseio/PulseOut.c b/ports/atmel-samd/common-hal/pulseio/PulseOut.c
index 68f5d8fff..528a5c808 100644
--- a/ports/atmel-samd/common-hal/pulseio/PulseOut.c
+++ b/ports/atmel-samd/common-hal/pulseio/PulseOut.c
@@ -113,13 +113,14 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
pulseout_tc_index = index;
+ set_timer_handler(true, index, TC_HANDLER_PULSEOUT);
// We use GCLK0 for SAMD21 and GCLK1 for SAMD51 because they both run at 48mhz making our
// math the same across the boards.
#ifdef SAMD21
- turn_on_clocks(true, index, 0, TC_HANDLER_PULSEOUT);
+ turn_on_clocks(true, index, 0);
#endif
#ifdef SAMD51
- turn_on_clocks(true, index, 1, TC_HANDLER_PULSEOUT);
+ turn_on_clocks(true, index, 1);
#endif
diff --git a/ports/atmel-samd/timer_handler.c b/ports/atmel-samd/timer_handler.c
index bb0d248b5..566dd8cbd 100644
--- a/ports/atmel-samd/timer_handler.c
+++ b/ports/atmel-samd/timer_handler.c
@@ -34,8 +34,10 @@
static uint8_t tc_handler[TC_INST_NUM];
-void set_timer_handler(uint8_t index, uint8_t timer_handler) {
- tc_handler[index] = timer_handler;
+void set_timer_handler(bool is_tc, uint8_t index, uint8_t timer_handler) {
+ if (is_tc) {
+ tc_handler[index] = timer_handler;
+ }
}
void shared_timer_handler(bool is_tc, uint8_t index) {
diff --git a/ports/atmel-samd/timer_handler.h b/ports/atmel-samd/timer_handler.h
index 3243740e2..a495e21f2 100644
--- a/ports/atmel-samd/timer_handler.h
+++ b/ports/atmel-samd/timer_handler.h
@@ -30,7 +30,7 @@
#define TC_HANDLER_PULSEOUT 0x1
#define TC_HANDLER_FREQUENCYIN 0x2
-void set_timer_handler(uint8_t index, uint8_t timer_handler);
+void set_timer_handler(bool is_tc, uint8_t index, uint8_t timer_handler);
void shared_timer_handler(bool is_tc, uint8_t index);
#endif // MICROPY_INCLUDED_ATMEL_SAMD_TIMER_HANDLER_H