1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-24 22:13:52 +01:00

Merge pull request #20807 from krzysztof-cabaj/stm32l476g-PWM

boards/stm32l476g-disco: add PWM support
This commit is contained in:
benpicco 2024-08-05 19:10:11 +00:00 committed by GitHub
commit cf1bb15c86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 45 additions and 0 deletions

View File

@ -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

View File

@ -129,6 +129,50 @@ static const adc_conf_t adc_config[] = {
#define ADC_NUMOF ARRAY_SIZE(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[] = {
{
.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)
/** @} */
#ifdef __cplusplus
}
#endif