Skip to content

Commit 55e7c5a

Browse files
committed
handle 'set_timer_handler' on this side, vs samd-periphs.
1 parent dafc370 commit 55e7c5a

5 files changed

Lines changed: 12 additions & 7 deletions

File tree

ports/atmel-samd/common-hal/audioio/AudioOut.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ void common_hal_audioio_audioout_construct(audioio_audioout_obj_t* self,
252252
tc_gclk = 1;
253253
#endif
254254

255-
turn_on_clocks(true, tc_index, tc_gclk, TC_HANDLER_NO_INTERRUPT);
255+
set_timer_handler(true, tc_index, TC_HANDLER_NO_INTERRUPT);
256+
turn_on_clocks(true, tc_index, tc_gclk);
256257

257258
// Don't bother setting the period. We set it before you playback anything.
258259
tc_set_enable(t, false);

ports/atmel-samd/common-hal/pulseio/PWMOut.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,9 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self,
235235
}
236236
}
237237

238+
set_timer_handler(timer->is_tc, timer->index, TC_HANDLER_NO_INTERRUPT);
238239
// We use the zeroeth clock on either port to go full speed.
239-
turn_on_clocks(timer->is_tc, timer->index, 0, TC_HANDLER_NO_INTERRUPT);
240+
turn_on_clocks(timer->is_tc, timer->index, 0);
240241

241242
if (timer->is_tc) {
242243
tc_periods[timer->index] = top;

ports/atmel-samd/common-hal/pulseio/PulseOut.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,14 @@ void common_hal_pulseio_pulseout_construct(pulseio_pulseout_obj_t* self,
113113

114114
pulseout_tc_index = index;
115115

116+
set_timer_handler(true, index, TC_HANDLER_PULSEOUT);
116117
// We use GCLK0 for SAMD21 and GCLK1 for SAMD51 because they both run at 48mhz making our
117118
// math the same across the boards.
118119
#ifdef SAMD21
119-
turn_on_clocks(true, index, 0, TC_HANDLER_PULSEOUT);
120+
turn_on_clocks(true, index, 0);
120121
#endif
121122
#ifdef SAMD51
122-
turn_on_clocks(true, index, 1, TC_HANDLER_PULSEOUT);
123+
turn_on_clocks(true, index, 1);
123124
#endif
124125

125126

ports/atmel-samd/timer_handler.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434

3535
static uint8_t tc_handler[TC_INST_NUM];
3636

37-
void set_timer_handler(uint8_t index, uint8_t timer_handler) {
38-
tc_handler[index] = timer_handler;
37+
void set_timer_handler(bool is_tc, uint8_t index, uint8_t timer_handler) {
38+
if (is_tc) {
39+
tc_handler[index] = timer_handler;
40+
}
3941
}
4042

4143
void shared_timer_handler(bool is_tc, uint8_t index) {

ports/atmel-samd/timer_handler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#define TC_HANDLER_PULSEOUT 0x1
3131
#define TC_HANDLER_FREQUENCYIN 0x2
3232

33-
void set_timer_handler(uint8_t index, uint8_t timer_handler);
33+
void set_timer_handler(bool is_tc, uint8_t index, uint8_t timer_handler);
3434
void shared_timer_handler(bool is_tc, uint8_t index);
3535

3636
#endif // MICROPY_INCLUDED_ATMEL_SAMD_TIMER_HANDLER_H

0 commit comments

Comments
 (0)