Add Aggregate PWM on Pin29 (PB10/TIM2CH3) (needs bodgewire to R175)

This commit is contained in:
n.jayaprakash
2024-07-04 22:07:26 +02:00
parent 9aca436798
commit 36e57e5671
5 changed files with 48 additions and 33 deletions

View File

@ -44,12 +44,13 @@ void ChannelControl_UpdatePWMs(
uint8_t radiatorfans,
uint8_t pwmpumps,
uint8_t tsacfans,
uint8_t pwmaggregat // TODO: Emulate PWN via PCA9535D!
){
uint8_t pwmaggregat)
{
pwmtimer3->Instance->CCR1 = radiatorfans << 8;
pwmtimer3->Instance->CCR4 = pwmpumps << 8;
pwmtimer2->Instance->CCR2 = tsacfans << 8;
pwmtimer2->Instance->CCR3 = pwmaggregat << 8;
if (timer3_running) {
if ((pwmpumps == 0) && (radiatorfans == 0)) {
@ -62,18 +63,20 @@ void ChannelControl_UpdatePWMs(
timer3_running = 1;
HAL_TIM_PWM_Start(pwmtimer3, TIM_CHANNEL_4);
HAL_TIM_PWM_Start(pwmtimer3, TIM_CHANNEL_1);
}
}
}
if (timer2_running) {
if (tsacfans == 0) {
if ( (tsacfans == 0) || (pwmaggregat == 0) ) {
timer2_running = 0;
HAL_TIM_PWM_Stop(pwmtimer2, TIM_CHANNEL_2);
HAL_TIM_PWM_Stop(pwmtimer2, TIM_CHANNEL_3);
}
} else {
if (tsacfans != 0) {
if ( (tsacfans != 0) || (pwmaggregat != 0) ) {
timer2_running = 1;
HAL_TIM_PWM_Start(pwmtimer2, TIM_CHANNEL_2);
HAL_TIM_PWM_Start(pwmtimer2, TIM_CHANNEL_3);
}
}

View File

@ -472,6 +472,10 @@ static void MX_TIM2_Init(void)
{
Error_Handler();
}
if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_3) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN TIM2_Init 2 */
/* USER CODE END TIM2_Init 2 */

View File

@ -494,9 +494,10 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
/* USER CODE END TIM2_MspPostInit 0 */
__HAL_RCC_GPIOB_CLK_ENABLE();
/**TIM2 GPIO Configuration
PB10 ------> TIM2_CH3
PB3 ------> TIM2_CH2
*/
GPIO_InitStruct.Pin = GPIO_PIN_3;
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;