Merge pull request #2896 from tyustli/l475

add stm32 l475 pwm2 channel3、4 driver
This commit is contained in:
Bernard Xiong 2019-07-26 14:13:58 +08:00 committed by GitHub
commit 767ea2ab74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 112 additions and 36 deletions

View File

@ -586,7 +586,7 @@ static int rt_hw_stm32_eth_init(void)
}
Tx_Buff = (rt_uint8_t *)rt_calloc(ETH_TXBUFNB, ETH_MAX_PACKET_SIZE);
if (Rx_Buff == RT_NULL)
if (Tx_Buff == RT_NULL)
{
LOG_E("No memory");
state = -RT_ENOMEM;

File diff suppressed because one or more lines are too long

View File

@ -11,13 +11,14 @@ KeepUserPlacement=false
Mcu.Family=STM32L4
Mcu.IP0=ADC1
Mcu.IP1=IWDG
Mcu.IP10=TIM4
Mcu.IP11=TIM15
Mcu.IP12=TIM16
Mcu.IP13=TIM17
Mcu.IP14=USART1
Mcu.IP15=USART2
Mcu.IP16=USB_OTG_FS
Mcu.IP10=TIM2
Mcu.IP11=TIM4
Mcu.IP12=TIM15
Mcu.IP13=TIM16
Mcu.IP14=TIM17
Mcu.IP15=USART1
Mcu.IP16=USART2
Mcu.IP17=USB_OTG_FS
Mcu.IP2=NVIC
Mcu.IP3=QUADSPI
Mcu.IP4=RCC
@ -26,7 +27,7 @@ Mcu.IP6=SPI1
Mcu.IP7=SPI2
Mcu.IP8=SYS
Mcu.IP9=TIM1
Mcu.IPNb=17
Mcu.IPNb=18
Mcu.Name=STM32L475V(C-E-G)Tx
Mcu.Package=LQFP100
Mcu.Pin0=PC14-OSC32_IN (PC14)
@ -38,39 +39,42 @@ Mcu.Pin13=PE12
Mcu.Pin14=PE13
Mcu.Pin15=PE14
Mcu.Pin16=PE15
Mcu.Pin17=PB13
Mcu.Pin18=PB14
Mcu.Pin19=PB15
Mcu.Pin17=PB10
Mcu.Pin18=PB11
Mcu.Pin19=PB13
Mcu.Pin2=PH0-OSC_IN (PH0)
Mcu.Pin20=PA9
Mcu.Pin21=PA10
Mcu.Pin22=PA11
Mcu.Pin23=PA12
Mcu.Pin24=PA13 (JTMS-SWDIO)
Mcu.Pin25=PA14 (JTCK-SWCLK)
Mcu.Pin26=PB7
Mcu.Pin27=PB8
Mcu.Pin28=VP_IWDG_VS_IWDG
Mcu.Pin29=VP_RTC_VS_RTC_Activate
Mcu.Pin20=PB14
Mcu.Pin21=PB15
Mcu.Pin22=PA9
Mcu.Pin23=PA10
Mcu.Pin24=PA11
Mcu.Pin25=PA12
Mcu.Pin26=PA13 (JTMS-SWDIO)
Mcu.Pin27=PA14 (JTCK-SWCLK)
Mcu.Pin28=PB7
Mcu.Pin29=PB8
Mcu.Pin3=PH1-OSC_OUT (PH1)
Mcu.Pin30=VP_SYS_VS_Systick
Mcu.Pin31=VP_TIM1_VS_ClockSourceINT
Mcu.Pin32=VP_TIM4_VS_ClockSourceINT
Mcu.Pin33=VP_TIM15_VS_ClockSourceINT
Mcu.Pin34=VP_TIM16_VS_ClockSourceINT
Mcu.Pin35=VP_TIM17_VS_ClockSourceINT
Mcu.Pin30=VP_IWDG_VS_IWDG
Mcu.Pin31=VP_RTC_VS_RTC_Activate
Mcu.Pin32=VP_SYS_VS_Systick
Mcu.Pin33=VP_TIM1_VS_ClockSourceINT
Mcu.Pin34=VP_TIM2_VS_ClockSourceINT
Mcu.Pin35=VP_TIM4_VS_ClockSourceINT
Mcu.Pin36=VP_TIM15_VS_ClockSourceINT
Mcu.Pin37=VP_TIM16_VS_ClockSourceINT
Mcu.Pin38=VP_TIM17_VS_ClockSourceINT
Mcu.Pin4=PA2
Mcu.Pin5=PA3
Mcu.Pin6=PA5
Mcu.Pin7=PA6
Mcu.Pin8=PA7
Mcu.Pin9=PC5
Mcu.PinsNb=36
Mcu.PinsNb=39
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32L475VETx
MxCube.Version=5.2.0
MxDb.Version=DB.5.0.20
MxCube.Version=5.3.0
MxDb.Version=DB.5.0.30
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
@ -104,6 +108,8 @@ PA7.Mode=Full_Duplex_Master
PA7.Signal=SPI1_MOSI
PA9.Mode=Asynchronous
PA9.Signal=USART1_TX
PB10.Signal=S_TIM2_CH3
PB11.Signal=S_TIM2_CH4
PB13.Locked=true
PB13.Mode=Full_Duplex_Master
PB13.Signal=SPI2_SCK
@ -238,6 +244,10 @@ SH.ADCx_IN14.0=ADC1_IN14,IN14-Single-Ended
SH.ADCx_IN14.ConfNb=1
SH.S_TIM1_CH1.0=TIM1_CH1,PWM Generation1 CH1
SH.S_TIM1_CH1.ConfNb=1
SH.S_TIM2_CH3.0=TIM2_CH3,PWM Generation3 CH3
SH.S_TIM2_CH3.ConfNb=1
SH.S_TIM2_CH4.0=TIM2_CH4,PWM Generation4 CH4
SH.S_TIM2_CH4.ConfNb=1
SH.S_TIM4_CH2.0=TIM4_CH2,PWM Generation2 CH2
SH.S_TIM4_CH2.ConfNb=1
SH.S_TIM4_CH3.0=TIM4_CH3,PWM Generation3 CH3
@ -254,6 +264,9 @@ SPI2.Mode=SPI_MODE_MASTER
SPI2.VirtualType=VM_MASTER
TIM1.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM1.IPParameters=Channel-PWM Generation1 CH1
TIM2.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
TIM2.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
TIM2.IPParameters=Channel-PWM Generation3 CH3,Channel-PWM Generation4 CH4
TIM4.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM4.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
TIM4.IPParameters=Channel-PWM Generation3 CH3,Channel-PWM Generation2 CH2
@ -277,6 +290,8 @@ VP_TIM17_VS_ClockSourceINT.Mode=Enable_Timer
VP_TIM17_VS_ClockSourceINT.Signal=TIM17_VS_ClockSourceINT
VP_TIM1_VS_ClockSourceINT.Mode=Internal
VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT
VP_TIM2_VS_ClockSourceINT.Mode=Internal
VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT
VP_TIM4_VS_ClockSourceINT.Mode=Internal
VP_TIM4_VS_ClockSourceINT.Signal=TIM4_VS_ClockSourceINT
board=custom

View File

@ -80,7 +80,7 @@
/* USER CODE END 0 */
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
/**
/**
* Initializes the Global MSP.
*/
void HAL_MspInit(void)
@ -409,6 +409,17 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
/* USER CODE END TIM1_MspInit 1 */
}
else if(htim_base->Instance==TIM2)
{
/* USER CODE BEGIN TIM2_MspInit 0 */
/* USER CODE END TIM2_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM2_CLK_ENABLE();
/* USER CODE BEGIN TIM2_MspInit 1 */
/* USER CODE END TIM2_MspInit 1 */
}
else if(htim_base->Instance==TIM4)
{
/* USER CODE BEGIN TIM4_MspInit 0 */
@ -479,6 +490,28 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
/* USER CODE END TIM1_MspPostInit 1 */
}
else if(htim->Instance==TIM2)
{
/* USER CODE BEGIN TIM2_MspPostInit 0 */
/* USER CODE END TIM2_MspPostInit 0 */
__HAL_RCC_GPIOB_CLK_ENABLE();
/**TIM2 GPIO Configuration
PB10 ------> TIM2_CH3
PB11 ------> TIM2_CH4
*/
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
GPIO_InitStruct.Alternate = GPIO_AF1_TIM2;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* USER CODE BEGIN TIM2_MspPostInit 1 */
/* USER CODE END TIM2_MspPostInit 1 */
}
else if(htim->Instance==TIM4)
{
/* USER CODE BEGIN TIM4_MspPostInit 0 */
@ -522,6 +555,17 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
/* USER CODE END TIM1_MspDeInit 1 */
}
else if(htim_base->Instance==TIM2)
{
/* USER CODE BEGIN TIM2_MspDeInit 0 */
/* USER CODE END TIM2_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM2_CLK_DISABLE();
/* USER CODE BEGIN TIM2_MspDeInit 1 */
/* USER CODE END TIM2_MspDeInit 1 */
}
else if(htim_base->Instance==TIM4)
{
/* USER CODE BEGIN TIM4_MspDeInit 0 */
@ -718,7 +762,7 @@ void HAL_PCD_MspInit(PCD_HandleTypeDef* hpcd)
HAL_PWREx_EnableVddUSB();
}
/* USB_OTG_FS interrupt Init */
HAL_NVIC_SetPriority(OTG_FS_IRQn, 5, 0);
HAL_NVIC_SetPriority(OTG_FS_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
/* USER CODE BEGIN USB_OTG_FS_MspInit 1 */

View File

@ -199,6 +199,20 @@ menu "On-chip Peripheral Drivers"
bool "Enable PWM1 channel1"
default n
endif
menuconfig BSP_USING_PWM2
bool "Enable timer2 output pwm"
default n
if BSP_USING_PWM2
config BSP_USING_PWM2_CH3
bool "Enable PWM2 channel3"
default n
config BSP_USING_PWM2_CH4
bool "Enable PWM2 channel4"
default n
endif
menuconfig BSP_USING_PWM4
bool "Enable timer4 output pwm"
default n