From 50e03bb2c93c4071de5834004c8b1a00055e4c71 Mon Sep 17 00:00:00 2001 From: krzysztof-cabaj Date: Wed, 27 Mar 2024 18:09:01 +0100 Subject: [PATCH 1/2] boards/nucleo-c031c6: initial PWM config --- boards/nucleo-c031c6/Makefile.features | 1 + boards/nucleo-c031c6/include/periph_conf.h | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/boards/nucleo-c031c6/Makefile.features b/boards/nucleo-c031c6/Makefile.features index 464936cf8b56..e7080029cc4d 100644 --- a/boards/nucleo-c031c6/Makefile.features +++ b/boards/nucleo-c031c6/Makefile.features @@ -4,6 +4,7 @@ CPU_MODEL = stm32c031c6 # Put defined MCU peripherals here (in alphabetical order) FEATURES_PROVIDED += periph_adc FEATURES_PROVIDED += periph_i2c +FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_timer FEATURES_PROVIDED += periph_uart diff --git a/boards/nucleo-c031c6/include/periph_conf.h b/boards/nucleo-c031c6/include/periph_conf.h index 8388c7917735..df33e4bc2d5f 100644 --- a/boards/nucleo-c031c6/include/periph_conf.h +++ b/boards/nucleo-c031c6/include/periph_conf.h @@ -120,6 +120,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) +/** @} */ + /** * @name SPI configuration * @{ From 603c5fe2911fd1a40f5f5be2a1f1dcd954cc57b5 Mon Sep 17 00:00:00 2001 From: krzysztof-cabaj Date: Thu, 28 Mar 2024 13:58:09 +0100 Subject: [PATCH 2/2] boards/nucleo-c031c6: full PWM config in periph_conf.h --- boards/nucleo-c031c6/include/periph_conf.h | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/boards/nucleo-c031c6/include/periph_conf.h b/boards/nucleo-c031c6/include/periph_conf.h index df33e4bc2d5f..aa14360238bd 100644 --- a/boards/nucleo-c031c6/include/periph_conf.h +++ b/boards/nucleo-c031c6/include/periph_conf.h @@ -123,8 +123,30 @@ 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 Nucleo-c031c6 this information is in the MCU datasheet, Table 13, page 35. + * */ -static const pwm_conf_t pwm_config[] = {{}}; +static const pwm_conf_t pwm_config[] = { + { + .dev = TIM3, + .rcc_mask = RCC_APBENR1_TIM3EN, + .chan = { { .pin = GPIO_PIN(PORT_B, 5) /*CN9 D6 */, .cc_chan = 1 }, + { .pin = GPIO_PIN(PORT_B, 0) /*CN5 D10 */, .cc_chan = 2 }, + { .pin = GPIO_PIN(PORT_B, 1) /*CN8 A3 */, .cc_chan = 3 }, + { .pin = GPIO_UNDEF, .cc_chan = 0 } }, + .af = GPIO_AF1, + .bus = APB1 + }, +}; #define PWM_NUMOF ARRAY_SIZE(pwm_config) /** @} */