Skip to content

Commit 16f9fc2

Browse files
committed
Update stm32_mcu.cpp
1 parent d4b86b9 commit 16f9fc2

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

src/drivers/hardware_specific/stm32/stm32_mcu.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -681,23 +681,29 @@ void* _configure8PWM(long pwm_frequency, float dead_zone)
681681
__HAL_RCC_TIM1_CLK_ENABLE();
682682
__HAL_RCC_TIM8_CLK_ENABLE();
683683

684-
// Configure GPIO pins for STSPIN32G4 internal FET driver
685-
686-
__HAL_RCC_GPIOE_CLK_ENABLE(); // enable GPIO clock
687-
GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_8 | GPIO_PIN_11 | GPIO_PIN_10 | GPIO_PIN_13 | GPIO_PIN_12;
688-
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; // alternate function mode with push-pull output
684+
// Configure PE8, PE9, PE10, PE11, PE12, PE13 as TIM1 channels
685+
GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12 | GPIO_PIN_13;
686+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
689687
GPIO_InitStruct.Pull = GPIO_NOPULL;
690688
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
691689
GPIO_InitStruct.Alternate = GPIO_AF6_TIM1;
692-
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
690+
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
693691

694-
// Configure TIM8 pins for alternate function mode with push-pull output
695-
GPIO_InitStruct.Pin = GPIO_PIN_14 | GPIO_PIN_0;
692+
// Configure PA14 and PB0 as TIM8 channels
693+
__HAL_RCC_GPIOA_CLK_ENABLE();
694+
__HAL_RCC_GPIOB_CLK_ENABLE();
695+
GPIO_InitStruct.Pin = GPIO_PIN_14;
696696
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
697697
GPIO_InitStruct.Pull = GPIO_NOPULL;
698-
GPIO_InitStruct.Alternate = GPIO_AF3_TIM8;
698+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
699+
GPIO_InitStruct.Alternate = GPIO_AF3_TIM8;
699700
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
700-
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
701+
GPIO_InitStruct.Pin = GPIO_PIN_0;
702+
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
703+
GPIO_InitStruct.Pull = GPIO_NOPULL;
704+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
705+
GPIO_InitStruct.Alternate = GPIO_AF3_TIM8;
706+
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
701707

702708

703709

0 commit comments

Comments
 (0)