[bsp][stm32f407-RoboMaster-C]Enable TIM5_CH1/2/3

This commit is contained in:
goldengrandpa 2022-12-31 17:43:24 +08:00 committed by Man, Jianting (Meco)
parent 7788227887
commit d355981041
4 changed files with 102 additions and 24 deletions

View File

@ -49,7 +49,7 @@ Robomaster 开发板C型 是大疆创新科技有限公司推出的一款基于
| GPIO | 支持 | PA0, PA1... PH1 ---> PIN: 0, 1...144 |
| UART | 支持 | UART1(FinSH), UART3(DBUS), UART6 |
| CAN | 支持 | CAN1, CAN2 |
| PWM | 支持 | TIM1(CH1/2/3/4), TIM4(CH3), TIM8(CH1/2/3) |
| PWM | 支持 | TIM1(CH1/2/3/4), TIM4(CH3), TIM5(CH1/2/3), TIM8(CH1/2/3) |
| SPI | 支持 | SPI2 |
| IIC | 支持 | 模拟IIC(SDA-->PF0, SCL-->PF1) |

View File

@ -10,9 +10,6 @@ ADC3.IPParameters=Rank-1\#ChannelRegularConversion,Channel-1\#ChannelRegularConv
ADC3.NbrOfConversionFlag=1
ADC3.Rank-1\#ChannelRegularConversion=1
ADC3.SamplingTime-1\#ChannelRegularConversion=ADC_SAMPLETIME_3CYCLES
CAD.formats=
CAD.pinconfig=
CAD.provider=
CAN1.BS1=CAN_BS1_1TQ
CAN1.BS2=CAN_BS2_1TQ
CAN1.CalculateBaudRate=875000
@ -32,10 +29,11 @@ Mcu.CPN=STM32F407IGH6
Mcu.Family=STM32F4
Mcu.IP0=ADC1
Mcu.IP1=ADC3
Mcu.IP10=TIM8
Mcu.IP11=USART1
Mcu.IP12=USART3
Mcu.IP13=USART6
Mcu.IP10=TIM5
Mcu.IP11=TIM8
Mcu.IP12=USART1
Mcu.IP13=USART3
Mcu.IP14=USART6
Mcu.IP2=CAN1
Mcu.IP3=CAN2
Mcu.IP4=I2C2
@ -44,7 +42,7 @@ Mcu.IP6=RCC
Mcu.IP7=SYS
Mcu.IP8=TIM1
Mcu.IP9=TIM4
Mcu.IPNb=14
Mcu.IPNb=15
Mcu.Name=STM32F407I(E-G)Hx
Mcu.Package=UFBGA176
Mcu.Pin0=PB5
@ -58,27 +56,31 @@ Mcu.Pin15=PH0-OSC_IN
Mcu.Pin16=PH1-OSC_OUT
Mcu.Pin17=PF1
Mcu.Pin18=PC6
Mcu.Pin19=PF10
Mcu.Pin19=PH12
Mcu.Pin2=PA14
Mcu.Pin20=PD14
Mcu.Pin21=PE13
Mcu.Pin22=PE9
Mcu.Pin23=PE11
Mcu.Pin24=PE14
Mcu.Pin25=VP_ADC1_TempSens_Input
Mcu.Pin26=VP_ADC1_Vref_Input
Mcu.Pin27=VP_SYS_VS_Systick
Mcu.Pin28=VP_TIM1_VS_ClockSourceINT
Mcu.Pin29=VP_TIM4_VS_ClockSourceINT
Mcu.Pin20=PF10
Mcu.Pin21=PH11
Mcu.Pin22=PH10
Mcu.Pin23=PD14
Mcu.Pin24=PE13
Mcu.Pin25=PE9
Mcu.Pin26=PE11
Mcu.Pin27=PE14
Mcu.Pin28=VP_ADC1_TempSens_Input
Mcu.Pin29=VP_ADC1_Vref_Input
Mcu.Pin3=PA13
Mcu.Pin30=VP_TIM8_VS_ClockSourceINT
Mcu.Pin30=VP_SYS_VS_Systick
Mcu.Pin31=VP_TIM1_VS_ClockSourceINT
Mcu.Pin32=VP_TIM4_VS_ClockSourceINT
Mcu.Pin33=VP_TIM5_VS_ClockSourceINT
Mcu.Pin34=VP_TIM8_VS_ClockSourceINT
Mcu.Pin4=PB7
Mcu.Pin5=PB6
Mcu.Pin6=PD0
Mcu.Pin7=PC11
Mcu.Pin8=PC10
Mcu.Pin9=PI7
Mcu.PinsNb=31
Mcu.PinsNb=35
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F407IGHx
@ -147,6 +149,9 @@ PH0-OSC_IN.Mode=HSE-External-Oscillator
PH0-OSC_IN.Signal=RCC_OSC_IN
PH1-OSC_OUT.Mode=HSE-External-Oscillator
PH1-OSC_OUT.Signal=RCC_OSC_OUT
PH10.Signal=S_TIM5_CH1
PH11.Signal=S_TIM5_CH2
PH12.Signal=S_TIM5_CH3
PI6.Signal=S_TIM8_CH2
PI7.Signal=S_TIM8_CH3
PinOutPanel.CurrentBGAView=Top
@ -178,7 +183,7 @@ ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=MDK-ARM V5
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART1_UART_Init-USART1-false-HAL-true,4-MX_ADC3_Init-ADC3-false-HAL-true,5-MX_CAN1_Init-CAN1-false-HAL-true,6-MX_CAN2_Init-CAN2-false-HAL-true,7-MX_TIM1_Init-TIM1-false-HAL-true,8-MX_TIM4_Init-TIM4-false-HAL-true,9-MX_TIM8_Init-TIM8-false-HAL-true,10-MX_USART3_UART_Init-USART3-false-HAL-true,11-MX_USART6_UART_Init-USART6-false-HAL-true,12-MX_ADC1_Init-ADC1-false-HAL-true
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART1_UART_Init-USART1-false-HAL-true,4-MX_ADC3_Init-ADC3-false-HAL-true,5-MX_CAN1_Init-CAN1-false-HAL-true,6-MX_CAN2_Init-CAN2-false-HAL-true,7-MX_TIM1_Init-TIM1-false-HAL-true,8-MX_TIM4_Init-TIM4-false-HAL-true,9-MX_TIM8_Init-TIM8-false-HAL-true,10-MX_USART3_UART_Init-USART3-false-HAL-true,11-MX_USART6_UART_Init-USART6-false-HAL-true,12-MX_ADC1_Init-ADC1-false-HAL-true,13-MX_I2C2_Init-I2C2-false-HAL-true,14-MX_TIM5_Init-TIM5-false-HAL-true
RCC.48MHZClocksFreq_Value=84000000
RCC.AHBFreq_Value=168000000
RCC.APB1CLKDivider=RCC_HCLK_DIV4
@ -222,6 +227,12 @@ SH.S_TIM1_CH4.0=TIM1_CH4,PWM Generation4 CH4
SH.S_TIM1_CH4.ConfNb=1
SH.S_TIM4_CH3.0=TIM4_CH3,PWM Generation3 CH3
SH.S_TIM4_CH3.ConfNb=1
SH.S_TIM5_CH1.0=TIM5_CH1,PWM Generation1 CH1
SH.S_TIM5_CH1.ConfNb=1
SH.S_TIM5_CH2.0=TIM5_CH2,PWM Generation2 CH2
SH.S_TIM5_CH2.ConfNb=1
SH.S_TIM5_CH3.0=TIM5_CH3,PWM Generation3 CH3
SH.S_TIM5_CH3.ConfNb=1
SH.S_TIM8_CH1.0=TIM8_CH1,PWM Generation1 CH1
SH.S_TIM8_CH1.ConfNb=1
SH.S_TIM8_CH2.0=TIM8_CH2,PWM Generation2 CH2
@ -235,6 +246,11 @@ TIM1.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
TIM1.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Channel-PWM Generation3 CH3,Channel-PWM Generation4 CH4
TIM4.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
TIM4.IPParameters=Channel-PWM Generation3 CH3
TIM5.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM5.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM5.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
TIM5.IPParameters=Channel-PWM Generation1 CH1,Channel-PWM Generation2 CH2,Channel-PWM Generation3 CH3,Period
TIM5.Period=65535
TIM8.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM8.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM8.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
@ -255,6 +271,8 @@ VP_TIM1_VS_ClockSourceINT.Mode=Internal
VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT
VP_TIM4_VS_ClockSourceINT.Mode=Internal
VP_TIM4_VS_ClockSourceINT.Signal=TIM4_VS_ClockSourceINT
VP_TIM5_VS_ClockSourceINT.Mode=Internal
VP_TIM5_VS_ClockSourceINT.Signal=TIM5_VS_ClockSourceINT
VP_TIM8_VS_ClockSourceINT.Mode=Internal
VP_TIM8_VS_ClockSourceINT.Signal=TIM8_VS_ClockSourceINT
board=custom

View File

@ -60,7 +60,7 @@
/* USER CODE END 0 */
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
/**
/**
* Initializes the Global MSP.
*/
void HAL_MspInit(void)
@ -382,6 +382,17 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
/* USER CODE END TIM4_MspInit 1 */
}
else if(htim_base->Instance==TIM5)
{
/* USER CODE BEGIN TIM5_MspInit 0 */
/* USER CODE END TIM5_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM5_CLK_ENABLE();
/* USER CODE BEGIN TIM5_MspInit 1 */
/* USER CODE END TIM5_MspInit 1 */
}
else if(htim_base->Instance==TIM8)
{
/* USER CODE BEGIN TIM8_MspInit 0 */
@ -443,6 +454,29 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
/* USER CODE END TIM4_MspPostInit 1 */
}
else if(htim->Instance==TIM5)
{
/* USER CODE BEGIN TIM5_MspPostInit 0 */
/* USER CODE END TIM5_MspPostInit 0 */
__HAL_RCC_GPIOH_CLK_ENABLE();
/**TIM5 GPIO Configuration
PH12 ------> TIM5_CH3
PH11 ------> TIM5_CH2
PH10 ------> TIM5_CH1
*/
GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_11|GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF2_TIM5;
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
/* USER CODE BEGIN TIM5_MspPostInit 1 */
/* USER CODE END TIM5_MspPostInit 1 */
}
else if(htim->Instance==TIM8)
{
/* USER CODE BEGIN TIM8_MspPostInit 0 */
@ -506,6 +540,17 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
/* USER CODE END TIM4_MspDeInit 1 */
}
else if(htim_base->Instance==TIM5)
{
/* USER CODE BEGIN TIM5_MspDeInit 0 */
/* USER CODE END TIM5_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM5_CLK_DISABLE();
/* USER CODE BEGIN TIM5_MspDeInit 1 */
/* USER CODE END TIM5_MspDeInit 1 */
}
else if(htim_base->Instance==TIM8)
{
/* USER CODE BEGIN TIM8_MspDeInit 0 */

View File

@ -119,6 +119,21 @@ menu "On-chip Peripheral Drivers"
default n
endif
menuconfig BSP_USING_PWM5
bool "Enable timer5 output PWM"
default n
if BSP_USING_PWM5
config BSP_USING_PWM5_CH1
bool "Enable PWM5 channel1(LED_B)"
default n
config BSP_USING_PWM5_CH2
bool "Enable PWM5 channel2(LED_G)"
default n
config BSP_USING_PWM5_CH3
bool "Enable PWM5 channel3(LED_R)"
default n
endif
menuconfig BSP_USING_PWM8
bool "Enable timer8 output PWM"
default n