From 7f016ae11e687efe699b019e551b18cfa0b3f291 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 11 Aug 2021 12:10:51 -0700 Subject: [PATCH] Fix build with filter to do OR --- ports/atmel-samd/Makefile | 8 +++----- ports/atmel-samd/common-hal/pwmio/PWMOut.c | 11 +++-------- ports/atmel-samd/common-hal/rgbmatrix/RGBMatrix.c | 1 + 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/ports/atmel-samd/Makefile b/ports/atmel-samd/Makefile index 00ce562e9e..810d86581b 100644 --- a/ports/atmel-samd/Makefile +++ b/ports/atmel-samd/Makefile @@ -322,11 +322,9 @@ SRC_C += \ reset.c \ timer_handler.c \ -ifeq ($(CIRCUITPY_PWMIO),1) -SRC_C += shared_timers.c -endif - -ifeq ($(CIRCUITPY_AUDIOIO),1) +# This is an OR because it filters to any 1s and then checks to see if it is not +# empty. +ifneq (,$(filter 1,$(CIRCUITPY_PWMIO) $(CIRCUITPY_AUDIOIO) $(CIRCUITPY_RGBMATRIX))) SRC_C += shared_timers.c endif diff --git a/ports/atmel-samd/common-hal/pwmio/PWMOut.c b/ports/atmel-samd/common-hal/pwmio/PWMOut.c index 3528b55e98..fa6a2d3f47 100644 --- a/ports/atmel-samd/common-hal/pwmio/PWMOut.c +++ b/ports/atmel-samd/common-hal/pwmio/PWMOut.c @@ -31,15 +31,15 @@ #include "common-hal/pwmio/PWMOut.h" #include "shared-bindings/pwmio/PWMOut.h" #include "shared-bindings/microcontroller/Processor.h" +#include "shared_timers.h" #include "timer_handler.h" #include "atmel_start_pins.h" #include "hal/utils/include/utils_repeat_macro.h" +#include "samd/pins.h" #include "samd/timers.h" #include "supervisor/shared/translate.h" -#include "samd/pins.h" - #undef ENABLE #define _TCC_SIZE(unused, n) TCC##n##_SIZE, @@ -77,16 +77,11 @@ void pwmout_reset(void) { target_tcc_frequencies[i] = 0; tcc_refcount[i] = 0; } - Tcc *tccs[TCC_INST_NUM] = TCC_INSTS; for (int i = 0; i < TCC_INST_NUM; i++) { if (!timer_ok_to_reset(i, false)) { continue; } - uint8_t mask = 0xff; - for (uint8_t j = 0; j < tcc_cc_num[i]; j++) { - mask <<= 1; - } - tcc_channels[i] = mask; + tcc_channels[i] = 0xff << tcc_cc_num[i]; } } diff --git a/ports/atmel-samd/common-hal/rgbmatrix/RGBMatrix.c b/ports/atmel-samd/common-hal/rgbmatrix/RGBMatrix.c index aa0bd78275..eca3757f20 100644 --- a/ports/atmel-samd/common-hal/rgbmatrix/RGBMatrix.c +++ b/ports/atmel-samd/common-hal/rgbmatrix/RGBMatrix.c @@ -29,6 +29,7 @@ #include "common-hal/rgbmatrix/RGBMatrix.h" #include "samd/timers.h" +#include "shared_timers.h" #include "timer_handler.h" void *common_hal_rgbmatrix_timer_allocate(rgbmatrix_rgbmatrix_obj_t *self) {