用CubeMX工具配置最小工程,之配置时钟和调试接口,其他都不配置。
然后生成MDK代码,生成时候只选择需要的代码,不用生成所有代码。这样就可以看出来哪些是最小工程需要配置的代码,有助于后期自己剪裁工程功能。
工程生成代码之后打开工程在keil中是显示如下:
生成的工程文件中如何才能快速获取文件夹中的文件夹和对应文件夹中的文件列表呢
在工程文件夹下新建一个bat文件,文档中输入 :tree /f >FileNameList.txt 然后保存双击运行
运行后会生成一个一个txt文件,里边包含了工程文件夹的文件树列表
1 └─STM32H743XIH6 2 │ .mxproject 3 │ STM32H743XIH6.ioc 4 │ 5 ├─Core 6 │ ├─Inc 7 │ │ gpio.h 8 │ │ main.h 9 │ │ stm32h7xx_hal_conf.h 10 │ │ stm32h7xx_it.h 11 │ │ 12 │ └─Src 13 │ gpio.c 14 │ main.c 15 │ stm32h7xx_hal_msp.c 16 │ stm32h7xx_it.c 17 │ system_stm32h7xx.c 18 │ 19 ├─Drivers 20 │ ├─CMSIS 21 │ │ ├─Device 22 │ │ │ └─ST 23 │ │ │ └─STM32H7xx 24 │ │ │ ├─Include 25 │ │ │ │ stm32h743xx.h 26 │ │ │ │ stm32h7xx.h 27 │ │ │ │ system_stm32h7xx.h 28 │ │ │ │ 29 │ │ │ └─Source 30 │ │ │ └─Templates 31 │ │ └─Include 32 │ │ cmsis_armcc.h 33 │ │ cmsis_armclang.h 34 │ │ cmsis_armclang_ltm.h 35 │ │ cmsis_compiler.h 36 │ │ cmsis_gcc.h 37 │ │ cmsis_iccarm.h 38 │ │ cmsis_version.h 39 │ │ core_armv81mml.h 40 │ │ core_armv8mbl.h 41 │ │ core_armv8mml.h 42 │ │ core_cm0.h 43 │ │ core_cm0plus.h 44 │ │ core_cm1.h 45 │ │ core_cm23.h 46 │ │ core_cm3.h 47 │ │ core_cm33.h 48 │ │ core_cm35p.h 49 │ │ core_cm4.h 50 │ │ core_cm7.h 51 │ │ core_sc000.h 52 │ │ core_sc300.h 53 │ │ mpu_armv7.h 54 │ │ mpu_armv8.h 55 │ │ tz_context.h 56 │ │ 57 │ └─STM32H7xx_HAL_Driver 58 │ ├─Inc 59 │ │ │ stm32h7xx_hal.h 60 │ │ │ stm32h7xx_hal_cortex.h 61 │ │ │ stm32h7xx_hal_def.h 62 │ │ │ stm32h7xx_hal_dma.h 63 │ │ │ stm32h7xx_hal_dma_ex.h 64 │ │ │ stm32h7xx_hal_exti.h 65 │ │ │ stm32h7xx_hal_flash.h 66 │ │ │ stm32h7xx_hal_flash_ex.h 67 │ │ │ stm32h7xx_hal_gpio.h 68 │ │ │ stm32h7xx_hal_gpio_ex.h 69 │ │ │ stm32h7xx_hal_hsem.h 70 │ │ │ stm32h7xx_hal_i2c.h 71 │ │ │ stm32h7xx_hal_i2c_ex.h 72 │ │ │ stm32h7xx_hal_mdma.h 73 │ │ │ stm32h7xx_hal_pwr.h 74 │ │ │ stm32h7xx_hal_pwr_ex.h 75 │ │ │ stm32h7xx_hal_rcc.h 76 │ │ │ stm32h7xx_hal_rcc_ex.h 77 │ │ │ stm32h7xx_hal_tim.h 78 │ │ │ stm32h7xx_hal_tim_ex.h 79 │ │ │ 80 │ │ └─Legacy 81 │ │ stm32_hal_legacy.h 82 │ │ 83 │ └─Src 84 │ stm32h7xx_hal.c 85 │ stm32h7xx_hal_cortex.c 86 │ stm32h7xx_hal_dma.c 87 │ stm32h7xx_hal_dma_ex.c 88 │ stm32h7xx_hal_exti.c 89 │ stm32h7xx_hal_flash.c 90 │ stm32h7xx_hal_flash_ex.c 91 │ stm32h7xx_hal_gpio.c 92 │ stm32h7xx_hal_hsem.c 93 │ stm32h7xx_hal_i2c.c 94 │ stm32h7xx_hal_i2c_ex.c 95 │ stm32h7xx_hal_mdma.c 96 │ stm32h7xx_hal_pwr.c 97 │ stm32h7xx_hal_pwr_ex.c 98 │ stm32h7xx_hal_rcc.c 99 │ stm32h7xx_hal_rcc_ex.c 100 │ stm32h7xx_hal_tim.c 101 │ stm32h7xx_hal_tim_ex.c 102 │ 103 └─MDK-ARM 104 startup_stm32h743xx.s 105 STM32H743XIH6.uvoptx 106 STM32H743XIH6.uvprojx
以上生成的文件就是最小工程需要的文件。
原文:https://www.cnblogs.com/723687715-Q/p/14906431.html