正在显示
28 个修改的文件
包含
3763 行增加
和
0 行删除
.mxproject
0 → 100644
1 | +[PreviousLibFiles] | ||
2 | +LibFiles=Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_gpio.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_exti.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_system.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_adc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_dma.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_dmamux.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_bus.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_cortex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_rcc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_utils.h;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_utils.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_exti.c;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_pwr.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_rcc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_rcc_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash_ramfunc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_gpio.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_gpio_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_dma.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_dma_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_pwr.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_pwr_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_cortex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_def.h;Drivers/STM32G0xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_exti.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_tim.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_tim_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_tim.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_usart.h;Middlewares/Third_Party/FreeRTOS/Source/include/croutine.h;Middlewares/Third_Party/FreeRTOS/Source/include/deprecated_definitions.h;Middlewares/Third_Party/FreeRTOS/Source/include/event_groups.h;Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h;Middlewares/Third_Party/FreeRTOS/Source/include/list.h;Middlewares/Third_Party/FreeRTOS/Source/include/message_buffer.h;Middlewares/Third_Party/FreeRTOS/Source/include/mpu_prototypes.h;Middlewares/Third_Party/FreeRTOS/Source/include/mpu_wrappers.h;Middlewares/Third_Party/FreeRTOS/Source/include/portable.h;Middlewares/Third_Party/FreeRTOS/Source/include/projdefs.h;Middlewares/Third_Party/FreeRTOS/Source/include/queue.h;Middlewares/Third_Party/FreeRTOS/Source/include/semphr.h;Middlewares/Third_Party/FreeRTOS/Source/include/stack_macros.h;Middlewares/Third_Party/FreeRTOS/Source/include/StackMacros.h;Middlewares/Third_Party/FreeRTOS/Source/include/stream_buffer.h;Middlewares/Third_Party/FreeRTOS/Source/include/task.h;Middlewares/Third_Party/FreeRTOS/Source/include/timers.h;Middlewares/Third_Party/FreeRTOS/Source/include/atomic.h;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.h;Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM0/portmacro.h;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_gpio.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_exti.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_adc.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_dma.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_rcc.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc_ex.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_flash.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_flash_ex.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_gpio.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_dma.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_dma_ex.c;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_dma.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_dmamux.h;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr_ex.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_cortex.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_exti.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim_ex.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_tim.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_usart.c;Middlewares/Third_Party/FreeRTOS/Source/croutine.c;Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;Middlewares/Third_Party/FreeRTOS/Source/list.c;Middlewares/Third_Party/FreeRTOS/Source/queue.c;Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;Middlewares/Third_Party/FreeRTOS/Source/tasks.c;Middlewares/Third_Party/FreeRTOS/Source/timers.c;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c;Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_gpio.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_exti.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_system.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_adc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_dma.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_dmamux.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_bus.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_cortex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_rcc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_utils.h;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_utils.c;Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_exti.c;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_pwr.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_rcc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_rcc_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_flash_ramfunc.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_gpio.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_gpio_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_dma.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_dma_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_pwr.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_pwr_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_cortex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_def.h;Drivers/STM32G0xx_HAL_Driver/Inc/Legacy/stm32_hal_legacy.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_exti.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_tim.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_hal_tim_ex.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_tim.h;Drivers/STM32G0xx_HAL_Driver/Inc/stm32g0xx_ll_usart.h;Middlewares/Third_Party/FreeRTOS/Source/include/croutine.h;Middlewares/Third_Party/FreeRTOS/Source/include/deprecated_definitions.h;Middlewares/Third_Party/FreeRTOS/Source/include/event_groups.h;Middlewares/Third_Party/FreeRTOS/Source/include/FreeRTOS.h;Middlewares/Third_Party/FreeRTOS/Source/include/list.h;Middlewares/Third_Party/FreeRTOS/Source/include/message_buffer.h;Middlewares/Third_Party/FreeRTOS/Source/include/mpu_prototypes.h;Middlewares/Third_Party/FreeRTOS/Source/include/mpu_wrappers.h;Middlewares/Third_Party/FreeRTOS/Source/include/portable.h;Middlewares/Third_Party/FreeRTOS/Source/include/projdefs.h;Middlewares/Third_Party/FreeRTOS/Source/include/queue.h;Middlewares/Third_Party/FreeRTOS/Source/include/semphr.h;Middlewares/Third_Party/FreeRTOS/Source/include/stack_macros.h;Middlewares/Third_Party/FreeRTOS/Source/include/StackMacros.h;Middlewares/Third_Party/FreeRTOS/Source/include/stream_buffer.h;Middlewares/Third_Party/FreeRTOS/Source/include/task.h;Middlewares/Third_Party/FreeRTOS/Source/include/timers.h;Middlewares/Third_Party/FreeRTOS/Source/include/atomic.h;Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.h;Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM0/portmacro.h;Drivers/CMSIS/Device/ST/STM32G0xx/Include/stm32g030xx.h;Drivers/CMSIS/Device/ST/STM32G0xx/Include/stm32g0xx.h;Drivers/CMSIS/Device/ST/STM32G0xx/Include/system_stm32g0xx.h;Drivers/CMSIS/Device/ST/STM32G0xx/Source/Templates/system_stm32g0xx.c;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_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; | ||
3 | + | ||
4 | +[PreviousUsedKeilFiles] | ||
5 | +SourceFiles=..\Core\Src\main.c;..\Core\Src\gpio.c;..\Core\Src\app_freertos.c;..\Core\Src\adc.c;..\Core\Src\dma.c;..\Core\Src\tim.c;..\Core\Src\usart.c;..\Core\Src\stm32g0xx_it.c;..\Core\Src\stm32g0xx_hal_msp.c;..\Core\Src\stm32g0xx_hal_timebase_tim.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_utils.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_exti.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_gpio.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_adc.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_dma.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_rcc.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc_ex.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_flash.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_flash_ex.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_gpio.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_dma.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_dma_ex.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr_ex.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_cortex.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_exti.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim_ex.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_tim.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_usart.c;..\Middlewares/Third_Party/FreeRTOS/Source/croutine.c;..\Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;..\Middlewares/Third_Party/FreeRTOS/Source/list.c;..\Middlewares/Third_Party/FreeRTOS/Source/queue.c;..\Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;..\Middlewares/Third_Party/FreeRTOS/Source/tasks.c;..\Middlewares/Third_Party/FreeRTOS/Source/timers.c;..\Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c;..\Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;..\Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c;..\Core\Src/system_stm32g0xx.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_utils.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_exti.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_gpio.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_adc.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_dma.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_rcc.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc_ex.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_flash.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_flash_ex.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_gpio.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_dma.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_dma_ex.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr_ex.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_cortex.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_exti.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim_ex.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_tim.c;..\Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_usart.c;..\Middlewares/Third_Party/FreeRTOS/Source/croutine.c;..\Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;..\Middlewares/Third_Party/FreeRTOS/Source/list.c;..\Middlewares/Third_Party/FreeRTOS/Source/queue.c;..\Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;..\Middlewares/Third_Party/FreeRTOS/Source/tasks.c;..\Middlewares/Third_Party/FreeRTOS/Source/timers.c;..\Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c;..\Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;..\Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c;..\Core\Src/system_stm32g0xx.c;..\Drivers/CMSIS/Device/ST/STM32G0xx/Source/Templates/system_stm32g0xx.c;;..\Middlewares/Third_Party/FreeRTOS/Source/croutine.c;..\Middlewares/Third_Party/FreeRTOS/Source/event_groups.c;..\Middlewares/Third_Party/FreeRTOS/Source/list.c;..\Middlewares/Third_Party/FreeRTOS/Source/queue.c;..\Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c;..\Middlewares/Third_Party/FreeRTOS/Source/tasks.c;..\Middlewares/Third_Party/FreeRTOS/Source/timers.c;..\Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS/cmsis_os.c;..\Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c;..\Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c; | ||
6 | +HeaderPath=..\Drivers\STM32G0xx_HAL_Driver\Inc;..\Drivers\STM32G0xx_HAL_Driver\Inc\Legacy;..\Middlewares\Third_Party\FreeRTOS\Source\include;..\Middlewares\Third_Party\FreeRTOS\Source\CMSIS_RTOS;..\Middlewares\Third_Party\FreeRTOS\Source\portable\RVDS\ARM_CM0;..\Drivers\CMSIS\Device\ST\STM32G0xx\Include;..\Drivers\CMSIS\Include;..\Core\Inc; | ||
7 | +CDefines=USE_FULL_LL_DRIVER;STM32G030xx;USE_FULL_LL_DRIVER;USE_HAL_DRIVER; | ||
8 | + | ||
9 | +[PreviousGenFiles] | ||
10 | +AdvancedFolderStructure=true | ||
11 | +HeaderFileListSize=10 | ||
12 | +HeaderFiles#0=D:/test_prj/STM32G0_ProjectBase/Core/Inc/gpio.h | ||
13 | +HeaderFiles#1=D:/test_prj/STM32G0_ProjectBase/Core/Inc/FreeRTOSConfig.h | ||
14 | +HeaderFiles#2=D:/test_prj/STM32G0_ProjectBase/Core/Inc/adc.h | ||
15 | +HeaderFiles#3=D:/test_prj/STM32G0_ProjectBase/Core/Inc/dma.h | ||
16 | +HeaderFiles#4=D:/test_prj/STM32G0_ProjectBase/Core/Inc/tim.h | ||
17 | +HeaderFiles#5=D:/test_prj/STM32G0_ProjectBase/Core/Inc/usart.h | ||
18 | +HeaderFiles#6=D:/test_prj/STM32G0_ProjectBase/Core/Inc/stm32g0xx_it.h | ||
19 | +HeaderFiles#7=D:/test_prj/STM32G0_ProjectBase/Core/Inc/stm32_assert.h | ||
20 | +HeaderFiles#8=D:/test_prj/STM32G0_ProjectBase/Core/Inc/stm32g0xx_hal_conf.h | ||
21 | +HeaderFiles#9=D:/test_prj/STM32G0_ProjectBase/Core/Inc/main.h | ||
22 | +HeaderFolderListSize=1 | ||
23 | +HeaderPath#0=D:/test_prj/STM32G0_ProjectBase/Core/Inc | ||
24 | +HeaderFiles=; | ||
25 | +SourceFileListSize=10 | ||
26 | +SourceFiles#0=D:/test_prj/STM32G0_ProjectBase/Core/Src/gpio.c | ||
27 | +SourceFiles#1=D:/test_prj/STM32G0_ProjectBase/Core/Src/app_freertos.c | ||
28 | +SourceFiles#2=D:/test_prj/STM32G0_ProjectBase/Core/Src/adc.c | ||
29 | +SourceFiles#3=D:/test_prj/STM32G0_ProjectBase/Core/Src/dma.c | ||
30 | +SourceFiles#4=D:/test_prj/STM32G0_ProjectBase/Core/Src/tim.c | ||
31 | +SourceFiles#5=D:/test_prj/STM32G0_ProjectBase/Core/Src/usart.c | ||
32 | +SourceFiles#6=D:/test_prj/STM32G0_ProjectBase/Core/Src/stm32g0xx_it.c | ||
33 | +SourceFiles#7=D:/test_prj/STM32G0_ProjectBase/Core/Src/stm32g0xx_hal_msp.c | ||
34 | +SourceFiles#8=D:/test_prj/STM32G0_ProjectBase/Core/Src/stm32g0xx_hal_timebase_tim.c | ||
35 | +SourceFiles#9=D:/test_prj/STM32G0_ProjectBase/Core/Src/main.c | ||
36 | +SourceFolderListSize=1 | ||
37 | +SourcePath#0=D:/test_prj/STM32G0_ProjectBase/Core/Src | ||
38 | +SourceFiles=; | ||
39 | + |
Core/Inc/FreeRTOSConfig.h
0 → 100644
1 | +/* USER CODE BEGIN Header */ | ||
2 | +/* | ||
3 | + * FreeRTOS Kernel V10.3.1 | ||
4 | + * Portion Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
5 | + * Portion Copyright (C) 2019 StMicroelectronics, Inc. All Rights Reserved. | ||
6 | + * | ||
7 | + * Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
8 | + * this software and associated documentation files (the "Software"), to deal in | ||
9 | + * the Software without restriction, including without limitation the rights to | ||
10 | + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
11 | + * the Software, and to permit persons to whom the Software is furnished to do so, | ||
12 | + * subject to the following conditions: | ||
13 | + * | ||
14 | + * The above copyright notice and this permission notice shall be included in all | ||
15 | + * copies or substantial portions of the Software. | ||
16 | + * | ||
17 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
18 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
19 | + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
20 | + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
21 | + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
22 | + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
23 | + * | ||
24 | + * http://www.FreeRTOS.org | ||
25 | + * http://aws.amazon.com/freertos | ||
26 | + * | ||
27 | + * 1 tab == 4 spaces! | ||
28 | + */ | ||
29 | +/* USER CODE END Header */ | ||
30 | + | ||
31 | +#ifndef FREERTOS_CONFIG_H | ||
32 | +#define FREERTOS_CONFIG_H | ||
33 | + | ||
34 | +/*----------------------------------------------------------- | ||
35 | + * Application specific definitions. | ||
36 | + * | ||
37 | + * These definitions should be adjusted for your particular hardware and | ||
38 | + * application requirements. | ||
39 | + * | ||
40 | + * These parameters and more are described within the 'configuration' section of the | ||
41 | + * FreeRTOS API documentation available on the FreeRTOS.org web site. | ||
42 | + * | ||
43 | + * See http://www.freertos.org/a00110.html | ||
44 | + *----------------------------------------------------------*/ | ||
45 | + | ||
46 | +/* USER CODE BEGIN Includes */ | ||
47 | +/* Section where include file can be added */ | ||
48 | +/* USER CODE END Includes */ | ||
49 | + | ||
50 | +/* Ensure definitions are only used by the compiler, and not by the assembler. */ | ||
51 | +#if defined(__ICCARM__) || defined(__CC_ARM) || defined(__GNUC__) | ||
52 | + #include <stdint.h> | ||
53 | + extern uint32_t SystemCoreClock; | ||
54 | +#endif | ||
55 | +#define configENABLE_FPU 0 | ||
56 | +#define configENABLE_MPU 0 | ||
57 | + | ||
58 | +#define configUSE_PREEMPTION 1 | ||
59 | +#define configSUPPORT_STATIC_ALLOCATION 0 | ||
60 | +#define configSUPPORT_DYNAMIC_ALLOCATION 1 | ||
61 | +#define configUSE_IDLE_HOOK 0 | ||
62 | +#define configUSE_TICK_HOOK 0 | ||
63 | +#define configCPU_CLOCK_HZ ( SystemCoreClock ) | ||
64 | +#define configTICK_RATE_HZ ((TickType_t)1000) | ||
65 | +#define configMAX_PRIORITIES ( 7 ) | ||
66 | +#define configMINIMAL_STACK_SIZE ((uint16_t)128) | ||
67 | +#define configTOTAL_HEAP_SIZE ((size_t)3072) | ||
68 | +#define configMAX_TASK_NAME_LEN ( 16 ) | ||
69 | +#define configUSE_16_BIT_TICKS 0 | ||
70 | +#define configUSE_MUTEXES 1 | ||
71 | +#define configQUEUE_REGISTRY_SIZE 8 | ||
72 | +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 | ||
73 | +/* USER CODE BEGIN MESSAGE_BUFFER_LENGTH_TYPE */ | ||
74 | +/* Defaults to size_t for backward compatibility, but can be changed | ||
75 | + if lengths will always be less than the number of bytes in a size_t. */ | ||
76 | +#define configMESSAGE_BUFFER_LENGTH_TYPE size_t | ||
77 | +/* USER CODE END MESSAGE_BUFFER_LENGTH_TYPE */ | ||
78 | + | ||
79 | +/* Co-routine definitions. */ | ||
80 | +#define configUSE_CO_ROUTINES 0 | ||
81 | +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) | ||
82 | + | ||
83 | +/* Set the following definitions to 1 to include the API function, or zero | ||
84 | +to exclude the API function. */ | ||
85 | +#define INCLUDE_vTaskPrioritySet 1 | ||
86 | +#define INCLUDE_uxTaskPriorityGet 1 | ||
87 | +#define INCLUDE_vTaskDelete 1 | ||
88 | +#define INCLUDE_vTaskCleanUpResources 0 | ||
89 | +#define INCLUDE_vTaskSuspend 1 | ||
90 | +#define INCLUDE_vTaskDelayUntil 0 | ||
91 | +#define INCLUDE_vTaskDelay 1 | ||
92 | +#define INCLUDE_xTaskGetSchedulerState 1 | ||
93 | + | ||
94 | +/* Normal assert() semantics without relying on the provision of an assert.h | ||
95 | +header file. */ | ||
96 | +/* USER CODE BEGIN 1 */ | ||
97 | +#define configASSERT( x ) if ((x) == 0) {taskDISABLE_INTERRUPTS(); for( ;; );} | ||
98 | +/* USER CODE END 1 */ | ||
99 | + | ||
100 | +/* Definitions that map the FreeRTOS port interrupt handlers to their CMSIS | ||
101 | +standard names. */ | ||
102 | +#define vPortSVCHandler SVC_Handler | ||
103 | +#define xPortPendSVHandler PendSV_Handler | ||
104 | + | ||
105 | +/* IMPORTANT: This define is commented when used with STM32Cube firmware, when the timebase source is SysTick, | ||
106 | + to prevent overwriting SysTick_Handler defined within STM32Cube HAL */ | ||
107 | + | ||
108 | +#define xPortSysTickHandler SysTick_Handler | ||
109 | + | ||
110 | +/* USER CODE BEGIN Defines */ | ||
111 | +/* Section where parameter definitions can be added (for instance, to override default ones in FreeRTOS.h) */ | ||
112 | +/* USER CODE END Defines */ | ||
113 | + | ||
114 | +#endif /* FREERTOS_CONFIG_H */ |
Core/Inc/adc.h
0 → 100644
1 | +/** | ||
2 | + ****************************************************************************** | ||
3 | + * @file adc.h | ||
4 | + * @brief This file contains all the function prototypes for | ||
5 | + * the adc.c file | ||
6 | + ****************************************************************************** | ||
7 | + * @attention | ||
8 | + * | ||
9 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
10 | + * All rights reserved.</center></h2> | ||
11 | + * | ||
12 | + * This software component is licensed by ST under Ultimate Liberty license | ||
13 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
14 | + * the License. You may obtain a copy of the License at: | ||
15 | + * www.st.com/SLA0044 | ||
16 | + * | ||
17 | + ****************************************************************************** | ||
18 | + */ | ||
19 | +/* Define to prevent recursive inclusion -------------------------------------*/ | ||
20 | +#ifndef __ADC_H__ | ||
21 | +#define __ADC_H__ | ||
22 | + | ||
23 | +#ifdef __cplusplus | ||
24 | +extern "C" { | ||
25 | +#endif | ||
26 | + | ||
27 | +/* Includes ------------------------------------------------------------------*/ | ||
28 | +#include "main.h" | ||
29 | + | ||
30 | +/* USER CODE BEGIN Includes */ | ||
31 | + | ||
32 | +/* USER CODE END Includes */ | ||
33 | + | ||
34 | +/* USER CODE BEGIN Private defines */ | ||
35 | + | ||
36 | +/* USER CODE END Private defines */ | ||
37 | + | ||
38 | +void MX_ADC1_Init(void); | ||
39 | + | ||
40 | +/* USER CODE BEGIN Prototypes */ | ||
41 | + | ||
42 | +/* USER CODE END Prototypes */ | ||
43 | + | ||
44 | +#ifdef __cplusplus | ||
45 | +} | ||
46 | +#endif | ||
47 | + | ||
48 | +#endif /* __ADC_H__ */ | ||
49 | + | ||
50 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Inc/dma.h
0 → 100644
1 | +/** | ||
2 | + ****************************************************************************** | ||
3 | + * @file dma.h | ||
4 | + * @brief This file contains all the function prototypes for | ||
5 | + * the dma.c file | ||
6 | + ****************************************************************************** | ||
7 | + * @attention | ||
8 | + * | ||
9 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
10 | + * All rights reserved.</center></h2> | ||
11 | + * | ||
12 | + * This software component is licensed by ST under Ultimate Liberty license | ||
13 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
14 | + * the License. You may obtain a copy of the License at: | ||
15 | + * www.st.com/SLA0044 | ||
16 | + * | ||
17 | + ****************************************************************************** | ||
18 | + */ | ||
19 | +/* Define to prevent recursive inclusion -------------------------------------*/ | ||
20 | +#ifndef __DMA_H__ | ||
21 | +#define __DMA_H__ | ||
22 | + | ||
23 | +#ifdef __cplusplus | ||
24 | +extern "C" { | ||
25 | +#endif | ||
26 | + | ||
27 | +/* Includes ------------------------------------------------------------------*/ | ||
28 | +#include "main.h" | ||
29 | + | ||
30 | +/* DMA memory to memory transfer handles -------------------------------------*/ | ||
31 | + | ||
32 | +/* USER CODE BEGIN Includes */ | ||
33 | + | ||
34 | +/* USER CODE END Includes */ | ||
35 | + | ||
36 | +/* USER CODE BEGIN Private defines */ | ||
37 | + | ||
38 | +/* USER CODE END Private defines */ | ||
39 | + | ||
40 | +void MX_DMA_Init(void); | ||
41 | + | ||
42 | +/* USER CODE BEGIN Prototypes */ | ||
43 | + | ||
44 | +/* USER CODE END Prototypes */ | ||
45 | + | ||
46 | +#ifdef __cplusplus | ||
47 | +} | ||
48 | +#endif | ||
49 | + | ||
50 | +#endif /* __DMA_H__ */ | ||
51 | + | ||
52 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Inc/gpio.h
0 → 100644
1 | +/** | ||
2 | + ****************************************************************************** | ||
3 | + * @file gpio.h | ||
4 | + * @brief This file contains all the function prototypes for | ||
5 | + * the gpio.c file | ||
6 | + ****************************************************************************** | ||
7 | + * @attention | ||
8 | + * | ||
9 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
10 | + * All rights reserved.</center></h2> | ||
11 | + * | ||
12 | + * This software component is licensed by ST under Ultimate Liberty license | ||
13 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
14 | + * the License. You may obtain a copy of the License at: | ||
15 | + * www.st.com/SLA0044 | ||
16 | + * | ||
17 | + ****************************************************************************** | ||
18 | + */ | ||
19 | +/* Define to prevent recursive inclusion -------------------------------------*/ | ||
20 | +#ifndef __GPIO_H__ | ||
21 | +#define __GPIO_H__ | ||
22 | + | ||
23 | +#ifdef __cplusplus | ||
24 | +extern "C" { | ||
25 | +#endif | ||
26 | + | ||
27 | +/* Includes ------------------------------------------------------------------*/ | ||
28 | +#include "main.h" | ||
29 | + | ||
30 | +/* USER CODE BEGIN Includes */ | ||
31 | + | ||
32 | +/* USER CODE END Includes */ | ||
33 | + | ||
34 | +/* USER CODE BEGIN Private defines */ | ||
35 | + | ||
36 | +/* USER CODE END Private defines */ | ||
37 | + | ||
38 | +void MX_GPIO_Init(void); | ||
39 | + | ||
40 | +/* USER CODE BEGIN Prototypes */ | ||
41 | + | ||
42 | +/* USER CODE END Prototypes */ | ||
43 | + | ||
44 | +#ifdef __cplusplus | ||
45 | +} | ||
46 | +#endif | ||
47 | +#endif /*__ GPIO_H__ */ | ||
48 | + | ||
49 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Inc/main.h
0 → 100644
1 | +/* USER CODE BEGIN Header */ | ||
2 | +/** | ||
3 | + ****************************************************************************** | ||
4 | + * @file : main.h | ||
5 | + * @brief : Header for main.c file. | ||
6 | + * This file contains the common defines of the application. | ||
7 | + ****************************************************************************** | ||
8 | + * @attention | ||
9 | + * | ||
10 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
11 | + * All rights reserved.</center></h2> | ||
12 | + * | ||
13 | + * This software component is licensed by ST under Ultimate Liberty license | ||
14 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
15 | + * the License. You may obtain a copy of the License at: | ||
16 | + * www.st.com/SLA0044 | ||
17 | + * | ||
18 | + ****************************************************************************** | ||
19 | + */ | ||
20 | +/* USER CODE END Header */ | ||
21 | + | ||
22 | +/* Define to prevent recursive inclusion -------------------------------------*/ | ||
23 | +#ifndef __MAIN_H | ||
24 | +#define __MAIN_H | ||
25 | + | ||
26 | +#ifdef __cplusplus | ||
27 | +extern "C" { | ||
28 | +#endif | ||
29 | + | ||
30 | +/* Includes ------------------------------------------------------------------*/ | ||
31 | +#include "stm32g0xx_hal.h" | ||
32 | + | ||
33 | +#include "stm32g0xx_ll_adc.h" | ||
34 | +#include "stm32g0xx_ll_dma.h" | ||
35 | +#include "stm32g0xx_ll_rcc.h" | ||
36 | +#include "stm32g0xx_ll_bus.h" | ||
37 | +#include "stm32g0xx_ll_system.h" | ||
38 | +#include "stm32g0xx_ll_exti.h" | ||
39 | +#include "stm32g0xx_ll_cortex.h" | ||
40 | +#include "stm32g0xx_ll_utils.h" | ||
41 | +#include "stm32g0xx_ll_pwr.h" | ||
42 | +#include "stm32g0xx_ll_tim.h" | ||
43 | +#include "stm32g0xx_ll_usart.h" | ||
44 | +#include "stm32g0xx_ll_gpio.h" | ||
45 | + | ||
46 | +/* Private includes ----------------------------------------------------------*/ | ||
47 | +/* USER CODE BEGIN Includes */ | ||
48 | + | ||
49 | +/* USER CODE END Includes */ | ||
50 | + | ||
51 | +/* Exported types ------------------------------------------------------------*/ | ||
52 | +/* USER CODE BEGIN ET */ | ||
53 | + | ||
54 | +/* USER CODE END ET */ | ||
55 | + | ||
56 | +/* Exported constants --------------------------------------------------------*/ | ||
57 | +/* USER CODE BEGIN EC */ | ||
58 | + | ||
59 | +/* USER CODE END EC */ | ||
60 | + | ||
61 | +/* Exported macro ------------------------------------------------------------*/ | ||
62 | +/* USER CODE BEGIN EM */ | ||
63 | + | ||
64 | +/* USER CODE END EM */ | ||
65 | + | ||
66 | +/* Exported functions prototypes ---------------------------------------------*/ | ||
67 | +void Error_Handler(void); | ||
68 | + | ||
69 | +/* USER CODE BEGIN EFP */ | ||
70 | + | ||
71 | +/* USER CODE END EFP */ | ||
72 | + | ||
73 | +/* Private defines -----------------------------------------------------------*/ | ||
74 | +#define ADC1_IN0_Pin LL_GPIO_PIN_0 | ||
75 | +#define ADC1_IN0_GPIO_Port GPIOA | ||
76 | +#define ADC1_IN1_Pin LL_GPIO_PIN_1 | ||
77 | +#define ADC1_IN1_GPIO_Port GPIOA | ||
78 | +/* USER CODE BEGIN Private defines */ | ||
79 | + | ||
80 | +/* USER CODE END Private defines */ | ||
81 | + | ||
82 | +#ifdef __cplusplus | ||
83 | +} | ||
84 | +#endif | ||
85 | + | ||
86 | +#endif /* __MAIN_H */ | ||
87 | + | ||
88 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Inc/stm32_assert.h
0 → 100644
1 | +/** | ||
2 | + ****************************************************************************** | ||
3 | + * @file stm32_assert.h | ||
4 | + * @brief STM32 assert file. | ||
5 | + ****************************************************************************** | ||
6 | + * @attention | ||
7 | + * | ||
8 | + * <h2><center>© Copyright (c) 2018 STMicroelectronics. | ||
9 | + * All rights reserved.</center></h2> | ||
10 | + * | ||
11 | + * This software component is licensed by ST under BSD 3-Clause license, | ||
12 | + * the "License"; You may not use this file except in compliance with the | ||
13 | + * License. You may obtain a copy of the License at: | ||
14 | + * opensource.org/licenses/BSD-3-Clause | ||
15 | + * | ||
16 | + ****************************************************************************** | ||
17 | + */ | ||
18 | + | ||
19 | +/* Define to prevent recursive inclusion -------------------------------------*/ | ||
20 | +#ifndef __STM32_ASSERT_H | ||
21 | +#define __STM32_ASSERT_H | ||
22 | + | ||
23 | +#ifdef __cplusplus | ||
24 | + extern "C" { | ||
25 | +#endif | ||
26 | + | ||
27 | +/* Exported types ------------------------------------------------------------*/ | ||
28 | +/* Exported constants --------------------------------------------------------*/ | ||
29 | +/* Includes ------------------------------------------------------------------*/ | ||
30 | +/* Exported macro ------------------------------------------------------------*/ | ||
31 | +#ifdef USE_FULL_ASSERT | ||
32 | +/** | ||
33 | + * @brief The assert_param macro is used for function's parameters check. | ||
34 | + * @param expr: If expr is false, it calls assert_failed function | ||
35 | + * which reports the name of the source file and the source | ||
36 | + * line number of the call that failed. | ||
37 | + * If expr is true, it returns no value. | ||
38 | + * @retval None | ||
39 | + */ | ||
40 | + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) | ||
41 | +/* Exported functions ------------------------------------------------------- */ | ||
42 | + void assert_failed(uint8_t* file, uint32_t line); | ||
43 | +#else | ||
44 | + #define assert_param(expr) ((void)0U) | ||
45 | +#endif /* USE_FULL_ASSERT */ | ||
46 | + | ||
47 | +#ifdef __cplusplus | ||
48 | +} | ||
49 | +#endif | ||
50 | + | ||
51 | +#endif /* __STM32_ASSERT_H */ | ||
52 | + | ||
53 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Inc/stm32g0xx_hal_conf.h
0 → 100644
1 | +/** | ||
2 | + ****************************************************************************** | ||
3 | + * @file stm32g0xx_hal_conf.h | ||
4 | + * @author MCD Application Team | ||
5 | + * @brief HAL configuration file. | ||
6 | + ****************************************************************************** | ||
7 | + * @attention | ||
8 | + * | ||
9 | + * <h2><center>© Copyright (c) 2018 STMicroelectronics. | ||
10 | + * All rights reserved.</center></h2> | ||
11 | + * | ||
12 | + * This software component is licensed by ST under BSD 3-Clause license, | ||
13 | + * the "License"; You may not use this file except in compliance with the | ||
14 | + * License. You may obtain a copy of the License at: | ||
15 | + * opensource.org/licenses/BSD-3-Clause | ||
16 | + * | ||
17 | + ****************************************************************************** | ||
18 | + */ | ||
19 | + | ||
20 | +/* Define to prevent recursive inclusion -------------------------------------*/ | ||
21 | +#ifndef STM32G0xx_HAL_CONF_H | ||
22 | +#define STM32G0xx_HAL_CONF_H | ||
23 | + | ||
24 | +#ifdef __cplusplus | ||
25 | +extern "C" { | ||
26 | +#endif | ||
27 | + | ||
28 | +/* Exported types ------------------------------------------------------------*/ | ||
29 | +/* Exported constants --------------------------------------------------------*/ | ||
30 | + | ||
31 | +/* ########################## Module Selection ############################## */ | ||
32 | +/** | ||
33 | + * @brief This is the list of modules to be used in the HAL driver | ||
34 | + */ | ||
35 | +#define HAL_MODULE_ENABLED | ||
36 | +/* #define HAL_ADC_MODULE_ENABLED */ | ||
37 | +/* #define HAL_CEC_MODULE_ENABLED */ | ||
38 | +/* #define HAL_COMP_MODULE_ENABLED */ | ||
39 | +/* #define HAL_CRC_MODULE_ENABLED */ | ||
40 | +/* #define HAL_CRYP_MODULE_ENABLED */ | ||
41 | +/* #define HAL_DAC_MODULE_ENABLED */ | ||
42 | +/* #define HAL_EXTI_MODULE_ENABLED */ | ||
43 | +/* #define HAL_FDCAN_MODULE_ENABLED */ | ||
44 | +/* #define HAL_HCD_MODULE_ENABLED */ | ||
45 | +/* #define HAL_I2C_MODULE_ENABLED */ | ||
46 | +/* #define HAL_I2S_MODULE_ENABLED */ | ||
47 | +/* #define HAL_IWDG_MODULE_ENABLED */ | ||
48 | +/* #define HAL_IRDA_MODULE_ENABLED */ | ||
49 | +/* #define HAL_LPTIM_MODULE_ENABLED */ | ||
50 | +/* #define HAL_PCD_MODULE_ENABLED */ | ||
51 | +/* #define HAL_RNG_MODULE_ENABLED */ | ||
52 | +/* #define HAL_RTC_MODULE_ENABLED */ | ||
53 | +/* #define HAL_SMARTCARD_MODULE_ENABLED */ | ||
54 | +/* #define HAL_SMBUS_MODULE_ENABLED */ | ||
55 | +/* #define HAL_SPI_MODULE_ENABLED */ | ||
56 | +#define HAL_TIM_MODULE_ENABLED | ||
57 | +/* #define HAL_UART_MODULE_ENABLED */ | ||
58 | +/* #define HAL_USART_MODULE_ENABLED */ | ||
59 | +/* #define HAL_WWDG_MODULE_ENABLED */ | ||
60 | +#define HAL_GPIO_MODULE_ENABLED | ||
61 | +#define HAL_EXTI_MODULE_ENABLED | ||
62 | +#define HAL_DMA_MODULE_ENABLED | ||
63 | +#define HAL_RCC_MODULE_ENABLED | ||
64 | +#define HAL_FLASH_MODULE_ENABLED | ||
65 | +#define HAL_PWR_MODULE_ENABLED | ||
66 | +#define HAL_CORTEX_MODULE_ENABLED | ||
67 | + | ||
68 | +/* ########################## Register Callbacks selection ############################## */ | ||
69 | +/** | ||
70 | + * @brief This is the list of modules where register callback can be used | ||
71 | + */ | ||
72 | +#define USE_HAL_ADC_REGISTER_CALLBACKS 0u | ||
73 | +#define USE_HAL_CEC_REGISTER_CALLBACKS 0u | ||
74 | +#define USE_HAL_COMP_REGISTER_CALLBACKS 0u | ||
75 | +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0u | ||
76 | +#define USE_HAL_DAC_REGISTER_CALLBACKS 0u | ||
77 | +#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0u | ||
78 | +#define USE_HAL_HCD_REGISTER_CALLBACKS 0u | ||
79 | +#define USE_HAL_I2C_REGISTER_CALLBACKS 0u | ||
80 | +#define USE_HAL_I2S_REGISTER_CALLBACKS 0u | ||
81 | +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0u | ||
82 | +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0u | ||
83 | +#define USE_HAL_PCD_REGISTER_CALLBACKS 0u | ||
84 | +#define USE_HAL_RNG_REGISTER_CALLBACKS 0u | ||
85 | +#define USE_HAL_RTC_REGISTER_CALLBACKS 0u | ||
86 | +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0u | ||
87 | +#define USE_HAL_SPI_REGISTER_CALLBACKS 0u | ||
88 | +#define USE_HAL_TIM_REGISTER_CALLBACKS 0u | ||
89 | +#define USE_HAL_UART_REGISTER_CALLBACKS 0u | ||
90 | +#define USE_HAL_USART_REGISTER_CALLBACKS 0u | ||
91 | +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0u | ||
92 | + | ||
93 | +/* ########################## Oscillator Values adaptation ####################*/ | ||
94 | +/** | ||
95 | + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. | ||
96 | + * This value is used by the RCC HAL module to compute the system frequency | ||
97 | + * (when HSE is used as system clock source, directly or through the PLL). | ||
98 | + */ | ||
99 | +#if !defined (HSE_VALUE) | ||
100 | +#define HSE_VALUE (8000000UL) /*!< Value of the External oscillator in Hz */ | ||
101 | +#endif /* HSE_VALUE */ | ||
102 | + | ||
103 | +#if !defined (HSE_STARTUP_TIMEOUT) | ||
104 | +#define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */ | ||
105 | +#endif /* HSE_STARTUP_TIMEOUT */ | ||
106 | + | ||
107 | +/** | ||
108 | + * @brief Internal High Speed oscillator (HSI) value. | ||
109 | + * This value is used by the RCC HAL module to compute the system frequency | ||
110 | + * (when HSI is used as system clock source, directly or through the PLL). | ||
111 | + */ | ||
112 | +#if !defined (HSI_VALUE) | ||
113 | +#define HSI_VALUE (16000000UL) /*!< Value of the Internal oscillator in Hz*/ | ||
114 | +#endif /* HSI_VALUE */ | ||
115 | + | ||
116 | +#if defined(STM32G0C1xx) || defined(STM32G0B1xx) || defined(STM32G0B0xx) | ||
117 | +/** | ||
118 | + * @brief Internal High Speed oscillator (HSI48) value for USB FS, SDMMC and RNG. | ||
119 | + * This internal oscillator is mainly dedicated to provide a high precision clock to | ||
120 | + * the USB peripheral by means of a special Clock Recovery System (CRS) circuitry. | ||
121 | + * When the CRS is not used, the HSI48 RC oscillator runs on it default frequency | ||
122 | + * which is subject to manufacturing process variations. | ||
123 | + */ | ||
124 | +#if !defined (HSI48_VALUE) | ||
125 | + #define HSI48_VALUE 48000000U /*!< Value of the Internal High Speed oscillator for USB FS/SDMMC/RNG in Hz. | ||
126 | + The real value my vary depending on manufacturing process variations.*/ | ||
127 | +#endif /* HSI48_VALUE */ | ||
128 | +#endif | ||
129 | + | ||
130 | +/** | ||
131 | + * @brief Internal Low Speed oscillator (LSI) value. | ||
132 | + */ | ||
133 | +#if !defined (LSI_VALUE) | ||
134 | +#define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/ | ||
135 | +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz | ||
136 | +The real value may vary depending on the variations | ||
137 | +in voltage and temperature.*/ | ||
138 | +/** | ||
139 | + * @brief External Low Speed oscillator (LSE) value. | ||
140 | + * This value is used by the UART, RTC HAL module to compute the system frequency | ||
141 | + */ | ||
142 | +#if !defined (LSE_VALUE) | ||
143 | +#define LSE_VALUE (32768UL) /*!< Value of the External oscillator in Hz*/ | ||
144 | +#endif /* LSE_VALUE */ | ||
145 | + | ||
146 | +#if !defined (LSE_STARTUP_TIMEOUT) | ||
147 | +#define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */ | ||
148 | +#endif /* LSE_STARTUP_TIMEOUT */ | ||
149 | + | ||
150 | +/** | ||
151 | + * @brief External clock source for I2S1 peripheral | ||
152 | + * This value is used by the RCC HAL module to compute the I2S1 clock source | ||
153 | + * frequency. | ||
154 | + */ | ||
155 | +#if !defined (EXTERNAL_I2S1_CLOCK_VALUE) | ||
156 | +#define EXTERNAL_I2S1_CLOCK_VALUE (12288000UL) /*!< Value of the I2S1 External clock source in Hz*/ | ||
157 | +#endif /* EXTERNAL_I2S1_CLOCK_VALUE */ | ||
158 | + | ||
159 | +#if defined(STM32G0C1xx) || defined(STM32G0B1xx) || defined(STM32G0B0xx) | ||
160 | +/** | ||
161 | + * @brief External clock source for I2S2 peripheral | ||
162 | + * This value is used by the RCC HAL module to compute the I2S2 clock source | ||
163 | + * frequency. | ||
164 | + */ | ||
165 | +#if !defined (EXTERNAL_I2S2_CLOCK_VALUE) | ||
166 | + #define EXTERNAL_I2S2_CLOCK_VALUE 48000U /*!< Value of the I2S2 External clock source in Hz*/ | ||
167 | +#endif /* EXTERNAL_I2S2_CLOCK_VALUE */ | ||
168 | +#endif | ||
169 | + | ||
170 | +/* Tip: To avoid modifying this file each time you need to use different HSE, | ||
171 | + === you can define the HSE value in your toolchain compiler preprocessor. */ | ||
172 | + | ||
173 | +/* ########################### System Configuration ######################### */ | ||
174 | +/** | ||
175 | + * @brief This is the HAL system configuration section | ||
176 | + */ | ||
177 | +#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */ | ||
178 | +#define TICK_INT_PRIORITY 0U /*!< tick interrupt priority */ | ||
179 | +#define USE_RTOS 0U | ||
180 | +#define PREFETCH_ENABLE 1U | ||
181 | +#define INSTRUCTION_CACHE_ENABLE 1U | ||
182 | + | ||
183 | +/* ################## SPI peripheral configuration ########################## */ | ||
184 | + | ||
185 | +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver | ||
186 | +* Activated: CRC code is present inside driver | ||
187 | +* Deactivated: CRC code cleaned from driver | ||
188 | +*/ | ||
189 | + | ||
190 | +#define USE_SPI_CRC 0U | ||
191 | + | ||
192 | +/* ################## CRYP peripheral configuration ########################## */ | ||
193 | + | ||
194 | +#define USE_HAL_CRYP_SUSPEND_RESUME 1U | ||
195 | + | ||
196 | +/* ########################## Assert Selection ############################## */ | ||
197 | +/** | ||
198 | + * @brief Uncomment the line below to expanse the "assert_param" macro in the | ||
199 | + * HAL drivers code | ||
200 | + */ | ||
201 | +/* #define USE_FULL_ASSERT 1U */ | ||
202 | + | ||
203 | +/* Includes ------------------------------------------------------------------*/ | ||
204 | +/** | ||
205 | + * @brief Include modules header file | ||
206 | + */ | ||
207 | + | ||
208 | +#ifdef HAL_RCC_MODULE_ENABLED | ||
209 | +#include "stm32g0xx_hal_rcc.h" | ||
210 | +#endif /* HAL_RCC_MODULE_ENABLED */ | ||
211 | + | ||
212 | +#ifdef HAL_GPIO_MODULE_ENABLED | ||
213 | +#include "stm32g0xx_hal_gpio.h" | ||
214 | +#endif /* HAL_GPIO_MODULE_ENABLED */ | ||
215 | + | ||
216 | +#ifdef HAL_DMA_MODULE_ENABLED | ||
217 | +#include "stm32g0xx_hal_dma.h" | ||
218 | +#endif /* HAL_DMA_MODULE_ENABLED */ | ||
219 | + | ||
220 | +#ifdef HAL_CORTEX_MODULE_ENABLED | ||
221 | +#include "stm32g0xx_hal_cortex.h" | ||
222 | +#endif /* HAL_CORTEX_MODULE_ENABLED */ | ||
223 | + | ||
224 | +#ifdef HAL_ADC_MODULE_ENABLED | ||
225 | +#include "stm32g0xx_hal_adc.h" | ||
226 | +#include "stm32g0xx_hal_adc_ex.h" | ||
227 | +#endif /* HAL_ADC_MODULE_ENABLED */ | ||
228 | + | ||
229 | +#ifdef HAL_CEC_MODULE_ENABLED | ||
230 | +#include "stm32g0xx_hal_cec.h" | ||
231 | +#endif /* HAL_CEC_MODULE_ENABLED */ | ||
232 | + | ||
233 | +#ifdef HAL_COMP_MODULE_ENABLED | ||
234 | +#include "stm32g0xx_hal_comp.h" | ||
235 | +#endif /* HAL_COMP_MODULE_ENABLED */ | ||
236 | + | ||
237 | +#ifdef HAL_CRC_MODULE_ENABLED | ||
238 | +#include "stm32g0xx_hal_crc.h" | ||
239 | +#endif /* HAL_CRC_MODULE_ENABLED */ | ||
240 | + | ||
241 | +#ifdef HAL_CRYP_MODULE_ENABLED | ||
242 | +#include "stm32g0xx_hal_cryp.h" | ||
243 | +#endif /* HAL_CRYP_MODULE_ENABLED */ | ||
244 | + | ||
245 | +#ifdef HAL_DAC_MODULE_ENABLED | ||
246 | +#include "stm32g0xx_hal_dac.h" | ||
247 | +#endif /* HAL_DAC_MODULE_ENABLED */ | ||
248 | + | ||
249 | +#ifdef HAL_EXTI_MODULE_ENABLED | ||
250 | +#include "stm32g0xx_hal_exti.h" | ||
251 | +#endif /* HAL_EXTI_MODULE_ENABLED */ | ||
252 | + | ||
253 | +#ifdef HAL_FLASH_MODULE_ENABLED | ||
254 | +#include "stm32g0xx_hal_flash.h" | ||
255 | +#endif /* HAL_FLASH_MODULE_ENABLED */ | ||
256 | + | ||
257 | +#ifdef HAL_FDCAN_MODULE_ENABLED | ||
258 | +#include "stm32g0xx_hal_fdcan.h" | ||
259 | +#endif /* HAL_FDCAN_MODULE_ENABLED */ | ||
260 | + | ||
261 | +#ifdef HAL_HCD_MODULE_ENABLED | ||
262 | +#include "stm32g0xx_hal_hcd.h" | ||
263 | +#endif /* HAL_HCD_MODULE_ENABLED */ | ||
264 | + | ||
265 | +#ifdef HAL_I2C_MODULE_ENABLED | ||
266 | +#include "stm32g0xx_hal_i2c.h" | ||
267 | +#endif /* HAL_I2C_MODULE_ENABLED */ | ||
268 | + | ||
269 | +#ifdef HAL_I2S_MODULE_ENABLED | ||
270 | +#include "stm32g0xx_hal_i2s.h" | ||
271 | +#endif /* HAL_I2S_MODULE_ENABLED */ | ||
272 | + | ||
273 | +#ifdef HAL_IRDA_MODULE_ENABLED | ||
274 | +#include "stm32g0xx_hal_irda.h" | ||
275 | +#endif /* HAL_IRDA_MODULE_ENABLED */ | ||
276 | + | ||
277 | +#ifdef HAL_IWDG_MODULE_ENABLED | ||
278 | +#include "stm32g0xx_hal_iwdg.h" | ||
279 | +#endif /* HAL_IWDG_MODULE_ENABLED */ | ||
280 | + | ||
281 | +#ifdef HAL_LPTIM_MODULE_ENABLED | ||
282 | +#include "stm32g0xx_hal_lptim.h" | ||
283 | +#endif /* HAL_LPTIM_MODULE_ENABLED */ | ||
284 | + | ||
285 | +#ifdef HAL_PCD_MODULE_ENABLED | ||
286 | +#include "stm32g0xx_hal_pcd.h" | ||
287 | +#endif /* HAL_PCD_MODULE_ENABLED */ | ||
288 | + | ||
289 | +#ifdef HAL_PWR_MODULE_ENABLED | ||
290 | +#include "stm32g0xx_hal_pwr.h" | ||
291 | +#endif /* HAL_PWR_MODULE_ENABLED */ | ||
292 | + | ||
293 | +#ifdef HAL_RNG_MODULE_ENABLED | ||
294 | +#include "stm32g0xx_hal_rng.h" | ||
295 | +#endif /* HAL_RNG_MODULE_ENABLED */ | ||
296 | + | ||
297 | +#ifdef HAL_RTC_MODULE_ENABLED | ||
298 | +#include "stm32g0xx_hal_rtc.h" | ||
299 | +#endif /* HAL_RTC_MODULE_ENABLED */ | ||
300 | + | ||
301 | +#ifdef HAL_SMARTCARD_MODULE_ENABLED | ||
302 | +#include "stm32g0xx_hal_smartcard.h" | ||
303 | +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ | ||
304 | + | ||
305 | +#ifdef HAL_SMBUS_MODULE_ENABLED | ||
306 | +#include "stm32g0xx_hal_smbus.h" | ||
307 | +#endif /* HAL_SMBUS_MODULE_ENABLED */ | ||
308 | + | ||
309 | +#ifdef HAL_SPI_MODULE_ENABLED | ||
310 | +#include "stm32g0xx_hal_spi.h" | ||
311 | +#endif /* HAL_SPI_MODULE_ENABLED */ | ||
312 | + | ||
313 | +#ifdef HAL_TIM_MODULE_ENABLED | ||
314 | +#include "stm32g0xx_hal_tim.h" | ||
315 | +#endif /* HAL_TIM_MODULE_ENABLED */ | ||
316 | + | ||
317 | +#ifdef HAL_UART_MODULE_ENABLED | ||
318 | +#include "stm32g0xx_hal_uart.h" | ||
319 | +#endif /* HAL_UART_MODULE_ENABLED */ | ||
320 | + | ||
321 | +#ifdef HAL_USART_MODULE_ENABLED | ||
322 | +#include "stm32g0xx_hal_usart.h" | ||
323 | +#endif /* HAL_USART_MODULE_ENABLED */ | ||
324 | + | ||
325 | +#ifdef HAL_WWDG_MODULE_ENABLED | ||
326 | +#include "stm32g0xx_hal_wwdg.h" | ||
327 | +#endif /* HAL_WWDG_MODULE_ENABLED */ | ||
328 | + | ||
329 | +/* Exported macro ------------------------------------------------------------*/ | ||
330 | +#ifdef USE_FULL_ASSERT | ||
331 | +/** | ||
332 | + * @brief The assert_param macro is used for functions parameters check. | ||
333 | + * @param expr If expr is false, it calls assert_failed function | ||
334 | + * which reports the name of the source file and the source | ||
335 | + * line number of the call that failed. | ||
336 | + * If expr is true, it returns no value. | ||
337 | + * @retval None | ||
338 | + */ | ||
339 | +#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) | ||
340 | +/* Exported functions ------------------------------------------------------- */ | ||
341 | +void assert_failed(uint8_t *file, uint32_t line); | ||
342 | +#else | ||
343 | +#define assert_param(expr) ((void)0U) | ||
344 | +#endif /* USE_FULL_ASSERT */ | ||
345 | + | ||
346 | +#ifdef __cplusplus | ||
347 | +} | ||
348 | +#endif | ||
349 | + | ||
350 | +#endif /* STM32G0xx_HAL_CONF_H */ | ||
351 | + | ||
352 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Inc/stm32g0xx_it.h
0 → 100644
1 | +/* USER CODE BEGIN Header */ | ||
2 | +/** | ||
3 | + ****************************************************************************** | ||
4 | + * @file stm32g0xx_it.h | ||
5 | + * @brief This file contains the headers of the interrupt handlers. | ||
6 | + ****************************************************************************** | ||
7 | + * @attention | ||
8 | + * | ||
9 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
10 | + * All rights reserved.</center></h2> | ||
11 | + * | ||
12 | + * This software component is licensed by ST under Ultimate Liberty license | ||
13 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
14 | + * the License. You may obtain a copy of the License at: | ||
15 | + * www.st.com/SLA0044 | ||
16 | + * | ||
17 | + ****************************************************************************** | ||
18 | + */ | ||
19 | +/* USER CODE END Header */ | ||
20 | + | ||
21 | +/* Define to prevent recursive inclusion -------------------------------------*/ | ||
22 | +#ifndef __STM32G0xx_IT_H | ||
23 | +#define __STM32G0xx_IT_H | ||
24 | + | ||
25 | +#ifdef __cplusplus | ||
26 | + extern "C" { | ||
27 | +#endif | ||
28 | + | ||
29 | +/* Private includes ----------------------------------------------------------*/ | ||
30 | +/* USER CODE BEGIN Includes */ | ||
31 | + | ||
32 | +/* USER CODE END Includes */ | ||
33 | + | ||
34 | +/* Exported types ------------------------------------------------------------*/ | ||
35 | +/* USER CODE BEGIN ET */ | ||
36 | + | ||
37 | +/* USER CODE END ET */ | ||
38 | + | ||
39 | +/* Exported constants --------------------------------------------------------*/ | ||
40 | +/* USER CODE BEGIN EC */ | ||
41 | + | ||
42 | +/* USER CODE END EC */ | ||
43 | + | ||
44 | +/* Exported macro ------------------------------------------------------------*/ | ||
45 | +/* USER CODE BEGIN EM */ | ||
46 | + | ||
47 | +/* USER CODE END EM */ | ||
48 | + | ||
49 | +/* Exported functions prototypes ---------------------------------------------*/ | ||
50 | +void NMI_Handler(void); | ||
51 | +void HardFault_Handler(void); | ||
52 | +void DMA1_Channel1_IRQHandler(void); | ||
53 | +void DMA1_Channel2_3_IRQHandler(void); | ||
54 | +void DMA1_Ch4_5_DMAMUX1_OVR_IRQHandler(void); | ||
55 | +void TIM16_IRQHandler(void); | ||
56 | +void USART1_IRQHandler(void); | ||
57 | +/* USER CODE BEGIN EFP */ | ||
58 | + | ||
59 | +/* USER CODE END EFP */ | ||
60 | + | ||
61 | +#ifdef __cplusplus | ||
62 | +} | ||
63 | +#endif | ||
64 | + | ||
65 | +#endif /* __STM32G0xx_IT_H */ | ||
66 | + | ||
67 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Inc/tim.h
0 → 100644
1 | +/** | ||
2 | + ****************************************************************************** | ||
3 | + * @file tim.h | ||
4 | + * @brief This file contains all the function prototypes for | ||
5 | + * the tim.c file | ||
6 | + ****************************************************************************** | ||
7 | + * @attention | ||
8 | + * | ||
9 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
10 | + * All rights reserved.</center></h2> | ||
11 | + * | ||
12 | + * This software component is licensed by ST under Ultimate Liberty license | ||
13 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
14 | + * the License. You may obtain a copy of the License at: | ||
15 | + * www.st.com/SLA0044 | ||
16 | + * | ||
17 | + ****************************************************************************** | ||
18 | + */ | ||
19 | +/* Define to prevent recursive inclusion -------------------------------------*/ | ||
20 | +#ifndef __TIM_H__ | ||
21 | +#define __TIM_H__ | ||
22 | + | ||
23 | +#ifdef __cplusplus | ||
24 | +extern "C" { | ||
25 | +#endif | ||
26 | + | ||
27 | +/* Includes ------------------------------------------------------------------*/ | ||
28 | +#include "main.h" | ||
29 | + | ||
30 | +/* USER CODE BEGIN Includes */ | ||
31 | + | ||
32 | +/* USER CODE END Includes */ | ||
33 | + | ||
34 | +/* USER CODE BEGIN Private defines */ | ||
35 | + | ||
36 | +/* USER CODE END Private defines */ | ||
37 | + | ||
38 | +void MX_TIM3_Init(void); | ||
39 | +void MX_TIM14_Init(void); | ||
40 | + | ||
41 | +/* USER CODE BEGIN Prototypes */ | ||
42 | + | ||
43 | +/* USER CODE END Prototypes */ | ||
44 | + | ||
45 | +#ifdef __cplusplus | ||
46 | +} | ||
47 | +#endif | ||
48 | + | ||
49 | +#endif /* __TIM_H__ */ | ||
50 | + | ||
51 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Inc/usart.h
0 → 100644
1 | +/** | ||
2 | + ****************************************************************************** | ||
3 | + * @file usart.h | ||
4 | + * @brief This file contains all the function prototypes for | ||
5 | + * the usart.c file | ||
6 | + ****************************************************************************** | ||
7 | + * @attention | ||
8 | + * | ||
9 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
10 | + * All rights reserved.</center></h2> | ||
11 | + * | ||
12 | + * This software component is licensed by ST under Ultimate Liberty license | ||
13 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
14 | + * the License. You may obtain a copy of the License at: | ||
15 | + * www.st.com/SLA0044 | ||
16 | + * | ||
17 | + ****************************************************************************** | ||
18 | + */ | ||
19 | +/* Define to prevent recursive inclusion -------------------------------------*/ | ||
20 | +#ifndef __USART_H__ | ||
21 | +#define __USART_H__ | ||
22 | + | ||
23 | +#ifdef __cplusplus | ||
24 | +extern "C" { | ||
25 | +#endif | ||
26 | + | ||
27 | +/* Includes ------------------------------------------------------------------*/ | ||
28 | +#include "main.h" | ||
29 | + | ||
30 | +/* USER CODE BEGIN Includes */ | ||
31 | + | ||
32 | +/* USER CODE END Includes */ | ||
33 | + | ||
34 | +/* USER CODE BEGIN Private defines */ | ||
35 | + | ||
36 | +/* USER CODE END Private defines */ | ||
37 | + | ||
38 | +void MX_USART1_UART_Init(void); | ||
39 | +void MX_USART2_UART_Init(void); | ||
40 | + | ||
41 | +/* USER CODE BEGIN Prototypes */ | ||
42 | + | ||
43 | +/* USER CODE END Prototypes */ | ||
44 | + | ||
45 | +#ifdef __cplusplus | ||
46 | +} | ||
47 | +#endif | ||
48 | + | ||
49 | +#endif /* __USART_H__ */ | ||
50 | + | ||
51 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Src/adc.c
0 → 100644
1 | +/** | ||
2 | + ****************************************************************************** | ||
3 | + * @file adc.c | ||
4 | + * @brief This file provides code for the configuration | ||
5 | + * of the ADC instances. | ||
6 | + ****************************************************************************** | ||
7 | + * @attention | ||
8 | + * | ||
9 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
10 | + * All rights reserved.</center></h2> | ||
11 | + * | ||
12 | + * This software component is licensed by ST under Ultimate Liberty license | ||
13 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
14 | + * the License. You may obtain a copy of the License at: | ||
15 | + * www.st.com/SLA0044 | ||
16 | + * | ||
17 | + ****************************************************************************** | ||
18 | + */ | ||
19 | + | ||
20 | +/* Includes ------------------------------------------------------------------*/ | ||
21 | +#include "adc.h" | ||
22 | + | ||
23 | +/* USER CODE BEGIN 0 */ | ||
24 | + | ||
25 | +/* USER CODE END 0 */ | ||
26 | + | ||
27 | +/* ADC1 init function */ | ||
28 | +void MX_ADC1_Init(void) | ||
29 | +{ | ||
30 | + /* USER CODE BEGIN ADC1_Init 0 */ | ||
31 | + | ||
32 | + /* USER CODE END ADC1_Init 0 */ | ||
33 | + | ||
34 | + LL_ADC_InitTypeDef ADC_InitStruct = {0}; | ||
35 | + LL_ADC_REG_InitTypeDef ADC_REG_InitStruct = {0}; | ||
36 | + //LL_ADC_CommonInitTypeDef | ||
37 | + LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||
38 | + | ||
39 | + /* Peripheral clock enable */ | ||
40 | + LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_ADC); | ||
41 | + | ||
42 | + LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA); | ||
43 | + /**ADC1 GPIO Configuration | ||
44 | + PA0 ------> ADC1_IN0 | ||
45 | + PA1 ------> ADC1_IN1 | ||
46 | + */ | ||
47 | + GPIO_InitStruct.Pin = ADC1_IN0_Pin; | ||
48 | + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; | ||
49 | + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; | ||
50 | + LL_GPIO_Init(ADC1_IN0_GPIO_Port, &GPIO_InitStruct); | ||
51 | + | ||
52 | + GPIO_InitStruct.Pin = ADC1_IN1_Pin; | ||
53 | + GPIO_InitStruct.Mode = LL_GPIO_MODE_ANALOG; | ||
54 | + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; | ||
55 | + LL_GPIO_Init(ADC1_IN1_GPIO_Port, &GPIO_InitStruct); | ||
56 | + | ||
57 | + /* ADC1 DMA Init */ | ||
58 | + | ||
59 | + /* ADC1 Init */ | ||
60 | + LL_DMA_SetPeriphRequest(DMA1, LL_DMA_CHANNEL_3, LL_DMAMUX_REQ_ADC1); | ||
61 | + | ||
62 | + //设置数据传输方向为 外设-->内存 | ||
63 | + LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_3, LL_DMA_DIRECTION_PERIPH_TO_MEMORY); | ||
64 | + | ||
65 | + LL_DMA_SetChannelPriorityLevel(DMA1, LL_DMA_CHANNEL_3, LL_DMA_PRIORITY_HIGH); | ||
66 | + | ||
67 | + //设置循环模式 | ||
68 | + LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_3, LL_DMA_MODE_CIRCULAR); | ||
69 | + | ||
70 | + LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_3, LL_DMA_PERIPH_NOINCREMENT); | ||
71 | + | ||
72 | + LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_3, LL_DMA_MEMORY_INCREMENT); | ||
73 | + | ||
74 | + //设置外设数据长度为 半字 | ||
75 | + LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_3, LL_DMA_PDATAALIGN_HALFWORD); | ||
76 | + | ||
77 | + //设置内存数据长度为 半字 | ||
78 | + LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_3, LL_DMA_MDATAALIGN_HALFWORD); | ||
79 | + | ||
80 | + /* USER CODE BEGIN ADC1_Init 1 */ | ||
81 | + | ||
82 | + /* USER CODE END ADC1_Init 1 */ | ||
83 | + /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) | ||
84 | + */ | ||
85 | + | ||
86 | + ADC_InitStruct.Clock = LL_ADC_CLOCK_SYNC_PCLK_DIV4; | ||
87 | + ADC_InitStruct.Resolution = LL_ADC_RESOLUTION_12B; | ||
88 | + ADC_InitStruct.DataAlignment = LL_ADC_DATA_ALIGN_RIGHT; | ||
89 | + ADC_InitStruct.LowPowerMode = LL_ADC_LP_MODE_NONE; | ||
90 | + LL_ADC_Init(ADC1, &ADC_InitStruct); | ||
91 | + LL_ADC_REG_SetSequencerConfigurable(ADC1, LL_ADC_REG_SEQ_CONFIGURABLE); | ||
92 | + | ||
93 | + while (LL_ADC_IsActiveFlag_CCRDY(ADC1) == 0); | ||
94 | + /* Clear flag ADC channel configuration ready */ | ||
95 | + LL_ADC_ClearFlag_CCRDY(ADC1); | ||
96 | + ADC_REG_InitStruct.TriggerSource = LL_ADC_REG_TRIG_SOFTWARE; | ||
97 | + ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS; //两个通道 | ||
98 | + ADC_REG_InitStruct.SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE; | ||
99 | + ADC_REG_InitStruct.ContinuousMode = LL_ADC_REG_CONV_CONTINUOUS; | ||
100 | + ADC_REG_InitStruct.DMATransfer = LL_ADC_REG_DMA_TRANSFER_UNLIMITED; | ||
101 | + ADC_REG_InitStruct.Overrun = LL_ADC_REG_OVR_DATA_PRESERVED; | ||
102 | + LL_ADC_REG_Init(ADC1, &ADC_REG_InitStruct); | ||
103 | + LL_ADC_SetOverSamplingScope(ADC1, LL_ADC_OVS_DISABLE); | ||
104 | + LL_ADC_SetTriggerFrequencyMode(ADC1, LL_ADC_CLOCK_FREQ_MODE_HIGH); | ||
105 | + LL_ADC_SetSamplingTimeCommonChannels(ADC1, LL_ADC_SAMPLINGTIME_COMMON_1, LL_ADC_SAMPLINGTIME_79CYCLES_5); | ||
106 | + LL_ADC_SetSamplingTimeCommonChannels(ADC1, LL_ADC_SAMPLINGTIME_COMMON_2, LL_ADC_SAMPLINGTIME_79CYCLES_5); | ||
107 | + LL_ADC_DisableIT_EOC(ADC1); | ||
108 | + LL_ADC_DisableIT_EOS(ADC1); | ||
109 | + | ||
110 | + /* Enable ADC internal voltage regulator */ | ||
111 | + LL_ADC_EnableInternalRegulator(ADC1); | ||
112 | + /* Delay for ADC internal voltage regulator stabilization. */ | ||
113 | + /* Compute number of CPU cycles to wait for, from delay in us. */ | ||
114 | + /* Note: Variable divided by 2 to compensate partially */ | ||
115 | + /* CPU processing cycles (depends on compilation optimization). */ | ||
116 | + /* Note: If system core clock frequency is below 200kHz, wait time */ | ||
117 | + /* is only a few CPU processing cycles. */ | ||
118 | + uint32_t wait_loop_index; | ||
119 | + wait_loop_index = ((LL_ADC_DELAY_INTERNAL_REGUL_STAB_US * (SystemCoreClock / (100000 * 2))) / 10); | ||
120 | + while(wait_loop_index != 0) | ||
121 | + { | ||
122 | + wait_loop_index--; | ||
123 | + } | ||
124 | + /** Configure Regular Channel | ||
125 | + */ | ||
126 | + LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_1, LL_ADC_CHANNEL_0); | ||
127 | + LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_0, LL_ADC_SAMPLINGTIME_COMMON_1); | ||
128 | + /** Configure Regular Channel | ||
129 | + */ | ||
130 | + LL_ADC_REG_SetSequencerRanks(ADC1, LL_ADC_REG_RANK_2, LL_ADC_CHANNEL_1); | ||
131 | + | ||
132 | + while (LL_ADC_IsActiveFlag_CCRDY(ADC1) == 0); | ||
133 | + /* Clear flag ADC channel configuration ready */ | ||
134 | + LL_ADC_ClearFlag_CCRDY(ADC1); | ||
135 | + LL_ADC_SetChannelSamplingTime(ADC1, LL_ADC_CHANNEL_1, LL_ADC_SAMPLINGTIME_COMMON_1); | ||
136 | + /* USER CODE BEGIN ADC1_Init 2 */ | ||
137 | + | ||
138 | + /* USER CODE END ADC1_Init 2 */ | ||
139 | +} | ||
140 | + | ||
141 | +/* USER CODE BEGIN 1 */ | ||
142 | + | ||
143 | +/* USER CODE END 1 */ | ||
144 | + | ||
145 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Src/app_freertos.c
0 → 100644
1 | +/* USER CODE BEGIN Header */ | ||
2 | +/** | ||
3 | + ****************************************************************************** | ||
4 | + * File Name : app_freertos.c | ||
5 | + * Description : Code for freertos applications | ||
6 | + ****************************************************************************** | ||
7 | + * @attention | ||
8 | + * | ||
9 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
10 | + * All rights reserved.</center></h2> | ||
11 | + * | ||
12 | + * This software component is licensed by ST under Ultimate Liberty license | ||
13 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
14 | + * the License. You may obtain a copy of the License at: | ||
15 | + * www.st.com/SLA0044 | ||
16 | + * | ||
17 | + ****************************************************************************** | ||
18 | + */ | ||
19 | +/* USER CODE END Header */ | ||
20 | + | ||
21 | +/* Includes ------------------------------------------------------------------*/ | ||
22 | +#include "FreeRTOS.h" | ||
23 | +#include "task.h" | ||
24 | +#include "main.h" | ||
25 | +#include "cmsis_os.h" | ||
26 | + | ||
27 | +/* Private includes ----------------------------------------------------------*/ | ||
28 | +/* USER CODE BEGIN Includes */ | ||
29 | +#include "stdio.h" | ||
30 | +/* USER CODE END Includes */ | ||
31 | + | ||
32 | +/* Private typedef -----------------------------------------------------------*/ | ||
33 | +/* USER CODE BEGIN PTD */ | ||
34 | + | ||
35 | +/* USER CODE END PTD */ | ||
36 | + | ||
37 | +/* Private define ------------------------------------------------------------*/ | ||
38 | +/* USER CODE BEGIN PD */ | ||
39 | + | ||
40 | +/* USER CODE END PD */ | ||
41 | + | ||
42 | +/* Private macro -------------------------------------------------------------*/ | ||
43 | +/* USER CODE BEGIN PM */ | ||
44 | + | ||
45 | +/* USER CODE END PM */ | ||
46 | + | ||
47 | +/* Private variables ---------------------------------------------------------*/ | ||
48 | +/* USER CODE BEGIN Variables */ | ||
49 | +extern uint16_t ADC_ConvertedValue[2]; | ||
50 | +/* USER CODE END Variables */ | ||
51 | +osThreadId defaultTaskHandle; | ||
52 | + | ||
53 | +/* Private function prototypes -----------------------------------------------*/ | ||
54 | +/* USER CODE BEGIN FunctionPrototypes */ | ||
55 | + | ||
56 | +/* USER CODE END FunctionPrototypes */ | ||
57 | + | ||
58 | +void StartDefaultTask(void const * argument); | ||
59 | + | ||
60 | +void MX_FREERTOS_Init(void); /* (MISRA C 2004 rule 8.1) */ | ||
61 | + | ||
62 | +/** | ||
63 | + * @brief FreeRTOS initialization | ||
64 | + * @param None | ||
65 | + * @retval None | ||
66 | + */ | ||
67 | +void MX_FREERTOS_Init(void) { | ||
68 | + /* USER CODE BEGIN Init */ | ||
69 | + | ||
70 | + /* USER CODE END Init */ | ||
71 | + | ||
72 | + /* USER CODE BEGIN RTOS_MUTEX */ | ||
73 | + /* add mutexes, ... */ | ||
74 | + /* USER CODE END RTOS_MUTEX */ | ||
75 | + | ||
76 | + /* USER CODE BEGIN RTOS_SEMAPHORES */ | ||
77 | + /* add semaphores, ... */ | ||
78 | + /* USER CODE END RTOS_SEMAPHORES */ | ||
79 | + | ||
80 | + /* USER CODE BEGIN RTOS_TIMERS */ | ||
81 | + /* start timers, add new ones, ... */ | ||
82 | + /* USER CODE END RTOS_TIMERS */ | ||
83 | + | ||
84 | + /* USER CODE BEGIN RTOS_QUEUES */ | ||
85 | + /* add queues, ... */ | ||
86 | + /* USER CODE END RTOS_QUEUES */ | ||
87 | + | ||
88 | + /* Create the thread(s) */ | ||
89 | + /* definition and creation of defaultTask */ | ||
90 | + osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128); | ||
91 | + defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL); | ||
92 | + | ||
93 | + /* USER CODE BEGIN RTOS_THREADS */ | ||
94 | + /* add threads, ... */ | ||
95 | + /* USER CODE END RTOS_THREADS */ | ||
96 | + | ||
97 | +} | ||
98 | + | ||
99 | +/* USER CODE BEGIN Header_StartDefaultTask */ | ||
100 | +/** | ||
101 | + * @brief Function implementing the defaultTask thread. | ||
102 | + * @param argument: Not used | ||
103 | + * @retval None | ||
104 | + */ | ||
105 | +/* USER CODE END Header_StartDefaultTask */ | ||
106 | +void StartDefaultTask(void const * argument) | ||
107 | +{ | ||
108 | + /* USER CODE BEGIN StartDefaultTask */ | ||
109 | + /* Infinite loop */ | ||
110 | + | ||
111 | + float adc_1,adc_2; | ||
112 | + | ||
113 | + for(;;) | ||
114 | + { | ||
115 | + adc_1 = ADC_ConvertedValue[0]*3300.0f/4096.0f; | ||
116 | + adc_2 = ADC_ConvertedValue[1]*3300.0f/4096.0f; | ||
117 | + | ||
118 | +// printf("0_%1.3f 1_%1.3f\r\n",adc_1,adc_2); | ||
119 | + osDelay(500); | ||
120 | + | ||
121 | + // printf("come rtos\r\n"); | ||
122 | + } | ||
123 | + /* USER CODE END StartDefaultTask */ | ||
124 | +} | ||
125 | + | ||
126 | +/* Private application code --------------------------------------------------*/ | ||
127 | +/* USER CODE BEGIN Application */ | ||
128 | + | ||
129 | +/* USER CODE END Application */ | ||
130 | + | ||
131 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Src/dma.c
0 → 100644
1 | +/** | ||
2 | + ****************************************************************************** | ||
3 | + * @file dma.c | ||
4 | + * @brief This file provides code for the configuration | ||
5 | + * of all the requested memory to memory DMA transfers. | ||
6 | + ****************************************************************************** | ||
7 | + * @attention | ||
8 | + * | ||
9 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
10 | + * All rights reserved.</center></h2> | ||
11 | + * | ||
12 | + * This software component is licensed by ST under Ultimate Liberty license | ||
13 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
14 | + * the License. You may obtain a copy of the License at: | ||
15 | + * www.st.com/SLA0044 | ||
16 | + * | ||
17 | + ****************************************************************************** | ||
18 | + */ | ||
19 | + | ||
20 | +/* Includes ------------------------------------------------------------------*/ | ||
21 | +#include "dma.h" | ||
22 | + | ||
23 | +/* USER CODE BEGIN 0 */ | ||
24 | + | ||
25 | +/* USER CODE END 0 */ | ||
26 | + | ||
27 | +/*----------------------------------------------------------------------------*/ | ||
28 | +/* Configure DMA */ | ||
29 | +/*----------------------------------------------------------------------------*/ | ||
30 | + | ||
31 | +/* USER CODE BEGIN 1 */ | ||
32 | + | ||
33 | +/* USER CODE END 1 */ | ||
34 | + | ||
35 | +/** | ||
36 | + * Enable DMA controller clock | ||
37 | + */ | ||
38 | +void MX_DMA_Init(void) | ||
39 | +{ | ||
40 | + | ||
41 | + /* Init with LL driver */ | ||
42 | + /* DMA controller clock enable */ | ||
43 | + LL_AHB1_GRP1_EnableClock(LL_AHB1_GRP1_PERIPH_DMA1); | ||
44 | + | ||
45 | + /* DMA interrupt init */ | ||
46 | + /* DMA1_Channel1_IRQn interrupt configuration */ | ||
47 | + NVIC_SetPriority(DMA1_Channel1_IRQn, 3); | ||
48 | + NVIC_EnableIRQ(DMA1_Channel1_IRQn); | ||
49 | + | ||
50 | + /* unuser */ | ||
51 | + | ||
52 | + /* DMA1_Channel2_3_IRQn interrupt configuration */ | ||
53 | +// NVIC_SetPriority(DMA1_Channel2_3_IRQn, 3); | ||
54 | +// NVIC_EnableIRQ(DMA1_Channel2_3_IRQn); | ||
55 | +// /* DMA1_Ch4_5_DMAMUX1_OVR_IRQn interrupt configuration */ | ||
56 | +// NVIC_SetPriority(DMA1_Ch4_5_DMAMUX1_OVR_IRQn, 3); | ||
57 | +// NVIC_EnableIRQ(DMA1_Ch4_5_DMAMUX1_OVR_IRQn); | ||
58 | + | ||
59 | +} | ||
60 | + | ||
61 | +/* USER CODE BEGIN 2 */ | ||
62 | + | ||
63 | +/* USER CODE END 2 */ | ||
64 | + | ||
65 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Src/gpio.c
0 → 100644
1 | +/** | ||
2 | + ****************************************************************************** | ||
3 | + * @file gpio.c | ||
4 | + * @brief This file provides code for the configuration | ||
5 | + * of all used GPIO pins. | ||
6 | + ****************************************************************************** | ||
7 | + * @attention | ||
8 | + * | ||
9 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
10 | + * All rights reserved.</center></h2> | ||
11 | + * | ||
12 | + * This software component is licensed by ST under Ultimate Liberty license | ||
13 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
14 | + * the License. You may obtain a copy of the License at: | ||
15 | + * www.st.com/SLA0044 | ||
16 | + * | ||
17 | + ****************************************************************************** | ||
18 | + */ | ||
19 | + | ||
20 | +/* Includes ------------------------------------------------------------------*/ | ||
21 | +#include "gpio.h" | ||
22 | + | ||
23 | +/* USER CODE BEGIN 0 */ | ||
24 | + | ||
25 | +/* USER CODE END 0 */ | ||
26 | + | ||
27 | +/*----------------------------------------------------------------------------*/ | ||
28 | +/* Configure GPIO */ | ||
29 | +/*----------------------------------------------------------------------------*/ | ||
30 | +/* USER CODE BEGIN 1 */ | ||
31 | + | ||
32 | +/* USER CODE END 1 */ | ||
33 | + | ||
34 | +/** Configure pins as | ||
35 | + * Analog | ||
36 | + * Input | ||
37 | + * Output | ||
38 | + * EVENT_OUT | ||
39 | + * EXTI | ||
40 | +*/ | ||
41 | +void MX_GPIO_Init(void) | ||
42 | +{ | ||
43 | + | ||
44 | + /* GPIO Ports Clock Enable */ | ||
45 | + LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOB); | ||
46 | + LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA); | ||
47 | + | ||
48 | +} | ||
49 | + | ||
50 | +/* USER CODE BEGIN 2 */ | ||
51 | + | ||
52 | +/* USER CODE END 2 */ | ||
53 | + | ||
54 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Src/main.c
0 → 100644
1 | +/* USER CODE BEGIN Header */ | ||
2 | +/** | ||
3 | + ****************************************************************************** | ||
4 | + * @file : main.c | ||
5 | + * @brief : Main program body | ||
6 | + ****************************************************************************** | ||
7 | + * @attention | ||
8 | + * | ||
9 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
10 | + * All rights reserved.</center></h2> | ||
11 | + * | ||
12 | + * This software component is licensed by ST under Ultimate Liberty license | ||
13 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
14 | + * the License. You may obtain a copy of the License at: | ||
15 | + * www.st.com/SLA0044 | ||
16 | + * | ||
17 | + ****************************************************************************** | ||
18 | + */ | ||
19 | +/* USER CODE END Header */ | ||
20 | +/* Includes ------------------------------------------------------------------*/ | ||
21 | +#include "main.h" | ||
22 | +#include "cmsis_os.h" | ||
23 | +#include "adc.h" | ||
24 | +#include "dma.h" | ||
25 | +#include "tim.h" | ||
26 | +#include "usart.h" | ||
27 | +#include "gpio.h" | ||
28 | + | ||
29 | +/* Private includes ----------------------------------------------------------*/ | ||
30 | +/* USER CODE BEGIN Includes */ | ||
31 | +#include "stdio.h" | ||
32 | +#include "adc_dma.h" | ||
33 | +#include "uart_dma.h" | ||
34 | +/* USER CODE END Includes */ | ||
35 | + | ||
36 | +/* Private typedef -----------------------------------------------------------*/ | ||
37 | +/* USER CODE BEGIN PTD */ | ||
38 | + | ||
39 | +/* USER CODE END PTD */ | ||
40 | + | ||
41 | +/* Private define ------------------------------------------------------------*/ | ||
42 | +/* USER CODE BEGIN PD */ | ||
43 | +/* USER CODE END PD */ | ||
44 | + | ||
45 | +/* Private macro -------------------------------------------------------------*/ | ||
46 | +/* USER CODE BEGIN PM */ | ||
47 | + | ||
48 | +#ifdef __GNUC__ | ||
49 | + #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) | ||
50 | +#else | ||
51 | + #define PUTCHAR_PROTOTYPE int fputc(int ch,FILE *f) | ||
52 | +#endif | ||
53 | +PUTCHAR_PROTOTYPE { | ||
54 | + | ||
55 | + LL_USART_TransmitData8(USART2,(uint8_t)ch); | ||
56 | + while(!LL_USART_IsActiveFlag_TXE(USART2)); | ||
57 | + | ||
58 | + return ch; | ||
59 | +} | ||
60 | + | ||
61 | +/* USER CODE END PM */ | ||
62 | + | ||
63 | +/* Private variables ---------------------------------------------------------*/ | ||
64 | + | ||
65 | +/* USER CODE BEGIN PV */ | ||
66 | + | ||
67 | +/* USER CODE END PV */ | ||
68 | + | ||
69 | +/* Private function prototypes -----------------------------------------------*/ | ||
70 | +void SystemClock_Config(void); | ||
71 | +void MX_FREERTOS_Init(void); | ||
72 | +/* USER CODE BEGIN PFP */ | ||
73 | + | ||
74 | +/* USER CODE END PFP */ | ||
75 | + | ||
76 | +/* Private user code ---------------------------------------------------------*/ | ||
77 | +/* USER CODE BEGIN 0 */ | ||
78 | + | ||
79 | +/* USER CODE END 0 */ | ||
80 | + | ||
81 | +/** | ||
82 | + * @brief The application entry point. | ||
83 | + * @retval int | ||
84 | + */ | ||
85 | +int main(void) | ||
86 | +{ | ||
87 | + /* USER CODE BEGIN 1 */ | ||
88 | + | ||
89 | + /* USER CODE END 1 */ | ||
90 | + | ||
91 | + /* MCU Configuration--------------------------------------------------------*/ | ||
92 | + | ||
93 | + /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ | ||
94 | + HAL_Init(); | ||
95 | + | ||
96 | + /* USER CODE BEGIN Init */ | ||
97 | + | ||
98 | + /* USER CODE END Init */ | ||
99 | + | ||
100 | + /* Configure the system clock */ | ||
101 | + SystemClock_Config(); | ||
102 | + | ||
103 | + /* USER CODE BEGIN SysInit */ | ||
104 | + | ||
105 | + /* USER CODE END SysInit */ | ||
106 | + | ||
107 | + /* Initialize all configured peripherals */ | ||
108 | + MX_GPIO_Init(); | ||
109 | + MX_DMA_Init(); | ||
110 | + MX_ADC1_Init(); | ||
111 | + MX_TIM3_Init(); | ||
112 | + MX_TIM14_Init(); | ||
113 | + MX_USART1_UART_Init(); | ||
114 | + MX_USART2_UART_Init(); | ||
115 | + /* USER CODE BEGIN 2 */ | ||
116 | + UartDma_Init(); //Æô¶¯ÅäÖà | ||
117 | + Adc_Dma_Initialize(); //Æô¶¯ÅäÖà | ||
118 | + /* USER CODE END 2 */ | ||
119 | + | ||
120 | + /* Call init function for freertos objects (in freertos.c) */ | ||
121 | + MX_FREERTOS_Init(); | ||
122 | + /* Start scheduler */ | ||
123 | + osKernelStart(); | ||
124 | + | ||
125 | + /* We should never get here as control is now taken by the scheduler */ | ||
126 | + /* Infinite loop */ | ||
127 | + /* USER CODE BEGIN WHILE */ | ||
128 | + while (1) | ||
129 | + { | ||
130 | + /* USER CODE END WHILE */ | ||
131 | + | ||
132 | + /* USER CODE BEGIN 3 */ | ||
133 | + } | ||
134 | + /* USER CODE END 3 */ | ||
135 | +} | ||
136 | + | ||
137 | +/** | ||
138 | + * @brief System Clock Configuration | ||
139 | + * @retval None | ||
140 | + */ | ||
141 | +void SystemClock_Config(void) | ||
142 | +{ | ||
143 | + LL_FLASH_SetLatency(LL_FLASH_LATENCY_2); | ||
144 | + while(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_2) | ||
145 | + { | ||
146 | + } | ||
147 | + | ||
148 | + /* HSI configuration and activation */ | ||
149 | + LL_RCC_HSI_Enable(); | ||
150 | + while(LL_RCC_HSI_IsReady() != 1) | ||
151 | + { | ||
152 | + } | ||
153 | + | ||
154 | + /* Main PLL configuration and activation */ | ||
155 | + LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_1, 8, LL_RCC_PLLR_DIV_2); | ||
156 | + LL_RCC_PLL_Enable(); | ||
157 | + LL_RCC_PLL_EnableDomain_SYS(); | ||
158 | + while(LL_RCC_PLL_IsReady() != 1) | ||
159 | + { | ||
160 | + } | ||
161 | + | ||
162 | + /* Set AHB prescaler*/ | ||
163 | + LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1); | ||
164 | + | ||
165 | + /* Sysclk activation on the main PLL */ | ||
166 | + LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); | ||
167 | + while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) | ||
168 | + { | ||
169 | + } | ||
170 | + | ||
171 | + /* Set APB1 prescaler*/ | ||
172 | + LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1); | ||
173 | + /* Update CMSIS variable (which can be updated also through SystemCoreClockUpdate function) */ | ||
174 | + LL_SetSystemCoreClock(64000000); | ||
175 | + | ||
176 | + /* Update the time base */ | ||
177 | + if (HAL_InitTick (TICK_INT_PRIORITY) != HAL_OK) | ||
178 | + { | ||
179 | + Error_Handler(); | ||
180 | + } | ||
181 | + LL_RCC_SetUSARTClockSource(LL_RCC_USART1_CLKSOURCE_PCLK1); | ||
182 | + LL_RCC_SetADCClockSource(LL_RCC_ADC_CLKSOURCE_SYSCLK); | ||
183 | +} | ||
184 | + | ||
185 | +/* USER CODE BEGIN 4 */ | ||
186 | + | ||
187 | +/* USER CODE END 4 */ | ||
188 | + | ||
189 | + /** | ||
190 | + * @brief Period elapsed callback in non blocking mode | ||
191 | + * @note This function is called when TIM16 interrupt took place, inside | ||
192 | + * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment | ||
193 | + * a global variable "uwTick" used as application time base. | ||
194 | + * @param htim : TIM handle | ||
195 | + * @retval None | ||
196 | + */ | ||
197 | +void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) | ||
198 | +{ | ||
199 | + /* USER CODE BEGIN Callback 0 */ | ||
200 | + | ||
201 | + /* USER CODE END Callback 0 */ | ||
202 | + if (htim->Instance == TIM16) { | ||
203 | + HAL_IncTick(); | ||
204 | + } | ||
205 | + /* USER CODE BEGIN Callback 1 */ | ||
206 | + | ||
207 | + /* USER CODE END Callback 1 */ | ||
208 | +} | ||
209 | + | ||
210 | +/** | ||
211 | + * @brief This function is executed in case of error occurrence. | ||
212 | + * @retval None | ||
213 | + */ | ||
214 | +void Error_Handler(void) | ||
215 | +{ | ||
216 | + /* USER CODE BEGIN Error_Handler_Debug */ | ||
217 | + /* User can add his own implementation to report the HAL error return state */ | ||
218 | + __disable_irq(); | ||
219 | + while (1) | ||
220 | + { | ||
221 | + } | ||
222 | + /* USER CODE END Error_Handler_Debug */ | ||
223 | +} | ||
224 | + | ||
225 | +#ifdef USE_FULL_ASSERT | ||
226 | +/** | ||
227 | + * @brief Reports the name of the source file and the source line number | ||
228 | + * where the assert_param error has occurred. | ||
229 | + * @param file: pointer to the source file name | ||
230 | + * @param line: assert_param error line source number | ||
231 | + * @retval None | ||
232 | + */ | ||
233 | +void assert_failed(uint8_t *file, uint32_t line) | ||
234 | +{ | ||
235 | + /* USER CODE BEGIN 6 */ | ||
236 | + /* User can add his own implementation to report the file name and line number, | ||
237 | + ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ | ||
238 | + /* USER CODE END 6 */ | ||
239 | +} | ||
240 | +#endif /* USE_FULL_ASSERT */ | ||
241 | + | ||
242 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Src/stm32g0xx_hal_msp.c
0 → 100644
1 | +/* USER CODE BEGIN Header */ | ||
2 | +/** | ||
3 | + ****************************************************************************** | ||
4 | + * @file stm32g0xx_hal_msp.c | ||
5 | + * @brief This file provides code for the MSP Initialization | ||
6 | + * and de-Initialization codes. | ||
7 | + ****************************************************************************** | ||
8 | + * @attention | ||
9 | + * | ||
10 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
11 | + * All rights reserved.</center></h2> | ||
12 | + * | ||
13 | + * This software component is licensed by ST under Ultimate Liberty license | ||
14 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
15 | + * the License. You may obtain a copy of the License at: | ||
16 | + * www.st.com/SLA0044 | ||
17 | + * | ||
18 | + ****************************************************************************** | ||
19 | + */ | ||
20 | +/* USER CODE END Header */ | ||
21 | + | ||
22 | +/* Includes ------------------------------------------------------------------*/ | ||
23 | +#include "main.h" | ||
24 | +/* USER CODE BEGIN Includes */ | ||
25 | + | ||
26 | +/* USER CODE END Includes */ | ||
27 | + | ||
28 | +/* Private typedef -----------------------------------------------------------*/ | ||
29 | +/* USER CODE BEGIN TD */ | ||
30 | + | ||
31 | +/* USER CODE END TD */ | ||
32 | + | ||
33 | +/* Private define ------------------------------------------------------------*/ | ||
34 | +/* USER CODE BEGIN Define */ | ||
35 | + | ||
36 | +/* USER CODE END Define */ | ||
37 | + | ||
38 | +/* Private macro -------------------------------------------------------------*/ | ||
39 | +/* USER CODE BEGIN Macro */ | ||
40 | + | ||
41 | +/* USER CODE END Macro */ | ||
42 | + | ||
43 | +/* Private variables ---------------------------------------------------------*/ | ||
44 | +/* USER CODE BEGIN PV */ | ||
45 | + | ||
46 | +/* USER CODE END PV */ | ||
47 | + | ||
48 | +/* Private function prototypes -----------------------------------------------*/ | ||
49 | +/* USER CODE BEGIN PFP */ | ||
50 | + | ||
51 | +/* USER CODE END PFP */ | ||
52 | + | ||
53 | +/* External functions --------------------------------------------------------*/ | ||
54 | +/* USER CODE BEGIN ExternalFunctions */ | ||
55 | + | ||
56 | +/* USER CODE END ExternalFunctions */ | ||
57 | + | ||
58 | +/* USER CODE BEGIN 0 */ | ||
59 | + | ||
60 | +/* USER CODE END 0 */ | ||
61 | +/** | ||
62 | + * Initializes the Global MSP. | ||
63 | + */ | ||
64 | +void HAL_MspInit(void) | ||
65 | +{ | ||
66 | + /* USER CODE BEGIN MspInit 0 */ | ||
67 | + | ||
68 | + /* USER CODE END MspInit 0 */ | ||
69 | + | ||
70 | + __HAL_RCC_SYSCFG_CLK_ENABLE(); | ||
71 | + __HAL_RCC_PWR_CLK_ENABLE(); | ||
72 | + | ||
73 | + /* System interrupt init*/ | ||
74 | + /* PendSV_IRQn interrupt configuration */ | ||
75 | + HAL_NVIC_SetPriority(PendSV_IRQn, 3, 0); | ||
76 | + | ||
77 | + /* USER CODE BEGIN MspInit 1 */ | ||
78 | + | ||
79 | + /* USER CODE END MspInit 1 */ | ||
80 | +} | ||
81 | + | ||
82 | +/* USER CODE BEGIN 1 */ | ||
83 | + | ||
84 | +/* USER CODE END 1 */ | ||
85 | + | ||
86 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Src/stm32g0xx_hal_timebase_tim.c
0 → 100644
1 | +/* USER CODE BEGIN Header */ | ||
2 | +/** | ||
3 | + ****************************************************************************** | ||
4 | + * @file stm32g0xx_hal_timebase_TIM.c | ||
5 | + * @brief HAL time base based on the hardware TIM. | ||
6 | + ****************************************************************************** | ||
7 | + * @attention | ||
8 | + * | ||
9 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
10 | + * All rights reserved.</center></h2> | ||
11 | + * | ||
12 | + * This software component is licensed by ST under Ultimate Liberty license | ||
13 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
14 | + * the License. You may obtain a copy of the License at: | ||
15 | + * www.st.com/SLA0044 | ||
16 | + * | ||
17 | + ****************************************************************************** | ||
18 | + */ | ||
19 | +/* USER CODE END Header */ | ||
20 | + | ||
21 | +/* Includes ------------------------------------------------------------------*/ | ||
22 | +#include "stm32g0xx_hal.h" | ||
23 | +#include "stm32g0xx_hal_tim.h" | ||
24 | + | ||
25 | +/* Private typedef -----------------------------------------------------------*/ | ||
26 | +/* Private define ------------------------------------------------------------*/ | ||
27 | +/* Private macro -------------------------------------------------------------*/ | ||
28 | +/* Private variables ---------------------------------------------------------*/ | ||
29 | +TIM_HandleTypeDef htim16; | ||
30 | +/* Private function prototypes -----------------------------------------------*/ | ||
31 | +/* Private functions ---------------------------------------------------------*/ | ||
32 | + | ||
33 | +/** | ||
34 | + * @brief This function configures the TIM16 as a time base source. | ||
35 | + * The time source is configured to have 1ms time base with a dedicated | ||
36 | + * Tick interrupt priority. | ||
37 | + * @note This function is called automatically at the beginning of program after | ||
38 | + * reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig(). | ||
39 | + * @param TickPriority: Tick interrupt priority. | ||
40 | + * @retval HAL status | ||
41 | + */ | ||
42 | +HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) | ||
43 | +{ | ||
44 | + RCC_ClkInitTypeDef clkconfig; | ||
45 | + uint32_t uwTimclock = 0; | ||
46 | + uint32_t uwPrescalerValue = 0; | ||
47 | + uint32_t pFLatency; | ||
48 | + /*Configure the TIM16 IRQ priority */ | ||
49 | + HAL_NVIC_SetPriority(TIM16_IRQn, TickPriority ,0); | ||
50 | + | ||
51 | + /* Enable the TIM16 global Interrupt */ | ||
52 | + HAL_NVIC_EnableIRQ(TIM16_IRQn); | ||
53 | + /* Enable TIM16 clock */ | ||
54 | + __HAL_RCC_TIM16_CLK_ENABLE(); | ||
55 | + | ||
56 | + /* Get clock configuration */ | ||
57 | + HAL_RCC_GetClockConfig(&clkconfig, &pFLatency); | ||
58 | + | ||
59 | + /* Compute TIM16 clock */ | ||
60 | + uwTimclock = HAL_RCC_GetPCLK1Freq(); | ||
61 | + /* Compute the prescaler value to have TIM16 counter clock equal to 1MHz */ | ||
62 | + uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U); | ||
63 | + | ||
64 | + /* Initialize TIM16 */ | ||
65 | + htim16.Instance = TIM16; | ||
66 | + | ||
67 | + /* Initialize TIMx peripheral as follow: | ||
68 | + + Period = [(TIM16CLK/1000) - 1]. to have a (1/1000) s time base. | ||
69 | + + Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock. | ||
70 | + + ClockDivision = 0 | ||
71 | + + Counter direction = Up | ||
72 | + */ | ||
73 | + htim16.Init.Period = (1000000U / 1000U) - 1U; | ||
74 | + htim16.Init.Prescaler = uwPrescalerValue; | ||
75 | + htim16.Init.ClockDivision = 0; | ||
76 | + htim16.Init.CounterMode = TIM_COUNTERMODE_UP; | ||
77 | + if(HAL_TIM_Base_Init(&htim16) == HAL_OK) | ||
78 | + { | ||
79 | + /* Start the TIM time Base generation in interrupt mode */ | ||
80 | + return HAL_TIM_Base_Start_IT(&htim16); | ||
81 | + } | ||
82 | + | ||
83 | + /* Return function status */ | ||
84 | + return HAL_ERROR; | ||
85 | +} | ||
86 | + | ||
87 | +/** | ||
88 | + * @brief Suspend Tick increment. | ||
89 | + * @note Disable the tick increment by disabling TIM16 update interrupt. | ||
90 | + * @param None | ||
91 | + * @retval None | ||
92 | + */ | ||
93 | +void HAL_SuspendTick(void) | ||
94 | +{ | ||
95 | + /* Disable TIM16 update Interrupt */ | ||
96 | + __HAL_TIM_DISABLE_IT(&htim16, TIM_IT_UPDATE); | ||
97 | +} | ||
98 | + | ||
99 | +/** | ||
100 | + * @brief Resume Tick increment. | ||
101 | + * @note Enable the tick increment by Enabling TIM16 update interrupt. | ||
102 | + * @param None | ||
103 | + * @retval None | ||
104 | + */ | ||
105 | +void HAL_ResumeTick(void) | ||
106 | +{ | ||
107 | + /* Enable TIM16 Update interrupt */ | ||
108 | + __HAL_TIM_ENABLE_IT(&htim16, TIM_IT_UPDATE); | ||
109 | +} | ||
110 | + | ||
111 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Src/stm32g0xx_it.c
0 → 100644
1 | +/* USER CODE BEGIN Header */ | ||
2 | +/** | ||
3 | + ****************************************************************************** | ||
4 | + * @file stm32g0xx_it.c | ||
5 | + * @brief Interrupt Service Routines. | ||
6 | + ****************************************************************************** | ||
7 | + * @attention | ||
8 | + * | ||
9 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
10 | + * All rights reserved.</center></h2> | ||
11 | + * | ||
12 | + * This software component is licensed by ST under Ultimate Liberty license | ||
13 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
14 | + * the License. You may obtain a copy of the License at: | ||
15 | + * www.st.com/SLA0044 | ||
16 | + * | ||
17 | + ****************************************************************************** | ||
18 | + */ | ||
19 | +/* USER CODE END Header */ | ||
20 | + | ||
21 | +/* Includes ------------------------------------------------------------------*/ | ||
22 | +#include "main.h" | ||
23 | +#include "stm32g0xx_it.h" | ||
24 | +/* Private includes ----------------------------------------------------------*/ | ||
25 | +/* USER CODE BEGIN Includes */ | ||
26 | +#include "uart_dma.h" | ||
27 | +/* USER CODE END Includes */ | ||
28 | + | ||
29 | +/* Private typedef -----------------------------------------------------------*/ | ||
30 | +/* USER CODE BEGIN TD */ | ||
31 | + | ||
32 | +/* USER CODE END TD */ | ||
33 | + | ||
34 | +/* Private define ------------------------------------------------------------*/ | ||
35 | +/* USER CODE BEGIN PD */ | ||
36 | + | ||
37 | +/* USER CODE END PD */ | ||
38 | + | ||
39 | +/* Private macro -------------------------------------------------------------*/ | ||
40 | +/* USER CODE BEGIN PM */ | ||
41 | + | ||
42 | +/* USER CODE END PM */ | ||
43 | + | ||
44 | +/* Private variables ---------------------------------------------------------*/ | ||
45 | +/* USER CODE BEGIN PV */ | ||
46 | + | ||
47 | +/* USER CODE END PV */ | ||
48 | + | ||
49 | +/* Private function prototypes -----------------------------------------------*/ | ||
50 | +/* USER CODE BEGIN PFP */ | ||
51 | + | ||
52 | +/* USER CODE END PFP */ | ||
53 | + | ||
54 | +/* Private user code ---------------------------------------------------------*/ | ||
55 | +/* USER CODE BEGIN 0 */ | ||
56 | + | ||
57 | +/* USER CODE END 0 */ | ||
58 | + | ||
59 | +/* External variables --------------------------------------------------------*/ | ||
60 | +extern TIM_HandleTypeDef htim16; | ||
61 | + | ||
62 | +/* USER CODE BEGIN EV */ | ||
63 | + | ||
64 | +/* USER CODE END EV */ | ||
65 | + | ||
66 | +/******************************************************************************/ | ||
67 | +/* Cortex-M0+ Processor Interruption and Exception Handlers */ | ||
68 | +/******************************************************************************/ | ||
69 | +/** | ||
70 | + * @brief This function handles Non maskable interrupt. | ||
71 | + */ | ||
72 | +void NMI_Handler(void) | ||
73 | +{ | ||
74 | + /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ | ||
75 | + | ||
76 | + /* USER CODE END NonMaskableInt_IRQn 0 */ | ||
77 | + /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ | ||
78 | + while (1) | ||
79 | + { | ||
80 | + } | ||
81 | + /* USER CODE END NonMaskableInt_IRQn 1 */ | ||
82 | +} | ||
83 | + | ||
84 | +/** | ||
85 | + * @brief This function handles Hard fault interrupt. | ||
86 | + */ | ||
87 | +void HardFault_Handler(void) | ||
88 | +{ | ||
89 | + /* USER CODE BEGIN HardFault_IRQn 0 */ | ||
90 | + | ||
91 | + /* USER CODE END HardFault_IRQn 0 */ | ||
92 | + while (1) | ||
93 | + { | ||
94 | + /* USER CODE BEGIN W1_HardFault_IRQn 0 */ | ||
95 | + /* USER CODE END W1_HardFault_IRQn 0 */ | ||
96 | + } | ||
97 | +} | ||
98 | + | ||
99 | +/******************************************************************************/ | ||
100 | +/* STM32G0xx Peripheral Interrupt Handlers */ | ||
101 | +/* Add here the Interrupt Handlers for the used peripherals. */ | ||
102 | +/* For the available peripheral interrupt handler names, */ | ||
103 | +/* please refer to the startup file (startup_stm32g0xx.s). */ | ||
104 | +/******************************************************************************/ | ||
105 | + | ||
106 | +/** | ||
107 | + * @brief This function handles DMA1 channel 1 interrupt. | ||
108 | + */ | ||
109 | +void DMA1_Channel1_IRQHandler(void) | ||
110 | +{ | ||
111 | + /* USER CODE BEGIN DMA1_Channel1_IRQn 0 */ | ||
112 | + if(LL_DMA_IsActiveFlag_TC1(DMA1)) | ||
113 | + { | ||
114 | + Dma_Recive_TC1(); | ||
115 | + } | ||
116 | + /* USER CODE END DMA1_Channel1_IRQn 0 */ | ||
117 | + | ||
118 | + /* USER CODE BEGIN DMA1_Channel1_IRQn 1 */ | ||
119 | + /* USER CODE END DMA1_Channel1_IRQn 1 */ | ||
120 | +} | ||
121 | + | ||
122 | +/** | ||
123 | + * @brief This function handles TIM16 global interrupt. | ||
124 | + */ | ||
125 | +void TIM16_IRQHandler(void) | ||
126 | +{ | ||
127 | + /* USER CODE BEGIN TIM16_IRQn 0 */ | ||
128 | + | ||
129 | + /* USER CODE END TIM16_IRQn 0 */ | ||
130 | + HAL_TIM_IRQHandler(&htim16); | ||
131 | + /* USER CODE BEGIN TIM16_IRQn 1 */ | ||
132 | + | ||
133 | + /* USER CODE END TIM16_IRQn 1 */ | ||
134 | +} | ||
135 | + | ||
136 | +/** | ||
137 | + * @brief This function handles USART1 global interrupt / USART1 wake-up interrupt through EXTI line 25. | ||
138 | + */ | ||
139 | +void USART1_IRQHandler(void) | ||
140 | +{ | ||
141 | + /* USER CODE BEGIN USART1_IRQn 0 */ | ||
142 | + if(LL_USART_IsActiveFlag_IDLE(USART1)==1) | ||
143 | + { | ||
144 | + UartIDLE_Recive_Data(); | ||
145 | + } | ||
146 | + /* USER CODE END USART1_IRQn 0 */ | ||
147 | + /* USER CODE BEGIN USART1_IRQn 1 */ | ||
148 | + | ||
149 | + /* USER CODE END USART1_IRQn 1 */ | ||
150 | +} | ||
151 | + | ||
152 | + | ||
153 | + | ||
154 | + /* unuser */ | ||
155 | + | ||
156 | +/** | ||
157 | + * @brief This function handles DMA1 channel 2 and channel 3 interrupts. | ||
158 | + */ | ||
159 | +//void DMA1_Channel2_3_IRQHandler(void) | ||
160 | +//{ | ||
161 | +// /* USER CODE BEGIN DMA1_Channel2_3_IRQn 0 */ | ||
162 | +// /* USER CODE END DMA1_Channel2_3_IRQn 0 */ | ||
163 | + | ||
164 | +// /* USER CODE BEGIN DMA1_Channel2_3_IRQn 1 */ | ||
165 | + | ||
166 | +// /* USER CODE END DMA1_Channel2_3_IRQn 1 */ | ||
167 | +//} | ||
168 | + | ||
169 | +/** | ||
170 | + * @brief This function handles DMA1 channel 4, channel 5 and DMAMUX1 interrupts. | ||
171 | + */ | ||
172 | +//void DMA1_Ch4_5_DMAMUX1_OVR_IRQHandler(void) | ||
173 | +//{ | ||
174 | +// /* USER CODE BEGIN DMA1_Ch4_5_DMAMUX1_OVR_IRQn 0 */ | ||
175 | +// /* USER CODE END DMA1_Ch4_5_DMAMUX1_OVR_IRQn 0 */ | ||
176 | + | ||
177 | +// /* USER CODE BEGIN DMA1_Ch4_5_DMAMUX1_OVR_IRQn 1 */ | ||
178 | + | ||
179 | +// /* USER CODE END DMA1_Ch4_5_DMAMUX1_OVR_IRQn 1 */ | ||
180 | +//} | ||
181 | + | ||
182 | + | ||
183 | +/* USER CODE BEGIN 1 */ | ||
184 | + | ||
185 | +/* USER CODE END 1 */ | ||
186 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Src/system_stm32g0xx.c
0 → 100644
1 | +/** | ||
2 | + ****************************************************************************** | ||
3 | + * @file system_stm32g0xx.c | ||
4 | + * @author MCD Application Team | ||
5 | + * @brief CMSIS Cortex-M0+ Device Peripheral Access Layer System Source File | ||
6 | + * | ||
7 | + * This file provides two functions and one global variable to be called from | ||
8 | + * user application: | ||
9 | + * - SystemInit(): This function is called at startup just after reset and | ||
10 | + * before branch to main program. This call is made inside | ||
11 | + * the "startup_stm32g0xx.s" file. | ||
12 | + * | ||
13 | + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used | ||
14 | + * by the user application to setup the SysTick | ||
15 | + * timer or configure other parameters. | ||
16 | + * | ||
17 | + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must | ||
18 | + * be called whenever the core clock is changed | ||
19 | + * during program execution. | ||
20 | + * | ||
21 | + * After each device reset the HSI (8 MHz then 16 MHz) is used as system clock source. | ||
22 | + * Then SystemInit() function is called, in "startup_stm32g0xx.s" file, to | ||
23 | + * configure the system clock before to branch to main program. | ||
24 | + * | ||
25 | + * This file configures the system clock as follows: | ||
26 | + *============================================================================= | ||
27 | + *----------------------------------------------------------------------------- | ||
28 | + * System Clock source | HSI | ||
29 | + *----------------------------------------------------------------------------- | ||
30 | + * SYSCLK(Hz) | 16000000 | ||
31 | + *----------------------------------------------------------------------------- | ||
32 | + * HCLK(Hz) | 16000000 | ||
33 | + *----------------------------------------------------------------------------- | ||
34 | + * AHB Prescaler | 1 | ||
35 | + *----------------------------------------------------------------------------- | ||
36 | + * APB Prescaler | 1 | ||
37 | + *----------------------------------------------------------------------------- | ||
38 | + * HSI Division factor | 1 | ||
39 | + *----------------------------------------------------------------------------- | ||
40 | + * PLL_M | 1 | ||
41 | + *----------------------------------------------------------------------------- | ||
42 | + * PLL_N | 8 | ||
43 | + *----------------------------------------------------------------------------- | ||
44 | + * PLL_P | 7 | ||
45 | + *----------------------------------------------------------------------------- | ||
46 | + * PLL_Q | 2 | ||
47 | + *----------------------------------------------------------------------------- | ||
48 | + * PLL_R | 2 | ||
49 | + *----------------------------------------------------------------------------- | ||
50 | + * Require 48MHz for RNG | Disabled | ||
51 | + *----------------------------------------------------------------------------- | ||
52 | + *============================================================================= | ||
53 | + ****************************************************************************** | ||
54 | + * @attention | ||
55 | + * | ||
56 | + * <h2><center>© Copyright (c) 2018 STMicroelectronics. | ||
57 | + * All rights reserved.</center></h2> | ||
58 | + * | ||
59 | + * This software component is licensed by ST under Apache License, Version 2.0, | ||
60 | + * the "License"; You may not use this file except in compliance with the | ||
61 | + * License. You may obtain a copy of the License at: | ||
62 | + * opensource.org/licenses/Apache-2.0 | ||
63 | + * | ||
64 | + ****************************************************************************** | ||
65 | + */ | ||
66 | + | ||
67 | +/** @addtogroup CMSIS | ||
68 | + * @{ | ||
69 | + */ | ||
70 | + | ||
71 | +/** @addtogroup stm32g0xx_system | ||
72 | + * @{ | ||
73 | + */ | ||
74 | + | ||
75 | +/** @addtogroup STM32G0xx_System_Private_Includes | ||
76 | + * @{ | ||
77 | + */ | ||
78 | + | ||
79 | +#include "stm32g0xx.h" | ||
80 | + | ||
81 | +#if !defined (HSE_VALUE) | ||
82 | +#define HSE_VALUE (8000000UL) /*!< Value of the External oscillator in Hz */ | ||
83 | +#endif /* HSE_VALUE */ | ||
84 | + | ||
85 | +#if !defined (HSI_VALUE) | ||
86 | + #define HSI_VALUE (16000000UL) /*!< Value of the Internal oscillator in Hz*/ | ||
87 | +#endif /* HSI_VALUE */ | ||
88 | + | ||
89 | +#if !defined (LSI_VALUE) | ||
90 | + #define LSI_VALUE (32000UL) /*!< Value of LSI in Hz*/ | ||
91 | +#endif /* LSI_VALUE */ | ||
92 | + | ||
93 | +#if !defined (LSE_VALUE) | ||
94 | + #define LSE_VALUE (32768UL) /*!< Value of LSE in Hz*/ | ||
95 | +#endif /* LSE_VALUE */ | ||
96 | + | ||
97 | +/** | ||
98 | + * @} | ||
99 | + */ | ||
100 | + | ||
101 | +/** @addtogroup STM32G0xx_System_Private_TypesDefinitions | ||
102 | + * @{ | ||
103 | + */ | ||
104 | + | ||
105 | +/** | ||
106 | + * @} | ||
107 | + */ | ||
108 | + | ||
109 | +/** @addtogroup STM32G0xx_System_Private_Defines | ||
110 | + * @{ | ||
111 | + */ | ||
112 | + | ||
113 | +/************************* Miscellaneous Configuration ************************/ | ||
114 | +/*!< Uncomment the following line if you need to relocate your vector Table in | ||
115 | + Internal SRAM. */ | ||
116 | +/* #define VECT_TAB_SRAM */ | ||
117 | +#define VECT_TAB_OFFSET 0x0U /*!< Vector Table base offset field. | ||
118 | + This value must be a multiple of 0x100. */ | ||
119 | +/******************************************************************************/ | ||
120 | +/** | ||
121 | + * @} | ||
122 | + */ | ||
123 | + | ||
124 | +/** @addtogroup STM32G0xx_System_Private_Macros | ||
125 | + * @{ | ||
126 | + */ | ||
127 | + | ||
128 | +/** | ||
129 | + * @} | ||
130 | + */ | ||
131 | + | ||
132 | +/** @addtogroup STM32G0xx_System_Private_Variables | ||
133 | + * @{ | ||
134 | + */ | ||
135 | + /* The SystemCoreClock variable is updated in three ways: | ||
136 | + 1) by calling CMSIS function SystemCoreClockUpdate() | ||
137 | + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() | ||
138 | + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency | ||
139 | + Note: If you use this function to configure the system clock; then there | ||
140 | + is no need to call the 2 first functions listed above, since SystemCoreClock | ||
141 | + variable is updated automatically. | ||
142 | + */ | ||
143 | + uint32_t SystemCoreClock = 16000000UL; | ||
144 | + | ||
145 | + const uint32_t AHBPrescTable[16UL] = {0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 1UL, 2UL, 3UL, 4UL, 6UL, 7UL, 8UL, 9UL}; | ||
146 | + const uint32_t APBPrescTable[8UL] = {0UL, 0UL, 0UL, 0UL, 1UL, 2UL, 3UL, 4UL}; | ||
147 | + | ||
148 | +/** | ||
149 | + * @} | ||
150 | + */ | ||
151 | + | ||
152 | +/** @addtogroup STM32G0xx_System_Private_FunctionPrototypes | ||
153 | + * @{ | ||
154 | + */ | ||
155 | + | ||
156 | +/** | ||
157 | + * @} | ||
158 | + */ | ||
159 | + | ||
160 | +/** @addtogroup STM32G0xx_System_Private_Functions | ||
161 | + * @{ | ||
162 | + */ | ||
163 | + | ||
164 | +/** | ||
165 | + * @brief Setup the microcontroller system. | ||
166 | + * @param None | ||
167 | + * @retval None | ||
168 | + */ | ||
169 | +void SystemInit(void) | ||
170 | +{ | ||
171 | + /* Configure the Vector Table location add offset address ------------------*/ | ||
172 | +#ifdef VECT_TAB_SRAM | ||
173 | + SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ | ||
174 | +#else | ||
175 | + SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */ | ||
176 | +#endif | ||
177 | +} | ||
178 | + | ||
179 | +/** | ||
180 | + * @brief Update SystemCoreClock variable according to Clock Register Values. | ||
181 | + * The SystemCoreClock variable contains the core clock (HCLK), it can | ||
182 | + * be used by the user application to setup the SysTick timer or configure | ||
183 | + * other parameters. | ||
184 | + * | ||
185 | + * @note Each time the core clock (HCLK) changes, this function must be called | ||
186 | + * to update SystemCoreClock variable value. Otherwise, any configuration | ||
187 | + * based on this variable will be incorrect. | ||
188 | + * | ||
189 | + * @note - The system frequency computed by this function is not the real | ||
190 | + * frequency in the chip. It is calculated based on the predefined | ||
191 | + * constant and the selected clock source: | ||
192 | + * | ||
193 | + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) / HSI division factor | ||
194 | + * | ||
195 | + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) | ||
196 | + * | ||
197 | + * - If SYSCLK source is LSI, SystemCoreClock will contain the LSI_VALUE | ||
198 | + * | ||
199 | + * - If SYSCLK source is LSE, SystemCoreClock will contain the LSE_VALUE | ||
200 | + * | ||
201 | + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(***) | ||
202 | + * or HSI_VALUE(*) multiplied/divided by the PLL factors. | ||
203 | + * | ||
204 | + * (**) HSI_VALUE is a constant defined in stm32g0xx_hal_conf.h file (default value | ||
205 | + * 16 MHz) but the real value may vary depending on the variations | ||
206 | + * in voltage and temperature. | ||
207 | + * | ||
208 | + * (***) HSE_VALUE is a constant defined in stm32g0xx_hal_conf.h file (default value | ||
209 | + * 8 MHz), user has to ensure that HSE_VALUE is same as the real | ||
210 | + * frequency of the crystal used. Otherwise, this function may | ||
211 | + * have wrong result. | ||
212 | + * | ||
213 | + * - The result of this function could be not correct when using fractional | ||
214 | + * value for HSE crystal. | ||
215 | + * | ||
216 | + * @param None | ||
217 | + * @retval None | ||
218 | + */ | ||
219 | +void SystemCoreClockUpdate(void) | ||
220 | +{ | ||
221 | + uint32_t tmp; | ||
222 | + uint32_t pllvco; | ||
223 | + uint32_t pllr; | ||
224 | + uint32_t pllsource; | ||
225 | + uint32_t pllm; | ||
226 | + uint32_t hsidiv; | ||
227 | + | ||
228 | + /* Get SYSCLK source -------------------------------------------------------*/ | ||
229 | + switch (RCC->CFGR & RCC_CFGR_SWS) | ||
230 | + { | ||
231 | + case RCC_CFGR_SWS_0: /* HSE used as system clock */ | ||
232 | + SystemCoreClock = HSE_VALUE; | ||
233 | + break; | ||
234 | + | ||
235 | + case (RCC_CFGR_SWS_1 | RCC_CFGR_SWS_0): /* LSI used as system clock */ | ||
236 | + SystemCoreClock = LSI_VALUE; | ||
237 | + break; | ||
238 | + | ||
239 | + case RCC_CFGR_SWS_2: /* LSE used as system clock */ | ||
240 | + SystemCoreClock = LSE_VALUE; | ||
241 | + break; | ||
242 | + | ||
243 | + case RCC_CFGR_SWS_1: /* PLL used as system clock */ | ||
244 | + /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN | ||
245 | + SYSCLK = PLL_VCO / PLLR | ||
246 | + */ | ||
247 | + pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); | ||
248 | + pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> RCC_PLLCFGR_PLLM_Pos) + 1UL; | ||
249 | + | ||
250 | + if(pllsource == 0x03UL) /* HSE used as PLL clock source */ | ||
251 | + { | ||
252 | + pllvco = (HSE_VALUE / pllm); | ||
253 | + } | ||
254 | + else /* HSI used as PLL clock source */ | ||
255 | + { | ||
256 | + pllvco = (HSI_VALUE / pllm); | ||
257 | + } | ||
258 | + pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> RCC_PLLCFGR_PLLN_Pos); | ||
259 | + pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> RCC_PLLCFGR_PLLR_Pos) + 1UL); | ||
260 | + | ||
261 | + SystemCoreClock = pllvco/pllr; | ||
262 | + break; | ||
263 | + | ||
264 | + case 0x00000000U: /* HSI used as system clock */ | ||
265 | + default: /* HSI used as system clock */ | ||
266 | + hsidiv = (1UL << ((READ_BIT(RCC->CR, RCC_CR_HSIDIV))>> RCC_CR_HSIDIV_Pos)); | ||
267 | + SystemCoreClock = (HSI_VALUE/hsidiv); | ||
268 | + break; | ||
269 | + } | ||
270 | + /* Compute HCLK clock frequency --------------------------------------------*/ | ||
271 | + /* Get HCLK prescaler */ | ||
272 | + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> RCC_CFGR_HPRE_Pos)]; | ||
273 | + /* HCLK clock frequency */ | ||
274 | + SystemCoreClock >>= tmp; | ||
275 | +} | ||
276 | + | ||
277 | + | ||
278 | +/** | ||
279 | + * @} | ||
280 | + */ | ||
281 | + | ||
282 | +/** | ||
283 | + * @} | ||
284 | + */ | ||
285 | + | ||
286 | +/** | ||
287 | + * @} | ||
288 | + */ | ||
289 | + | ||
290 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Src/tim.c
0 → 100644
1 | +/** | ||
2 | + ****************************************************************************** | ||
3 | + * @file tim.c | ||
4 | + * @brief This file provides code for the configuration | ||
5 | + * of the TIM instances. | ||
6 | + ****************************************************************************** | ||
7 | + * @attention | ||
8 | + * | ||
9 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
10 | + * All rights reserved.</center></h2> | ||
11 | + * | ||
12 | + * This software component is licensed by ST under Ultimate Liberty license | ||
13 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
14 | + * the License. You may obtain a copy of the License at: | ||
15 | + * www.st.com/SLA0044 | ||
16 | + * | ||
17 | + ****************************************************************************** | ||
18 | + */ | ||
19 | + | ||
20 | +/* Includes ------------------------------------------------------------------*/ | ||
21 | +#include "tim.h" | ||
22 | + | ||
23 | +/* USER CODE BEGIN 0 */ | ||
24 | + | ||
25 | +static void Pwm_Start(TIM_TypeDef *TIMx, uint32_t Channels); | ||
26 | + | ||
27 | +/* USER CODE END 0 */ | ||
28 | + | ||
29 | +/* TIM3 init function */ | ||
30 | +void MX_TIM3_Init(void) | ||
31 | +{ | ||
32 | + | ||
33 | + /* USER CODE BEGIN TIM3_Init 0 */ | ||
34 | + | ||
35 | + /* USER CODE END TIM3_Init 0 */ | ||
36 | + | ||
37 | + LL_TIM_InitTypeDef TIM_InitStruct = {0}; | ||
38 | + LL_TIM_OC_InitTypeDef TIM_OC_InitStruct = {0}; | ||
39 | + | ||
40 | + LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||
41 | + /* Peripheral clock enable */ | ||
42 | + LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3); | ||
43 | + | ||
44 | + /* USER CODE BEGIN TIM3_Init 1 */ | ||
45 | + | ||
46 | + /* USER CODE END TIM3_Init 1 */ | ||
47 | + TIM_InitStruct.Prescaler = 63; | ||
48 | + TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP; | ||
49 | + TIM_InitStruct.Autoreload = 1000; | ||
50 | + TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1; | ||
51 | + LL_TIM_Init(TIM3, &TIM_InitStruct); | ||
52 | + LL_TIM_DisableARRPreload(TIM3); | ||
53 | + LL_TIM_OC_EnablePreload(TIM3, LL_TIM_CHANNEL_CH1); | ||
54 | + TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_PWM1; | ||
55 | + TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_DISABLE; | ||
56 | + TIM_OC_InitStruct.OCNState = LL_TIM_OCSTATE_DISABLE; | ||
57 | + TIM_OC_InitStruct.CompareValue = 0; | ||
58 | + TIM_OC_InitStruct.OCPolarity = LL_TIM_OCPOLARITY_HIGH; | ||
59 | + LL_TIM_OC_Init(TIM3, LL_TIM_CHANNEL_CH1, &TIM_OC_InitStruct); | ||
60 | + LL_TIM_OC_DisableFast(TIM3, LL_TIM_CHANNEL_CH1); | ||
61 | + LL_TIM_OC_EnablePreload(TIM3, LL_TIM_CHANNEL_CH2); | ||
62 | + LL_TIM_OC_Init(TIM3, LL_TIM_CHANNEL_CH2, &TIM_OC_InitStruct); | ||
63 | + LL_TIM_OC_DisableFast(TIM3, LL_TIM_CHANNEL_CH2); | ||
64 | + LL_TIM_SetTriggerOutput(TIM3, LL_TIM_TRGO_RESET); | ||
65 | + LL_TIM_DisableMasterSlaveMode(TIM3); | ||
66 | + /* USER CODE BEGIN TIM3_Init 2 */ | ||
67 | + | ||
68 | + /* USER CODE END TIM3_Init 2 */ | ||
69 | + LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA); | ||
70 | + /**TIM3 GPIO Configuration | ||
71 | + PA6 ------> TIM3_CH1 | ||
72 | + PA7 ------> TIM3_CH2 | ||
73 | + */ | ||
74 | + GPIO_InitStruct.Pin = LL_GPIO_PIN_6 | LL_GPIO_PIN_7; | ||
75 | + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; | ||
76 | + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; | ||
77 | + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; | ||
78 | + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; | ||
79 | + GPIO_InitStruct.Alternate = LL_GPIO_AF_1; | ||
80 | + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); | ||
81 | + | ||
82 | + Pwm_Start(TIM3,LL_TIM_CHANNEL_CH1); | ||
83 | + Pwm_Start(TIM3,LL_TIM_CHANNEL_CH2); | ||
84 | + | ||
85 | +} | ||
86 | +/* TIM14 init function */ | ||
87 | +void MX_TIM14_Init(void) | ||
88 | +{ | ||
89 | + | ||
90 | + /* USER CODE BEGIN TIM14_Init 0 */ | ||
91 | + | ||
92 | + /* USER CODE END TIM14_Init 0 */ | ||
93 | + | ||
94 | + LL_TIM_InitTypeDef TIM_InitStruct = {0}; | ||
95 | + LL_TIM_OC_InitTypeDef TIM_OC_InitStruct = {0}; | ||
96 | + | ||
97 | + LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||
98 | + /* Peripheral clock enable */ | ||
99 | + LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_TIM14); | ||
100 | + | ||
101 | + /* USER CODE BEGIN TIM14_Init 1 */ | ||
102 | + | ||
103 | + /* USER CODE END TIM14_Init 1 */ | ||
104 | + TIM_InitStruct.Prescaler = 63; | ||
105 | + TIM_InitStruct.CounterMode = LL_TIM_COUNTERMODE_UP; | ||
106 | + TIM_InitStruct.Autoreload = 1000; | ||
107 | + TIM_InitStruct.ClockDivision = LL_TIM_CLOCKDIVISION_DIV1; | ||
108 | + LL_TIM_Init(TIM14, &TIM_InitStruct); | ||
109 | + LL_TIM_DisableARRPreload(TIM14); | ||
110 | + LL_TIM_OC_EnablePreload(TIM14, LL_TIM_CHANNEL_CH1); | ||
111 | + TIM_OC_InitStruct.OCMode = LL_TIM_OCMODE_PWM1; | ||
112 | + TIM_OC_InitStruct.OCState = LL_TIM_OCSTATE_DISABLE; | ||
113 | + TIM_OC_InitStruct.OCNState = LL_TIM_OCSTATE_DISABLE; | ||
114 | + TIM_OC_InitStruct.CompareValue = 0; | ||
115 | + TIM_OC_InitStruct.OCPolarity = LL_TIM_OCPOLARITY_HIGH; | ||
116 | + LL_TIM_OC_Init(TIM14, LL_TIM_CHANNEL_CH1, &TIM_OC_InitStruct); | ||
117 | + LL_TIM_OC_DisableFast(TIM14, LL_TIM_CHANNEL_CH1); | ||
118 | + /* USER CODE BEGIN TIM14_Init 2 */ | ||
119 | + | ||
120 | + /* USER CODE END TIM14_Init 2 */ | ||
121 | + LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA); | ||
122 | + /**TIM14 GPIO Configuration | ||
123 | + PA4 ------> TIM14_CH1 | ||
124 | + */ | ||
125 | + GPIO_InitStruct.Pin = LL_GPIO_PIN_4; | ||
126 | + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; | ||
127 | + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; | ||
128 | + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; | ||
129 | + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; | ||
130 | + GPIO_InitStruct.Alternate = LL_GPIO_AF_4; | ||
131 | + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); | ||
132 | + | ||
133 | + Pwm_Start(TIM14,LL_TIM_CHANNEL_CH1); | ||
134 | +} | ||
135 | + | ||
136 | +/* USER CODE BEGIN 1 */ | ||
137 | + | ||
138 | +/** | ||
139 | + * | ||
140 | + */ | ||
141 | +static void Pwm_Start(TIM_TypeDef *TIMx, uint32_t Channels) | ||
142 | +{ | ||
143 | + LL_TIM_CC_EnableChannel(TIMx,Channels); | ||
144 | + LL_TIM_EnableAllOutputs(TIMx); | ||
145 | + LL_TIM_EnableCounter(TIMx); | ||
146 | +// LL_TIM_GenerateEvent_UPDATE(TIMx); | ||
147 | +} | ||
148 | +/* USER CODE END 1 */ | ||
149 | + | ||
150 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/Src/usart.c
0 → 100644
1 | +/** | ||
2 | + ****************************************************************************** | ||
3 | + * @file usart.c | ||
4 | + * @brief This file provides code for the configuration | ||
5 | + * of the USART instances. | ||
6 | + ****************************************************************************** | ||
7 | + * @attention | ||
8 | + * | ||
9 | + * <h2><center>© Copyright (c) 2025 STMicroelectronics. | ||
10 | + * All rights reserved.</center></h2> | ||
11 | + * | ||
12 | + * This software component is licensed by ST under Ultimate Liberty license | ||
13 | + * SLA0044, the "License"; You may not use this file except in compliance with | ||
14 | + * the License. You may obtain a copy of the License at: | ||
15 | + * www.st.com/SLA0044 | ||
16 | + * | ||
17 | + ****************************************************************************** | ||
18 | + */ | ||
19 | + | ||
20 | +/* Includes ------------------------------------------------------------------*/ | ||
21 | +#include "usart.h" | ||
22 | + | ||
23 | +/* USER CODE BEGIN 0 */ | ||
24 | + | ||
25 | +/* USER CODE END 0 */ | ||
26 | + | ||
27 | +/* USART1 init function */ | ||
28 | + | ||
29 | +void MX_USART1_UART_Init(void) | ||
30 | +{ | ||
31 | + | ||
32 | + /* USER CODE BEGIN USART1_Init 0 */ | ||
33 | + | ||
34 | + /* USER CODE END USART1_Init 0 */ | ||
35 | + | ||
36 | + LL_USART_InitTypeDef USART_InitStruct = {0}; | ||
37 | + | ||
38 | + LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||
39 | + | ||
40 | + /* Peripheral clock enable */ | ||
41 | + LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1); | ||
42 | + | ||
43 | + LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOB); | ||
44 | + /**USART1 GPIO Configuration | ||
45 | + PB7 ------> USART1_RX | ||
46 | + PB6 ------> USART1_TX | ||
47 | + */ | ||
48 | + GPIO_InitStruct.Pin = LL_GPIO_PIN_7; | ||
49 | + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; | ||
50 | + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; | ||
51 | + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; | ||
52 | + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; | ||
53 | + GPIO_InitStruct.Alternate = LL_GPIO_AF_0; | ||
54 | + LL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||
55 | + | ||
56 | + GPIO_InitStruct.Pin = LL_GPIO_PIN_6; | ||
57 | + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; | ||
58 | + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; | ||
59 | + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; | ||
60 | + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; | ||
61 | + GPIO_InitStruct.Alternate = LL_GPIO_AF_0; | ||
62 | + LL_GPIO_Init(GPIOB, &GPIO_InitStruct); | ||
63 | + | ||
64 | + /* USART1 DMA Init */ | ||
65 | + | ||
66 | + /* USART1_RX Init */ | ||
67 | + LL_DMA_SetPeriphRequest(DMA1, LL_DMA_CHANNEL_1, LL_DMAMUX_REQ_USART1_RX); | ||
68 | + | ||
69 | + LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_1, LL_DMA_DIRECTION_PERIPH_TO_MEMORY); | ||
70 | + | ||
71 | + LL_DMA_SetChannelPriorityLevel(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PRIORITY_LOW); | ||
72 | + | ||
73 | + LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MODE_CIRCULAR); | ||
74 | + | ||
75 | + LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PERIPH_NOINCREMENT); | ||
76 | + | ||
77 | + LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MEMORY_INCREMENT); | ||
78 | + | ||
79 | + LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_1, LL_DMA_PDATAALIGN_BYTE); | ||
80 | + | ||
81 | + LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_1, LL_DMA_MDATAALIGN_BYTE); | ||
82 | + | ||
83 | + /* USART1_TX Init */ | ||
84 | + LL_DMA_SetPeriphRequest(DMA1, LL_DMA_CHANNEL_2, LL_DMAMUX_REQ_USART1_TX); | ||
85 | + | ||
86 | + LL_DMA_SetDataTransferDirection(DMA1, LL_DMA_CHANNEL_2, LL_DMA_DIRECTION_MEMORY_TO_PERIPH); | ||
87 | + | ||
88 | + LL_DMA_SetChannelPriorityLevel(DMA1, LL_DMA_CHANNEL_2, LL_DMA_PRIORITY_LOW); | ||
89 | + | ||
90 | + LL_DMA_SetMode(DMA1, LL_DMA_CHANNEL_2, LL_DMA_MODE_NORMAL); | ||
91 | + | ||
92 | + LL_DMA_SetPeriphIncMode(DMA1, LL_DMA_CHANNEL_2, LL_DMA_PERIPH_NOINCREMENT); | ||
93 | + | ||
94 | + LL_DMA_SetMemoryIncMode(DMA1, LL_DMA_CHANNEL_2, LL_DMA_MEMORY_INCREMENT); | ||
95 | + | ||
96 | + LL_DMA_SetPeriphSize(DMA1, LL_DMA_CHANNEL_2, LL_DMA_PDATAALIGN_BYTE); | ||
97 | + | ||
98 | + LL_DMA_SetMemorySize(DMA1, LL_DMA_CHANNEL_2, LL_DMA_MDATAALIGN_BYTE); | ||
99 | + | ||
100 | + /* USART1 interrupt Init */ | ||
101 | + NVIC_SetPriority(USART1_IRQn, 3); | ||
102 | + NVIC_EnableIRQ(USART1_IRQn); | ||
103 | + | ||
104 | + /* USER CODE BEGIN USART1_Init 1 */ | ||
105 | + | ||
106 | + /* USER CODE END USART1_Init 1 */ | ||
107 | + USART_InitStruct.PrescalerValue = LL_USART_PRESCALER_DIV1; | ||
108 | + USART_InitStruct.BaudRate = 115200; | ||
109 | + USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B; | ||
110 | + USART_InitStruct.StopBits = LL_USART_STOPBITS_1; | ||
111 | + USART_InitStruct.Parity = LL_USART_PARITY_NONE; | ||
112 | + USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX; | ||
113 | + USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE; | ||
114 | + USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16; | ||
115 | + LL_USART_Init(USART1, &USART_InitStruct); | ||
116 | + LL_USART_SetTXFIFOThreshold(USART1, LL_USART_FIFOTHRESHOLD_1_8); | ||
117 | + LL_USART_SetRXFIFOThreshold(USART1, LL_USART_FIFOTHRESHOLD_1_8); | ||
118 | + LL_USART_DisableFIFO(USART1); | ||
119 | + LL_USART_ConfigAsyncMode(USART1); | ||
120 | + | ||
121 | + /* USER CODE BEGIN WKUPType USART1 */ | ||
122 | + | ||
123 | + /* USER CODE END WKUPType USART1 */ | ||
124 | + | ||
125 | + LL_USART_Enable(USART1); | ||
126 | + | ||
127 | + /* Polling USART1 initialisation */ | ||
128 | + while((!(LL_USART_IsActiveFlag_TEACK(USART1))) || (!(LL_USART_IsActiveFlag_REACK(USART1)))) | ||
129 | + { | ||
130 | + } | ||
131 | + /* USER CODE BEGIN USART1_Init 2 */ | ||
132 | + | ||
133 | + /* USER CODE END USART1_Init 2 */ | ||
134 | + | ||
135 | +} | ||
136 | +/* USART2 init function */ | ||
137 | + | ||
138 | +void MX_USART2_UART_Init(void) | ||
139 | +{ | ||
140 | + | ||
141 | + /* USER CODE BEGIN USART2_Init 0 */ | ||
142 | + | ||
143 | + /* USER CODE END USART2_Init 0 */ | ||
144 | + | ||
145 | + LL_USART_InitTypeDef USART_InitStruct = {0}; | ||
146 | + | ||
147 | + LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||
148 | + | ||
149 | + /* Peripheral clock enable */ | ||
150 | + LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2); | ||
151 | + | ||
152 | + LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOA); | ||
153 | + /**USART2 GPIO Configuration | ||
154 | + PA2 ------> USART2_TX | ||
155 | + PA3 ------> USART2_RX | ||
156 | + */ | ||
157 | + GPIO_InitStruct.Pin = LL_GPIO_PIN_2; | ||
158 | + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; | ||
159 | + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; | ||
160 | + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; | ||
161 | + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; | ||
162 | + GPIO_InitStruct.Alternate = LL_GPIO_AF_1; | ||
163 | + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); | ||
164 | + | ||
165 | + GPIO_InitStruct.Pin = LL_GPIO_PIN_3; | ||
166 | + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; | ||
167 | + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; | ||
168 | + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; | ||
169 | + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; | ||
170 | + GPIO_InitStruct.Alternate = LL_GPIO_AF_1; | ||
171 | + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); | ||
172 | + | ||
173 | + /* USER CODE BEGIN USART2_Init 1 */ | ||
174 | + | ||
175 | + /* USER CODE END USART2_Init 1 */ | ||
176 | + USART_InitStruct.PrescalerValue = LL_USART_PRESCALER_DIV1; | ||
177 | + USART_InitStruct.BaudRate = 115200; | ||
178 | + USART_InitStruct.DataWidth = LL_USART_DATAWIDTH_8B; | ||
179 | + USART_InitStruct.StopBits = LL_USART_STOPBITS_1; | ||
180 | + USART_InitStruct.Parity = LL_USART_PARITY_NONE; | ||
181 | + USART_InitStruct.TransferDirection = LL_USART_DIRECTION_TX_RX; | ||
182 | + USART_InitStruct.HardwareFlowControl = LL_USART_HWCONTROL_NONE; | ||
183 | + USART_InitStruct.OverSampling = LL_USART_OVERSAMPLING_16; | ||
184 | + LL_USART_Init(USART2, &USART_InitStruct); | ||
185 | + LL_USART_ConfigAsyncMode(USART2); | ||
186 | + | ||
187 | + /* USER CODE BEGIN WKUPType USART2 */ | ||
188 | + | ||
189 | + /* USER CODE END WKUPType USART2 */ | ||
190 | + | ||
191 | + LL_USART_Enable(USART2); | ||
192 | + | ||
193 | + /* Polling USART2 initialisation */ | ||
194 | + while((!(LL_USART_IsActiveFlag_TEACK(USART2))) || (!(LL_USART_IsActiveFlag_REACK(USART2)))) | ||
195 | + { | ||
196 | + } | ||
197 | + /* USER CODE BEGIN USART2_Init 2 */ | ||
198 | + | ||
199 | + /* USER CODE END USART2_Init 2 */ | ||
200 | + | ||
201 | +} | ||
202 | + | ||
203 | +/* USER CODE BEGIN 1 */ | ||
204 | + | ||
205 | +/* USER CODE END 1 */ | ||
206 | + | ||
207 | +/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
Core/User/bsp/adc_dma.c
0 → 100644
1 | +#include "adc_dma.h" | ||
2 | + | ||
3 | +#define ADC_CHANNEL_NUM 2 | ||
4 | + | ||
5 | + | ||
6 | +uint16_t ADC_ConvertedValue[ADC_CHANNEL_NUM] = {0}; | ||
7 | + | ||
8 | + | ||
9 | +// | ||
10 | +int Adc_Dma_Initialize(void) | ||
11 | +{ | ||
12 | + LL_DMA_SetDataLength(DMA1, LL_DMA_CHANNEL_3, ADC_CHANNEL_NUM); | ||
13 | + LL_DMA_SetPeriphAddress(DMA1, LL_DMA_CHANNEL_3, LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA)); | ||
14 | + LL_DMA_SetMemoryAddress(DMA1, LL_DMA_CHANNEL_3, (uint32_t)&ADC_ConvertedValue); | ||
15 | + LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_3); | ||
16 | + | ||
17 | + // ADC开始校准 | ||
18 | + LL_ADC_StartCalibration(ADC1); | ||
19 | + // 等待校准完成 | ||
20 | + while (LL_ADC_IsCalibrationOnGoing(ADC1)); | ||
21 | + | ||
22 | + LL_ADC_Enable(ADC1); | ||
23 | + LL_ADC_REG_StartConversion(ADC1); | ||
24 | + // 设置ADC组通过DMA定期转换数据传输 | ||
25 | + LL_ADC_REG_SetDMATransfer(ADC1, LL_ADC_REG_DMA_TRANSFER_UNLIMITED); | ||
26 | +} |
Core/User/bsp/adc_dma.h
0 → 100644
Core/User/bsp/uart_dma.c
0 → 100644
1 | +/* | ||
2 | +UartDma_Init() 串口DMA 发送接收配置 及 中断使能 | ||
3 | +UartIDLE_Recive_Data() 串口空闲中断处理,在空闲中断中调用 | ||
4 | +Dma_Recive_TC1() 串口接收满溢中断处理,接收的数据超出dma的接收大小导致接收不全 | ||
5 | +Uart_Data_Send() | ||
6 | + | ||
7 | +*/ | ||
8 | + | ||
9 | +#include "uart_dma.h" | ||
10 | +#include "stdio.h" | ||
11 | +#include "string.h" | ||
12 | +#include "main.h" | ||
13 | +//#include "data_extract.h" | ||
14 | + | ||
15 | +#define DMA_RX_SIZE 256 //定义串口DMA接收数组大小 | ||
16 | +#define DMA_TX_SIZE 256 //定义串口DMA发送数组大小 | ||
17 | + | ||
18 | + | ||
19 | +static uint32_t ByteCount = 0; //串口接收总计数 | ||
20 | +static uint16_t ReciveLen = 0; //接收长度 | ||
21 | +static uint16_t ReciveCnt = 0; //接收数据总长度 | ||
22 | + | ||
23 | +static uint8_t RxDmaBuff[DMA_RX_SIZE] = {0}; //接收串口 DMA 数据 | ||
24 | +static uint8_t TxDmaBuff[DMA_TX_SIZE] = {0}; //发送串口 DMA 数组 | ||
25 | + | ||
26 | + | ||
27 | +//串口DMA 初始化 | ||
28 | +void UartDma_Init(void) | ||
29 | +{ | ||
30 | + //设置串口接收DMA内存地址 | ||
31 | + LL_DMA_SetMemoryAddress(DMA1,LL_DMA_CHANNEL_1,(uint32_t)RxDmaBuff); | ||
32 | + //设置外设地址 | ||
33 | + LL_DMA_SetPeriphAddress(DMA1,LL_DMA_CHANNEL_1,LL_USART_DMA_GetRegAddr(USART1,LL_USART_DMA_REG_DATA_RECEIVE)); | ||
34 | + //设置数据长度 | ||
35 | + LL_DMA_SetDataLength(DMA1,LL_DMA_CHANNEL_1,DMA_RX_SIZE); | ||
36 | + | ||
37 | + //设置串口接收DMA内存地址 | ||
38 | + LL_DMA_SetMemoryAddress(DMA1,LL_DMA_CHANNEL_2,(uint32_t)TxDmaBuff); | ||
39 | + //设置外设地址 | ||
40 | + LL_DMA_SetPeriphAddress(DMA1,LL_DMA_CHANNEL_2,LL_USART_DMA_GetRegAddr(USART1,LL_USART_DMA_REG_DATA_TRANSMIT)); | ||
41 | + //设置数据长度 | ||
42 | + LL_DMA_SetDataLength(DMA1,LL_DMA_CHANNEL_2,DMA_TX_SIZE); | ||
43 | + | ||
44 | + //使能串口接收请求 | ||
45 | + LL_USART_EnableDMAReq_RX(USART1); | ||
46 | + //使能串口发送请求 | ||
47 | + LL_USART_EnableDMAReq_TX(USART1); | ||
48 | + //使能串口空闲中断 | ||
49 | + LL_USART_EnableIT_IDLE(USART1); | ||
50 | + //使能DMA满溢中断, RX | ||
51 | + LL_DMA_EnableIT_TC(DMA1,LL_DMA_CHANNEL_1); | ||
52 | + //使能DMA传输通道1, RX | ||
53 | + LL_DMA_EnableChannel(DMA1,LL_DMA_CHANNEL_1); | ||
54 | + //使能DMA传输通道2, TX | ||
55 | +// LL_DMA_EnableChannel(DMA1,LL_DMA_CHANNEL_2); | ||
56 | + | ||
57 | +} | ||
58 | + | ||
59 | + | ||
60 | + | ||
61 | +//串口接收 | ||
62 | +int8_t UartIDLE_Recive_Data(void) | ||
63 | +{ | ||
64 | + //清除接收空闲中断标志 | ||
65 | + LL_USART_ClearFlag_IDLE(USART1); | ||
66 | + | ||
67 | + //计算数据长度, 本次接收数据长度 = 总的数组大小 - 剩余空间 - 累计接收大小 | ||
68 | + ReciveLen = DMA_RX_SIZE - LL_DMA_GetDataLength(DMA1,LL_DMA_CHANNEL_1) - ReciveCnt; | ||
69 | + | ||
70 | + //数据入队 | ||
71 | +// ringBufWrite(&UartRingBufHandle,(char*)&RxDmaBuff[ReciveCnt],ReciveLen); | ||
72 | + | ||
73 | + //空闲接收数据增加 | ||
74 | + ReciveCnt += ReciveLen; | ||
75 | + | ||
76 | + //接收数据总计数 | ||
77 | + ByteCount += ReciveLen; | ||
78 | + | ||
79 | + printf("%d %d %d\r\n",ReciveLen,ByteCount,ReciveCnt); | ||
80 | + | ||
81 | + LL_DMA_SetDataLength(DMA1,LL_DMA_CHANNEL_1,DMA_RX_SIZE); | ||
82 | + | ||
83 | + return 0; | ||
84 | +} | ||
85 | + | ||
86 | + | ||
87 | +//dma 满溢中断接收处理 | ||
88 | +void Dma_Recive_TC1(void) | ||
89 | +{ | ||
90 | + //清除标志位 | ||
91 | + LL_DMA_ClearFlag_TC1(DMA1); | ||
92 | + | ||
93 | + //计算数据长度 , 溢出时接收数据 = 总大小 - 已接收数据大小 | ||
94 | + ReciveLen = DMA_RX_SIZE - ReciveCnt; | ||
95 | + | ||
96 | + //数据入队 | ||
97 | +// ringBufWrite(&UartRingBufHandle,(char*)&RxDmaBuff[ReciveCnt],ReciveLen); | ||
98 | + | ||
99 | + ByteCount+=ReciveLen; | ||
100 | + | ||
101 | + LL_DMA_SetDataLength(DMA1,LL_DMA_CHANNEL_1,DMA_RX_SIZE); | ||
102 | + | ||
103 | + printf("++ %d %d\r\n",ReciveLen,ReciveCnt); | ||
104 | + | ||
105 | + //溢出时清空 | ||
106 | + ReciveCnt = 0; | ||
107 | +} | ||
108 | + | ||
109 | + | ||
110 | +//串口数据发送 | ||
111 | +void Uart_Data_Send(uint8_t* data,uint16_t len) | ||
112 | +{ | ||
113 | + if(LL_USART_IsActiveFlag_TC(USART1)) | ||
114 | + { | ||
115 | + LL_DMA_ClearFlag_TC2(DMA1); | ||
116 | + | ||
117 | + //将要发送的数据 拷贝到 DMA 发送的内存 | ||
118 | + memcpy(TxDmaBuff,data,len); | ||
119 | + | ||
120 | + LL_DMA_DisableChannel(DMA1,LL_DMA_CHANNEL_2); | ||
121 | + LL_DMA_SetDataLength(DMA1,LL_DMA_CHANNEL_2,len); | ||
122 | + LL_DMA_EnableChannel(DMA1,LL_DMA_CHANNEL_2); | ||
123 | + } | ||
124 | + | ||
125 | +} | ||
126 | + | ||
127 | + | ||
128 | + | ||
129 | + |
Core/User/bsp/uart_dma.h
0 → 100644
1 | +#ifndef __UART_DMA_H_ | ||
2 | +#define __UART_DMA_H_ | ||
3 | + | ||
4 | + | ||
5 | +#ifdef __cplusplus | ||
6 | +extern "C" { | ||
7 | +#endif | ||
8 | + | ||
9 | + #include "main.h" | ||
10 | + | ||
11 | + //串口DMA初始化 | ||
12 | + void UartDma_Init(void); | ||
13 | + | ||
14 | + //串口空闲中断接收 | ||
15 | + int8_t UartIDLE_Recive_Data(void); | ||
16 | + | ||
17 | + //dma 满溢中断接收处理 | ||
18 | + void Dma_Recive_TC1(void); | ||
19 | + | ||
20 | + //串口数据发送 | ||
21 | + void Uart_Data_Send(uint8_t* data,uint16_t len); | ||
22 | + | ||
23 | +#ifdef __cplusplus | ||
24 | +} | ||
25 | +#endif | ||
26 | + | ||
27 | +#endif |
Core/User/info.txt
0 → 100644
1 | + | ||
2 | + | ||
3 | +库 : ll(主) + hal(次) | ||
4 | + | ||
5 | +MCU : STM32G0F6P6 | ||
6 | + | ||
7 | +主要配置: RTOS + PWM + USART + DMA + ADC | ||
8 | + | ||
9 | +RTOS : 创建管理任务 | ||
10 | +PWM : LL库实现PWM输出 | ||
11 | +USART : LL库,利用 串口IDLE + DMA溢满中断,实现串口不定长数据接收 | ||
12 | +ADC : LL库,ADC + DMA 双路采样.使用 DMA循环模式,在任务中获取 ADC的值 | ||
13 | + | ||
14 | + | ||
15 | +引脚 | ||
16 | + | ||
17 | +USART1 : | ||
18 | + PB3 ==> TX | ||
19 | + PB7 ==> RX | ||
20 | + | ||
21 | +USART2 : | ||
22 | + PA2 ==> TX | ||
23 | + PA3 ==> RX | ||
24 | + | ||
25 | +ADC : | ||
26 | + PA0 ==> ADC1_IN0 | ||
27 | + PA1 ==> ADC1_IN1 | ||
28 | + | ||
29 | +PWM : | ||
30 | + PA4 ==> TIM14_CH1 | ||
31 | + PA6 ==> TIM3_CH1 | ||
32 | + PA7 ==> TIM3_CH2 |
Drivers/CMSIS/Core/Include/cmsis_armcc.h
0 → 100644
1 | +/**************************************************************************//** | ||
2 | + * @file cmsis_armcc.h | ||
3 | + * @brief CMSIS compiler ARMCC (Arm Compiler 5) header file | ||
4 | + * @version V5.1.0 | ||
5 | + * @date 08. May 2019 | ||
6 | + ******************************************************************************/ | ||
7 | +/* | ||
8 | + * Copyright (c) 2009-2019 Arm Limited. All rights reserved. | ||
9 | + * | ||
10 | + * SPDX-License-Identifier: Apache-2.0 | ||
11 | + * | ||
12 | + * Licensed under the Apache License, Version 2.0 (the License); you may | ||
13 | + * not use this file except in compliance with the License. | ||
14 | + * You may obtain a copy of the License at | ||
15 | + * | ||
16 | + * www.apache.org/licenses/LICENSE-2.0 | ||
17 | + * | ||
18 | + * Unless required by applicable law or agreed to in writing, software | ||
19 | + * distributed under the License is distributed on an AS IS BASIS, WITHOUT | ||
20 | + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
21 | + * See the License for the specific language governing permissions and | ||
22 | + * limitations under the License. | ||
23 | + */ | ||
24 | + | ||
25 | +#ifndef __CMSIS_ARMCC_H | ||
26 | +#define __CMSIS_ARMCC_H | ||
27 | + | ||
28 | + | ||
29 | +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677) | ||
30 | + #error "Please use Arm Compiler Toolchain V4.0.677 or later!" | ||
31 | +#endif | ||
32 | + | ||
33 | +/* CMSIS compiler control architecture macros */ | ||
34 | +#if ((defined (__TARGET_ARCH_6_M ) && (__TARGET_ARCH_6_M == 1)) || \ | ||
35 | + (defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M == 1)) ) | ||
36 | + #define __ARM_ARCH_6M__ 1 | ||
37 | +#endif | ||
38 | + | ||
39 | +#if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M == 1)) | ||
40 | + #define __ARM_ARCH_7M__ 1 | ||
41 | +#endif | ||
42 | + | ||
43 | +#if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1)) | ||
44 | + #define __ARM_ARCH_7EM__ 1 | ||
45 | +#endif | ||
46 | + | ||
47 | + /* __ARM_ARCH_8M_BASE__ not applicable */ | ||
48 | + /* __ARM_ARCH_8M_MAIN__ not applicable */ | ||
49 | + | ||
50 | +/* CMSIS compiler control DSP macros */ | ||
51 | +#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) | ||
52 | + #define __ARM_FEATURE_DSP 1 | ||
53 | +#endif | ||
54 | + | ||
55 | +/* CMSIS compiler specific defines */ | ||
56 | +#ifndef __ASM | ||
57 | + #define __ASM __asm | ||
58 | +#endif | ||
59 | +#ifndef __INLINE | ||
60 | + #define __INLINE __inline | ||
61 | +#endif | ||
62 | +#ifndef __STATIC_INLINE | ||
63 | + #define __STATIC_INLINE static __inline | ||
64 | +#endif | ||
65 | +#ifndef __STATIC_FORCEINLINE | ||
66 | + #define __STATIC_FORCEINLINE static __forceinline | ||
67 | +#endif | ||
68 | +#ifndef __NO_RETURN | ||
69 | + #define __NO_RETURN __declspec(noreturn) | ||
70 | +#endif | ||
71 | +#ifndef __USED | ||
72 | + #define __USED __attribute__((used)) | ||
73 | +#endif | ||
74 | +#ifndef __WEAK | ||
75 | + #define __WEAK __attribute__((weak)) | ||
76 | +#endif | ||
77 | +#ifndef __PACKED | ||
78 | + #define __PACKED __attribute__((packed)) | ||
79 | +#endif | ||
80 | +#ifndef __PACKED_STRUCT | ||
81 | + #define __PACKED_STRUCT __packed struct | ||
82 | +#endif | ||
83 | +#ifndef __PACKED_UNION | ||
84 | + #define __PACKED_UNION __packed union | ||
85 | +#endif | ||
86 | +#ifndef __UNALIGNED_UINT32 /* deprecated */ | ||
87 | + #define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x))) | ||
88 | +#endif | ||
89 | +#ifndef __UNALIGNED_UINT16_WRITE | ||
90 | + #define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val)) | ||
91 | +#endif | ||
92 | +#ifndef __UNALIGNED_UINT16_READ | ||
93 | + #define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr))) | ||
94 | +#endif | ||
95 | +#ifndef __UNALIGNED_UINT32_WRITE | ||
96 | + #define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val)) | ||
97 | +#endif | ||
98 | +#ifndef __UNALIGNED_UINT32_READ | ||
99 | + #define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr))) | ||
100 | +#endif | ||
101 | +#ifndef __ALIGNED | ||
102 | + #define __ALIGNED(x) __attribute__((aligned(x))) | ||
103 | +#endif | ||
104 | +#ifndef __RESTRICT | ||
105 | + #define __RESTRICT __restrict | ||
106 | +#endif | ||
107 | +#ifndef __COMPILER_BARRIER | ||
108 | + #define __COMPILER_BARRIER() __memory_changed() | ||
109 | +#endif | ||
110 | + | ||
111 | +/* ######################### Startup and Lowlevel Init ######################## */ | ||
112 | + | ||
113 | +#ifndef __PROGRAM_START | ||
114 | +#define __PROGRAM_START __main | ||
115 | +#endif | ||
116 | + | ||
117 | +#ifndef __INITIAL_SP | ||
118 | +#define __INITIAL_SP Image$$ARM_LIB_STACK$$ZI$$Limit | ||
119 | +#endif | ||
120 | + | ||
121 | +#ifndef __STACK_LIMIT | ||
122 | +#define __STACK_LIMIT Image$$ARM_LIB_STACK$$ZI$$Base | ||
123 | +#endif | ||
124 | + | ||
125 | +#ifndef __VECTOR_TABLE | ||
126 | +#define __VECTOR_TABLE __Vectors | ||
127 | +#endif | ||
128 | + | ||
129 | +#ifndef __VECTOR_TABLE_ATTRIBUTE | ||
130 | +#define __VECTOR_TABLE_ATTRIBUTE __attribute((used, section("RESET"))) | ||
131 | +#endif | ||
132 | + | ||
133 | +/* ########################### Core Function Access ########################### */ | ||
134 | +/** \ingroup CMSIS_Core_FunctionInterface | ||
135 | + \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions | ||
136 | + @{ | ||
137 | + */ | ||
138 | + | ||
139 | +/** | ||
140 | + \brief Enable IRQ Interrupts | ||
141 | + \details Enables IRQ interrupts by clearing the I-bit in the CPSR. | ||
142 | + Can only be executed in Privileged modes. | ||
143 | + */ | ||
144 | +/* intrinsic void __enable_irq(); */ | ||
145 | + | ||
146 | + | ||
147 | +/** | ||
148 | + \brief Disable IRQ Interrupts | ||
149 | + \details Disables IRQ interrupts by setting the I-bit in the CPSR. | ||
150 | + Can only be executed in Privileged modes. | ||
151 | + */ | ||
152 | +/* intrinsic void __disable_irq(); */ | ||
153 | + | ||
154 | +/** | ||
155 | + \brief Get Control Register | ||
156 | + \details Returns the content of the Control Register. | ||
157 | + \return Control Register value | ||
158 | + */ | ||
159 | +__STATIC_INLINE uint32_t __get_CONTROL(void) | ||
160 | +{ | ||
161 | + register uint32_t __regControl __ASM("control"); | ||
162 | + return(__regControl); | ||
163 | +} | ||
164 | + | ||
165 | + | ||
166 | +/** | ||
167 | + \brief Set Control Register | ||
168 | + \details Writes the given value to the Control Register. | ||
169 | + \param [in] control Control Register value to set | ||
170 | + */ | ||
171 | +__STATIC_INLINE void __set_CONTROL(uint32_t control) | ||
172 | +{ | ||
173 | + register uint32_t __regControl __ASM("control"); | ||
174 | + __regControl = control; | ||
175 | +} | ||
176 | + | ||
177 | + | ||
178 | +/** | ||
179 | + \brief Get IPSR Register | ||
180 | + \details Returns the content of the IPSR Register. | ||
181 | + \return IPSR Register value | ||
182 | + */ | ||
183 | +__STATIC_INLINE uint32_t __get_IPSR(void) | ||
184 | +{ | ||
185 | + register uint32_t __regIPSR __ASM("ipsr"); | ||
186 | + return(__regIPSR); | ||
187 | +} | ||
188 | + | ||
189 | + | ||
190 | +/** | ||
191 | + \brief Get APSR Register | ||
192 | + \details Returns the content of the APSR Register. | ||
193 | + \return APSR Register value | ||
194 | + */ | ||
195 | +__STATIC_INLINE uint32_t __get_APSR(void) | ||
196 | +{ | ||
197 | + register uint32_t __regAPSR __ASM("apsr"); | ||
198 | + return(__regAPSR); | ||
199 | +} | ||
200 | + | ||
201 | + | ||
202 | +/** | ||
203 | + \brief Get xPSR Register | ||
204 | + \details Returns the content of the xPSR Register. | ||
205 | + \return xPSR Register value | ||
206 | + */ | ||
207 | +__STATIC_INLINE uint32_t __get_xPSR(void) | ||
208 | +{ | ||
209 | + register uint32_t __regXPSR __ASM("xpsr"); | ||
210 | + return(__regXPSR); | ||
211 | +} | ||
212 | + | ||
213 | + | ||
214 | +/** | ||
215 | + \brief Get Process Stack Pointer | ||
216 | + \details Returns the current value of the Process Stack Pointer (PSP). | ||
217 | + \return PSP Register value | ||
218 | + */ | ||
219 | +__STATIC_INLINE uint32_t __get_PSP(void) | ||
220 | +{ | ||
221 | + register uint32_t __regProcessStackPointer __ASM("psp"); | ||
222 | + return(__regProcessStackPointer); | ||
223 | +} | ||
224 | + | ||
225 | + | ||
226 | +/** | ||
227 | + \brief Set Process Stack Pointer | ||
228 | + \details Assigns the given value to the Process Stack Pointer (PSP). | ||
229 | + \param [in] topOfProcStack Process Stack Pointer value to set | ||
230 | + */ | ||
231 | +__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) | ||
232 | +{ | ||
233 | + register uint32_t __regProcessStackPointer __ASM("psp"); | ||
234 | + __regProcessStackPointer = topOfProcStack; | ||
235 | +} | ||
236 | + | ||
237 | + | ||
238 | +/** | ||
239 | + \brief Get Main Stack Pointer | ||
240 | + \details Returns the current value of the Main Stack Pointer (MSP). | ||
241 | + \return MSP Register value | ||
242 | + */ | ||
243 | +__STATIC_INLINE uint32_t __get_MSP(void) | ||
244 | +{ | ||
245 | + register uint32_t __regMainStackPointer __ASM("msp"); | ||
246 | + return(__regMainStackPointer); | ||
247 | +} | ||
248 | + | ||
249 | + | ||
250 | +/** | ||
251 | + \brief Set Main Stack Pointer | ||
252 | + \details Assigns the given value to the Main Stack Pointer (MSP). | ||
253 | + \param [in] topOfMainStack Main Stack Pointer value to set | ||
254 | + */ | ||
255 | +__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) | ||
256 | +{ | ||
257 | + register uint32_t __regMainStackPointer __ASM("msp"); | ||
258 | + __regMainStackPointer = topOfMainStack; | ||
259 | +} | ||
260 | + | ||
261 | + | ||
262 | +/** | ||
263 | + \brief Get Priority Mask | ||
264 | + \details Returns the current state of the priority mask bit from the Priority Mask Register. | ||
265 | + \return Priority Mask value | ||
266 | + */ | ||
267 | +__STATIC_INLINE uint32_t __get_PRIMASK(void) | ||
268 | +{ | ||
269 | + register uint32_t __regPriMask __ASM("primask"); | ||
270 | + return(__regPriMask); | ||
271 | +} | ||
272 | + | ||
273 | + | ||
274 | +/** | ||
275 | + \brief Set Priority Mask | ||
276 | + \details Assigns the given value to the Priority Mask Register. | ||
277 | + \param [in] priMask Priority Mask | ||
278 | + */ | ||
279 | +__STATIC_INLINE void __set_PRIMASK(uint32_t priMask) | ||
280 | +{ | ||
281 | + register uint32_t __regPriMask __ASM("primask"); | ||
282 | + __regPriMask = (priMask); | ||
283 | +} | ||
284 | + | ||
285 | + | ||
286 | +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ | ||
287 | + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) | ||
288 | + | ||
289 | +/** | ||
290 | + \brief Enable FIQ | ||
291 | + \details Enables FIQ interrupts by clearing the F-bit in the CPSR. | ||
292 | + Can only be executed in Privileged modes. | ||
293 | + */ | ||
294 | +#define __enable_fault_irq __enable_fiq | ||
295 | + | ||
296 | + | ||
297 | +/** | ||
298 | + \brief Disable FIQ | ||
299 | + \details Disables FIQ interrupts by setting the F-bit in the CPSR. | ||
300 | + Can only be executed in Privileged modes. | ||
301 | + */ | ||
302 | +#define __disable_fault_irq __disable_fiq | ||
303 | + | ||
304 | + | ||
305 | +/** | ||
306 | + \brief Get Base Priority | ||
307 | + \details Returns the current value of the Base Priority register. | ||
308 | + \return Base Priority register value | ||
309 | + */ | ||
310 | +__STATIC_INLINE uint32_t __get_BASEPRI(void) | ||
311 | +{ | ||
312 | + register uint32_t __regBasePri __ASM("basepri"); | ||
313 | + return(__regBasePri); | ||
314 | +} | ||
315 | + | ||
316 | + | ||
317 | +/** | ||
318 | + \brief Set Base Priority | ||
319 | + \details Assigns the given value to the Base Priority register. | ||
320 | + \param [in] basePri Base Priority value to set | ||
321 | + */ | ||
322 | +__STATIC_INLINE void __set_BASEPRI(uint32_t basePri) | ||
323 | +{ | ||
324 | + register uint32_t __regBasePri __ASM("basepri"); | ||
325 | + __regBasePri = (basePri & 0xFFU); | ||
326 | +} | ||
327 | + | ||
328 | + | ||
329 | +/** | ||
330 | + \brief Set Base Priority with condition | ||
331 | + \details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled, | ||
332 | + or the new value increases the BASEPRI priority level. | ||
333 | + \param [in] basePri Base Priority value to set | ||
334 | + */ | ||
335 | +__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri) | ||
336 | +{ | ||
337 | + register uint32_t __regBasePriMax __ASM("basepri_max"); | ||
338 | + __regBasePriMax = (basePri & 0xFFU); | ||
339 | +} | ||
340 | + | ||
341 | + | ||
342 | +/** | ||
343 | + \brief Get Fault Mask | ||
344 | + \details Returns the current value of the Fault Mask register. | ||
345 | + \return Fault Mask register value | ||
346 | + */ | ||
347 | +__STATIC_INLINE uint32_t __get_FAULTMASK(void) | ||
348 | +{ | ||
349 | + register uint32_t __regFaultMask __ASM("faultmask"); | ||
350 | + return(__regFaultMask); | ||
351 | +} | ||
352 | + | ||
353 | + | ||
354 | +/** | ||
355 | + \brief Set Fault Mask | ||
356 | + \details Assigns the given value to the Fault Mask register. | ||
357 | + \param [in] faultMask Fault Mask value to set | ||
358 | + */ | ||
359 | +__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) | ||
360 | +{ | ||
361 | + register uint32_t __regFaultMask __ASM("faultmask"); | ||
362 | + __regFaultMask = (faultMask & (uint32_t)1U); | ||
363 | +} | ||
364 | + | ||
365 | +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ | ||
366 | + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ | ||
367 | + | ||
368 | + | ||
369 | +/** | ||
370 | + \brief Get FPSCR | ||
371 | + \details Returns the current value of the Floating Point Status/Control register. | ||
372 | + \return Floating Point Status/Control register value | ||
373 | + */ | ||
374 | +__STATIC_INLINE uint32_t __get_FPSCR(void) | ||
375 | +{ | ||
376 | +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ | ||
377 | + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) | ||
378 | + register uint32_t __regfpscr __ASM("fpscr"); | ||
379 | + return(__regfpscr); | ||
380 | +#else | ||
381 | + return(0U); | ||
382 | +#endif | ||
383 | +} | ||
384 | + | ||
385 | + | ||
386 | +/** | ||
387 | + \brief Set FPSCR | ||
388 | + \details Assigns the given value to the Floating Point Status/Control register. | ||
389 | + \param [in] fpscr Floating Point Status/Control value to set | ||
390 | + */ | ||
391 | +__STATIC_INLINE void __set_FPSCR(uint32_t fpscr) | ||
392 | +{ | ||
393 | +#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \ | ||
394 | + (defined (__FPU_USED ) && (__FPU_USED == 1U)) ) | ||
395 | + register uint32_t __regfpscr __ASM("fpscr"); | ||
396 | + __regfpscr = (fpscr); | ||
397 | +#else | ||
398 | + (void)fpscr; | ||
399 | +#endif | ||
400 | +} | ||
401 | + | ||
402 | + | ||
403 | +/*@} end of CMSIS_Core_RegAccFunctions */ | ||
404 | + | ||
405 | + | ||
406 | +/* ########################## Core Instruction Access ######################### */ | ||
407 | +/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface | ||
408 | + Access to dedicated instructions | ||
409 | + @{ | ||
410 | +*/ | ||
411 | + | ||
412 | +/** | ||
413 | + \brief No Operation | ||
414 | + \details No Operation does nothing. This instruction can be used for code alignment purposes. | ||
415 | + */ | ||
416 | +#define __NOP __nop | ||
417 | + | ||
418 | + | ||
419 | +/** | ||
420 | + \brief Wait For Interrupt | ||
421 | + \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs. | ||
422 | + */ | ||
423 | +#define __WFI __wfi | ||
424 | + | ||
425 | + | ||
426 | +/** | ||
427 | + \brief Wait For Event | ||
428 | + \details Wait For Event is a hint instruction that permits the processor to enter | ||
429 | + a low-power state until one of a number of events occurs. | ||
430 | + */ | ||
431 | +#define __WFE __wfe | ||
432 | + | ||
433 | + | ||
434 | +/** | ||
435 | + \brief Send Event | ||
436 | + \details Send Event is a hint instruction. It causes an event to be signaled to the CPU. | ||
437 | + */ | ||
438 | +#define __SEV __sev | ||
439 | + | ||
440 | + | ||
441 | +/** | ||
442 | + \brief Instruction Synchronization Barrier | ||
443 | + \details Instruction Synchronization Barrier flushes the pipeline in the processor, | ||
444 | + so that all instructions following the ISB are fetched from cache or memory, | ||
445 | + after the instruction has been completed. | ||
446 | + */ | ||
447 | +#define __ISB() do {\ | ||
448 | + __schedule_barrier();\ | ||
449 | + __isb(0xF);\ | ||
450 | + __schedule_barrier();\ | ||
451 | + } while (0U) | ||
452 | + | ||
453 | +/** | ||
454 | + \brief Data Synchronization Barrier | ||
455 | + \details Acts as a special kind of Data Memory Barrier. | ||
456 | + It completes when all explicit memory accesses before this instruction complete. | ||
457 | + */ | ||
458 | +#define __DSB() do {\ | ||
459 | + __schedule_barrier();\ | ||
460 | + __dsb(0xF);\ | ||
461 | + __schedule_barrier();\ | ||
462 | + } while (0U) | ||
463 | + | ||
464 | +/** | ||
465 | + \brief Data Memory Barrier | ||
466 | + \details Ensures the apparent order of the explicit memory operations before | ||
467 | + and after the instruction, without ensuring their completion. | ||
468 | + */ | ||
469 | +#define __DMB() do {\ | ||
470 | + __schedule_barrier();\ | ||
471 | + __dmb(0xF);\ | ||
472 | + __schedule_barrier();\ | ||
473 | + } while (0U) | ||
474 | + | ||
475 | + | ||
476 | +/** | ||
477 | + \brief Reverse byte order (32 bit) | ||
478 | + \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412. | ||
479 | + \param [in] value Value to reverse | ||
480 | + \return Reversed value | ||
481 | + */ | ||
482 | +#define __REV __rev | ||
483 | + | ||
484 | + | ||
485 | +/** | ||
486 | + \brief Reverse byte order (16 bit) | ||
487 | + \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856. | ||
488 | + \param [in] value Value to reverse | ||
489 | + \return Reversed value | ||
490 | + */ | ||
491 | +#ifndef __NO_EMBEDDED_ASM | ||
492 | +__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value) | ||
493 | +{ | ||
494 | + rev16 r0, r0 | ||
495 | + bx lr | ||
496 | +} | ||
497 | +#endif | ||
498 | + | ||
499 | + | ||
500 | +/** | ||
501 | + \brief Reverse byte order (16 bit) | ||
502 | + \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000. | ||
503 | + \param [in] value Value to reverse | ||
504 | + \return Reversed value | ||
505 | + */ | ||
506 | +#ifndef __NO_EMBEDDED_ASM | ||
507 | +__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value) | ||
508 | +{ | ||
509 | + revsh r0, r0 | ||
510 | + bx lr | ||
511 | +} | ||
512 | +#endif | ||
513 | + | ||
514 | + | ||
515 | +/** | ||
516 | + \brief Rotate Right in unsigned value (32 bit) | ||
517 | + \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits. | ||
518 | + \param [in] op1 Value to rotate | ||
519 | + \param [in] op2 Number of Bits to rotate | ||
520 | + \return Rotated value | ||
521 | + */ | ||
522 | +#define __ROR __ror | ||
523 | + | ||
524 | + | ||
525 | +/** | ||
526 | + \brief Breakpoint | ||
527 | + \details Causes the processor to enter Debug state. | ||
528 | + Debug tools can use this to investigate system state when the instruction at a particular address is reached. | ||
529 | + \param [in] value is ignored by the processor. | ||
530 | + If required, a debugger can use it to store additional information about the breakpoint. | ||
531 | + */ | ||
532 | +#define __BKPT(value) __breakpoint(value) | ||
533 | + | ||
534 | + | ||
535 | +/** | ||
536 | + \brief Reverse bit order of value | ||
537 | + \details Reverses the bit order of the given value. | ||
538 | + \param [in] value Value to reverse | ||
539 | + \return Reversed value | ||
540 | + */ | ||
541 | +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ | ||
542 | + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) | ||
543 | + #define __RBIT __rbit | ||
544 | +#else | ||
545 | +__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value) | ||
546 | +{ | ||
547 | + uint32_t result; | ||
548 | + uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */ | ||
549 | + | ||
550 | + result = value; /* r will be reversed bits of v; first get LSB of v */ | ||
551 | + for (value >>= 1U; value != 0U; value >>= 1U) | ||
552 | + { | ||
553 | + result <<= 1U; | ||
554 | + result |= value & 1U; | ||
555 | + s--; | ||
556 | + } | ||
557 | + result <<= s; /* shift when v's highest bits are zero */ | ||
558 | + return result; | ||
559 | +} | ||
560 | +#endif | ||
561 | + | ||
562 | + | ||
563 | +/** | ||
564 | + \brief Count leading zeros | ||
565 | + \details Counts the number of leading zeros of a data value. | ||
566 | + \param [in] value Value to count the leading zeros | ||
567 | + \return number of leading zeros in value | ||
568 | + */ | ||
569 | +#define __CLZ __clz | ||
570 | + | ||
571 | + | ||
572 | +#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ | ||
573 | + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) | ||
574 | + | ||
575 | +/** | ||
576 | + \brief LDR Exclusive (8 bit) | ||
577 | + \details Executes a exclusive LDR instruction for 8 bit value. | ||
578 | + \param [in] ptr Pointer to data | ||
579 | + \return value of type uint8_t at (*ptr) | ||
580 | + */ | ||
581 | +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) | ||
582 | + #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr)) | ||
583 | +#else | ||
584 | + #define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop") | ||
585 | +#endif | ||
586 | + | ||
587 | + | ||
588 | +/** | ||
589 | + \brief LDR Exclusive (16 bit) | ||
590 | + \details Executes a exclusive LDR instruction for 16 bit values. | ||
591 | + \param [in] ptr Pointer to data | ||
592 | + \return value of type uint16_t at (*ptr) | ||
593 | + */ | ||
594 | +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) | ||
595 | + #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr)) | ||
596 | +#else | ||
597 | + #define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop") | ||
598 | +#endif | ||
599 | + | ||
600 | + | ||
601 | +/** | ||
602 | + \brief LDR Exclusive (32 bit) | ||
603 | + \details Executes a exclusive LDR instruction for 32 bit values. | ||
604 | + \param [in] ptr Pointer to data | ||
605 | + \return value of type uint32_t at (*ptr) | ||
606 | + */ | ||
607 | +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) | ||
608 | + #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr)) | ||
609 | +#else | ||
610 | + #define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop") | ||
611 | +#endif | ||
612 | + | ||
613 | + | ||
614 | +/** | ||
615 | + \brief STR Exclusive (8 bit) | ||
616 | + \details Executes a exclusive STR instruction for 8 bit values. | ||
617 | + \param [in] value Value to store | ||
618 | + \param [in] ptr Pointer to location | ||
619 | + \return 0 Function succeeded | ||
620 | + \return 1 Function failed | ||
621 | + */ | ||
622 | +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) | ||
623 | + #define __STREXB(value, ptr) __strex(value, ptr) | ||
624 | +#else | ||
625 | + #define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") | ||
626 | +#endif | ||
627 | + | ||
628 | + | ||
629 | +/** | ||
630 | + \brief STR Exclusive (16 bit) | ||
631 | + \details Executes a exclusive STR instruction for 16 bit values. | ||
632 | + \param [in] value Value to store | ||
633 | + \param [in] ptr Pointer to location | ||
634 | + \return 0 Function succeeded | ||
635 | + \return 1 Function failed | ||
636 | + */ | ||
637 | +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) | ||
638 | + #define __STREXH(value, ptr) __strex(value, ptr) | ||
639 | +#else | ||
640 | + #define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") | ||
641 | +#endif | ||
642 | + | ||
643 | + | ||
644 | +/** | ||
645 | + \brief STR Exclusive (32 bit) | ||
646 | + \details Executes a exclusive STR instruction for 32 bit values. | ||
647 | + \param [in] value Value to store | ||
648 | + \param [in] ptr Pointer to location | ||
649 | + \return 0 Function succeeded | ||
650 | + \return 1 Function failed | ||
651 | + */ | ||
652 | +#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020) | ||
653 | + #define __STREXW(value, ptr) __strex(value, ptr) | ||
654 | +#else | ||
655 | + #define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop") | ||
656 | +#endif | ||
657 | + | ||
658 | + | ||
659 | +/** | ||
660 | + \brief Remove the exclusive lock | ||
661 | + \details Removes the exclusive lock which is created by LDREX. | ||
662 | + */ | ||
663 | +#define __CLREX __clrex | ||
664 | + | ||
665 | + | ||
666 | +/** | ||
667 | + \brief Signed Saturate | ||
668 | + \details Saturates a signed value. | ||
669 | + \param [in] value Value to be saturated | ||
670 | + \param [in] sat Bit position to saturate to (1..32) | ||
671 | + \return Saturated value | ||
672 | + */ | ||
673 | +#define __SSAT __ssat | ||
674 | + | ||
675 | + | ||
676 | +/** | ||
677 | + \brief Unsigned Saturate | ||
678 | + \details Saturates an unsigned value. | ||
679 | + \param [in] value Value to be saturated | ||
680 | + \param [in] sat Bit position to saturate to (0..31) | ||
681 | + \return Saturated value | ||
682 | + */ | ||
683 | +#define __USAT __usat | ||
684 | + | ||
685 | + | ||
686 | +/** | ||
687 | + \brief Rotate Right with Extend (32 bit) | ||
688 | + \details Moves each bit of a bitstring right by one bit. | ||
689 | + The carry input is shifted in at the left end of the bitstring. | ||
690 | + \param [in] value Value to rotate | ||
691 | + \return Rotated value | ||
692 | + */ | ||
693 | +#ifndef __NO_EMBEDDED_ASM | ||
694 | +__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value) | ||
695 | +{ | ||
696 | + rrx r0, r0 | ||
697 | + bx lr | ||
698 | +} | ||
699 | +#endif | ||
700 | + | ||
701 | + | ||
702 | +/** | ||
703 | + \brief LDRT Unprivileged (8 bit) | ||
704 | + \details Executes a Unprivileged LDRT instruction for 8 bit value. | ||
705 | + \param [in] ptr Pointer to data | ||
706 | + \return value of type uint8_t at (*ptr) | ||
707 | + */ | ||
708 | +#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr)) | ||
709 | + | ||
710 | + | ||
711 | +/** | ||
712 | + \brief LDRT Unprivileged (16 bit) | ||
713 | + \details Executes a Unprivileged LDRT instruction for 16 bit values. | ||
714 | + \param [in] ptr Pointer to data | ||
715 | + \return value of type uint16_t at (*ptr) | ||
716 | + */ | ||
717 | +#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr)) | ||
718 | + | ||
719 | + | ||
720 | +/** | ||
721 | + \brief LDRT Unprivileged (32 bit) | ||
722 | + \details Executes a Unprivileged LDRT instruction for 32 bit values. | ||
723 | + \param [in] ptr Pointer to data | ||
724 | + \return value of type uint32_t at (*ptr) | ||
725 | + */ | ||
726 | +#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr)) | ||
727 | + | ||
728 | + | ||
729 | +/** | ||
730 | + \brief STRT Unprivileged (8 bit) | ||
731 | + \details Executes a Unprivileged STRT instruction for 8 bit values. | ||
732 | + \param [in] value Value to store | ||
733 | + \param [in] ptr Pointer to location | ||
734 | + */ | ||
735 | +#define __STRBT(value, ptr) __strt(value, ptr) | ||
736 | + | ||
737 | + | ||
738 | +/** | ||
739 | + \brief STRT Unprivileged (16 bit) | ||
740 | + \details Executes a Unprivileged STRT instruction for 16 bit values. | ||
741 | + \param [in] value Value to store | ||
742 | + \param [in] ptr Pointer to location | ||
743 | + */ | ||
744 | +#define __STRHT(value, ptr) __strt(value, ptr) | ||
745 | + | ||
746 | + | ||
747 | +/** | ||
748 | + \brief STRT Unprivileged (32 bit) | ||
749 | + \details Executes a Unprivileged STRT instruction for 32 bit values. | ||
750 | + \param [in] value Value to store | ||
751 | + \param [in] ptr Pointer to location | ||
752 | + */ | ||
753 | +#define __STRT(value, ptr) __strt(value, ptr) | ||
754 | + | ||
755 | +#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ | ||
756 | + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ | ||
757 | + | ||
758 | +/** | ||
759 | + \brief Signed Saturate | ||
760 | + \details Saturates a signed value. | ||
761 | + \param [in] value Value to be saturated | ||
762 | + \param [in] sat Bit position to saturate to (1..32) | ||
763 | + \return Saturated value | ||
764 | + */ | ||
765 | +__attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat) | ||
766 | +{ | ||
767 | + if ((sat >= 1U) && (sat <= 32U)) | ||
768 | + { | ||
769 | + const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U); | ||
770 | + const int32_t min = -1 - max ; | ||
771 | + if (val > max) | ||
772 | + { | ||
773 | + return max; | ||
774 | + } | ||
775 | + else if (val < min) | ||
776 | + { | ||
777 | + return min; | ||
778 | + } | ||
779 | + } | ||
780 | + return val; | ||
781 | +} | ||
782 | + | ||
783 | +/** | ||
784 | + \brief Unsigned Saturate | ||
785 | + \details Saturates an unsigned value. | ||
786 | + \param [in] value Value to be saturated | ||
787 | + \param [in] sat Bit position to saturate to (0..31) | ||
788 | + \return Saturated value | ||
789 | + */ | ||
790 | +__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat) | ||
791 | +{ | ||
792 | + if (sat <= 31U) | ||
793 | + { | ||
794 | + const uint32_t max = ((1U << sat) - 1U); | ||
795 | + if (val > (int32_t)max) | ||
796 | + { | ||
797 | + return max; | ||
798 | + } | ||
799 | + else if (val < 0) | ||
800 | + { | ||
801 | + return 0U; | ||
802 | + } | ||
803 | + } | ||
804 | + return (uint32_t)val; | ||
805 | +} | ||
806 | + | ||
807 | +#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \ | ||
808 | + (defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ | ||
809 | + | ||
810 | +/*@}*/ /* end of group CMSIS_Core_InstructionInterface */ | ||
811 | + | ||
812 | + | ||
813 | +/* ################### Compiler specific Intrinsics ########################### */ | ||
814 | +/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics | ||
815 | + Access to dedicated SIMD instructions | ||
816 | + @{ | ||
817 | +*/ | ||
818 | + | ||
819 | +#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) | ||
820 | + | ||
821 | +#define __SADD8 __sadd8 | ||
822 | +#define __QADD8 __qadd8 | ||
823 | +#define __SHADD8 __shadd8 | ||
824 | +#define __UADD8 __uadd8 | ||
825 | +#define __UQADD8 __uqadd8 | ||
826 | +#define __UHADD8 __uhadd8 | ||
827 | +#define __SSUB8 __ssub8 | ||
828 | +#define __QSUB8 __qsub8 | ||
829 | +#define __SHSUB8 __shsub8 | ||
830 | +#define __USUB8 __usub8 | ||
831 | +#define __UQSUB8 __uqsub8 | ||
832 | +#define __UHSUB8 __uhsub8 | ||
833 | +#define __SADD16 __sadd16 | ||
834 | +#define __QADD16 __qadd16 | ||
835 | +#define __SHADD16 __shadd16 | ||
836 | +#define __UADD16 __uadd16 | ||
837 | +#define __UQADD16 __uqadd16 | ||
838 | +#define __UHADD16 __uhadd16 | ||
839 | +#define __SSUB16 __ssub16 | ||
840 | +#define __QSUB16 __qsub16 | ||
841 | +#define __SHSUB16 __shsub16 | ||
842 | +#define __USUB16 __usub16 | ||
843 | +#define __UQSUB16 __uqsub16 | ||
844 | +#define __UHSUB16 __uhsub16 | ||
845 | +#define __SASX __sasx | ||
846 | +#define __QASX __qasx | ||
847 | +#define __SHASX __shasx | ||
848 | +#define __UASX __uasx | ||
849 | +#define __UQASX __uqasx | ||
850 | +#define __UHASX __uhasx | ||
851 | +#define __SSAX __ssax | ||
852 | +#define __QSAX __qsax | ||
853 | +#define __SHSAX __shsax | ||
854 | +#define __USAX __usax | ||
855 | +#define __UQSAX __uqsax | ||
856 | +#define __UHSAX __uhsax | ||
857 | +#define __USAD8 __usad8 | ||
858 | +#define __USADA8 __usada8 | ||
859 | +#define __SSAT16 __ssat16 | ||
860 | +#define __USAT16 __usat16 | ||
861 | +#define __UXTB16 __uxtb16 | ||
862 | +#define __UXTAB16 __uxtab16 | ||
863 | +#define __SXTB16 __sxtb16 | ||
864 | +#define __SXTAB16 __sxtab16 | ||
865 | +#define __SMUAD __smuad | ||
866 | +#define __SMUADX __smuadx | ||
867 | +#define __SMLAD __smlad | ||
868 | +#define __SMLADX __smladx | ||
869 | +#define __SMLALD __smlald | ||
870 | +#define __SMLALDX __smlaldx | ||
871 | +#define __SMUSD __smusd | ||
872 | +#define __SMUSDX __smusdx | ||
873 | +#define __SMLSD __smlsd | ||
874 | +#define __SMLSDX __smlsdx | ||
875 | +#define __SMLSLD __smlsld | ||
876 | +#define __SMLSLDX __smlsldx | ||
877 | +#define __SEL __sel | ||
878 | +#define __QADD __qadd | ||
879 | +#define __QSUB __qsub | ||
880 | + | ||
881 | +#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \ | ||
882 | + ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) ) | ||
883 | + | ||
884 | +#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \ | ||
885 | + ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) ) | ||
886 | + | ||
887 | +#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \ | ||
888 | + ((int64_t)(ARG3) << 32U) ) >> 32U)) | ||
889 | + | ||
890 | +#endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */ | ||
891 | +/*@} end of group CMSIS_SIMD_intrinsics */ | ||
892 | + | ||
893 | + | ||
894 | +#endif /* __CMSIS_ARMCC_H */ |
-
请 注册 或 登录 后发表评论