Skip to content
Snippets Groups Projects
Commit 7b856cda authored by Hauke Petersen's avatar Hauke Petersen
Browse files

boards/stm32-based: adapted PWM configuration

parent 4d09d09e
No related branches found
No related tags found
No related merge requests found
...@@ -76,24 +76,21 @@ static const timer_conf_t timer_config[] = { ...@@ -76,24 +76,21 @@ static const timer_conf_t timer_config[] = {
/** @} */ /** @} */
/** /**
* @name PWM configuration * @brief PWM configuration
* @{ * @{
*/ */
#define PWM_NUMOF (1U) static const pwm_conf_t pwm_config[] = {
#define PWM_0_EN 1 {
#define PWM_MAX_CHANNELS 1 /* Increase if Timer with more channels is used */ .dev = TIM11,
.rcc_mask = RCC_APB2ENR_TIM11EN,
/* PWM 0 device configuration */ .pins = { GPIO_PIN(PORT_B, 9), GPIO_UNDEF, GPIO_UNDEF, GPIO_UNDEF },
#define PWM_0_DEV TIM11 .af = GPIO_AF3,
#define PWM_0_CHANNELS 1 .chan = 1,
#define PWM_0_CLK (168000000U) .bus = APB2
#define PWM_0_CLKEN() (RCC->APB2ENR |= RCC_APB2ENR_TIM11EN) }
#define PWM_0_CLKDIS() (RCC->APB2ENR &= ~RCC_APB2ENR_TIM11EN) };
/* PWM 0 pin configuration */
#define PWM_0_PORT GPIOB #define PWM_NUMOF (sizeof(pwm_config) / sizeof(pwm_config[0]))
#define PWM_0_PORT_CLKEN() (RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN)
#define PWM_0_PIN_CH0 9
#define PWM_0_PIN_AF 3
/** @} */ /** @} */
/** /**
......
...@@ -51,25 +51,22 @@ extern "C" { ...@@ -51,25 +51,22 @@ extern "C" {
/** @} */ /** @} */
/** /**
* @name PWM configuration * @brief PWM configuration
* @{ * @{
*/ */
#define PWM_NUMOF (1U) static const pwm_conf_t pwm_config[] = {
#define PWM_0_EN 1
static const pwm_conf_t pwm_config[PWM_NUMOF] = {
{ {
.tim = 2, .dev = TIM3,
.port = GPIOC, .rcc_mask = RCC_APB1ENR_TIM3EN,
.bus = AHB1, .pins = { GPIO_PIN(PORT_C, 6), GPIO_PIN(PORT_C, 7),
.rcc_mask = RCC_AHB1ENR_GPIOCEN, GPIO_PIN(PORT_C, 8), GPIO_PIN(PORT_C, 9) },
.CH0 = 6, .af = GPIO_AF2,
.CH1 = 7, .chan = 4,
.CH2 = 8, .bus = APB1
.CH3 = 9,
.AF = 2
} }
}; };
#define PWM_NUMOF (sizeof(pwm_config) / sizeof(pwm_config[0]))
/** @} */ /** @} */
/** /**
...@@ -91,13 +88,6 @@ static const timer_conf_t timer_config[] = { ...@@ -91,13 +88,6 @@ static const timer_conf_t timer_config[] = {
.bus = APB1, .bus = APB1,
.irqn = TIM5_IRQn .irqn = TIM5_IRQn
}, },
{
.dev = TIM3,
.max = 0xffffffff,
.rcc_mask = RCC_APB1ENR_TIM3EN,
.bus = APB1,
.irqn = TIM3_IRQn
},
{ {
.dev = TIM4, .dev = TIM4,
.max = 0xffffffff, .max = 0xffffffff,
......
...@@ -124,28 +124,22 @@ static const timer_conf_t timer_config[] = { ...@@ -124,28 +124,22 @@ static const timer_conf_t timer_config[] = {
/** @} */ /** @} */
/** /**
* @brief PWM configuration * @brief PWM configuration
* @{ * @{
*/ */
#define PWM_NUMOF (1U) static const pwm_conf_t pwm_config[] = {
#define PWM_0_EN 1 {
.dev = TIM3,
#define PWM_MAX_CHANNELS 4 .rcc_mask = RCC_APB1ENR_TIM3EN,
.pins = { GPIO_PIN(PORT_C, 6), GPIO_PIN(PORT_C, 7),
/* PWM 0 device configuration */ GPIO_PIN(PORT_C, 8), GPIO_PIN(PORT_C, 9) },
#define PWM_0_DEV TIM3 .af = GPIO_AF2,
#define PWM_0_CHANNELS 4 .chan = 4,
#define PWM_0_CLK (72000000U) .bus = APB1
#define PWM_0_CLKEN() (RCC->APB1ENR |= RCC_APB1ENR_TIM3EN) }
#define PWM_0_CLKDIS() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM3EN)) };
/* PWM 0 pin configuration */
#define PWM_0_PORT GPIOC #define PWM_NUMOF (sizeof(pwm_config) / sizeof(pwm_config[0]))
#define PWM_0_PORT_CLKEN() (RCC->AHBENR |= RCC_AHBENR_GPIOCEN)
#define PWM_0_PIN_CH0 6
#define PWM_0_PIN_CH1 7
#define PWM_0_PIN_CH2 8
#define PWM_0_PIN_CH3 9
#define PWM_0_PIN_AF 2
/** @} */ /** @} */
/** /**
......
# Put defined MCU peripherals here (in alphabetical order) # Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_cpuid FEATURES_PROVIDED += periph_cpuid
FEATURES_PROVIDED += periph_gpio FEATURES_PROVIDED += periph_gpio
FEATURES_PROVIDED += periph_pwm
FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_timer FEATURES_PROVIDED += periph_timer
FEATURES_PROVIDED += periph_uart FEATURES_PROVIDED += periph_uart
......
...@@ -101,6 +101,25 @@ static const timer_conf_t timer_config[] = { ...@@ -101,6 +101,25 @@ static const timer_conf_t timer_config[] = {
#define UART_0_AF 7 #define UART_0_AF 7
/** @} */ /** @} */
/**
* @brief PWM configuration
* @{
*/
static const pwm_conf_t pwm_config[] = {
{
.dev = TIM3,
.rcc_mask = RCC_APB1ENR_TIM3EN,
.pins = { GPIO_PIN(PORT_C, 6), GPIO_PIN(PORT_C, 7),
GPIO_PIN(PORT_C, 8), GPIO_PIN(PORT_C, 9) },
.af = GPIO_AF2,
.chan = 4,
.bus = APB1
}
};
#define PWM_NUMOF (sizeof(pwm_config) / sizeof(pwm_config[0]))
/** @} */
/** /**
* @name SPI configuration * @name SPI configuration
* @{ * @{
......
...@@ -126,44 +126,31 @@ static const timer_conf_t timer_config[] = { ...@@ -126,44 +126,31 @@ static const timer_conf_t timer_config[] = {
/** @} */ /** @} */
/** /**
* @brief PWM configuration * @brief PWM configuration
* @{ * @{
*/ */
#define PWM_NUMOF (2U) static const pwm_conf_t pwm_config[] = {
#define PWM_0_EN 1 {
#define PWM_1_EN 1 .dev = TIM3,
.rcc_mask = RCC_APB1ENR_TIM3EN,
#define PWM_MAX_CHANNELS 4 .pins = { GPIO_PIN(PORT_C, 6), GPIO_PIN(PORT_C, 7),
GPIO_PIN(PORT_C, 8), GPIO_PIN(PORT_C, 9) },
/* PWM 0 device configuration */ .af = GPIO_AF2,
#define PWM_0_DEV TIM3 .chan = 4,
#define PWM_0_CHANNELS 4 .bus = APB1
#define PWM_0_CLK (72000000U) },
#define PWM_0_CLKEN() (RCC->APB1ENR |= RCC_APB1ENR_TIM3EN) {
#define PWM_0_CLKDIS() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM3EN)) .dev = TIM4,
/* PWM 0 pin configuration */ .rcc_mask = RCC_APB1ENR_TIM4EN,
#define PWM_0_PORT GPIOC .pins = { GPIO_PIN(PORT_D, 12), GPIO_PIN(PORT_D, 13),
#define PWM_0_PORT_CLKEN() (RCC->AHBENR |= RCC_AHBENR_GPIOCEN) GPIO_PIN(PORT_D, 14), GPIO_PIN(PORT_D, 15) },
#define PWM_0_PIN_CH0 6 .af = GPIO_AF2,
#define PWM_0_PIN_CH1 7 .chan = 4,
#define PWM_0_PIN_CH2 8 .bus = APB1
#define PWM_0_PIN_CH3 9 }
#define PWM_0_PIN_AF 2 };
/* PWM 1 device configuration */ #define PWM_NUMOF (sizeof(pwm_config) / sizeof(pwm_config[0]))
#define PWM_1_DEV TIM4
#define PWM_1_CHANNELS 4
#define PWM_1_CLK (72000000U)
#define PWM_1_CLKEN() (RCC->APB1ENR |= RCC_APB1ENR_TIM4EN)
#define PWM_1_CLKDIS() (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM4EN))
/* PWM 1 pin configuration */
#define PWM_1_PORT GPIOD
#define PWM_1_PORT_CLKEN() (RCC->AHBENR |= RCC_AHBENR_GPIODEN)
#define PWM_1_PIN_CH0 12
#define PWM_1_PIN_CH1 13
#define PWM_1_PIN_CH2 14
#define PWM_1_PIN_CH3 15
#define PWM_1_PIN_AF 2
/** @} */ /** @} */
/** /**
......
...@@ -148,43 +148,31 @@ static const uart_conf_t uart_config[] = { ...@@ -148,43 +148,31 @@ static const uart_conf_t uart_config[] = {
/** @} */ /** @} */
/** /**
* @name PWM configuration * @brief PWM configuration
* @{ * @{
*/ */
#define PWM_NUMOF (2U) static const pwm_conf_t pwm_config[] = {
#define PWM_0_EN 1 {
#define PWM_1_EN 1 .dev = TIM1,
#define PWM_MAX_CHANNELS 4 .rcc_mask = RCC_APB2ENR_TIM1EN,
.pins = { GPIO_PIN(PORT_E, 9), GPIO_PIN(PORT_E, 11),
/* PWM 0 device configuration */ GPIO_PIN(PORT_E, 11), GPIO_PIN(PORT_E, 14) },
#define PWM_0_DEV TIM1 .af = GPIO_AF1,
#define PWM_0_CHANNELS 4 .chan = 4,
#define PWM_0_CLK (168000000U) .bus = APB2
#define PWM_0_CLKEN() (RCC->APB2ENR |= RCC_APB2ENR_TIM1EN) },
#define PWM_0_CLKDIS() (RCC->APB2ENR &= ~RCC_APB2ENR_TIM1EN) {
/* PWM 0 pin configuration */ .dev = TIM3,
#define PWM_0_PORT GPIOE .rcc_mask = RCC_APB1ENR_TIM3EN,
#define PWM_0_PORT_CLKEN() (RCC->AHB1ENR |= RCC_AHB1ENR_GPIOEEN) .pins = { GPIO_PIN(PORT_B, 4), GPIO_PIN(PORT_B, 5),
#define PWM_0_PIN_CH0 9 GPIO_PIN(PORT_B, 0), GPIO_PIN(PORT_B, 1) },
#define PWM_0_PIN_CH1 11 .af = GPIO_AF2,
#define PWM_0_PIN_CH2 13 .chan = 4,
#define PWM_0_PIN_CH3 14 .bus = APB1
#define PWM_0_PIN_AF 1 }
};
/* PWM 1 device configuration */ #define PWM_NUMOF (sizeof(pwm_config) / sizeof(pwm_config[0]))
#define PWM_1_DEV TIM3
#define PWM_1_CHANNELS 3
#define PWM_1_CLK (84000000U)
#define PWM_1_CLKEN() (RCC->APB1ENR |= RCC_APB1ENR_TIM3EN)
#define PWM_1_CLKDIS() (RCC->APB1ENR &= ~RCC_APB1ENR_TIM3EN)
/* PWM 1 pin configuration */
#define PWM_1_PORT GPIOB
#define PWM_1_PORT_CLKEN() (RCC->AHB1ENR |= RCC_AHB1ENR_GPIOBEN)
#define PWM_1_PIN_CH0 4
#define PWM_1_PIN_CH1 5
#define PWM_1_PIN_CH2 0
#define PWM_1_PIN_CH3 1
#define PWM_1_PIN_AF 2
/** @} */ /** @} */
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment