From 335f669933292f13b6423f4c75c44bcabf7739c6 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Sun, 26 Apr 2020 22:42:20 +0200 Subject: [PATCH] boards/hamilton: update PWM configuration --- boards/hamilton/include/periph_conf.h | 45 ++++++++++++++++----------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/boards/hamilton/include/periph_conf.h b/boards/hamilton/include/periph_conf.h index 4909c4bae7..68d8881736 100644 --- a/boards/hamilton/include/periph_conf.h +++ b/boards/hamilton/include/periph_conf.h @@ -179,28 +179,37 @@ static const adc_conf_chan_t adc_channels[] = { */ #define PWM_0_EN 1 #define PWM_1_EN 1 -#define PWM_NUMOF (PWM_0_EN + PWM_1_EN) -#define PWM_MAX_CHANNELS 2 -/* PWM device configuration */ -#if PWM_NUMOF -static const pwm_conf_t pwm_config[] = { #if PWM_0_EN - {TCC1, { - /* GPIO pin, MUX value, TCC channel */ - {GPIO_PIN(PA, 6), GPIO_MUX_E, 0}, - {GPIO_PIN(PA, 7), GPIO_MUX_E, 1} - }}, -#endif -#if PWM_1_EN - {TCC0, { - /* GPIO pin, MUX value, TCC channel */ - {GPIO_PIN(PA, 18), GPIO_MUX_F, 2}, - {GPIO_PIN(PA, 19), GPIO_MUX_F, 3} - }}, -#endif +/* PWM0 channels */ +static const pwm_conf_chan_t pwm_chan0_config[] = { + /* GPIO pin, MUX value, TCC channel */ + {GPIO_PIN(PA, 6), GPIO_MUX_E, 0}, + {GPIO_PIN(PA, 7), GPIO_MUX_E, 1}, }; #endif +#if PWM_1_EN +/* PWM1 channels */ +static const pwm_conf_chan_t pwm_chan1_config[] = { + /* GPIO pin, MUX value, TCC channel */ + {GPIO_PIN(PA, 18), GPIO_MUX_F, 2}, + {GPIO_PIN(PA, 19), GPIO_MUX_F, 3}, +}; +#endif + + +/* PWM device configuration */ +static const pwm_conf_t pwm_config[] = { +#if PWM_0_EN + {TCC1, pwm_chan0_config, ARRAY_SIZE(pwm_chan0_config)}, +#endif +#if PWM_1_EN + {TCC0, pwm_chan1_config, ARRAY_SIZE(pwm_chan1_config)}, +#endif +}; + +/* number of devices that are actually defined */ +#define PWM_NUMOF ARRAY_SIZE(pwm_config) /** @} */ /**