From e42209a6b21ac840208139f8cf07f14015754e51 Mon Sep 17 00:00:00 2001 From: Bryan Siepert Date: Tue, 27 Feb 2018 00:42:40 -0800 Subject: [PATCH] fixes timer number assumptions for samd51s for issue #646 --- ports/atmel-samd/timers.c | 18 ++++++++++++++++-- ports/atmel-samd/timers.h | 2 +- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/ports/atmel-samd/timers.c b/ports/atmel-samd/timers.c index 7b5d06cb0c..2e8541f242 100644 --- a/ports/atmel-samd/timers.c +++ b/ports/atmel-samd/timers.c @@ -73,8 +73,16 @@ const uint8_t tc_gclk_ids[TC_INST_NUM] = {TC0_GCLK_ID, TC7_GCLK_ID, #endif }; -const uint8_t tcc_gclk_ids[5] = {TCC0_GCLK_ID, TCC1_GCLK_ID, TCC2_GCLK_ID, TCC3_GCLK_ID, - TCC4_GCLK_ID}; +const uint8_t tcc_gclk_ids[TCC_INST_NUM] = {TCC0_GCLK_ID, + TCC1_GCLK_ID, + TCC2_GCLK_ID, +#ifdef TCC3_GCLK_ID + TCC3_GCLK_ID, +#endif +#ifdef TCC4_GCLK_ID + TCC4_GCLK_ID +#endif + }; #endif Tc* const tc_insts[TC_INST_NUM] = TC_INSTS; Tcc* const tcc_insts[TCC_INST_NUM] = TCC_INSTS; @@ -89,9 +97,15 @@ IRQn_Type const tc_irq[TC_INST_NUM] = { #ifdef TC2 TC2_IRQn, #endif +#ifdef TC3 TC3_IRQn, +#endif +#ifdef TC4 TC4_IRQn, +#endif +#ifdef TC5 TC5_IRQn, +#endif #ifdef TC6 TC6_IRQn, #endif diff --git a/ports/atmel-samd/timers.h b/ports/atmel-samd/timers.h index a22ec74844..bb3ab5ee7c 100644 --- a/ports/atmel-samd/timers.h +++ b/ports/atmel-samd/timers.h @@ -36,7 +36,7 @@ const uint8_t tcc_gclk_ids[3]; #ifdef SAMD51 const uint8_t tcc_cc_num[5]; const uint8_t tc_gclk_ids[TC_INST_NUM]; -const uint8_t tcc_gclk_ids[5]; +const uint8_t tcc_gclk_ids[TCC_INST_NUM]; #endif Tc* const tc_insts[TC_INST_NUM]; Tcc* const tcc_insts[TCC_INST_NUM];