3535#include "hpl/gclk/hpl_gclk_base.h"
3636#endif
3737
38+ #ifdef SAMD51
39+ #include "hri/hri_gclk_d51.h"
40+ #endif
41+
3842// This bitmask keeps track of which channels of a TCC are currently claimed.
3943#ifdef SAMD21
4044const uint8_t tcc_cc_num [3 ] = {4 , 2 , 2 };
@@ -51,7 +55,7 @@ const uint8_t tc_gclk_ids[TC_INST_NUM] = {TC3_GCLK_ID,
5155const uint8_t tcc_gclk_ids [3 ] = {TCC0_GCLK_ID , TCC1_GCLK_ID , TCC2_GCLK_ID };
5256#endif
5357#ifdef SAMD51
54- static const uint8_t tcc_cc_num [5 ] = {6 , 4 , 3 , 2 , 2 };
58+ const uint8_t tcc_cc_num [5 ] = {6 , 4 , 3 , 2 , 2 };
5559const uint8_t tc_gclk_ids [TC_INST_NUM ] = {TC0_GCLK_ID ,
5660 TC1_GCLK_ID ,
5761 TC2_GCLK_ID ,
@@ -228,6 +232,13 @@ void shared_timer_handler(bool is_tc, uint8_t index) {
228232 }
229233}
230234
235+ #ifdef SAMD51
236+ #define TC_OFFSET 0
237+ #endif
238+ #ifdef SAMD21
239+ #define TC_OFFSET 0
240+ #endif
241+
231242void TCC0_Handler (void ) {
232243 shared_timer_handler (false, 0 );
233244}
@@ -237,22 +248,38 @@ void TCC1_Handler(void) {
237248void TCC2_Handler (void ) {
238249 shared_timer_handler (false, 2 );
239250}
240- void TC3_Handler (void ) {
251+ // TC0 - TC2 only exist on the SAMD51
252+ #ifdef TC0
253+ void TC0_Handler (void ) {
241254 shared_timer_handler (true, 0 );
242255}
243- void TC4_Handler (void ) {
256+ #endif
257+ #ifdef TC1
258+ void TC1_Handler (void ) {
244259 shared_timer_handler (true, 1 );
245260}
246- void TC5_Handler (void ) {
261+ #endif
262+ #ifdef TC2
263+ void TC2_Handler (void ) {
247264 shared_timer_handler (true, 2 );
248265}
266+ #endif
267+ void TC3_Handler (void ) {
268+ shared_timer_handler (true, 3 - TC_OFFSET );
269+ }
270+ void TC4_Handler (void ) {
271+ shared_timer_handler (true, 4 - TC_OFFSET );
272+ }
273+ void TC5_Handler (void ) {
274+ shared_timer_handler (true, 5 - TC_OFFSET );
275+ }
249276#ifdef TC6
250277void TC6_Handler (void ) {
251- shared_timer_handler (true, 3 );
278+ shared_timer_handler (true, 6 - TC_OFFSET );
252279}
253280#endif
254281#ifdef TC7
255282void TC7_Handler (void ) {
256- shared_timer_handler (true, 4 );
283+ shared_timer_handler (true, 7 - TC_OFFSET );
257284}
258285#endif
0 commit comments