diff --git a/.mxproject b/.mxproject
index 1076ece..60d436c 100644
--- a/.mxproject
+++ b/.mxproject
@@ -2,23 +2,29 @@
LibFiles=Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_tim.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_tim.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_tim_ex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_def.h;Drivers\STM32L0xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_i2c.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_i2c_ex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_rcc.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_rcc_ex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_bus.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_rcc.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_crs.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_system.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_utils.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_flash_ramfunc.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_flash.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_flash_ex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_gpio.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_gpio_ex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_gpio.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_dma.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_dma_ex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_dma.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_pwr.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_pwr_ex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_pwr.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_cortex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_cortex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_exti.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_exti.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_uart.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_usart.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_lpuart.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_uart_ex.h;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_tim.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_tim_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_i2c.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_i2c_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_rcc.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_rcc_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_flash_ramfunc.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_flash.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_flash_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_gpio.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_dma.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_pwr.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_pwr_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_cortex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_exti.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_uart.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_uart_ex.c;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_tim.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_tim.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_tim_ex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_def.h;Drivers\STM32L0xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_i2c.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_i2c_ex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_rcc.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_rcc_ex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_bus.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_rcc.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_crs.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_system.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_utils.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_flash_ramfunc.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_flash.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_flash_ex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_gpio.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_gpio_ex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_gpio.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_dma.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_dma_ex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_dma.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_pwr.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_pwr_ex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_pwr.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_cortex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_cortex.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_exti.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_exti.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_uart.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_usart.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_ll_lpuart.h;Drivers\STM32L0xx_HAL_Driver\Inc\stm32l0xx_hal_uart_ex.h;Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l073xx.h;Drivers\CMSIS\Device\ST\STM32L0xx\Include\stm32l0xx.h;Drivers\CMSIS\Device\ST\STM32L0xx\Include\system_stm32l0xx.h;Drivers\CMSIS\Device\ST\STM32L0xx\Include\system_stm32l0xx.h;Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\system_stm32l0xx.c;Drivers\CMSIS\Include\cmsis_armcc.h;Drivers\CMSIS\Include\cmsis_armclang.h;Drivers\CMSIS\Include\cmsis_compiler.h;Drivers\CMSIS\Include\cmsis_gcc.h;Drivers\CMSIS\Include\cmsis_iccarm.h;Drivers\CMSIS\Include\cmsis_version.h;Drivers\CMSIS\Include\core_armv8mbl.h;Drivers\CMSIS\Include\core_armv8mml.h;Drivers\CMSIS\Include\core_cm0.h;Drivers\CMSIS\Include\core_cm0plus.h;Drivers\CMSIS\Include\core_cm1.h;Drivers\CMSIS\Include\core_cm23.h;Drivers\CMSIS\Include\core_cm3.h;Drivers\CMSIS\Include\core_cm33.h;Drivers\CMSIS\Include\core_cm4.h;Drivers\CMSIS\Include\core_cm7.h;Drivers\CMSIS\Include\core_sc000.h;Drivers\CMSIS\Include\core_sc300.h;Drivers\CMSIS\Include\mpu_armv7.h;Drivers\CMSIS\Include\mpu_armv8.h;Drivers\CMSIS\Include\tz_context.h;
[PreviousUsedCubeIDEFiles]
-SourceFiles=Core\Src\main.c;Core\Src\stm32l0xx_it.c;Core\Src\stm32l0xx_hal_msp.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_tim.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_tim_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_i2c.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_i2c_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_rcc.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_rcc_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_flash_ramfunc.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_flash.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_flash_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_gpio.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_dma.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_pwr.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_pwr_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_cortex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_exti.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_uart.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_uart_ex.c;Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\system_stm32l0xx.c;Core\Src\system_stm32l0xx.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_tim.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_tim_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_i2c.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_i2c_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_rcc.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_rcc_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_flash_ramfunc.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_flash.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_flash_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_gpio.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_dma.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_pwr.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_pwr_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_cortex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_exti.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_uart.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_uart_ex.c;Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\system_stm32l0xx.c;Core\Src\system_stm32l0xx.c;;;
+SourceFiles=Core\Src\main.c;Core\Src\gpio.c;Core\Src\tim.c;Core\Src\usart.c;Core\Src\stm32l0xx_it.c;Core\Src\stm32l0xx_hal_msp.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_tim.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_tim_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_i2c.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_i2c_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_rcc.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_rcc_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_flash_ramfunc.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_flash.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_flash_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_gpio.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_dma.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_pwr.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_pwr_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_cortex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_exti.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_uart.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_uart_ex.c;Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\system_stm32l0xx.c;Core\Src\system_stm32l0xx.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_tim.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_tim_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_i2c.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_i2c_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_rcc.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_rcc_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_flash_ramfunc.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_flash.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_flash_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_gpio.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_dma.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_pwr.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_pwr_ex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_cortex.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_exti.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_uart.c;Drivers\STM32L0xx_HAL_Driver\Src\stm32l0xx_hal_uart_ex.c;Drivers\CMSIS\Device\ST\STM32L0xx\Source\Templates\system_stm32l0xx.c;Core\Src\system_stm32l0xx.c;;;
HeaderPath=Drivers\STM32L0xx_HAL_Driver\Inc;Drivers\STM32L0xx_HAL_Driver\Inc\Legacy;Drivers\CMSIS\Device\ST\STM32L0xx\Include;Drivers\CMSIS\Include;Core\Inc;
CDefines=USE_HAL_DRIVER;STM32L073xx;USE_HAL_DRIVER;USE_HAL_DRIVER;
[PreviousGenFiles]
AdvancedFolderStructure=true
-HeaderFileListSize=3
-HeaderFiles#0=..\Core\Inc\stm32l0xx_it.h
-HeaderFiles#1=..\Core\Inc\stm32l0xx_hal_conf.h
-HeaderFiles#2=..\Core\Inc\main.h
+HeaderFileListSize=6
+HeaderFiles#0=..\Core\Inc\gpio.h
+HeaderFiles#1=..\Core\Inc\tim.h
+HeaderFiles#2=..\Core\Inc\usart.h
+HeaderFiles#3=..\Core\Inc\stm32l0xx_it.h
+HeaderFiles#4=..\Core\Inc\stm32l0xx_hal_conf.h
+HeaderFiles#5=..\Core\Inc\main.h
HeaderFolderListSize=1
HeaderPath#0=..\Core\Inc
HeaderFiles=;
-SourceFileListSize=3
-SourceFiles#0=..\Core\Src\stm32l0xx_it.c
-SourceFiles#1=..\Core\Src\stm32l0xx_hal_msp.c
-SourceFiles#2=..\Core\Src\main.c
+SourceFileListSize=6
+SourceFiles#0=..\Core\Src\gpio.c
+SourceFiles#1=..\Core\Src\tim.c
+SourceFiles#2=..\Core\Src\usart.c
+SourceFiles#3=..\Core\Src\stm32l0xx_it.c
+SourceFiles#4=..\Core\Src\stm32l0xx_hal_msp.c
+SourceFiles#5=..\Core\Src\main.c
SourceFolderListSize=1
SourcePath#0=..\Core\Src
SourceFiles=;
diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml
index 08a37ff..1856fbd 100644
--- a/.settings/language.settings.xml
+++ b/.settings/language.settings.xml
@@ -5,7 +5,7 @@
-
+
@@ -16,7 +16,7 @@
-
+
diff --git a/ControleMoteur2.ioc b/ControleMoteur2.ioc
index 3da4615..ce9528b 100644
--- a/ControleMoteur2.ioc
+++ b/ControleMoteur2.ioc
@@ -10,45 +10,44 @@ Mcu.Family=STM32L0
Mcu.IP0=NVIC
Mcu.IP1=RCC
Mcu.IP2=SYS
-Mcu.IP3=TIM3
-Mcu.IP4=USART2
-Mcu.IPNb=5
+Mcu.IP3=TIM2
+Mcu.IP4=TIM3
+Mcu.IP5=USART2
+Mcu.IPNb=6
Mcu.Name=STM32L073R(B-Z)Tx
Mcu.Package=LQFP64
Mcu.Pin0=PC13
Mcu.Pin1=PC14-OSC32_IN
-Mcu.Pin10=PA5
-Mcu.Pin11=PC6
-Mcu.Pin12=PC7
-Mcu.Pin13=PC8
-Mcu.Pin14=PC9
-Mcu.Pin15=PA13
-Mcu.Pin16=PA14
-Mcu.Pin17=PC10
-Mcu.Pin18=VP_SYS_VS_Systick
-Mcu.Pin19=VP_TIM3_VS_ClockSourceINT
+Mcu.Pin10=PC7
+Mcu.Pin11=PC8
+Mcu.Pin12=PC9
+Mcu.Pin13=PA13
+Mcu.Pin14=PA14
+Mcu.Pin15=PC10
+Mcu.Pin16=VP_SYS_VS_Systick
+Mcu.Pin17=VP_TIM3_VS_ClockSourceINT
Mcu.Pin2=PC15-OSC32_OUT
Mcu.Pin3=PH0-OSC_IN
-Mcu.Pin4=PC0
-Mcu.Pin5=PC1
-Mcu.Pin6=PC2
-Mcu.Pin7=PC3
-Mcu.Pin8=PA2
-Mcu.Pin9=PA3
-Mcu.PinsNb=20
+Mcu.Pin4=PA0
+Mcu.Pin5=PA1
+Mcu.Pin6=PA2
+Mcu.Pin7=PA3
+Mcu.Pin8=PA5
+Mcu.Pin9=PC6
+Mcu.PinsNb=18
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32L073RZTx
MxCube.Version=6.13.0
MxDb.Version=DB.6.0.130
-NVIC.EXTI0_1_IRQn=true\:0\:0\:false\:true\:true\:1\:true\:true\:true
-NVIC.EXTI2_3_IRQn=true\:0\:0\:false\:true\:true\:2\:true\:true\:true
NVIC.ForceEnableDMAVector=true
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.SVC_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:true
NVIC.SysTick_IRQn=true\:0\:0\:true\:false\:true\:true\:true\:false
+PA0.Signal=S_TIM2_CH1
+PA1.Signal=S_TIM2_CH2
PA13.GPIOParameters=GPIO_Label
PA13.GPIO_Label=TMS
PA13.Locked=true
@@ -73,14 +72,6 @@ PA5.GPIOParameters=GPIO_Label
PA5.GPIO_Label=LD2 [Green Led]
PA5.Locked=true
PA5.Signal=GPIO_Output
-PC0.GPIOParameters=GPIO_PuPd
-PC0.GPIO_PuPd=GPIO_PULLUP
-PC0.Locked=true
-PC0.Signal=GPXTI0
-PC1.GPIOParameters=GPIO_PuPd
-PC1.GPIO_PuPd=GPIO_PULLUP
-PC1.Locked=true
-PC1.Signal=GPXTI1
PC10.Locked=true
PC10.Signal=GPIO_Output
PC13.GPIOParameters=GPIO_Label,GPIO_ModeDefaultEXTI
@@ -94,14 +85,6 @@ PC14-OSC32_IN.Signal=RCC_OSC32_IN
PC15-OSC32_OUT.Locked=true
PC15-OSC32_OUT.Mode=LSE-External-Oscillator
PC15-OSC32_OUT.Signal=RCC_OSC32_OUT
-PC2.GPIOParameters=GPIO_PuPd
-PC2.GPIO_PuPd=GPIO_PULLUP
-PC2.Locked=true
-PC2.Signal=GPXTI2
-PC3.GPIOParameters=GPIO_PuPd
-PC3.GPIO_PuPd=GPIO_PULLUP
-PC3.Locked=true
-PC3.Signal=GPXTI3
PC6.Locked=true
PC6.Signal=S_TIM3_CH1
PC7.Locked=true
@@ -120,7 +103,7 @@ ProjectManager.AskForMigrate=true
ProjectManager.BackupPrevious=false
ProjectManager.CompilerOptimize=6
ProjectManager.ComputerToolchain=false
-ProjectManager.CoupleFile=false
+ProjectManager.CoupleFile=true
ProjectManager.CustomerFirmwarePackage=
ProjectManager.DefaultFWLocation=true
ProjectManager.DeletePrevious=true
@@ -146,7 +129,7 @@ ProjectManager.ToolChainLocation=
ProjectManager.UAScriptAfterPath=
ProjectManager.UAScriptBeforePath=
ProjectManager.UnderRoot=true
-ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_USART2_UART_Init-USART2-false-HAL-true,4-MX_TIM3_Init-TIM3-false-HAL-true
+ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_USART2_UART_Init-USART2-false-HAL-true,4-MX_TIM3_Init-TIM3-false-HAL-true,5-MX_TIM2_Init-TIM2-false-HAL-true
RCC.48CLKFreq_Value=24000000
RCC.AHBFreq_Value=16000000
RCC.APB1Freq_Value=16000000
@@ -181,16 +164,12 @@ RCC.USART1Freq_Value=16000000
RCC.USART2Freq_Value=16000000
RCC.VCOOutputFreq_Value=48000000
RCC.WatchDogFreq_Value=37000
-SH.GPXTI0.0=GPIO_EXTI0
-SH.GPXTI0.ConfNb=1
-SH.GPXTI1.0=GPIO_EXTI1
-SH.GPXTI1.ConfNb=1
SH.GPXTI13.0=GPIO_EXTI13
SH.GPXTI13.ConfNb=1
-SH.GPXTI2.0=GPIO_EXTI2
-SH.GPXTI2.ConfNb=1
-SH.GPXTI3.0=GPIO_EXTI3
-SH.GPXTI3.ConfNb=1
+SH.S_TIM2_CH1.0=TIM2_CH1,Encoder_Interface
+SH.S_TIM2_CH1.ConfNb=1
+SH.S_TIM2_CH2.0=TIM2_CH2,Encoder_Interface
+SH.S_TIM2_CH2.ConfNb=1
SH.S_TIM3_CH1.0=TIM3_CH1,PWM Generation1 CH1
SH.S_TIM3_CH1.ConfNb=1
SH.S_TIM3_CH2.0=TIM3_CH2,PWM Generation2 CH2
@@ -199,6 +178,12 @@ SH.S_TIM3_CH3.0=TIM3_CH3,PWM Generation3 CH3
SH.S_TIM3_CH3.ConfNb=1
SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4
SH.S_TIM3_CH4.ConfNb=1
+TIM2.EncoderMode=TIM_ENCODERMODE_TI12
+TIM2.IC1Filter=10
+TIM2.IC1Polarity=TIM_ICPOLARITY_FALLING
+TIM2.IC2Filter=0
+TIM2.IC2Polarity=TIM_ICPOLARITY_FALLING
+TIM2.IPParameters=EncoderMode,IC1Polarity,IC2Polarity,IC2Filter,IC1Filter
TIM3.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
TIM3.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM3.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
diff --git a/Core/Inc/gpio.h b/Core/Inc/gpio.h
new file mode 100644
index 0000000..9ac4857
--- /dev/null
+++ b/Core/Inc/gpio.h
@@ -0,0 +1,49 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file gpio.h
+ * @brief This file contains all the function prototypes for
+ * the gpio.c file
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __GPIO_H__
+#define __GPIO_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "main.h"
+
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+/* USER CODE BEGIN Private defines */
+
+/* USER CODE END Private defines */
+
+void MX_GPIO_Init(void);
+
+/* USER CODE BEGIN Prototypes */
+
+/* USER CODE END Prototypes */
+
+#ifdef __cplusplus
+}
+#endif
+#endif /*__ GPIO_H__ */
+
diff --git a/Core/Inc/main.h b/Core/Inc/main.h
index 1c0900b..c43ffed 100644
--- a/Core/Inc/main.h
+++ b/Core/Inc/main.h
@@ -49,8 +49,6 @@ extern "C" {
/* USER CODE END EM */
-void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
-
/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);
diff --git a/Core/Inc/stm32l0xx_it.h b/Core/Inc/stm32l0xx_it.h
index b2c6196..c0087c3 100644
--- a/Core/Inc/stm32l0xx_it.h
+++ b/Core/Inc/stm32l0xx_it.h
@@ -51,8 +51,6 @@ void HardFault_Handler(void);
void SVC_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
-void EXTI0_1_IRQHandler(void);
-void EXTI2_3_IRQHandler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */
diff --git a/Core/Inc/tim.h b/Core/Inc/tim.h
new file mode 100644
index 0000000..9932570
--- /dev/null
+++ b/Core/Inc/tim.h
@@ -0,0 +1,57 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file tim.h
+ * @brief This file contains all the function prototypes for
+ * the tim.c file
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __TIM_H__
+#define __TIM_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "main.h"
+
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+extern TIM_HandleTypeDef htim2;
+
+extern TIM_HandleTypeDef htim3;
+
+/* USER CODE BEGIN Private defines */
+
+/* USER CODE END Private defines */
+
+void MX_TIM2_Init(void);
+void MX_TIM3_Init(void);
+
+void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
+
+/* USER CODE BEGIN Prototypes */
+
+/* USER CODE END Prototypes */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __TIM_H__ */
+
diff --git a/Core/Inc/usart.h b/Core/Inc/usart.h
new file mode 100644
index 0000000..cf91933
--- /dev/null
+++ b/Core/Inc/usart.h
@@ -0,0 +1,52 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file usart.h
+ * @brief This file contains all the function prototypes for
+ * the usart.c file
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+/* Define to prevent recursive inclusion -------------------------------------*/
+#ifndef __USART_H__
+#define __USART_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Includes ------------------------------------------------------------------*/
+#include "main.h"
+
+/* USER CODE BEGIN Includes */
+
+/* USER CODE END Includes */
+
+extern UART_HandleTypeDef huart2;
+
+/* USER CODE BEGIN Private defines */
+
+/* USER CODE END Private defines */
+
+void MX_USART2_UART_Init(void);
+
+/* USER CODE BEGIN Prototypes */
+
+/* USER CODE END Prototypes */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __USART_H__ */
+
diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c
new file mode 100644
index 0000000..e12c61b
--- /dev/null
+++ b/Core/Src/gpio.c
@@ -0,0 +1,82 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file gpio.c
+ * @brief This file provides code for the configuration
+ * of all used GPIO pins.
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+
+/* Includes ------------------------------------------------------------------*/
+#include "gpio.h"
+
+/* USER CODE BEGIN 0 */
+
+/* USER CODE END 0 */
+
+/*----------------------------------------------------------------------------*/
+/* Configure GPIO */
+/*----------------------------------------------------------------------------*/
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */
+
+/** Configure pins as
+ * Analog
+ * Input
+ * Output
+ * EVENT_OUT
+ * EXTI
+*/
+void MX_GPIO_Init(void)
+{
+
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+
+ /* GPIO Ports Clock Enable */
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ __HAL_RCC_GPIOH_CLK_ENABLE();
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+
+ /*Configure GPIO pin Output Level */
+ HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
+
+ /*Configure GPIO pin Output Level */
+ HAL_GPIO_WritePin(GPIOC, GPIO_PIN_10, GPIO_PIN_RESET);
+
+ /*Configure GPIO pin : B1_Pin */
+ GPIO_InitStruct.Pin = B1_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
+
+ /*Configure GPIO pin : LD2_Pin */
+ GPIO_InitStruct.Pin = LD2_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct);
+
+ /*Configure GPIO pin : PC10 */
+ GPIO_InitStruct.Pin = GPIO_PIN_10;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
+
+}
+
+/* USER CODE BEGIN 2 */
+
+/* USER CODE END 2 */
diff --git a/Core/Src/main.c b/Core/Src/main.c
index 492b381..34a000c 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -18,6 +18,9 @@
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
+#include "tim.h"
+#include "usart.h"
+#include "gpio.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
@@ -42,20 +45,16 @@ void ModelecOdometryLoop();
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
-TIM_HandleTypeDef htim3;
-
-UART_HandleTypeDef huart2;
/* USER CODE BEGIN PV */
-
+uint32_t rawCounter = 0;
+uint32_t counter = 0;
+uint32_t last_counter = 0;
+uint32_t blink_delay = 200;
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
-static void MX_GPIO_Init(void);
-static void MX_USART2_UART_Init(void);
-static void MX_TIM3_Init(void);
-static void MX_NVIC_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
@@ -96,10 +95,14 @@ int main(void)
MX_GPIO_Init();
MX_USART2_UART_Init();
MX_TIM3_Init();
-
- /* Initialize interrupts */
- MX_NVIC_Init();
+ MX_TIM2_Init();
/* USER CODE BEGIN 2 */
+ HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_1);
+ HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_2);
+ HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4);
+ HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_3);
+ HAL_TIM_Encoder_Start(&htim2, TIM_CHANNEL_ALL);
+
ModelecOdometrySetup();
/* USER CODE END 2 */
@@ -109,9 +112,10 @@ int main(void)
{
ModelecOdometryLoop();
- /* USER CODE END WHILE */
+ /* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
+ rawCounter = __HAL_TIM_GET_COUNTER(&htim2);
}
/* USER CODE END 3 */
}
@@ -163,184 +167,7 @@ void SystemClock_Config(void)
}
}
-/**
- * @brief NVIC Configuration.
- * @retval None
- */
-static void MX_NVIC_Init(void)
-{
- /* EXTI0_1_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(EXTI0_1_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(EXTI0_1_IRQn);
- /* EXTI2_3_IRQn interrupt configuration */
- HAL_NVIC_SetPriority(EXTI2_3_IRQn, 0, 0);
- HAL_NVIC_EnableIRQ(EXTI2_3_IRQn);
-}
-
-/**
- * @brief TIM3 Initialization Function
- * @param None
- * @retval None
- */
-static void MX_TIM3_Init(void)
-{
-
- /* USER CODE BEGIN TIM3_Init 0 */
-
- /* USER CODE END TIM3_Init 0 */
-
- TIM_ClockConfigTypeDef sClockSourceConfig = {0};
- TIM_MasterConfigTypeDef sMasterConfig = {0};
- TIM_OC_InitTypeDef sConfigOC = {0};
-
- /* USER CODE BEGIN TIM3_Init 1 */
-
- /* USER CODE END TIM3_Init 1 */
- htim3.Instance = TIM3;
- htim3.Init.Prescaler = 0;
- htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
- htim3.Init.Period = 639;
- htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
- htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
- if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
- {
- Error_Handler();
- }
- sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
- if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
- {
- Error_Handler();
- }
- if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
- {
- Error_Handler();
- }
- sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
- sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
- if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
- {
- Error_Handler();
- }
- sConfigOC.OCMode = TIM_OCMODE_PWM1;
- sConfigOC.Pulse = 0;
- sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
- sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
- if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
- {
- Error_Handler();
- }
- if (HAL_TIMEx_RemapConfig(&htim3, TIM3_TI1_GPIO|TIM3_TI4_GPIOC9_AF2) != HAL_OK)
- {
- Error_Handler();
- }
- if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
- {
- Error_Handler();
- }
- if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_3) != HAL_OK)
- {
- Error_Handler();
- }
- if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN TIM3_Init 2 */
-
- /* USER CODE END TIM3_Init 2 */
- HAL_TIM_MspPostInit(&htim3);
-
-}
-
-/**
- * @brief USART2 Initialization Function
- * @param None
- * @retval None
- */
-static void MX_USART2_UART_Init(void)
-{
-
- /* USER CODE BEGIN USART2_Init 0 */
-
- /* USER CODE END USART2_Init 0 */
-
- /* USER CODE BEGIN USART2_Init 1 */
-
- /* USER CODE END USART2_Init 1 */
- huart2.Instance = USART2;
- huart2.Init.BaudRate = 115200;
- huart2.Init.WordLength = UART_WORDLENGTH_8B;
- huart2.Init.StopBits = UART_STOPBITS_1;
- huart2.Init.Parity = UART_PARITY_NONE;
- huart2.Init.Mode = UART_MODE_TX_RX;
- huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
- huart2.Init.OverSampling = UART_OVERSAMPLING_16;
- huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
- huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
- if (HAL_UART_Init(&huart2) != HAL_OK)
- {
- Error_Handler();
- }
- /* USER CODE BEGIN USART2_Init 2 */
-
- /* USER CODE END USART2_Init 2 */
-
-}
-
-/**
- * @brief GPIO Initialization Function
- * @param None
- * @retval None
- */
-static void MX_GPIO_Init(void)
-{
- GPIO_InitTypeDef GPIO_InitStruct = {0};
-/* USER CODE BEGIN MX_GPIO_Init_1 */
-/* USER CODE END MX_GPIO_Init_1 */
-
- /* GPIO Ports Clock Enable */
- __HAL_RCC_GPIOC_CLK_ENABLE();
- __HAL_RCC_GPIOH_CLK_ENABLE();
- __HAL_RCC_GPIOA_CLK_ENABLE();
-
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);
-
- /*Configure GPIO pin Output Level */
- HAL_GPIO_WritePin(GPIOC, GPIO_PIN_10, GPIO_PIN_RESET);
-
- /*Configure GPIO pin : B1_Pin */
- GPIO_InitStruct.Pin = B1_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- HAL_GPIO_Init(B1_GPIO_Port, &GPIO_InitStruct);
-
- /*Configure GPIO pins : PC0 PC1 PC2 PC3 */
- GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3;
- GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
-
- /*Configure GPIO pin : LD2_Pin */
- GPIO_InitStruct.Pin = LD2_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(LD2_GPIO_Port, &GPIO_InitStruct);
-
- /*Configure GPIO pin : PC10 */
- GPIO_InitStruct.Pin = GPIO_PIN_10;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
-
-/* USER CODE BEGIN MX_GPIO_Init_2 */
-/* USER CODE END MX_GPIO_Init_2 */
-}
-
/* USER CODE BEGIN 4 */
-
/* USER CODE END 4 */
/**
diff --git a/Core/Src/modelec.cpp b/Core/Src/modelec.cpp
index e0f73b0..4c30d3c 100644
--- a/Core/Src/modelec.cpp
+++ b/Core/Src/modelec.cpp
@@ -26,6 +26,7 @@ extern "C" {
// Fonction de setup appelee au debut du main.c
void ModelecOdometrySetup(){
HAL_UART_Transmit(&huart2, (uint8_t *)"SETUP COMPLETE\n", 15, HAL_MAX_DELAY);
+ motor.accelerer(500);
}
// Fonction de loop appelee en boucle dans le main.c
@@ -34,6 +35,7 @@ extern "C" {
//On actualise toute les 10ms et on effectue tous les controles périodiques
if(isDelayPassed(10)) {
+
if(encoder1.getTotalDistance() > 10) {
motor.stop();
}
@@ -41,15 +43,6 @@ extern "C" {
motor.update();
}
}
-
- void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
- {
- if(GPIO_Pin == GPIO_PIN_0 || GPIO_Pin == GPIO_PIN_1) {
- encoder1.trigger(); // trigger de l'encodeur 1
- } else if (GPIO_Pin == GPIO_PIN_2 || GPIO_Pin == GPIO_PIN_3) {
- encoder2.trigger(); // trigger de l'encodeur 2
- }
- }
}
diff --git a/Core/Src/stm32l0xx_hal_msp.c b/Core/Src/stm32l0xx_hal_msp.c
index 72da193..fc0edb8 100644
--- a/Core/Src/stm32l0xx_hal_msp.c
+++ b/Core/Src/stm32l0xx_hal_msp.c
@@ -57,9 +57,7 @@
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
-
-void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
- /**
+/**
* Initializes the Global MSP.
*/
void HAL_MspInit(void)
@@ -79,146 +77,6 @@ void HAL_MspInit(void)
/* USER CODE END MspInit 1 */
}
-/**
-* @brief TIM_Base MSP Initialization
-* This function configures the hardware resources used in this example
-* @param htim_base: TIM_Base handle pointer
-* @retval None
-*/
-void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* htim_base)
-{
- if(htim_base->Instance==TIM3)
- {
- /* USER CODE BEGIN TIM3_MspInit 0 */
-
- /* USER CODE END TIM3_MspInit 0 */
- /* Peripheral clock enable */
- __HAL_RCC_TIM3_CLK_ENABLE();
- /* USER CODE BEGIN TIM3_MspInit 1 */
-
- /* USER CODE END TIM3_MspInit 1 */
-
- }
-
-}
-
-void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
-{
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- if(htim->Instance==TIM3)
- {
- /* USER CODE BEGIN TIM3_MspPostInit 0 */
-
- /* USER CODE END TIM3_MspPostInit 0 */
-
- __HAL_RCC_GPIOC_CLK_ENABLE();
- /**TIM3 GPIO Configuration
- PC6 ------> TIM3_CH1
- PC7 ------> TIM3_CH2
- PC8 ------> TIM3_CH3
- PC9 ------> TIM3_CH4
- */
- GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
- GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
- HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
-
- /* USER CODE BEGIN TIM3_MspPostInit 1 */
-
- /* USER CODE END TIM3_MspPostInit 1 */
- }
-
-}
-/**
-* @brief TIM_Base MSP De-Initialization
-* This function freeze the hardware resources used in this example
-* @param htim_base: TIM_Base handle pointer
-* @retval None
-*/
-void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* htim_base)
-{
- if(htim_base->Instance==TIM3)
- {
- /* USER CODE BEGIN TIM3_MspDeInit 0 */
-
- /* USER CODE END TIM3_MspDeInit 0 */
- /* Peripheral clock disable */
- __HAL_RCC_TIM3_CLK_DISABLE();
- /* USER CODE BEGIN TIM3_MspDeInit 1 */
-
- /* USER CODE END TIM3_MspDeInit 1 */
- }
-
-}
-
-/**
-* @brief UART MSP Initialization
-* This function configures the hardware resources used in this example
-* @param huart: UART handle pointer
-* @retval None
-*/
-void HAL_UART_MspInit(UART_HandleTypeDef* huart)
-{
- GPIO_InitTypeDef GPIO_InitStruct = {0};
- if(huart->Instance==USART2)
- {
- /* USER CODE BEGIN USART2_MspInit 0 */
-
- /* USER CODE END USART2_MspInit 0 */
- /* Peripheral clock enable */
- __HAL_RCC_USART2_CLK_ENABLE();
-
- __HAL_RCC_GPIOA_CLK_ENABLE();
- /**USART2 GPIO Configuration
- PA2 ------> USART2_TX
- PA3 ------> USART2_RX
- */
- GPIO_InitStruct.Pin = USART_TX_Pin|USART_RX_Pin;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
- GPIO_InitStruct.Alternate = GPIO_AF4_USART2;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
-
- /* USER CODE BEGIN USART2_MspInit 1 */
-
- /* USER CODE END USART2_MspInit 1 */
-
- }
-
-}
-
-/**
-* @brief UART MSP De-Initialization
-* This function freeze the hardware resources used in this example
-* @param huart: UART handle pointer
-* @retval None
-*/
-void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
-{
- if(huart->Instance==USART2)
- {
- /* USER CODE BEGIN USART2_MspDeInit 0 */
-
- /* USER CODE END USART2_MspDeInit 0 */
- /* Peripheral clock disable */
- __HAL_RCC_USART2_CLK_DISABLE();
-
- /**USART2 GPIO Configuration
- PA2 ------> USART2_TX
- PA3 ------> USART2_RX
- */
- HAL_GPIO_DeInit(GPIOA, USART_TX_Pin|USART_RX_Pin);
-
- /* USER CODE BEGIN USART2_MspDeInit 1 */
-
- /* USER CODE END USART2_MspDeInit 1 */
- }
-
-}
-
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
diff --git a/Core/Src/stm32l0xx_it.c b/Core/Src/stm32l0xx_it.c
index b528abb..b3939b9 100644
--- a/Core/Src/stm32l0xx_it.c
+++ b/Core/Src/stm32l0xx_it.c
@@ -140,36 +140,6 @@ void SysTick_Handler(void)
/* please refer to the startup file (startup_stm32l0xx.s). */
/******************************************************************************/
-/**
- * @brief This function handles EXTI line 0 and line 1 interrupts.
- */
-void EXTI0_1_IRQHandler(void)
-{
- /* USER CODE BEGIN EXTI0_1_IRQn 0 */
-
- /* USER CODE END EXTI0_1_IRQn 0 */
- HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
- HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1);
- /* USER CODE BEGIN EXTI0_1_IRQn 1 */
-
- /* USER CODE END EXTI0_1_IRQn 1 */
-}
-
-/**
- * @brief This function handles EXTI line 2 and line 3 interrupts.
- */
-void EXTI2_3_IRQHandler(void)
-{
- /* USER CODE BEGIN EXTI2_3_IRQn 0 */
-
- /* USER CODE END EXTI2_3_IRQn 0 */
- HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2);
- HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_3);
- /* USER CODE BEGIN EXTI2_3_IRQn 1 */
-
- /* USER CODE END EXTI2_3_IRQn 1 */
-}
-
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
diff --git a/Core/Src/stm32l0xx_it.cpp b/Core/Src/stm32l0xx_it.cpp
deleted file mode 100644
index e9c9147..0000000
--- a/Core/Src/stm32l0xx_it.cpp
+++ /dev/null
@@ -1,180 +0,0 @@
-/* USER CODE BEGIN Header */
-/**
- ******************************************************************************
- * @file stm32l0xx_it.c
- * @brief Interrupt Service Routines.
- ******************************************************************************
- * @attention
- *
- * Copyright (c) 2025 STMicroelectronics.
- * All rights reserved.
- *
- * This software is licensed under terms that can be found in the LICENSE file
- * in the root directory of this software component.
- * If no LICENSE file comes with this software, it is provided AS-IS.
- *
- ******************************************************************************
- */
-/* USER CODE END Header */
-
-/* Includes ------------------------------------------------------------------*/
-#include "main.h"
-#include "stm32l0xx_it.h"
-#include "encoder.h"
-/* Private includes ----------------------------------------------------------*/
-/* USER CODE BEGIN Includes */
-/* USER CODE END Includes */
-
-/* Private typedef -----------------------------------------------------------*/
-/* USER CODE BEGIN TD */
-
-/* USER CODE END TD */
-
-/* Private define ------------------------------------------------------------*/
-/* USER CODE BEGIN PD */
-
-/* USER CODE END PD */
-
-/* Private macro -------------------------------------------------------------*/
-/* USER CODE BEGIN PM */
-
-/* USER CODE END PM */
-
-/* Private variables ---------------------------------------------------------*/
-/* USER CODE BEGIN PV */
-
-/* USER CODE END PV */
-
-/* Private function prototypes -----------------------------------------------*/
-/* USER CODE BEGIN PFP */
-
-/* USER CODE END PFP */
-
-/* Private user code ---------------------------------------------------------*/
-/* USER CODE BEGIN 0 */
-
-/* USER CODE END 0 */
-
-/* External variables --------------------------------------------------------*/
-
-/* USER CODE BEGIN EV */
-
-/* USER CODE END EV */
-
-/******************************************************************************/
-/* Cortex-M0+ Processor Interruption and Exception Handlers */
-/******************************************************************************/
-/**
- * @brief This function handles Non maskable Interrupt.
- */
-void NMI_Handler(void)
-{
- /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
-
- /* USER CODE END NonMaskableInt_IRQn 0 */
- /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
- while (1)
- {
- }
- /* USER CODE END NonMaskableInt_IRQn 1 */
-}
-
-/**
- * @brief This function handles Hard fault interrupt.
- */
-void HardFault_Handler(void)
-{
- /* USER CODE BEGIN HardFault_IRQn 0 */
-
- /* USER CODE END HardFault_IRQn 0 */
- while (1)
- {
- /* USER CODE BEGIN W1_HardFault_IRQn 0 */
- /* USER CODE END W1_HardFault_IRQn 0 */
- }
-}
-
-/**
- * @brief This function handles System service call via SWI instruction.
- */
-void SVC_Handler(void)
-{
- /* USER CODE BEGIN SVC_IRQn 0 */
-
- /* USER CODE END SVC_IRQn 0 */
- /* USER CODE BEGIN SVC_IRQn 1 */
-
- /* USER CODE END SVC_IRQn 1 */
-}
-
-/**
- * @brief This function handles Pendable request for system service.
- */
-void PendSV_Handler(void)
-{
- /* USER CODE BEGIN PendSV_IRQn 0 */
-
- /* USER CODE END PendSV_IRQn 0 */
- /* USER CODE BEGIN PendSV_IRQn 1 */
-
- /* USER CODE END PendSV_IRQn 1 */
-}
-
-/**
- * @brief This function handles System tick timer.
- */
-void SysTick_Handler(void)
-{
- /* USER CODE BEGIN SysTick_IRQn 0 */
-
- /* USER CODE END SysTick_IRQn 0 */
- HAL_IncTick();
- /* USER CODE BEGIN SysTick_IRQn 1 */
-
- /* USER CODE END SysTick_IRQn 1 */
-}
-
-/******************************************************************************/
-/* STM32L0xx Peripheral Interrupt Handlers */
-/* Add here the Interrupt Handlers for the used peripherals. */
-/* For the available peripheral interrupt handler names, */
-/* please refer to the startup file (startup_stm32l0xx.s). */
-/******************************************************************************/
-
-/**
- * @brief This function handles EXTI line 0 and line 1 interrupts.
- */
-void EXTI0_1_IRQHandler(void)
-{
- /* USER CODE BEGIN EXTI0_1_IRQn 0 */
-
- // On branche le fil A et le fil B du meme encodeur sur la meme interruption et on determine nous meme lequel a trigger l'interruption
-
- /* USER CODE END EXTI0_1_IRQn 0 */
- HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_0);
- HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_1);
- /* USER CODE BEGIN EXTI0_1_IRQn 1 */
-
- // Est ce que le callback est appelé deux fois à la suite ??
-
- /* USER CODE END EXTI0_1_IRQn 1 */
-}
-
-/**
- * @brief This function handles EXTI line 2 and line 3 interrupts.
- */
-void EXTI2_3_IRQHandler(void)
-{
- /* USER CODE BEGIN EXTI2_3_IRQn 0 */
-
- /* USER CODE END EXTI2_3_IRQn 0 */
- HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_2);
- HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_3);
- /* USER CODE BEGIN EXTI2_3_IRQn 1 */
-
- /* USER CODE END EXTI2_3_IRQn 1 */
-}
-
-/* USER CODE BEGIN 1 */
-
-/* USER CODE END 1 */
diff --git a/Core/Src/tim.c b/Core/Src/tim.c
new file mode 100644
index 0000000..2826122
--- /dev/null
+++ b/Core/Src/tim.c
@@ -0,0 +1,262 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file tim.c
+ * @brief This file provides code for the configuration
+ * of the TIM instances.
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+/* Includes ------------------------------------------------------------------*/
+#include "tim.h"
+
+/* USER CODE BEGIN 0 */
+
+/* USER CODE END 0 */
+
+TIM_HandleTypeDef htim2;
+TIM_HandleTypeDef htim3;
+
+/* TIM2 init function */
+void MX_TIM2_Init(void)
+{
+
+ /* USER CODE BEGIN TIM2_Init 0 */
+
+ /* USER CODE END TIM2_Init 0 */
+
+ TIM_Encoder_InitTypeDef sConfig = {0};
+ TIM_MasterConfigTypeDef sMasterConfig = {0};
+
+ /* USER CODE BEGIN TIM2_Init 1 */
+
+ /* USER CODE END TIM2_Init 1 */
+ htim2.Instance = TIM2;
+ htim2.Init.Prescaler = 0;
+ htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
+ htim2.Init.Period = 65535;
+ htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
+ htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
+ sConfig.EncoderMode = TIM_ENCODERMODE_TI12;
+ sConfig.IC1Polarity = TIM_ICPOLARITY_FALLING;
+ sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI;
+ sConfig.IC1Prescaler = TIM_ICPSC_DIV1;
+ sConfig.IC1Filter = 10;
+ sConfig.IC2Polarity = TIM_ICPOLARITY_FALLING;
+ sConfig.IC2Selection = TIM_ICSELECTION_DIRECTTI;
+ sConfig.IC2Prescaler = TIM_ICPSC_DIV1;
+ sConfig.IC2Filter = 0;
+ if (HAL_TIM_Encoder_Init(&htim2, &sConfig) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
+ sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
+ if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ /* USER CODE BEGIN TIM2_Init 2 */
+
+ /* USER CODE END TIM2_Init 2 */
+
+}
+/* TIM3 init function */
+void MX_TIM3_Init(void)
+{
+
+ /* USER CODE BEGIN TIM3_Init 0 */
+
+ /* USER CODE END TIM3_Init 0 */
+
+ TIM_ClockConfigTypeDef sClockSourceConfig = {0};
+ TIM_MasterConfigTypeDef sMasterConfig = {0};
+ TIM_OC_InitTypeDef sConfigOC = {0};
+
+ /* USER CODE BEGIN TIM3_Init 1 */
+
+ /* USER CODE END TIM3_Init 1 */
+ htim3.Instance = TIM3;
+ htim3.Init.Prescaler = 0;
+ htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
+ htim3.Init.Period = 639;
+ htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
+ htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_ENABLE;
+ if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
+ if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
+ sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
+ if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ sConfigOC.OCMode = TIM_OCMODE_PWM1;
+ sConfigOC.Pulse = 0;
+ sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
+ sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
+ if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_1) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ if (HAL_TIMEx_RemapConfig(&htim3, TIM3_TI1_GPIO|TIM3_TI4_GPIOC9_AF2) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_2) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_3) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ /* USER CODE BEGIN TIM3_Init 2 */
+
+ /* USER CODE END TIM3_Init 2 */
+ HAL_TIM_MspPostInit(&htim3);
+
+}
+
+void HAL_TIM_Encoder_MspInit(TIM_HandleTypeDef* tim_encoderHandle)
+{
+
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ if(tim_encoderHandle->Instance==TIM2)
+ {
+ /* USER CODE BEGIN TIM2_MspInit 0 */
+
+ /* USER CODE END TIM2_MspInit 0 */
+ /* TIM2 clock enable */
+ __HAL_RCC_TIM2_CLK_ENABLE();
+
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ /**TIM2 GPIO Configuration
+ PA0 ------> TIM2_CH1
+ PA1 ------> TIM2_CH2
+ */
+ GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF2_TIM2;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* USER CODE BEGIN TIM2_MspInit 1 */
+
+ /* USER CODE END TIM2_MspInit 1 */
+ }
+}
+
+void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
+{
+
+ if(tim_baseHandle->Instance==TIM3)
+ {
+ /* USER CODE BEGIN TIM3_MspInit 0 */
+
+ /* USER CODE END TIM3_MspInit 0 */
+ /* TIM3 clock enable */
+ __HAL_RCC_TIM3_CLK_ENABLE();
+ /* USER CODE BEGIN TIM3_MspInit 1 */
+
+ /* USER CODE END TIM3_MspInit 1 */
+ }
+}
+void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
+{
+
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ if(timHandle->Instance==TIM3)
+ {
+ /* USER CODE BEGIN TIM3_MspPostInit 0 */
+
+ /* USER CODE END TIM3_MspPostInit 0 */
+
+ __HAL_RCC_GPIOC_CLK_ENABLE();
+ /**TIM3 GPIO Configuration
+ PC6 ------> TIM3_CH1
+ PC7 ------> TIM3_CH2
+ PC8 ------> TIM3_CH3
+ PC9 ------> TIM3_CH4
+ */
+ GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
+ GPIO_InitStruct.Alternate = GPIO_AF2_TIM3;
+ HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
+
+ /* USER CODE BEGIN TIM3_MspPostInit 1 */
+
+ /* USER CODE END TIM3_MspPostInit 1 */
+ }
+
+}
+
+void HAL_TIM_Encoder_MspDeInit(TIM_HandleTypeDef* tim_encoderHandle)
+{
+
+ if(tim_encoderHandle->Instance==TIM2)
+ {
+ /* USER CODE BEGIN TIM2_MspDeInit 0 */
+
+ /* USER CODE END TIM2_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_TIM2_CLK_DISABLE();
+
+ /**TIM2 GPIO Configuration
+ PA0 ------> TIM2_CH1
+ PA1 ------> TIM2_CH2
+ */
+ HAL_GPIO_DeInit(GPIOA, GPIO_PIN_0|GPIO_PIN_1);
+
+ /* USER CODE BEGIN TIM2_MspDeInit 1 */
+
+ /* USER CODE END TIM2_MspDeInit 1 */
+ }
+}
+
+void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
+{
+
+ if(tim_baseHandle->Instance==TIM3)
+ {
+ /* USER CODE BEGIN TIM3_MspDeInit 0 */
+
+ /* USER CODE END TIM3_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_TIM3_CLK_DISABLE();
+ /* USER CODE BEGIN TIM3_MspDeInit 1 */
+
+ /* USER CODE END TIM3_MspDeInit 1 */
+ }
+}
+
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */
diff --git a/Core/Src/usart.c b/Core/Src/usart.c
new file mode 100644
index 0000000..4a4afce
--- /dev/null
+++ b/Core/Src/usart.c
@@ -0,0 +1,116 @@
+/* USER CODE BEGIN Header */
+/**
+ ******************************************************************************
+ * @file usart.c
+ * @brief This file provides code for the configuration
+ * of the USART instances.
+ ******************************************************************************
+ * @attention
+ *
+ * Copyright (c) 2025 STMicroelectronics.
+ * All rights reserved.
+ *
+ * This software is licensed under terms that can be found in the LICENSE file
+ * in the root directory of this software component.
+ * If no LICENSE file comes with this software, it is provided AS-IS.
+ *
+ ******************************************************************************
+ */
+/* USER CODE END Header */
+/* Includes ------------------------------------------------------------------*/
+#include "usart.h"
+
+/* USER CODE BEGIN 0 */
+
+/* USER CODE END 0 */
+
+UART_HandleTypeDef huart2;
+
+/* USART2 init function */
+
+void MX_USART2_UART_Init(void)
+{
+
+ /* USER CODE BEGIN USART2_Init 0 */
+
+ /* USER CODE END USART2_Init 0 */
+
+ /* USER CODE BEGIN USART2_Init 1 */
+
+ /* USER CODE END USART2_Init 1 */
+ huart2.Instance = USART2;
+ huart2.Init.BaudRate = 115200;
+ huart2.Init.WordLength = UART_WORDLENGTH_8B;
+ huart2.Init.StopBits = UART_STOPBITS_1;
+ huart2.Init.Parity = UART_PARITY_NONE;
+ huart2.Init.Mode = UART_MODE_TX_RX;
+ huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
+ huart2.Init.OverSampling = UART_OVERSAMPLING_16;
+ huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
+ huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
+ if (HAL_UART_Init(&huart2) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ /* USER CODE BEGIN USART2_Init 2 */
+
+ /* USER CODE END USART2_Init 2 */
+
+}
+
+void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
+{
+
+ GPIO_InitTypeDef GPIO_InitStruct = {0};
+ if(uartHandle->Instance==USART2)
+ {
+ /* USER CODE BEGIN USART2_MspInit 0 */
+
+ /* USER CODE END USART2_MspInit 0 */
+ /* USART2 clock enable */
+ __HAL_RCC_USART2_CLK_ENABLE();
+
+ __HAL_RCC_GPIOA_CLK_ENABLE();
+ /**USART2 GPIO Configuration
+ PA2 ------> USART2_TX
+ PA3 ------> USART2_RX
+ */
+ GPIO_InitStruct.Pin = USART_TX_Pin|USART_RX_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
+ GPIO_InitStruct.Pull = GPIO_NOPULL;
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
+ GPIO_InitStruct.Alternate = GPIO_AF4_USART2;
+ HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
+ /* USER CODE BEGIN USART2_MspInit 1 */
+
+ /* USER CODE END USART2_MspInit 1 */
+ }
+}
+
+void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
+{
+
+ if(uartHandle->Instance==USART2)
+ {
+ /* USER CODE BEGIN USART2_MspDeInit 0 */
+
+ /* USER CODE END USART2_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_USART2_CLK_DISABLE();
+
+ /**USART2 GPIO Configuration
+ PA2 ------> USART2_TX
+ PA3 ------> USART2_RX
+ */
+ HAL_GPIO_DeInit(GPIOA, USART_TX_Pin|USART_RX_Pin);
+
+ /* USER CODE BEGIN USART2_MspDeInit 1 */
+
+ /* USER CODE END USART2_MspDeInit 1 */
+ }
+}
+
+/* USER CODE BEGIN 1 */
+
+/* USER CODE END 1 */