summaryrefslogtreecommitdiff
path: root/bsp/stm32/libraries
diff options
context:
space:
mode:
authorwdfk-prog <[email protected]>2022-11-26 17:56:16 +0800
committerMan, Jianting (Meco) <[email protected]>2022-12-06 00:07:57 -0500
commitdb3e261bc4f79c176c3ad44e80e4ba0f6b0d675c (patch)
tree1600ceaf487a810e4b46bd03fa0510ba520089af /bsp/stm32/libraries
parentf54f2c2c917e6237567c4cc7a8d94dbba327747d (diff)
添加判断当前使用定时器是否可配置为主从定时器模式
Diffstat (limited to 'bsp/stm32/libraries')
-rw-r--r--bsp/stm32/libraries/HAL_Drivers/drv_pwm.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/bsp/stm32/libraries/HAL_Drivers/drv_pwm.c b/bsp/stm32/libraries/HAL_Drivers/drv_pwm.c
index bf9660f86b..52b6d16bfc 100644
--- a/bsp/stm32/libraries/HAL_Drivers/drv_pwm.c
+++ b/bsp/stm32/libraries/HAL_Drivers/drv_pwm.c
@@ -402,13 +402,16 @@ static rt_err_t stm32_hw_pwm_init(struct stm32_pwm *device)
goto __exit;
}
- master_config.MasterOutputTrigger = TIM_TRGO_RESET;
- master_config.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
- if (HAL_TIMEx_MasterConfigSynchronization(tim, &master_config) != HAL_OK)
+ if(IS_TIM_MASTER_INSTANCE(tim->Instance))
{
- LOG_E("%s master config failed", device->name);
- result = -RT_ERROR;
- goto __exit;
+ master_config.MasterOutputTrigger = TIM_TRGO_RESET;
+ master_config.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
+ if (HAL_TIMEx_MasterConfigSynchronization(tim, &master_config) != HAL_OK)
+ {
+ LOG_E("%s master config failed", device->name);
+ result = -RT_ERROR;
+ goto __exit;
+ }
}
oc_config.OCMode = TIM_OCMODE_PWM1;