diff --git a/.cproject b/.cproject
index 68ed0ee..f156b46 100644
--- a/.cproject
+++ b/.cproject
@@ -24,7 +24,7 @@
-
+
@@ -141,7 +141,7 @@
-
+
diff --git a/.mxproject b/.mxproject
index 1973685..d2522d3 100644
--- a/.mxproject
+++ b/.mxproject
@@ -1,25 +1,25 @@
[PreviousLibFiles]
-LibFiles=Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_adc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_adc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_adc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_bus.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_system.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_utils.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dmamux.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_exti.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_exti.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_i2c.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_tim.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usart.h;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_adc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_adc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_adc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_bus.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_rcc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_system.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_utils.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_flash_ramfunc.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_gpio_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_gpio.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dma.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_dmamux.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_pwr.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_cortex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal.h;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_def.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_exti.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_exti.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_i2c.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_i2c_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_tim_ex.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_tim.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_uart.h;Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_ll_usart.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f411xe.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Include/system_stm32f4xx.h;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Drivers/CMSIS/Include/core_cm85.h;Drivers/CMSIS/Include/cachel1_armv7.h;Drivers/CMSIS/Include/pac_armv81.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/core_cm35p.h;Drivers/CMSIS/Include/mpu_armv7.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/core_armv81mml.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_cm55.h;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/pmu_armv8.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/core_starmc1.h;Drivers/CMSIS/Include/cmsis_armclang_ltm.h;
+LibFiles=Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_adc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_adc_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_adc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_rcc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_rcc_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_bus.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_rcc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_system.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_utils.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_flash.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_flash_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_flash_ramfunc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_gpio.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_gpio_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_gpio.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_dma_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_dma.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_dma.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_dmamux.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_pwr.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_pwr_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_pwr.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_cortex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_cortex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal.h;Drivers\STM32F4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_def.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_exti.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_exti.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_i2c.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_i2c.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_i2c_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_tim.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_tim_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_tim.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_uart.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_usart.h;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_adc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_adc_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_ll_adc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ramfunc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_gpio.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cortex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_exti.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_i2c.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_i2c_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_uart.c;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_adc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_adc_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_adc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_rcc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_rcc_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_bus.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_rcc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_system.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_utils.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_flash.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_flash_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_flash_ramfunc.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_gpio.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_gpio_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_gpio.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_dma_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_dma.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_dma.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_dmamux.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_pwr.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_pwr_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_pwr.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_cortex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_cortex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal.h;Drivers\STM32F4xx_HAL_Driver\Inc\Legacy\stm32_hal_legacy.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_def.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_exti.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_exti.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_i2c.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_i2c.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_i2c_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_tim.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_tim_ex.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_tim.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_hal_uart.h;Drivers\STM32F4xx_HAL_Driver\Inc\stm32f4xx_ll_usart.h;Drivers\CMSIS\Device\ST\STM32F4xx\Include\stm32f411xe.h;Drivers\CMSIS\Device\ST\STM32F4xx\Include\stm32f4xx.h;Drivers\CMSIS\Device\ST\STM32F4xx\Include\system_stm32f4xx.h;Drivers\CMSIS\Device\ST\STM32F4xx\Include\system_stm32f4xx.h;Drivers\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c;Drivers\CMSIS\Include\cachel1_armv7.h;Drivers\CMSIS\Include\cmsis_armcc.h;Drivers\CMSIS\Include\cmsis_armclang.h;Drivers\CMSIS\Include\cmsis_armclang_ltm.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_armv81mml.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_cm35p.h;Drivers\CMSIS\Include\core_cm4.h;Drivers\CMSIS\Include\core_cm55.h;Drivers\CMSIS\Include\core_cm7.h;Drivers\CMSIS\Include\core_cm85.h;Drivers\CMSIS\Include\core_sc000.h;Drivers\CMSIS\Include\core_sc300.h;Drivers\CMSIS\Include\core_starmc1.h;Drivers\CMSIS\Include\mpu_armv7.h;Drivers\CMSIS\Include\mpu_armv8.h;Drivers\CMSIS\Include\pac_armv81.h;Drivers\CMSIS\Include\pmu_armv8.h;Drivers\CMSIS\Include\tz_context.h;
[PreviousUsedCubeIDEFiles]
-SourceFiles=Core/Src/main.c;Core/Src/stm32f4xx_it.c;Core/Src/stm32f4xx_hal_msp.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Core/Src/system_stm32f4xx.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_adc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_i2c_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c;Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c;Drivers/CMSIS/Device/ST/STM32F4xx/Source/Templates/system_stm32f4xx.c;Core/Src/system_stm32f4xx.c;;;
-HeaderPath=Drivers/STM32F4xx_HAL_Driver/Inc;Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;Drivers/CMSIS/Device/ST/STM32F4xx/Include;Drivers/CMSIS/Include;Core/Inc;
+SourceFiles=Core\Src\main.c;Core\Src\stm32f4xx_it.c;Core\Src\stm32f4xx_hal_msp.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_adc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_adc_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_ll_adc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ramfunc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_gpio.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cortex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_exti.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_i2c.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_i2c_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_uart.c;Drivers\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c;Core\Src\system_stm32f4xx.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_adc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_adc_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_ll_adc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_rcc_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_flash_ramfunc.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_gpio.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_dma.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_pwr_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_cortex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_exti.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_i2c.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_i2c_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_tim_ex.c;Drivers\STM32F4xx_HAL_Driver\Src\stm32f4xx_hal_uart.c;Drivers\CMSIS\Device\ST\STM32F4xx\Source\Templates\system_stm32f4xx.c;Core\Src\system_stm32f4xx.c;;;
+HeaderPath=Drivers\STM32F4xx_HAL_Driver\Inc;Drivers\STM32F4xx_HAL_Driver\Inc\Legacy;Drivers\CMSIS\Device\ST\STM32F4xx\Include;Drivers\CMSIS\Include;Core\Inc;
CDefines=USE_HAL_DRIVER;STM32F411xE;USE_HAL_DRIVER;USE_HAL_DRIVER;
[PreviousGenFiles]
AdvancedFolderStructure=true
HeaderFileListSize=3
-HeaderFiles#0=../Core/Inc/stm32f4xx_it.h
-HeaderFiles#1=../Core/Inc/stm32f4xx_hal_conf.h
-HeaderFiles#2=../Core/Inc/main.h
+HeaderFiles#0=..\Core\Inc\stm32f4xx_it.h
+HeaderFiles#1=..\Core\Inc\stm32f4xx_hal_conf.h
+HeaderFiles#2=..\Core\Inc\main.h
HeaderFolderListSize=1
-HeaderPath#0=../Core/Inc
+HeaderPath#0=..\Core\Inc
HeaderFiles=;
SourceFileListSize=3
-SourceFiles#0=../Core/Src/stm32f4xx_it.c
-SourceFiles#1=../Core/Src/stm32f4xx_hal_msp.c
-SourceFiles#2=../Core/Src/main.c
+SourceFiles#0=..\Core\Src\stm32f4xx_it.c
+SourceFiles#1=..\Core\Src\stm32f4xx_hal_msp.c
+SourceFiles#2=..\Core\Src\main.c
SourceFolderListSize=1
-SourcePath#0=../Core/Src
+SourcePath#0=..\Core\Src
SourceFiles=;
diff --git a/.settings/language.settings.xml b/.settings/language.settings.xml
index 1639232..84455a4 100644
--- a/.settings/language.settings.xml
+++ b/.settings/language.settings.xml
@@ -5,7 +5,7 @@
-
+
@@ -16,7 +16,7 @@
-
+
diff --git a/.settings/stm32cubeide.project.prefs b/.settings/stm32cubeide.project.prefs
index f72821e..31a812a 100644
--- a/.settings/stm32cubeide.project.prefs
+++ b/.settings/stm32cubeide.project.prefs
@@ -1,5 +1,5 @@
635E684B79701B039C64EA45C3F84D30=C4495712B0C2E8A2AF8F69A17C20BF90
66BE74F758C12D739921AEA421D593D3=1
-8DF89ED150041C4CBC7CB9A9CAA90856=77372D1B316F94A23E0081AE2C8086CD
-DC22A860405A8BF2F2C095E5B6529F12=77372D1B316F94A23E0081AE2C8086CD
+8DF89ED150041C4CBC7CB9A9CAA90856=941708D65AE899D041E2E88BD48979ED
+DC22A860405A8BF2F2C095E5B6529F12=941708D65AE899D041E2E88BD48979ED
eclipse.preferences.version=1
diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json
new file mode 100644
index 0000000..521cab6
--- /dev/null
+++ b/.vscode/c_cpp_properties.json
@@ -0,0 +1,57 @@
+//
+// !!! WARNING !!! AUTO-GENERATED FILE!
+// PLEASE DO NOT MODIFY IT AND USE "platformio.ini":
+// https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags
+//
+{
+ "configurations": [
+ {
+ "name": "PlatformIO",
+ "includePath": [
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro",
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/Drivers/SSD1306/Inc",
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/Library/Inc",
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/Program/Inc",
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/Core/Inc",
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/Drivers/STM32F4xx_HAL_Driver/Inc",
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy",
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/Drivers/CMSIS/Device/ST/STM32F4xx/Include",
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/Drivers/CMSIS/Include",
+ ""
+ ],
+ "browse": {
+ "limitSymbolsToIncludedHeaders": true,
+ "path": [
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro",
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/Drivers/SSD1306/Inc",
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/Library/Inc",
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/Program/Inc",
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/Core/Inc",
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/Drivers/STM32F4xx_HAL_Driver/Inc",
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy",
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/Drivers/CMSIS/Device/ST/STM32F4xx/Include",
+ "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/Drivers/CMSIS/Include",
+ ""
+ ]
+ },
+ "defines": [
+ "F_CPU=100000000L",
+ "PLATFORMIO=60115",
+ "STM32F4xx",
+ "STM32F411xE",
+ ""
+ ],
+ "compilerPath": "C:/Users/Bavan2002.DESKTOP-TITUVCT/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin/arm-none-eabi-gcc.exe",
+ "compilerArgs": [
+ "-mthumb",
+ "-mcpu=cortex-m4",
+ "-mthumb",
+ "-mcpu=cortex-m4",
+ "-mfpu=fpv4-sp-d16",
+ "-mfloat-abi=hard",
+ ""
+ ]
+ }
+ ],
+ "version": 4
+}
diff --git a/.vscode/extensions.json b/.vscode/extensions.json
new file mode 100644
index 0000000..080e70d
--- /dev/null
+++ b/.vscode/extensions.json
@@ -0,0 +1,10 @@
+{
+ // See http://go.microsoft.com/fwlink/?LinkId=827846
+ // for the documentation about the extensions.json format
+ "recommendations": [
+ "platformio.platformio-ide"
+ ],
+ "unwantedRecommendations": [
+ "ms-vscode.cpptools-extension-pack"
+ ]
+}
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..5b01beb
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,47 @@
+// AUTOMATICALLY GENERATED FILE. PLEASE DO NOT MODIFY IT MANUALLY
+//
+// PlatformIO Debugging Solution
+//
+// Documentation: https://docs.platformio.org/en/latest/plus/debugging.html
+// Configuration: https://docs.platformio.org/en/latest/projectconf/sections/env/options/debug/index.html
+
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "type": "platformio-debug",
+ "request": "launch",
+ "name": "PIO Debug",
+ "executable": "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/.pio/build/kitro/firmware.elf",
+ "projectEnvName": "kitro",
+ "toolchainBinDir": "C:/Users/Bavan2002.DESKTOP-TITUVCT/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin",
+ "internalConsoleOptions": "openOnSessionStart",
+ "svdPath": "C:/Users/Bavan2002.DESKTOP-TITUVCT/.platformio/platforms/ststm32/misc/svd/STM32F411xx.svd",
+ "preLaunchTask": {
+ "type": "PlatformIO",
+ "task": "Pre-Debug"
+ }
+ },
+ {
+ "type": "platformio-debug",
+ "request": "launch",
+ "name": "PIO Debug (skip Pre-Debug)",
+ "executable": "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/.pio/build/kitro/firmware.elf",
+ "projectEnvName": "kitro",
+ "toolchainBinDir": "C:/Users/Bavan2002.DESKTOP-TITUVCT/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin",
+ "internalConsoleOptions": "openOnSessionStart",
+ "svdPath": "C:/Users/Bavan2002.DESKTOP-TITUVCT/.platformio/platforms/ststm32/misc/svd/STM32F411xx.svd"
+ },
+ {
+ "type": "platformio-debug",
+ "request": "launch",
+ "name": "PIO Debug (without uploading)",
+ "executable": "C:/Users/Bavan2002.DESKTOP-TITUVCT/Desktop/robot/kitro/.pio/build/kitro/firmware.elf",
+ "projectEnvName": "kitro",
+ "toolchainBinDir": "C:/Users/Bavan2002.DESKTOP-TITUVCT/.platformio/packages/toolchain-gccarmnoneeabi@1.70201.0/bin",
+ "internalConsoleOptions": "openOnSessionStart",
+ "svdPath": "C:/Users/Bavan2002.DESKTOP-TITUVCT/.platformio/platforms/ststm32/misc/svd/STM32F411xx.svd",
+ "loadMode": "manual"
+ }
+ ]
+}
diff --git a/Core/Inc/main.h b/Core/Inc/main.h
index add4cf0..029a1d1 100644
--- a/Core/Inc/main.h
+++ b/Core/Inc/main.h
@@ -63,20 +63,12 @@ void Error_Handler(void);
#define ONB_LED_GPIO_Port GPIOC
#define ONB_KEY_Pin GPIO_PIN_0
#define ONB_KEY_GPIO_Port GPIOA
-#define SHARP_1_Pin GPIO_PIN_2
-#define SHARP_1_GPIO_Port GPIOA
-#define SHARP_2_Pin GPIO_PIN_3
-#define SHARP_2_GPIO_Port GPIOA
#define SHARP_3_Pin GPIO_PIN_4
#define SHARP_3_GPIO_Port GPIOA
#define SHARP_4_Pin GPIO_PIN_5
#define SHARP_4_GPIO_Port GPIOA
-#define GYRO_SCL_Pin GPIO_PIN_10
-#define GYRO_SCL_GPIO_Port GPIOB
#define DISPLAY_SCL_Pin GPIO_PIN_8
#define DISPLAY_SCL_GPIO_Port GPIOA
-#define GYRO_SDA_Pin GPIO_PIN_3
-#define GYRO_SDA_GPIO_Port GPIOB
#define DISPLAY_SDA_Pin GPIO_PIN_4
#define DISPLAY_SDA_GPIO_Port GPIOB
#define PWM_CH1_Pin GPIO_PIN_6
@@ -89,7 +81,14 @@ void Error_Handler(void);
#define PWM_CH4_GPIO_Port GPIOB
/* USER CODE BEGIN Private defines */
-
+#define TIM1_START HAL_TIM_Base_Start(&htim1)
+#define TIM1_STOP HAL_TIM_Base_Stop(&htim1);
+#define TIM6_IT_START HAL_TIM_Base_Start_IT(&htim6)
+#define TIM6_IT_STOP HAL_TIM_Base_Stop_IT(&htim6)
+#define TIM10_IT_START HAL_TIM_Base_Start_IT(&htim10)
+#define TIM10_IT_STOP HAL_TIM_Base_Stop_IT(&htim10)
+#define TIM11_IT_START HAL_TIM_Base_Start_IT(&htim11)
+#define TIM11_IT_STOP HAL_TIM_Base_Stop_IT(&htim11)
/* USER CODE END Private defines */
#ifdef __cplusplus
diff --git a/Core/Inc/stm32f4xx_it.h b/Core/Inc/stm32f4xx_it.h
index 962e8e4..72bc18a 100644
--- a/Core/Inc/stm32f4xx_it.h
+++ b/Core/Inc/stm32f4xx_it.h
@@ -55,6 +55,7 @@ void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
+void TIM1_UP_TIM10_IRQHandler(void);
/* USER CODE BEGIN EFP */
/* USER CODE END EFP */
diff --git a/Core/Src/main.c b/Core/Src/main.c
index 6e83f31..db84b45 100644
--- a/Core/Src/main.c
+++ b/Core/Src/main.c
@@ -45,9 +45,12 @@ ADC_HandleTypeDef hadc1;
I2C_HandleTypeDef hi2c2;
I2C_HandleTypeDef hi2c3;
+TIM_HandleTypeDef htim1;
TIM_HandleTypeDef htim2;
TIM_HandleTypeDef htim3;
TIM_HandleTypeDef htim4;
+TIM_HandleTypeDef htim10;
+TIM_HandleTypeDef htim11;
UART_HandleTypeDef huart1;
@@ -65,13 +68,20 @@ static void MX_TIM4_Init(void);
static void MX_USART1_UART_Init(void);
static void MX_TIM2_Init(void);
static void MX_TIM3_Init(void);
+static void MX_TIM1_Init(void);
+static void MX_TIM10_Init(void);
+static void MX_TIM11_Init(void);
/* USER CODE BEGIN PFP */
-
+//#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
-
+int _write(int fd, char * ptr, int len)
+{
+ HAL_UART_Transmit(&huart1, (uint8_t *) ptr, len, HAL_MAX_DELAY);
+ return len;
+}
/* USER CODE END 0 */
/**
@@ -83,6 +93,7 @@ int main(void)
/* USER CODE BEGIN 1 */
+
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
@@ -110,6 +121,9 @@ int main(void)
MX_USART1_UART_Init();
MX_TIM2_Init();
MX_TIM3_Init();
+ MX_TIM1_Init();
+ MX_TIM10_Init();
+ MX_TIM11_Init();
/* USER CODE BEGIN 2 */
/* USER CODE END 2 */
@@ -147,7 +161,12 @@ void SystemClock_Config(void)
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
- RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
+ RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
+ RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
+ RCC_OscInitStruct.PLL.PLLM = 8;
+ RCC_OscInitStruct.PLL.PLLN = 84;
+ RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
+ RCC_OscInitStruct.PLL.PLLQ = 4;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
@@ -157,12 +176,12 @@ void SystemClock_Config(void)
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
- RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_HSI;
+ RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
- RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
+ RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
- if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
+ if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
Error_Handler();
}
@@ -189,7 +208,7 @@ static void MX_ADC1_Init(void)
/** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion)
*/
hadc1.Instance = ADC1;
- hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;
+ hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
hadc1.Init.Resolution = ADC_RESOLUTION_12B;
hadc1.Init.ScanConvMode = DISABLE;
hadc1.Init.ContinuousConvMode = DISABLE;
@@ -207,7 +226,7 @@ static void MX_ADC1_Init(void)
/** Configure for the selected ADC regular channel its corresponding rank in the sequencer and its sample time.
*/
- sConfig.Channel = ADC_CHANNEL_2;
+ sConfig.Channel = ADC_CHANNEL_4;
sConfig.Rank = 1;
sConfig.SamplingTime = ADC_SAMPLETIME_3CYCLES;
if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
@@ -236,7 +255,7 @@ static void MX_I2C2_Init(void)
/* USER CODE END I2C2_Init 1 */
hi2c2.Instance = I2C2;
- hi2c2.Init.ClockSpeed = 100000;
+ hi2c2.Init.ClockSpeed = 400000;
hi2c2.Init.DutyCycle = I2C_DUTYCYCLE_2;
hi2c2.Init.OwnAddress1 = 0;
hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
@@ -288,6 +307,52 @@ static void MX_I2C3_Init(void)
}
+/**
+ * @brief TIM1 Initialization Function
+ * @param None
+ * @retval None
+ */
+static void MX_TIM1_Init(void)
+{
+
+ /* USER CODE BEGIN TIM1_Init 0 */
+
+ /* USER CODE END TIM1_Init 0 */
+
+ TIM_ClockConfigTypeDef sClockSourceConfig = {0};
+ TIM_MasterConfigTypeDef sMasterConfig = {0};
+
+ /* USER CODE BEGIN TIM1_Init 1 */
+
+ /* USER CODE END TIM1_Init 1 */
+ htim1.Instance = TIM1;
+ htim1.Init.Prescaler = 0;
+ htim1.Init.CounterMode = TIM_COUNTERMODE_UP;
+ htim1.Init.Period = 65535;
+ htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
+ htim1.Init.RepetitionCounter = 0;
+ htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
+ if (HAL_TIM_Base_Init(&htim1) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
+ if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
+ sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
+ if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ /* USER CODE BEGIN TIM1_Init 2 */
+
+ /* USER CODE END TIM1_Init 2 */
+
+}
+
/**
* @brief TIM2 Initialization Function
* @param None
@@ -309,10 +374,10 @@ static void MX_TIM2_Init(void)
htim2.Instance = TIM2;
htim2.Init.Prescaler = 0;
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
- htim2.Init.Period = 4294967295;
+ htim2.Init.Period = 65535;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
- sConfig.EncoderMode = TIM_ENCODERMODE_TI1;
+ sConfig.EncoderMode = TIM_ENCODERMODE_TI12;
sConfig.IC1Polarity = TIM_ICPOLARITY_RISING;
sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI;
sConfig.IC1Prescaler = TIM_ICPSC_DIV1;
@@ -361,7 +426,7 @@ static void MX_TIM3_Init(void)
htim3.Init.Period = 65535;
htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
- sConfig.EncoderMode = TIM_ENCODERMODE_TI1;
+ sConfig.EncoderMode = TIM_ENCODERMODE_TI12;
sConfig.IC1Polarity = TIM_ICPOLARITY_RISING;
sConfig.IC1Selection = TIM_ICSELECTION_DIRECTTI;
sConfig.IC1Prescaler = TIM_ICPSC_DIV1;
@@ -447,6 +512,68 @@ static void MX_TIM4_Init(void)
}
+/**
+ * @brief TIM10 Initialization Function
+ * @param None
+ * @retval None
+ */
+static void MX_TIM10_Init(void)
+{
+
+ /* USER CODE BEGIN TIM10_Init 0 */
+
+ /* USER CODE END TIM10_Init 0 */
+
+ /* USER CODE BEGIN TIM10_Init 1 */
+
+ /* USER CODE END TIM10_Init 1 */
+ htim10.Instance = TIM10;
+ htim10.Init.Prescaler = 2047;
+ htim10.Init.CounterMode = TIM_COUNTERMODE_UP;
+ htim10.Init.Period = 50000;
+ htim10.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
+ htim10.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
+ if (HAL_TIM_Base_Init(&htim10) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ /* USER CODE BEGIN TIM10_Init 2 */
+
+ /* USER CODE END TIM10_Init 2 */
+
+}
+
+/**
+ * @brief TIM11 Initialization Function
+ * @param None
+ * @retval None
+ */
+static void MX_TIM11_Init(void)
+{
+
+ /* USER CODE BEGIN TIM11_Init 0 */
+
+ /* USER CODE END TIM11_Init 0 */
+
+ /* USER CODE BEGIN TIM11_Init 1 */
+
+ /* USER CODE END TIM11_Init 1 */
+ htim11.Instance = TIM11;
+ htim11.Init.Prescaler = 1;
+ htim11.Init.CounterMode = TIM_COUNTERMODE_UP;
+ htim11.Init.Period = 50000;
+ htim11.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
+ htim11.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
+ if (HAL_TIM_Base_Init(&htim11) != HAL_OK)
+ {
+ Error_Handler();
+ }
+ /* USER CODE BEGIN TIM11_Init 2 */
+
+ /* USER CODE END TIM11_Init 2 */
+
+}
+
/**
* @brief USART1 Initialization Function
* @param None
@@ -513,6 +640,14 @@ static void MX_GPIO_Init(void)
HAL_GPIO_Init(ONB_KEY_GPIO_Port, &GPIO_InitStruct);
/* USER CODE BEGIN MX_GPIO_Init_2 */
+// // TIM3 CH1 (PA6) and CH2 (PA7) for left encoder
+// GPIO_InitStruct.Pin = GPIO_PIN_6 | GPIO_PIN_7;
+// 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; // Alternate function for TIM3
+// HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+
/* USER CODE END MX_GPIO_Init_2 */
}
diff --git a/Core/Src/stm32f4xx_hal_msp.c b/Core/Src/stm32f4xx_hal_msp.c
index 1e574fc..8517ea2 100644
--- a/Core/Src/stm32f4xx_hal_msp.c
+++ b/Core/Src/stm32f4xx_hal_msp.c
@@ -99,12 +99,10 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
__HAL_RCC_GPIOA_CLK_ENABLE();
/**ADC1 GPIO Configuration
- PA2 ------> ADC1_IN2
- PA3 ------> ADC1_IN3
PA4 ------> ADC1_IN4
PA5 ------> ADC1_IN5
*/
- GPIO_InitStruct.Pin = SHARP_1_Pin|SHARP_2_Pin|SHARP_3_Pin|SHARP_4_Pin;
+ GPIO_InitStruct.Pin = SHARP_3_Pin|SHARP_4_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
@@ -134,12 +132,10 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
__HAL_RCC_ADC1_CLK_DISABLE();
/**ADC1 GPIO Configuration
- PA2 ------> ADC1_IN2
- PA3 ------> ADC1_IN3
PA4 ------> ADC1_IN4
PA5 ------> ADC1_IN5
*/
- HAL_GPIO_DeInit(GPIOA, SHARP_1_Pin|SHARP_2_Pin|SHARP_3_Pin|SHARP_4_Pin);
+ HAL_GPIO_DeInit(GPIOA, SHARP_3_Pin|SHARP_4_Pin);
/* USER CODE BEGIN ADC1_MspDeInit 1 */
@@ -168,19 +164,19 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
PB10 ------> I2C2_SCL
PB3 ------> I2C2_SDA
*/
- GPIO_InitStruct.Pin = GYRO_SCL_Pin;
+ GPIO_InitStruct.Pin = GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF4_I2C2;
- HAL_GPIO_Init(GYRO_SCL_GPIO_Port, &GPIO_InitStruct);
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
- GPIO_InitStruct.Pin = GYRO_SDA_Pin;
+ GPIO_InitStruct.Pin = GPIO_PIN_3;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_I2C2;
- HAL_GPIO_Init(GYRO_SDA_GPIO_Port, &GPIO_InitStruct);
+ HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* Peripheral clock enable */
__HAL_RCC_I2C2_CLK_ENABLE();
@@ -243,9 +239,9 @@ void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
PB10 ------> I2C2_SCL
PB3 ------> I2C2_SDA
*/
- HAL_GPIO_DeInit(GYRO_SCL_GPIO_Port, GYRO_SCL_Pin);
+ HAL_GPIO_DeInit(GPIOB, GPIO_PIN_10);
- HAL_GPIO_DeInit(GYRO_SDA_GPIO_Port, GYRO_SDA_Pin);
+ HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3);
/* USER CODE BEGIN I2C2_MspDeInit 1 */
@@ -274,6 +270,56 @@ void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
}
+/**
+* @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==TIM1)
+ {
+ /* USER CODE BEGIN TIM1_MspInit 0 */
+
+ /* USER CODE END TIM1_MspInit 0 */
+ /* Peripheral clock enable */
+ __HAL_RCC_TIM1_CLK_ENABLE();
+ /* TIM1 interrupt Init */
+ HAL_NVIC_SetPriority(TIM1_UP_TIM10_IRQn, 0, 0);
+ HAL_NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn);
+ /* USER CODE BEGIN TIM1_MspInit 1 */
+
+ /* USER CODE END TIM1_MspInit 1 */
+ }
+ else if(htim_base->Instance==TIM10)
+ {
+ /* USER CODE BEGIN TIM10_MspInit 0 */
+
+ /* USER CODE END TIM10_MspInit 0 */
+ /* Peripheral clock enable */
+ __HAL_RCC_TIM10_CLK_ENABLE();
+ /* TIM10 interrupt Init */
+ HAL_NVIC_SetPriority(TIM1_UP_TIM10_IRQn, 0, 0);
+ HAL_NVIC_EnableIRQ(TIM1_UP_TIM10_IRQn);
+ /* USER CODE BEGIN TIM10_MspInit 1 */
+
+ /* USER CODE END TIM10_MspInit 1 */
+ }
+ else if(htim_base->Instance==TIM11)
+ {
+ /* USER CODE BEGIN TIM11_MspInit 0 */
+
+ /* USER CODE END TIM11_MspInit 0 */
+ /* Peripheral clock enable */
+ __HAL_RCC_TIM11_CLK_ENABLE();
+ /* USER CODE BEGIN TIM11_MspInit 1 */
+
+ /* USER CODE END TIM11_MspInit 1 */
+ }
+
+}
+
/**
* @brief TIM_Encoder MSP Initialization
* This function configures the hardware resources used in this example
@@ -386,6 +432,70 @@ void HAL_TIM_MspPostInit(TIM_HandleTypeDef* htim)
}
}
+/**
+* @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==TIM1)
+ {
+ /* USER CODE BEGIN TIM1_MspDeInit 0 */
+
+ /* USER CODE END TIM1_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_TIM1_CLK_DISABLE();
+
+ /* TIM1 interrupt DeInit */
+ /* USER CODE BEGIN TIM1:TIM1_UP_TIM10_IRQn disable */
+ /**
+ * Uncomment the line below to disable the "TIM1_UP_TIM10_IRQn" interrupt
+ * Be aware, disabling shared interrupt may affect other IPs
+ */
+ /* HAL_NVIC_DisableIRQ(TIM1_UP_TIM10_IRQn); */
+ /* USER CODE END TIM1:TIM1_UP_TIM10_IRQn disable */
+
+ /* USER CODE BEGIN TIM1_MspDeInit 1 */
+
+ /* USER CODE END TIM1_MspDeInit 1 */
+ }
+ else if(htim_base->Instance==TIM10)
+ {
+ /* USER CODE BEGIN TIM10_MspDeInit 0 */
+
+ /* USER CODE END TIM10_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_TIM10_CLK_DISABLE();
+
+ /* TIM10 interrupt DeInit */
+ /* USER CODE BEGIN TIM10:TIM1_UP_TIM10_IRQn disable */
+ /**
+ * Uncomment the line below to disable the "TIM1_UP_TIM10_IRQn" interrupt
+ * Be aware, disabling shared interrupt may affect other IPs
+ */
+ /* HAL_NVIC_DisableIRQ(TIM1_UP_TIM10_IRQn); */
+ /* USER CODE END TIM10:TIM1_UP_TIM10_IRQn disable */
+
+ /* USER CODE BEGIN TIM10_MspDeInit 1 */
+
+ /* USER CODE END TIM10_MspDeInit 1 */
+ }
+ else if(htim_base->Instance==TIM11)
+ {
+ /* USER CODE BEGIN TIM11_MspDeInit 0 */
+
+ /* USER CODE END TIM11_MspDeInit 0 */
+ /* Peripheral clock disable */
+ __HAL_RCC_TIM11_CLK_DISABLE();
+ /* USER CODE BEGIN TIM11_MspDeInit 1 */
+
+ /* USER CODE END TIM11_MspDeInit 1 */
+ }
+
+}
+
/**
* @brief TIM_Encoder MSP De-Initialization
* This function freeze the hardware resources used in this example
diff --git a/Core/Src/stm32f4xx_it.c b/Core/Src/stm32f4xx_it.c
index 912f2cb..6efa9f5 100644
--- a/Core/Src/stm32f4xx_it.c
+++ b/Core/Src/stm32f4xx_it.c
@@ -55,7 +55,8 @@
/* USER CODE END 0 */
/* External variables --------------------------------------------------------*/
-
+extern TIM_HandleTypeDef htim1;
+extern TIM_HandleTypeDef htim10;
/* USER CODE BEGIN EV */
/* USER CODE END EV */
@@ -198,6 +199,21 @@ void SysTick_Handler(void)
/* please refer to the startup file (startup_stm32f4xx.s). */
/******************************************************************************/
+/**
+ * @brief This function handles TIM1 update interrupt and TIM10 global interrupt.
+ */
+void TIM1_UP_TIM10_IRQHandler(void)
+{
+ /* USER CODE BEGIN TIM1_UP_TIM10_IRQn 0 */
+
+ /* USER CODE END TIM1_UP_TIM10_IRQn 0 */
+ HAL_TIM_IRQHandler(&htim1);
+ HAL_TIM_IRQHandler(&htim10);
+ /* USER CODE BEGIN TIM1_UP_TIM10_IRQn 1 */
+
+ /* USER CODE END TIM1_UP_TIM10_IRQn 1 */
+}
+
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
diff --git a/Library/Inc/L3GD20.h b/Library/Inc/MPU6050.h
old mode 100755
new mode 100644
similarity index 92%
rename from Library/Inc/L3GD20.h
rename to Library/Inc/MPU6050.h
index f13acc8..ab10a95
--- a/Library/Inc/L3GD20.h
+++ b/Library/Inc/MPU6050.h
@@ -1,5 +1,5 @@
-#ifndef __L3GD20_H
-#define __L3GD20_H
+#ifndef __MPU6050_H
+#define __MPU6050_H
#include "led.h"
#include "typedefs.h"
diff --git a/Library/Inc/PD.h b/Library/Inc/PD.h
index 04454d2..3baf543 100755
--- a/Library/Inc/PD.h
+++ b/Library/Inc/PD.h
@@ -4,12 +4,12 @@
#include "motor.h"
#include "typedefs.h"
#include "encoder.h"
-#include "L3GD20.h"
#include "parameters_.h"
#include "led.h"
#include "main.h"
#include "read_sensors.h"
#include
+#include
extern bool align_select;
extern u32 l_start;
diff --git a/Library/Inc/display.h b/Library/Inc/display.h
index 04d2947..78a28c9 100755
--- a/Library/Inc/display.h
+++ b/Library/Inc/display.h
@@ -28,7 +28,7 @@ HUGE // 16x24
// THIS VARIABLE DECIDES WHAT IS ON SCREEN
extern DISP_State disp_state;
-// INITIALIZATION OF THE DISPLAY
+// INITIALIZATION OF THE DISPLAY
void displayInit(void);
// CLEARNING SCREEN
diff --git a/Library/Inc/encoder.h b/Library/Inc/encoder.h
index 13a7f82..28878e1 100755
--- a/Library/Inc/encoder.h
+++ b/Library/Inc/encoder.h
@@ -4,9 +4,9 @@
#include "main.h"
#include "typedefs.h"
-#define _ENCODER_START (u32)u32_max/1e4
-#define l_position TIM2-> CNT
-#define r_position (u32_max-TIM5-> CNT)
+#define _ENCODER_START 1000 //(u16)u16_max/1e2
+#define r_position TIM2-> CNT
+#define l_position TIM3-> CNT // (u16_max-TIM3-> CNT)
void encoderInit(void);
diff --git a/Library/Inc/typedefs.h b/Library/Inc/typedefs.h
index ccb9651..de27766 100755
--- a/Library/Inc/typedefs.h
+++ b/Library/Inc/typedefs.h
@@ -5,6 +5,7 @@
#include
#define u32_max 4294967295
+#define u16_max 65535
#define u32 uint32_t
#define u16 uint16_t
diff --git a/Library/Src/L3GD20.c b/Library/Src/L3GD20.c
deleted file mode 100755
index e10ccd6..0000000
--- a/Library/Src/L3GD20.c
+++ /dev/null
@@ -1,113 +0,0 @@
-//#include "L3GD20.h"
-//
-//const float timeDifference = 2e-3;
-//const float NOISE_THRESHOLD = NOISE_THRESHOLD_;
-//const float GYRO_SENSITIVITY = GYRO_SENSITIVITY_;
-//
-//u8 gyro_identity;
-//float angle_z = 0;
-//float last_angle_rate = 0, angle_rate=0;
-//
-//float offset;
-//float noise;
-//
-//static u8 spiTxBuf[2];
-//static u8 spiRxBuf[2];
-//
-//
-//void gyroInit(void)
-//{
-// HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_RESET);
-// spiTxBuf[0] = 0x0F | 0x80; // WHO_AM_I
-// HAL_SPI_Transmit(&hspi1, spiTxBuf, 1, 50);
-// HAL_SPI_Receive(&hspi1, &gyro_identity, 1, 50);
-// HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_SET);
-// HAL_Delay(20);
-//
-// HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_RESET);
-// HAL_Delay(20);
-// spiTxBuf[0] = 0x20; // CTRL1: DR1 DR0 BW1 BW0 PD Zen Xen Yen
-// spiTxBuf[1] = 0xfc; // 800Hz, BW-100Hz 1 1 1 1 1 1 0 0
-// HAL_SPI_Transmit(&hspi1, spiTxBuf, 2, 50);
-// HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_SET);
-// HAL_Delay(20);
-//
-// HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_RESET);
-// HAL_Delay(20);
-// spiTxBuf[0] = 0x21; // CTRL2: EXTRen LVLen HPM1 HMP0 HPCF3 HPCF2 HPCF1 HPCF0
-// spiTxBuf[1] = 0x03; // 2Hz 0 0 0 0 0 1 0 1
-// HAL_SPI_Transmit(&hspi1, spiTxBuf, 2, 50);
-// HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_SET);
-// HAL_Delay(20);
-//
-// HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_RESET);
-// HAL_Delay(20);
-// spiTxBuf[0] = 0x23; // CTRL4: BDU BLE FS1 FS0 IMPen ST2 ST1 SIM
-// spiTxBuf[1] = 0x30; // 2000dps 0 0 1 1 0 0 0 0
-// HAL_SPI_Transmit(&hspi1, spiTxBuf, 2, 50);
-// HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_SET);
-// HAL_Delay(20);
-//
-// HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_RESET);
-// HAL_Delay(20);
-// spiTxBuf[0] = 0x24; // CTRL5: BOOT FIFO_EN StopOnFTH HPen IG_Sel1 IG_Sel2 Out_Sel1 Out_Sel0
-// spiTxBuf[1] = 0x00; // 0 0 0 0 0 0 0 0
-// HAL_SPI_Transmit(&hspi1, spiTxBuf, 2, 50);
-// HAL_GPIO_WritePin(GPIOC, GPIO_PIN_8, GPIO_PIN_SET);
-// HAL_Delay(20);
-//}
-//
-//int gyroUpdate(void)
-//{
-// LED8_ON;
-// angle_rate = (float)(readGyro() - offset) * GYRO_SENSITIVITY;
-// angle_rate = (fabs(angle_rate) < noise && fabs(angle_rate) 2000) ||( (current_time - last_exit_time) > 100 && last_exit_time != 0))
-// {
-// if (fm_counter > 5)
-// {
-// l_start = 0, r_start = 0;
-// fm_counter = 0;
+ sc_last_error = 0, ac_last_error = 0, fm_counter = 0;
+ previous_time = current_time;
+ start_time = current_time, last_exit_time = 0;
+ assignParameters();
+ return false;
+ }
+
+ // CORRECTIONS
+ PD_correction_ac = 0, PD_correction_ir = 0;
+ speedController();
+
+ // TERMINATION CODITION
+ if (fabs(PD_correction_sc) < fabs(TERMINATION_TH) || (current_time - start_time > 2000) ||( (current_time - last_exit_time) > 100 && last_exit_time != 0))
+ {
+ if (fm_counter > 5)
+ {
+ l_start = 0, r_start = 0;
+ fm_counter = 0;
// (mv_type == STRAIGHT_RUN) ? LED1_OFF : ((mv_type == POINT_TURN) ? LED2_OFF : LED3_OFF);
-// return true;
-// }
-// fm_counter++;
-// HAL_Delay(20);
-// }
-//
-// // SET WHEEL
-// switch (mv_type)
-// {
-// case STRAIGHT_RUN:
-// l_speed = PD_correction_sc - PD_correction_ac + PD_correction_ir;
-// r_speed = PD_correction_sc + PD_correction_ac - PD_correction_ir;
-// break;
-// case POINT_TURN:
-// l_speed = -PD_correction_sc + PD_correction_ac;
-// r_speed = +PD_correction_sc - PD_correction_ac;
-// break;
-// case FRONT_ALIGN:
-// l_speed = -PD_correction_sc ;
-// r_speed = PD_correction_sc ;
-// break;
-// }
-// setWheels();
-// previous_time = current_time;
-// align_select = false;
-// return false;
-//}
-//
-//////////////////////////////////////////////////// PARAMETER CHOICE ///////////////////////////////////////////////////////////////
-//// PARAMETERS
-//static float sc_kp = 0, sc_kd = 0, sc_red = 1e3;
-//static float ac_kp = 0, ac_kd = 0, ac_red = 1e3;
-//static float ir_kp = 0, ir_kd = 0, ir_red = 1e3;
-//static float counts_ = 0; // CONVERTING ANGLE/ DISTANCE TO ENCODER COUNTS
-//static float speed_th_ = 0;
-//
-//void assignParameters(void)
-//{
-// switch (mv_type)
-// {
-// case IDLE:
-// sc_red = 1e5, ac_red = 1e5;
-// break;
-//
-// case STRAIGHT_RUN:
-// speed_th_ = st_speed;
-// counts_ = dist_ang * LINEAR_SENSITIVITY;
-//
-// if (fabs(st_speed - 0.3) < .05)
-// {
-// sc_kp = 1, sc_kd = 5e-3, sc_red = 200;
-// ac_kp = 1.1, ac_kd = 8e-2, ac_red = 100;
-// ir_kp = 1, ir_kd = 3e-2, ir_red = 5e2;
-// }
-// else if (fabs(st_speed - 0.5) < .05)
-// {
-// sc_kp = 1.1, sc_kd = 2e-3, sc_red = 400;
-// ac_kp = 1.3, ac_kd = 1e-3, ac_red = 500;
-// ir_kp = 1, ir_kd = 1e-3, ir_red = 2000;
-// }
-// else
-// {
-// sc_kp = 1.2, sc_kd = 2e-3, sc_red = 450;
-// ac_kp = 1.3, ac_kd = 1e-3, ac_red = 600;
-// ir_kp = 1, ir_kd = 1e-3, ir_red = 2500;
-// }
-// break;
-//
-// case POINT_TURN:
-// counts_ = dist_ang * TURN_SENSITIVITY;
-// speed_th_ = rt_speed;
-//
-// sc_kp = 1.2, sc_kd = 1e-2, sc_red = 60; // 2e-3
-// ac_kp = 1, ac_kd = 3e-3, ac_red = 1000;
-// break;
-//
-// case FRONT_ALIGN:
-// speed_th_ = al_speed;
-// sc_kp = 1, sc_kd = 0, sc_red = 500;
-// break;
-// }
-// return;
-//}
-///////////////////////////////////////////////////// SPEED CONTROLLER /////////////////////////////////////////////////////////////
-//static float sc_error = 0;
-//
-//void speedController(void)
-//{
-// switch (mv_type)
-// {
-// case IDLE:
-// sc_error = 0;
-// break;
-//
-// case STRAIGHT_RUN:
-// sc_error = l_start + r_start + 2 * counts_, sc_error -= l_position, sc_error -= r_position; // sc_error = (l_start + r_start + 2*counts_) - l_position - r_position
-// break;
-//
-// case POINT_TURN:
-// // ENCODER BASED TURN : sc_error = (counts_ - (l_start - l_position)) + (counts_ - (r_position - r_start))
-// // sc_error = 2*counts_ - l_start + r_start, sc_error += l_position, sc_error -=r_position; // BACK UP : ENCODER BASED TURN
-// // GYRO BASED TURN
-// sc_error = (start_angle + dist_ang) - angle_z;
-// break;
-//
-// case FRONT_ALIGN:
+ return true;
+ }
+ fm_counter++;
+ HAL_Delay(20);
+ }
+
+ // SET WHEEL
+ switch (mv_type)
+ {
+ case STRAIGHT_RUN:
+ l_speed = PD_correction_sc - PD_correction_ac + PD_correction_ir;
+ r_speed = PD_correction_sc + PD_correction_ac - PD_correction_ir;
+ break;
+ case POINT_TURN:
+ l_speed = -PD_correction_sc + PD_correction_ac;
+ r_speed = +PD_correction_sc - PD_correction_ac;
+ break;
+ case FRONT_ALIGN:
+ l_speed = -PD_correction_sc ;
+ r_speed = PD_correction_sc ;
+ break;
+ }
+ setWheels();
+ previous_time = current_time;
+ align_select = false;
+ return false;
+}
+
+////////////////////////////////////////////////// PARAMETER CHOICE ///////////////////////////////////////////////////////////////
+// PARAMETERS
+static float sc_kp = 0, sc_kd = 0, sc_red = 1e3;
+static float ac_kp = 0, ac_kd = 0, ac_red = 1e3;
+static float ir_kp = 0, ir_kd = 0, ir_red = 1e3;
+static float counts_ = 0; // CONVERTING ANGLE/ DISTANCE TO ENCODER COUNTS
+static float speed_th_ = 0;
+
+void assignParameters(void)
+{
+ switch (mv_type)
+ {
+ case IDLE:
+ sc_red = 1e5, ac_red = 1e5;
+ break;
+
+ case STRAIGHT_RUN:
+ speed_th_ = st_speed;
+ counts_ = dist_ang * LINEAR_SENSITIVITY;
+
+ if (fabs(st_speed - 0.3) < .05)
+ {
+ sc_kp = 1, sc_kd = 5e-3, sc_red = 200;
+ ac_kp = 1.1, ac_kd = 8e-2, ac_red = 100;
+ ir_kp = 1, ir_kd = 3e-2, ir_red = 5e2;
+ }
+ else if (fabs(st_speed - 0.5) < .05)
+ {
+ sc_kp = 1.1, sc_kd = 2e-3, sc_red = 400;
+ ac_kp = 1.3, ac_kd = 1e-3, ac_red = 500;
+ ir_kp = 1, ir_kd = 1e-3, ir_red = 2000;
+ }
+ else
+ {
+ sc_kp = 1.2, sc_kd = 2e-3, sc_red = 450;
+ ac_kp = 1.3, ac_kd = 1e-3, ac_red = 600;
+ ir_kp = 1, ir_kd = 1e-3, ir_red = 2500;
+ }
+ break;
+
+ case POINT_TURN:
+ counts_ = dist_ang * TURN_SENSITIVITY;
+ speed_th_ = rt_speed;
+
+ sc_kp = 1.2, sc_kd = 1e-2, sc_red = 60; // 2e-3
+ ac_kp = 1, ac_kd = 3e-3, ac_red = 1000;
+ break;
+
+ case FRONT_ALIGN:
+ speed_th_ = al_speed;
+ sc_kp = 1, sc_kd = 0, sc_red = 500;
+ break;
+ }
+ return;
+}
+/////////////////////////////////////////////////// SPEED CONTROLLER /////////////////////////////////////////////////////////////
+static float sc_error = 0;
+
+void speedController(void)
+{
+ switch (mv_type)
+ {
+ case IDLE:
+ sc_error = 0;
+ break;
+
+ case STRAIGHT_RUN:
+ sc_error = l_start + r_start + 2 * counts_, sc_error -= l_position, sc_error -= r_position; // sc_error = (l_start + r_start + 2*counts_) - l_position - r_position
+ break;
+
+ case POINT_TURN:
+ // ENCODER BASED TURN : sc_error = (counts_ - (l_start - l_position)) + (counts_ - (r_position - r_start))
+ // sc_error = 2*counts_ - l_start + r_start, sc_error += l_position, sc_error -=r_position; // BACK UP : ENCODER BASED TURN
+ // GYRO BASED TURN
+ sc_error = (start_angle + dist_ang) - angle_z;
+ break;
+
+ case FRONT_ALIGN:
// sc_error = (LFSensor - RFSensor);
-// break;
-// }
-//
-// PD_correction_sc = (float)(sc_kp * sc_error + sc_kd * 1e3 * (sc_error - sc_last_error) / (current_time - previous_time)) / sc_red;
-// sc_last_error = sc_error;
-// if (fabs(PD_correction_sc) > speed_th_)
-// {
-// PD_correction_sc = (PD_correction_sc > 0) ? speed_th_ : -speed_th_;
-// if (irController() && align_select)
-// {
-// PD_correction_ac = 0;
-// irController();
-// }
-// else
-// {
-// PD_correction_ir = 0;
-// angularController();
-// }
-// return;
-// }
-// // PD_correction_ac = 0;
-//}
-//
-//////////////////////////////////////////// ANGULAR CONTROLLER //////////////////////////////////////////////////////////
-//static float ac_error = 0;
-//
-//void angularController(void)
-//{
-// switch (mv_type)
-// {
-//
-// // STRAIGHT RUN
-// case (STRAIGHT_RUN):
-// ac_error = l_position, ac_error -= r_position;
-// break;
-//
-// // POINT-ROTATION
-// case (POINT_TURN):
-// ac_error = r_position, ac_error += l_position, ac_error -= (l_start + r_start), ac_error = (float)ac_error; // a_error = (l_position - l_start) + (r_position - r_start)
-// break;
-// default:
-// ac_error = 0;
-// break;
-// }
-//
-// PD_correction_ac = (ac_kp * ac_error + sc_kd * 1e3 * (sc_error - sc_last_error) / (current_time - previous_time)) / ac_red;
-// ac_last_error = ac_error;
-// if (fabs(PD_correction_ac) > .5 * speed_th_)
-// PD_correction_ac = (PD_correction_ac > 0) ? .5 * speed_th_ : -.5 * speed_th_;
-//
-// return;
-//}
-//
-///////////////////////////////////////////////////////// IR-CONTROLLER /////////////////////////////////////////////////////////////////////////////////
+ break;
+ }
+
+ PD_correction_sc = (float)(sc_kp * sc_error + sc_kd * 1e3 * (sc_error - sc_last_error) / (current_time - previous_time)) / sc_red;
+ sc_last_error = sc_error;
+ if (fabs(PD_correction_sc) > speed_th_)
+ {
+ PD_correction_sc = (PD_correction_sc > 0) ? speed_th_ : -speed_th_;
+ if (irController() && align_select)
+ {
+ PD_correction_ac = 0;
+ irController();
+ }
+ else
+ {
+ PD_correction_ir = 0;
+ angularController();
+ }
+ return;
+ }
+ // PD_correction_ac = 0;
+}
+
+////////////////////////////////////////// ANGULAR CONTROLLER //////////////////////////////////////////////////////////
+static float ac_error = 0;
+
+void angularController(void)
+{
+ switch (mv_type)
+ {
+
+ // STRAIGHT RUN
+ case (STRAIGHT_RUN):
+ ac_error = l_position, ac_error -= r_position;
+ break;
+
+ // POINT-ROTATION
+ case (POINT_TURN):
+ ac_error = r_position, ac_error += l_position, ac_error -= (l_start + r_start), ac_error = (float)ac_error; // a_error = (l_position - l_start) + (r_position - r_start)
+ break;
+ default:
+ ac_error = 0;
+ break;
+ }
+
+ PD_correction_ac = (ac_kp * ac_error + sc_kd * 1e3 * (sc_error - sc_last_error) / (current_time - previous_time)) / ac_red;
+ ac_last_error = ac_error;
+ if (fabs(PD_correction_ac) > .5 * speed_th_)
+ PD_correction_ac = (PD_correction_ac > 0) ? .5 * speed_th_ : -.5 * speed_th_;
+
+ return;
+}
+
+/////////////////////////////////////////////////////// IR-CONTROLLER /////////////////////////////////////////////////////////////////////////////////
//static float ir_error = 0;
//const float MIDDLE_VALUE_DL = 1210;
//
@@ -232,8 +232,8 @@
//}
//static bool a = false;
//// DL SENSOR ALIGNMENT
-//bool irController(void)
-//{
+bool irController(void)
+{
// calculateAndSaveAverages();
// a = leftWall();
// if ((mv_type == STRAIGHT_RUN))
@@ -256,5 +256,5 @@
// return true;
// }
// PD_correction_ir = 0;
-// return false;
-//}
+ return false;
+}
diff --git a/Library/Src/encoder.c b/Library/Src/encoder.c
index fcc2b4c..af4d16d 100755
--- a/Library/Src/encoder.c
+++ b/Library/Src/encoder.c
@@ -3,13 +3,13 @@
// FUCTION: INTIALIZATION OF ENCODER RELATED HARDWARE
void encoderInit(void){
-// HAL_TIM_Encoder_Start(&htim2, TIM_CHANNEL_ALL); // LEFT ENCODER
-// HAL_TIM_Encoder_Start(&htim5, TIM_CHANNEL_ALL); // RIGHT ENCODER
-// resetEncoder();
+ HAL_TIM_Encoder_Start(&htim2, TIM_CHANNEL_ALL); // LEFT ENCODER
+ HAL_TIM_Encoder_Start(&htim3, TIM_CHANNEL_ALL); // RIGHT ENCODER
+ resetEncoder();
}
void resetEncoder(void){
TIM2->CNT = _ENCODER_START + 1;
- TIM5->CNT = u32_max-_ENCODER_START;
+ TIM3->CNT = _ENCODER_START + 1 ;//u16_max-_ENCODER_START;
}
diff --git a/Library/Src/motor.c b/Library/Src/motor.c
index 01c0458..2bf4cb9 100755
--- a/Library/Src/motor.c
+++ b/Library/Src/motor.c
@@ -16,37 +16,37 @@ void motorInit(void)
HAL_TIM_PWM_Start(&htim4, TIM_CHANNEL_4); // RPWMB
STOP_ROBOT;
}
-//
-//void setLeftWheel(float l_speed)
-//{
-// uint16_t l_pwma, l_pwmb;
-//
-// if (fabs(l_speed) > SPEED_THRESHOLD)
-// l_speed = (l_speed > 0) ? SPEED_THRESHOLD : -SPEED_THRESHOLD;
-//
-// l_pwma = (l_speed < 0) ? (-l_speed) * u12_max : 0;
-// l_pwmb = (l_speed >= 0) ? l_speed * u12_max : 0;
-//
-// __HAL_TIM_SET_COMPARE(&htim4, TIM_CHANNEL_2, l_pwma); // LPWMA
-// __HAL_TIM_SET_COMPARE(&htim4, TIM_CHANNEL_1, l_pwmb); // LPWMB
-//}
-//
-//void setRightWheel(float r_speed)
-//{
-// uint16_t r_pwma, r_pwmb;
-//
-// if (fabs(r_speed) > SPEED_THRESHOLD)
-// r_speed = (r_speed > 0) ? SPEED_THRESHOLD : -SPEED_THRESHOLD;
-// r_pwma = (r_speed < 0) ? (-r_speed) * u12_max : 0;
-// r_pwmb = (r_speed >= 0) ? r_speed * u12_max : 0;
-//
-// __HAL_TIM_SET_COMPARE(&htim4, TIM_CHANNEL_3, r_pwma); // RPWMA
-// __HAL_TIM_SET_COMPARE(&htim4, TIM_CHANNEL_4, r_pwmb); // RPWMB
-//}
-//
-//int setWheels()
-//{
-// setRightWheel(r_speed), setLeftWheel(l_speed);
-// return 0;
-//}
-//
+
+void setLeftWheel(float l_speed)
+{
+ uint16_t l_pwma, l_pwmb;
+
+ if (fabs(l_speed) > SPEED_THRESHOLD)
+ l_speed = (l_speed > 0) ? SPEED_THRESHOLD : -SPEED_THRESHOLD;
+
+ l_pwma = (l_speed < 0) ? (-l_speed) * u12_max : 0;
+ l_pwmb = (l_speed >= 0) ? l_speed * u12_max : 0;
+
+ __HAL_TIM_SET_COMPARE(&htim4, TIM_CHANNEL_2, l_pwma); // LPWMA
+ __HAL_TIM_SET_COMPARE(&htim4, TIM_CHANNEL_1, l_pwmb); // LPWMB
+}
+
+void setRightWheel(float r_speed)
+{
+ uint16_t r_pwma, r_pwmb;
+
+ if (fabs(r_speed) > SPEED_THRESHOLD)
+ r_speed = (r_speed > 0) ? SPEED_THRESHOLD : -SPEED_THRESHOLD;
+ r_pwma = (r_speed < 0) ? (-r_speed) * u12_max : 0;
+ r_pwmb = (r_speed >= 0) ? r_speed * u12_max : 0;
+
+ __HAL_TIM_SET_COMPARE(&htim4, TIM_CHANNEL_3, r_pwma); // RPWMA
+ __HAL_TIM_SET_COMPARE(&htim4, TIM_CHANNEL_4, r_pwmb); // RPWMB
+}
+
+int setWheels()
+{
+ setRightWheel(r_speed), setLeftWheel(l_speed);
+ return 0;
+}
+
diff --git a/Program/Inc/entry.h b/Program/Inc/entry.h
index 329f009..7924485 100644
--- a/Program/Inc/entry.h
+++ b/Program/Inc/entry.h
@@ -22,17 +22,17 @@ extern "C" {
#include "algo.h"
// #include "adc.h"
// #include "led.h"
-// #include "motor.h"
-// #include "encoder.h"
+#include "motor.h"
+#include "encoder.h"
// #include "display.h"
-// #include "L3GD20.h"
+#include
// #include "read_sensors.h"
-// #include "typedefs.h"
+#include "typedefs.h"
#include "ssd1306.h"
// #include "buzzer.h"
-// #include "PD.h"
+#include "PD.h"
// extern bool buttonPress;
// extern int mouseState;
@@ -53,14 +53,19 @@ int greymatter(void);
// INITIALIZATION OF HARDWARE
//extern TIM_HandleTypeDef htim4;
-// int initialization_block(void);
+int initialization_block(void);
+
+extern TIM_HandleTypeDef htim1;
extern TIM_HandleTypeDef htim2;
extern TIM_HandleTypeDef htim3;
extern TIM_HandleTypeDef htim4;
+extern TIM_HandleTypeDef htim10;
+extern TIM_HandleTypeDef htim11;
+extern I2C_HandleTypeDef hi2c2;
// INTERRUPTS
// void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin);
-// void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim);
+void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim);
#ifdef __cplusplus
}
diff --git a/Program/Src/entry.cpp b/Program/Src/entry.cpp
index d5fde9d..e7782c3 100644
--- a/Program/Src/entry.cpp
+++ b/Program/Src/entry.cpp
@@ -42,8 +42,12 @@
// void mouseRun();
+void print(const char *str){
+ printf(str);
+}
+
int greymatter(void) {
- // initialization_block();
+ initialization_block();
// HAL_Delay(1000);
// disp_state = DEFAULT;
//
@@ -66,48 +70,71 @@ int greymatter(void) {
while (1) {
// mouseRun();
// i++;
- HAL_GPIO_TogglePin(ONB_LED_GPIO_Port, ONB_LED_Pin);
- ssd1306_Fill(Black);
- ssd1306_UpdateScreen();
- HAL_Delay(500);
- ssd1306_Fill(White);
- ssd1306_UpdateScreen();
- HAL_Delay(500);
+// HAL_GPIO_TogglePin(ONB_LED_GPIO_Port, ONB_LED_Pin);
+// ssd1306_Fill(Black);
+// ssd1306_UpdateScreen();
+// HAL_Delay(500);
+// ssd1306_Fill(White);
+// ssd1306_UpdateScreen();
+// HAL_Delay(500);
+// print("a\n\r");
+// printf("l %d \n",l_position);
+// printf("r %d \n",r_position);;
+// HAL_TIM_PeriodElapsedCallback(&htim10);
+ printf("%f \n", angle_z);
+ HAL_Delay(100);
+// if (r_position < 5000){
+// setRightWheel(1);
+// } else {
+// setRightWheel(0);
+// }
+//
+// if (l_position < 5000){
+// setLeftWheel(1);
+// } else {
+// setLeftWheel(0);
+// }
+
+// finishMove(STRAIGHT_RUN, 100);
+// setLeftWheel(1);
+// setRightWheel(1);
+
+
}
}
-// int initialization_block(void)
-//{
+int initialization_block(void)
+{
// ALL_LED_ON;
-// TIM1_START; ////////////////// CRUCIAL PART DON"T OFFFFFFFFFFFFFFFF
-///////////////////////////// TIM6_IT_START;
-//
-// motorInit();
-// encoderInit();
-// gyroInit();
+ TIM1_START; ////////////////// CRUCIAL PART DON"T OFFFFFFFFFFFFFFFF
+/////////////////////////// TIM6_IT_START;
+
+ motorInit();
+ encoderInit();
+ gyroInit();
// displayInit();
// buzzerInit();
-//
+
// ALL_LED_OFF;
-// HAL_Delay(1000);
-// gyroCalibration();
+ HAL_Delay(1000);
+ gyroCalibration();
// disp_state = DEFAULT;
-// TIM13_IT_START;
-// // TIM14_IT_START;
-//
-// return 0;
-// }
+ TIM10_IT_START;
+ // TIM14_IT_START;
-// void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
-//{
-// if (htim == &htim14)
+ return 0;
+ }
+
+void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
+{
+// if (htim == &htim11)
// ;
-// else if (htim == &htim13)
-// gyroUpdate(),
+ if (htim == &htim10)
+ gyroUpdate();
// readSensor();
// else if (htim == &htim6)
// displayUpdate();
-// }
+}
//
// void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
//{
diff --git a/kitro Debug.launch b/kitro Debug.launch
index 6c59335..df6f065 100644
--- a/kitro Debug.launch
+++ b/kitro Debug.launch
@@ -7,11 +7,11 @@
-
+
-
-
+
+
@@ -20,6 +20,7 @@
+
@@ -33,14 +34,23 @@
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
diff --git a/kitro.ioc b/kitro.ioc
index e8f1fd6..ec1f2fa 100644
--- a/kitro.ioc
+++ b/kitro.ioc
@@ -1,5 +1,5 @@
#MicroXplorer Configuration settings - do not modify
-ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_2
+ADC1.Channel-1\#ChannelRegularConversion=ADC_CHANNEL_4
ADC1.IPParameters=Rank-1\#ChannelRegularConversion,master,Channel-1\#ChannelRegularConversion,SamplingTime-1\#ChannelRegularConversion,NbrOfConversionFlag
ADC1.NbrOfConversionFlag=1
ADC1.Rank-1\#ChannelRegularConversion=1
@@ -9,6 +9,8 @@ CAD.formats=
CAD.pinconfig=
CAD.provider=
File.Version=6
+I2C2.I2C_Mode=I2C_Fast
+I2C2.IPParameters=I2C_Mode
I2C3.I2C_Mode=I2C_Fast
I2C3.IPParameters=I2C_Mode
KeepUserPlacement=false
@@ -16,39 +18,43 @@ Mcu.CPN=STM32F411CEU6
Mcu.Family=STM32F4
Mcu.IP0=ADC1
Mcu.IP1=I2C2
+Mcu.IP10=TIM10
+Mcu.IP11=TIM11
+Mcu.IP12=USART1
Mcu.IP2=I2C3
Mcu.IP3=NVIC
Mcu.IP4=RCC
Mcu.IP5=SYS
-Mcu.IP6=TIM2
-Mcu.IP7=TIM3
-Mcu.IP8=TIM4
-Mcu.IP9=USART1
-Mcu.IPNb=10
+Mcu.IP6=TIM1
+Mcu.IP7=TIM2
+Mcu.IP8=TIM3
+Mcu.IP9=TIM4
+Mcu.IPNb=13
Mcu.Name=STM32F411C(C-E)Ux
Mcu.Package=UFQFPN48
Mcu.Pin0=PC13-ANTI_TAMP
Mcu.Pin1=PA0-WKUP
-Mcu.Pin10=PA8
-Mcu.Pin11=PA9
-Mcu.Pin12=PA10
-Mcu.Pin13=PA15
-Mcu.Pin14=PB3
-Mcu.Pin15=PB4
-Mcu.Pin16=PB6
-Mcu.Pin17=PB7
-Mcu.Pin18=PB8
-Mcu.Pin19=PB9
+Mcu.Pin10=PA10
+Mcu.Pin11=PA15
+Mcu.Pin12=PB3
+Mcu.Pin13=PB4
+Mcu.Pin14=PB6
+Mcu.Pin15=PB7
+Mcu.Pin16=PB8
+Mcu.Pin17=PB9
+Mcu.Pin18=VP_SYS_VS_Systick
+Mcu.Pin19=VP_TIM1_VS_ClockSourceINT
Mcu.Pin2=PA1
-Mcu.Pin20=VP_SYS_VS_Systick
-Mcu.Pin3=PA2
-Mcu.Pin4=PA3
-Mcu.Pin5=PA4
-Mcu.Pin6=PA5
-Mcu.Pin7=PA6
-Mcu.Pin8=PA7
-Mcu.Pin9=PB10
-Mcu.PinsNb=21
+Mcu.Pin20=VP_TIM10_VS_ClockSourceINT
+Mcu.Pin21=VP_TIM11_VS_ClockSourceINT
+Mcu.Pin3=PA4
+Mcu.Pin4=PA5
+Mcu.Pin5=PA6
+Mcu.Pin6=PA7
+Mcu.Pin7=PB10
+Mcu.Pin8=PA8
+Mcu.Pin9=PA9
+Mcu.PinsNb=22
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F411CEUx
@@ -64,6 +70,7 @@ NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
+NVIC.TIM1_UP_TIM10_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
PA0-WKUP.GPIOParameters=GPIO_Label
PA0-WKUP.GPIO_Label=ONB_KEY
@@ -73,12 +80,6 @@ PA1.Signal=S_TIM2_CH2
PA10.Mode=Asynchronous
PA10.Signal=USART1_RX
PA15.Signal=S_TIM2_CH1_ETR
-PA2.GPIOParameters=GPIO_Label
-PA2.GPIO_Label=SHARP_1
-PA2.Signal=ADCx_IN2
-PA3.GPIOParameters=GPIO_Label
-PA3.GPIO_Label=SHARP_2
-PA3.Signal=ADCx_IN3
PA4.GPIOParameters=GPIO_Label
PA4.GPIO_Label=SHARP_3
PA4.Signal=ADCx_IN4
@@ -93,12 +94,8 @@ PA8.Mode=I2C
PA8.Signal=I2C3_SCL
PA9.Mode=Asynchronous
PA9.Signal=USART1_TX
-PB10.GPIOParameters=GPIO_Label
-PB10.GPIO_Label=GYRO_SCL
PB10.Mode=I2C
PB10.Signal=I2C2_SCL
-PB3.GPIOParameters=GPIO_Label
-PB3.GPIO_Label=GYRO_SDA
PB3.Mode=I2C
PB3.Signal=I2C2_SDA
PB4.GPIOParameters=GPIO_Label
@@ -152,32 +149,38 @@ 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_ADC1_Init-ADC1-false-HAL-true,4-MX_I2C2_Init-I2C2-false-HAL-true,5-MX_I2C3_Init-I2C3-false-HAL-true,6-MX_TIM4_Init-TIM4-false-HAL-true,7-MX_USART1_UART_Init-USART1-false-HAL-true
-RCC.AHBFreq_Value=16000000
-RCC.APB1Freq_Value=16000000
-RCC.APB2Freq_Value=16000000
-RCC.CortexFreq_Value=16000000
+ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_ADC1_Init-ADC1-false-HAL-true,4-MX_I2C2_Init-I2C2-false-HAL-true,5-MX_I2C3_Init-I2C3-false-HAL-true,6-MX_TIM4_Init-TIM4-false-HAL-true,7-MX_USART1_UART_Init-USART1-false-HAL-true,8-MX_TIM2_Init-TIM2-false-HAL-true,9-MX_TIM3_Init-TIM3-false-HAL-true,10-MX_TIM1_Init-TIM1-false-HAL-true,11-MX_TIM10_Init-TIM10-false-HAL-true,12-MX_TIM11_Init-TIM11-false-HAL-true
+RCC.48MHZClocksFreq_Value=42000000
+RCC.AHBFreq_Value=84000000
+RCC.APB1CLKDivider=RCC_HCLK_DIV2
+RCC.APB1Freq_Value=42000000
+RCC.APB1TimFreq_Value=84000000
+RCC.APB2Freq_Value=84000000
+RCC.APB2TimFreq_Value=84000000
+RCC.CortexFreq_Value=84000000
+RCC.EthernetFreq_Value=84000000
+RCC.FCLKCortexFreq_Value=84000000
RCC.FamilyName=M
+RCC.HCLKFreq_Value=84000000
RCC.HSE_VALUE=25000000
RCC.HSI_VALUE=16000000
RCC.I2SClocksFreq_Value=96000000
-RCC.IPParameters=AHBFreq_Value,APB1Freq_Value,APB2Freq_Value,CortexFreq_Value,FamilyName,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSE_VALUE,LSI_VALUE,PLLCLKFreq_Value,PLLQCLKFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOInputMFreq_Value,VCOOutputFreq_Value,VcooutputI2S
+RCC.IPParameters=48MHZClocksFreq_Value,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,CortexFreq_Value,EthernetFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,HSE_VALUE,HSI_VALUE,I2SClocksFreq_Value,LSE_VALUE,LSI_VALUE,PLLCLKFreq_Value,PLLM,PLLN,PLLQCLKFreq_Value,RTCFreq_Value,RTCHSEDivFreq_Value,SYSCLKFreq_VALUE,SYSCLKSource,VCOI2SOutputFreq_Value,VCOInputFreq_Value,VCOInputMFreq_Value,VCOOutputFreq_Value,VcooutputI2S
RCC.LSE_VALUE=32768
RCC.LSI_VALUE=32000
-RCC.PLLCLKFreq_Value=96000000
-RCC.PLLQCLKFreq_Value=48000000
+RCC.PLLCLKFreq_Value=84000000
+RCC.PLLM=8
+RCC.PLLN=84
+RCC.PLLQCLKFreq_Value=42000000
RCC.RTCFreq_Value=32000
RCC.RTCHSEDivFreq_Value=12500000
-RCC.SYSCLKFreq_VALUE=16000000
+RCC.SYSCLKFreq_VALUE=84000000
+RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
RCC.VCOI2SOutputFreq_Value=192000000
-RCC.VCOInputFreq_Value=1000000
+RCC.VCOInputFreq_Value=2000000
RCC.VCOInputMFreq_Value=1000000
-RCC.VCOOutputFreq_Value=192000000
+RCC.VCOOutputFreq_Value=168000000
RCC.VcooutputI2S=96000000
-SH.ADCx_IN2.0=ADC1_IN2,IN2
-SH.ADCx_IN2.ConfNb=1
-SH.ADCx_IN3.0=ADC1_IN3,IN3
-SH.ADCx_IN3.ConfNb=1
SH.ADCx_IN4.0=ADC1_IN4,IN4
SH.ADCx_IN4.ConfNb=1
SH.ADCx_IN5.0=ADC1_IN5,IN5
@@ -198,6 +201,17 @@ SH.S_TIM4_CH3.0=TIM4_CH3,PWM Generation3 CH3
SH.S_TIM4_CH3.ConfNb=1
SH.S_TIM4_CH4.0=TIM4_CH4,PWM Generation4 CH4
SH.S_TIM4_CH4.ConfNb=1
+TIM10.IPParameters=Period,Prescaler
+TIM10.Period=50000
+TIM10.Prescaler=2047
+TIM11.IPParameters=Prescaler,Period
+TIM11.Period=50000
+TIM11.Prescaler=1
+TIM2.EncoderMode=TIM_ENCODERMODE_TI12
+TIM2.IPParameters=Period,EncoderMode
+TIM2.Period=65535
+TIM3.EncoderMode=TIM_ENCODERMODE_TI12
+TIM3.IPParameters=EncoderMode
TIM4.Channel-PWM\ Generation1\ CH1=TIM_CHANNEL_1
TIM4.Channel-PWM\ Generation2\ CH2=TIM_CHANNEL_2
TIM4.Channel-PWM\ Generation3\ CH3=TIM_CHANNEL_3
@@ -208,5 +222,11 @@ USART1.IPParameters=VirtualMode
USART1.VirtualMode=VM_ASYNC
VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
+VP_TIM10_VS_ClockSourceINT.Mode=Enable_Timer
+VP_TIM10_VS_ClockSourceINT.Signal=TIM10_VS_ClockSourceINT
+VP_TIM11_VS_ClockSourceINT.Mode=Enable_Timer
+VP_TIM11_VS_ClockSourceINT.Signal=TIM11_VS_ClockSourceINT
+VP_TIM1_VS_ClockSourceINT.Mode=Internal
+VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT
board=custom
isbadioc=false