[bsp][stm32l476-nucleo] support timer 7 for RTduino (#7721)

This commit is contained in:
Man, Jianting (Meco) 2023-06-25 21:30:21 -04:00 committed by GitHub
parent 139d2b9fb9
commit 64c1d626e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 49 additions and 27 deletions

View File

@ -63,16 +63,6 @@
#define LED_BUILTIN D22 /* Default Built-in LED */ #define LED_BUILTIN D22 /* Default Built-in LED */
/*
* High accuracy timing is provided by hardware timer 7.
* ALL of the Cortex-M CPU don't need to provide extra hardware timer.
* RTduino will automatically use Cortex-M internal timer to provide the
* high accuracy timing.
* This is just an example to show how to use hardware timer to provide
* high accuracy timing for RTduino.
*/
#define RTDUINO_DEFAULT_HWTIMER_DEVICE_NAME "timer7"
/* Serial2 - PA2-TX PA3-RX */ /* Serial2 - PA2-TX PA3-RX */
#define RTDUINO_SERIAL2_DEVICE_NAME "uart2" #define RTDUINO_SERIAL2_DEVICE_NAME "uart2"

View File

@ -24,8 +24,6 @@ menu "Onboard Peripheral Drivers"
select PKG_USING_RTDUINO select PKG_USING_RTDUINO
select BSP_USING_STLINK_TO_USART select BSP_USING_STLINK_TO_USART
select BSP_USING_GPIO select BSP_USING_GPIO
select BSP_USING_TIM
select BSP_USING_TIM7
select BSP_USING_PWM select BSP_USING_PWM
select BSP_USING_PWM1 select BSP_USING_PWM1
select BSP_USING_PWM1_CH1 select BSP_USING_PWM1_CH1

View File

@ -43,4 +43,6 @@
/* i2c1 : PB9-SDA PB8-SCL */ /* i2c1 : PB9-SDA PB8-SCL */
#define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1" #define RTDUINO_DEFAULT_IIC_BUS_NAME "i2c1"
#define RTDUINO_TONE_HWTIMER_DEVICE_NAME "timer7"
#endif /* Pins_Arduino_h */ #endif /* Pins_Arduino_h */

View File

@ -6,12 +6,12 @@ SourceFiles=..\Src\main.c;..\Src\stm32l4xx_it.c;..\Src\stm32l4xx_hal_msp.c;F:\ST
HeaderPath=F:\STM32Cube\Repository\STM32Cube_FW_L4_V1.15.1\Drivers\STM32L4xx_HAL_Driver\Inc;F:\STM32Cube\Repository\STM32Cube_FW_L4_V1.15.1\Drivers\STM32L4xx_HAL_Driver\Inc\Legacy;F:\STM32Cube\Repository\STM32Cube_FW_L4_V1.15.1\Drivers\CMSIS\Device\ST\STM32L4xx\Include;F:\STM32Cube\Repository\STM32Cube_FW_L4_V1.15.1\Drivers\CMSIS\Include;..\Inc; HeaderPath=F:\STM32Cube\Repository\STM32Cube_FW_L4_V1.15.1\Drivers\STM32L4xx_HAL_Driver\Inc;F:\STM32Cube\Repository\STM32Cube_FW_L4_V1.15.1\Drivers\STM32L4xx_HAL_Driver\Inc\Legacy;F:\STM32Cube\Repository\STM32Cube_FW_L4_V1.15.1\Drivers\CMSIS\Device\ST\STM32L4xx\Include;F:\STM32Cube\Repository\STM32Cube_FW_L4_V1.15.1\Drivers\CMSIS\Include;..\Inc;
CDefines=USE_HAL_DRIVER;STM32L476xx;USE_HAL_DRIVER;USE_HAL_DRIVER; CDefines=USE_HAL_DRIVER;STM32L476xx;USE_HAL_DRIVER;USE_HAL_DRIVER;
[]
SourceFiles=;;
[PreviousGenFiles] [PreviousGenFiles]
HeaderPath=..\Inc HeaderPath=..\Inc
HeaderFiles=stm32l4xx_it.h;stm32l4xx_hal_conf.h;main.h; HeaderFiles=stm32l4xx_it.h;stm32l4xx_hal_conf.h;main.h;
SourcePath=..\Src SourcePath=..\Src
SourceFiles=stm32l4xx_it.c;stm32l4xx_hal_msp.c;main.c; SourceFiles=stm32l4xx_it.c;stm32l4xx_hal_msp.c;main.c;
[]
SourceFiles=;;

View File

@ -16,10 +16,11 @@ Mcu.CPN=STM32L476RGT3
Mcu.Family=STM32L4 Mcu.Family=STM32L4
Mcu.IP0=ADC1 Mcu.IP0=ADC1
Mcu.IP1=LPTIM1 Mcu.IP1=LPTIM1
Mcu.IP10=TIM15 Mcu.IP10=TIM7
Mcu.IP11=TIM16 Mcu.IP11=TIM15
Mcu.IP12=TIM17 Mcu.IP12=TIM16
Mcu.IP13=USART2 Mcu.IP13=TIM17
Mcu.IP14=USART2
Mcu.IP2=NVIC Mcu.IP2=NVIC
Mcu.IP3=RCC Mcu.IP3=RCC
Mcu.IP4=RTC Mcu.IP4=RTC
@ -28,7 +29,7 @@ Mcu.IP6=SYS
Mcu.IP7=TIM2 Mcu.IP7=TIM2
Mcu.IP8=TIM3 Mcu.IP8=TIM3
Mcu.IP9=TIM4 Mcu.IP9=TIM4
Mcu.IPNb=14 Mcu.IPNb=15
Mcu.Name=STM32L476R(C-E-G)Tx Mcu.Name=STM32L476R(C-E-G)Tx
Mcu.Package=LQFP64 Mcu.Package=LQFP64
Mcu.Pin0=PC14-OSC32_IN (PC14) Mcu.Pin0=PC14-OSC32_IN (PC14)
@ -48,9 +49,10 @@ Mcu.Pin20=PB6
Mcu.Pin21=VP_LPTIM1_VS_LPTIM_counterModeInternalClock Mcu.Pin21=VP_LPTIM1_VS_LPTIM_counterModeInternalClock
Mcu.Pin22=VP_RTC_VS_RTC_Activate Mcu.Pin22=VP_RTC_VS_RTC_Activate
Mcu.Pin23=VP_SYS_VS_Systick Mcu.Pin23=VP_SYS_VS_Systick
Mcu.Pin24=VP_TIM15_VS_ClockSourceINT Mcu.Pin24=VP_TIM7_VS_ClockSourceINT
Mcu.Pin25=VP_TIM16_VS_ClockSourceINT Mcu.Pin25=VP_TIM15_VS_ClockSourceINT
Mcu.Pin26=VP_TIM17_VS_ClockSourceINT Mcu.Pin26=VP_TIM16_VS_ClockSourceINT
Mcu.Pin27=VP_TIM17_VS_ClockSourceINT
Mcu.Pin3=PC1 Mcu.Pin3=PC1
Mcu.Pin4=PA0 Mcu.Pin4=PA0
Mcu.Pin5=PA1 Mcu.Pin5=PA1
@ -58,7 +60,7 @@ Mcu.Pin6=PA2
Mcu.Pin7=PA3 Mcu.Pin7=PA3
Mcu.Pin8=PA4 Mcu.Pin8=PA4
Mcu.Pin9=PA7 Mcu.Pin9=PA7
Mcu.PinsNb=27 Mcu.PinsNb=28
Mcu.ThirdPartyNb=0 Mcu.ThirdPartyNb=0
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32L476RGTx Mcu.UserName=STM32L476RGTx
@ -147,7 +149,7 @@ ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=MDK-ARM V5 ProjectManager.TargetToolchain=MDK-ARM V5
ProjectManager.ToolChainLocation= ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=false ProjectManager.UnderRoot=false
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART2_UART_Init-USART2-false-HAL-true,4-MX_RTC_Init-RTC-false-HAL-true,5-MX_SPI3_Init-SPI3-false-HAL-true,6-MX_TIM15_Init-TIM15-false-HAL-true,7-MX_TIM16_Init-TIM16-false-HAL-true,8-MX_TIM17_Init-TIM17-false-HAL-true,9-MX_ADC1_Init-ADC1-false-HAL-true,10-MX_ADC2_Init-ADC2-false-HAL-true,11-MX_ADC3_Init-ADC3-false-HAL-true,12-MX_LPTIM1_Init-LPTIM1-false-HAL-true,13-MX_TIM2_Init-TIM2-false-HAL-true,14-MX_TIM3_Init-TIM3-false-HAL-true,15-MX_TIM4_Init-TIM4-false-HAL-true ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART2_UART_Init-USART2-false-HAL-true,4-MX_RTC_Init-RTC-false-HAL-true,5-MX_SPI3_Init-SPI3-false-HAL-true,6-MX_TIM15_Init-TIM15-false-HAL-true,7-MX_TIM16_Init-TIM16-false-HAL-true,8-MX_TIM17_Init-TIM17-false-HAL-true,9-MX_ADC1_Init-ADC1-false-HAL-true,10-MX_LPTIM1_Init-LPTIM1-false-HAL-true,11-MX_TIM2_Init-TIM2-false-HAL-true,12-MX_TIM3_Init-TIM3-false-HAL-true,13-MX_TIM4_Init-TIM4-false-HAL-true
RCC.ADCFreq_Value=64000000 RCC.ADCFreq_Value=64000000
RCC.AHBFreq_Value=80000000 RCC.AHBFreq_Value=80000000
RCC.APB1Freq_Value=80000000 RCC.APB1Freq_Value=80000000
@ -256,4 +258,6 @@ VP_TIM16_VS_ClockSourceINT.Mode=Enable_Timer
VP_TIM16_VS_ClockSourceINT.Signal=TIM16_VS_ClockSourceINT VP_TIM16_VS_ClockSourceINT.Signal=TIM16_VS_ClockSourceINT
VP_TIM17_VS_ClockSourceINT.Mode=Enable_Timer VP_TIM17_VS_ClockSourceINT.Mode=Enable_Timer
VP_TIM17_VS_ClockSourceINT.Signal=TIM17_VS_ClockSourceINT VP_TIM17_VS_ClockSourceINT.Signal=TIM17_VS_ClockSourceINT
VP_TIM7_VS_ClockSourceINT.Mode=Enable_Timer
VP_TIM7_VS_ClockSourceINT.Signal=TIM7_VS_ClockSourceINT
board=custom board=custom

View File

@ -433,7 +433,18 @@ void HAL_TIM_PWM_MspInit(TIM_HandleTypeDef* htim_pwm)
*/ */
void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base) void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
{ {
if(htim_base->Instance==TIM15) if(htim_base->Instance==TIM7)
{
/* USER CODE BEGIN TIM7_MspInit 0 */
/* USER CODE END TIM7_MspInit 0 */
/* Peripheral clock enable */
__HAL_RCC_TIM7_CLK_ENABLE();
/* USER CODE BEGIN TIM7_MspInit 1 */
/* USER CODE END TIM7_MspInit 1 */
}
else if(htim_base->Instance==TIM15)
{ {
/* USER CODE BEGIN TIM15_MspInit 0 */ /* USER CODE BEGIN TIM15_MspInit 0 */
@ -619,7 +630,18 @@ void HAL_TIM_PWM_MspDeInit(TIM_HandleTypeDef* htim_pwm)
*/ */
void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base) void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
{ {
if(htim_base->Instance==TIM15) if(htim_base->Instance==TIM7)
{
/* USER CODE BEGIN TIM7_MspDeInit 0 */
/* USER CODE END TIM7_MspDeInit 0 */
/* Peripheral clock disable */
__HAL_RCC_TIM7_CLK_DISABLE();
/* USER CODE BEGIN TIM7_MspDeInit 1 */
/* USER CODE END TIM7_MspDeInit 1 */
}
else if(htim_base->Instance==TIM15)
{ {
/* USER CODE BEGIN TIM15_MspDeInit 0 */ /* USER CODE BEGIN TIM15_MspDeInit 0 */

View File

@ -20,6 +20,8 @@ menu "Onboard Peripheral Drivers"
select PKG_USING_RTDUINO select PKG_USING_RTDUINO
select BSP_USING_STLINK_TO_USART select BSP_USING_STLINK_TO_USART
select BSP_USING_GPIO select BSP_USING_GPIO
select BSP_USING_TIM
select BSP_USING_TIM7
select BSP_USING_ADC select BSP_USING_ADC
select BSP_USING_ADC1 select BSP_USING_ADC1
select BSP_USING_PWM select BSP_USING_PWM
@ -176,6 +178,10 @@ menu "On-chip Peripheral Drivers"
default n default n
select RT_USING_HWTIMER select RT_USING_HWTIMER
if BSP_USING_TIM if BSP_USING_TIM
config BSP_USING_TIM7
bool "Enable TIM7"
default n
config BSP_USING_TIM15 config BSP_USING_TIM15
bool "Enable TIM15" bool "Enable TIM15"
default n default n