From b2ef0c67d795cd655032964d9664b537ef3a10cc Mon Sep 17 00:00:00 2001 From: krzysztof-cabaj Date: Mon, 5 Aug 2024 16:07:04 +0200 Subject: [PATCH 1/2] boards/stm32l476g-disco: add initial PWM config --- boards/stm32l476g-disco/Makefile.features | 1 + boards/stm32l476g-disco/include/periph_conf.h | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/boards/stm32l476g-disco/Makefile.features b/boards/stm32l476g-disco/Makefile.features index 92ab935753..d6744b44ba 100644 --- a/boards/stm32l476g-disco/Makefile.features +++ b/boards/stm32l476g-disco/Makefile.features @@ -3,6 +3,7 @@ CPU_MODEL = stm32l476vg # Put defined MCU peripherals here (in alphabetical order) FEATURES_PROVIDED += periph_adc +FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_rtc FEATURES_PROVIDED += periph_rtt FEATURES_PROVIDED += periph_timer diff --git a/boards/stm32l476g-disco/include/periph_conf.h b/boards/stm32l476g-disco/include/periph_conf.h index 205f848059..1d9164ac6a 100644 --- a/boards/stm32l476g-disco/include/periph_conf.h +++ b/boards/stm32l476g-disco/include/periph_conf.h @@ -129,6 +129,15 @@ static const adc_conf_t adc_config[] = { #define ADC_NUMOF ARRAY_SIZE(adc_config) /** @} */ +/** + * @name PWM configuration + * @{ + */ +static const pwm_conf_t pwm_config[] = {{}}; + +#define PWM_NUMOF ARRAY_SIZE(pwm_config) +/** @} */ + #ifdef __cplusplus } #endif From 72f8a8f2686b4347bf61f173221816547e60bf05 Mon Sep 17 00:00:00 2001 From: krzysztof-cabaj Date: Mon, 5 Aug 2024 17:48:20 +0200 Subject: [PATCH 2/2] boards/stm32l476g-disco: add PWM config and doxygen doc --- boards/stm32l476g-disco/include/periph_conf.h | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/boards/stm32l476g-disco/include/periph_conf.h b/boards/stm32l476g-disco/include/periph_conf.h index 1d9164ac6a..311541992b 100644 --- a/boards/stm32l476g-disco/include/periph_conf.h +++ b/boards/stm32l476g-disco/include/periph_conf.h @@ -132,8 +132,43 @@ static const adc_conf_t adc_config[] = { /** * @name PWM configuration * @{ + * + * To find appriopate device and channel find in the MCU datasheet table + * concerning "Alternate function AF0 to AF7" a text similar to TIM[X]_CH[Y], + * where: + * TIM[X] - is device, + * [Y] - describes used channel (indexed from 0), for example TIM2_CH1 is + * channel 0 in configuration structure (cc_chan - field), + * Port column in the table describes connected port. + * + * For stm32l476g-disco this information is in the MCU datasheet, + * Table 17, page 88. + * + * Remark! + * PMW device 0 overlaps with ADC. */ -static const pwm_conf_t pwm_config[] = {{}}; +static const pwm_conf_t pwm_config[] = { + { + .dev = TIM2, + .rcc_mask = RCC_APB1ENR1_TIM2EN, + .chan = { { .pin = GPIO_PIN(PORT_A, 5), .cc_chan = 0}, + { .pin = GPIO_PIN(PORT_A, 1), .cc_chan = 1}, + { .pin = GPIO_PIN(PORT_A, 2), .cc_chan = 2}, + { .pin = GPIO_PIN(PORT_A, 3), .cc_chan = 3} }, + .af = GPIO_AF1, + .bus = APB1 + }, + { + .dev = TIM1, + .rcc_mask = RCC_APB2ENR_TIM1EN, + .chan = { { .pin = GPIO_PIN(PORT_E, 11), .cc_chan = 1}, + { .pin = GPIO_PIN(PORT_E, 13), .cc_chan = 2}, + { .pin = GPIO_PIN(PORT_E, 14), .cc_chan = 3}, + { .pin = GPIO_UNDEF, .cc_chan = 0} }, + .af = GPIO_AF1, + .bus = APB2 + } +}; #define PWM_NUMOF ARRAY_SIZE(pwm_config) /** @} */