Skip to content

Commit

Permalink
update stm32f411 mpy firmware and Add stm32f411 8Mhz crystal oscillator
Browse files Browse the repository at this point in the history
support
  • Loading branch information
YXZhu committed Dec 11, 2023
1 parent 7af5e79 commit 5c89e89
Show file tree
Hide file tree
Showing 20 changed files with 83,512 additions and 26 deletions.
78 changes: 78 additions & 0 deletions SDK/STM32F411CEU6/HAL/F411_ST7735/CrystalsChangeTo8Mhz.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
@echo off
title WeAct Studio Project Crystals Change To 8MHz Tool
setlocal EnableDelayedExpansion
cls

echo.
echo WeAct Studio Project 25Mhz Crystals Change To 8MHz
echo.

call :Search "main.c"
if not %return%=="" (
call :Replace %return% "RCC_OscInitStruct.PLL.PLLM = 12;" "RCC_OscInitStruct.PLL.PLLM = 4;"
call :Replace %return% "RCC_OscInitStruct.PLL.PLLN = 96;" "RCC_OscInitStruct.PLL.PLLN = 100;"
)

call :Search "stm32f4xx_hal_conf.h"
if not %return%=="" (
call :Replace %return% "#define HSE_VALUE ((uint32_t)25000000U)" "#define HSE_VALUE ((uint32_t)8000000U)"
)

call :Search "*.ioc"
if not %return%=="" (
call :Replace %return% "RCC.HSE_VALUE=25000000" "RCC.HSE_VALUE=8000000"
call :Replace %return% "RCC.PLLM=12" "RCC.PLLM=4"
call :Replace %return% "RCC.PLLN=96" "RCC.PLLN=100"
)

echo Replace Completed.
echo Thank You
echo.

pause
exit

REM Replace "File" "Old" "New"
:Replace
(echo Set FSO=Wscript.CreateObject("Scripting.FileSystemObject"^)
echo S=ReadFile("%~1","utf-8"^)
echo S=replace(S,"%~2", "%~3"^)
echo Call WriteToFile("%~1",S,"utf-8"^)
echo Wscript.Quit
echo Function ReadFile(FileUrl, CharSet^)
echo Dim Str
echo Set stm = CreateObject("Adodb.Stream"^)
echo stm.Type = 2
echo stm.mode = 3
echo stm.charset = CharSet
echo stm.Open
echo stm.loadfromfile FileUrl
echo Str = stm.readtext
echo stm.Close
echo Set stm = Nothing
echo ReadFile = Str
echo End Function
echo Function WriteToFile (FileUrl, Str, CharSet^)
echo Set stm = CreateObject("Adodb.Stream"^)
echo stm.Type = 2
echo stm.mode = 3
echo stm.charset = CharSet
echo stm.Open
echo stm.WriteText Str
echo stm.SaveToFile FileUrl, 2
echo stm.flush
echo stm.Close
echo Set stm = Nothing
echo End Function)>Replace.vbs
Replace.vbs
del /f /q Replace.vbs
goto :eof

:Search
set return=""
for %%a in (.) do for /f "delims=" %%b in ('dir /a-d/b/s %%a\%~1') do (
echo Find %%b
set return=%%b
goto :eof
)
goto :eof
78 changes: 78 additions & 0 deletions SDK/STM32F411CEU6/HAL/GPIO/GPIO_IOToggle/CrystalsChangeTo8Mhz.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
@echo off
title WeAct Studio Project Crystals Change To 8MHz Tool
setlocal EnableDelayedExpansion
cls

echo.
echo WeAct Studio Project 25Mhz Crystals Change To 8MHz
echo.

call :Search "main.c"
if not %return%=="" (
call :Replace %return% "RCC_OscInitStruct.PLL.PLLM = 12;" "RCC_OscInitStruct.PLL.PLLM = 4;"
call :Replace %return% "RCC_OscInitStruct.PLL.PLLN = 96;" "RCC_OscInitStruct.PLL.PLLN = 100;"
)

call :Search "stm32f4xx_hal_conf.h"
if not %return%=="" (
call :Replace %return% "#define HSE_VALUE ((uint32_t)25000000U)" "#define HSE_VALUE ((uint32_t)8000000U)"
)

call :Search "*.ioc"
if not %return%=="" (
call :Replace %return% "RCC.HSE_VALUE=25000000" "RCC.HSE_VALUE=8000000"
call :Replace %return% "RCC.PLLM=12" "RCC.PLLM=4"
call :Replace %return% "RCC.PLLN=96" "RCC.PLLN=100"
)

echo Replace Completed.
echo Thank You
echo.

pause
exit

REM Replace "File" "Old" "New"
:Replace
(echo Set FSO=Wscript.CreateObject("Scripting.FileSystemObject"^)
echo S=ReadFile("%~1","utf-8"^)
echo S=replace(S,"%~2", "%~3"^)
echo Call WriteToFile("%~1",S,"utf-8"^)
echo Wscript.Quit
echo Function ReadFile(FileUrl, CharSet^)
echo Dim Str
echo Set stm = CreateObject("Adodb.Stream"^)
echo stm.Type = 2
echo stm.mode = 3
echo stm.charset = CharSet
echo stm.Open
echo stm.loadfromfile FileUrl
echo Str = stm.readtext
echo stm.Close
echo Set stm = Nothing
echo ReadFile = Str
echo End Function
echo Function WriteToFile (FileUrl, Str, CharSet^)
echo Set stm = CreateObject("Adodb.Stream"^)
echo stm.Type = 2
echo stm.mode = 3
echo stm.charset = CharSet
echo stm.Open
echo stm.WriteText Str
echo stm.SaveToFile FileUrl, 2
echo stm.flush
echo stm.Close
echo Set stm = Nothing
echo End Function)>Replace.vbs
Replace.vbs
del /f /q Replace.vbs
goto :eof

:Search
set return=""
for %%a in (.) do for /f "delims=" %%b in ('dir /a-d/b/s %%a\%~1') do (
echo Find %%b
set return=%%b
goto :eof
)
goto :eof
4 changes: 4 additions & 0 deletions SDK/STM32F411CEU6/HAL/READMD-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
2. `XXXX_test_xx` 为出厂测试例程 呼吸灯、USBCDC功能、RTC功能
3. `XXXX_USBDisk+FATFS` 为U盘和FATFS文件系统例程 需要外接FLASH
4. `STM32F411_test_CubeIDE` CubeIDE 例程

## 重要说明

8Mhz晶振的板子,打开工程前先运行工程目录里的`CrystalsChangeTo8Mhz.bat`,脚本会自动修改工程的晶振配置,由25Mhz改为8Mhz
4 changes: 4 additions & 0 deletions SDK/STM32F411CEU6/HAL/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@
2. `xxxx_test` is the factory test routine breathing lamp, USBCDC function, RTC function
3. `XXXX_USBDisk+fatfs` for usb drives and FATFS file system routines require external FLASH
4. `STM32F411_test_CubeIDE` CubeIDE sample

## Important note

8Mhz crystal oscillator circuit board,Run the `CrystalsChangeTo8Mhz.bat` in the project directory before opening the project, and the script will automatically modify the crystal configuration of the project from 25Mhz to 8Mhz
76 changes: 76 additions & 0 deletions SDK/STM32F411CEU6/HAL/USB_HOST_TEST/CrystalsChangeTo8Mhz.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
@echo off
title WeAct Studio Project Crystals Change To 8MHz Tool
setlocal EnableDelayedExpansion
cls

echo.
echo WeAct Studio Project 25Mhz Crystals Change To 8MHz
echo.

call :Search "main.c"
if not %return%=="" (
call :Replace %return% "RCC_OscInitStruct.PLL.PLLM = 25;" "RCC_OscInitStruct.PLL.PLLM = 8;"
)

call :Search "stm32f4xx_hal_conf.h"
if not %return%=="" (
call :Replace %return% "#define HSE_VALUE ((uint32_t)25000000U)" "#define HSE_VALUE ((uint32_t)8000000U)"
)

call :Search "*.ioc"
if not %return%=="" (
call :Replace %return% "RCC.HSE_VALUE=25000000" "RCC.HSE_VALUE=8000000"
call :Replace %return% "RCC.PLLM=25" "RCC.PLLM=8"
)

echo Replace Completed.
echo Thank You
echo.

pause
exit

REM Replace "File" "Old" "New"
:Replace
(echo Set FSO=Wscript.CreateObject("Scripting.FileSystemObject"^)
echo S=ReadFile("%~1","utf-8"^)
echo S=replace(S,"%~2", "%~3"^)
echo Call WriteToFile("%~1",S,"utf-8"^)
echo Wscript.Quit
echo Function ReadFile(FileUrl, CharSet^)
echo Dim Str
echo Set stm = CreateObject("Adodb.Stream"^)
echo stm.Type = 2
echo stm.mode = 3
echo stm.charset = CharSet
echo stm.Open
echo stm.loadfromfile FileUrl
echo Str = stm.readtext
echo stm.Close
echo Set stm = Nothing
echo ReadFile = Str
echo End Function
echo Function WriteToFile (FileUrl, Str, CharSet^)
echo Set stm = CreateObject("Adodb.Stream"^)
echo stm.Type = 2
echo stm.mode = 3
echo stm.charset = CharSet
echo stm.Open
echo stm.WriteText Str
echo stm.SaveToFile FileUrl, 2
echo stm.flush
echo stm.Close
echo Set stm = Nothing
echo End Function)>Replace.vbs
Replace.vbs
del /f /q Replace.vbs
goto :eof

:Search
set return=""
for %%a in (.) do for /f "delims=" %%b in ('dir /a-d/b/s %%a\%~1') do (
echo Find %%b
set return=%%b
goto :eof
)
goto :eof
76 changes: 76 additions & 0 deletions SDK/STM32F411CEU6/HAL/WeAct_RGB_WS2812/CrystalsChangeTo8Mhz.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
@echo off
title WeAct Studio Project Crystals Change To 8MHz Tool
setlocal EnableDelayedExpansion
cls

echo.
echo WeAct Studio Project 25Mhz Crystals Change To 8MHz
echo.

call :Search "main.c"
if not %return%=="" (
call :Replace %return% "RCC_OscInitStruct.PLL.PLLM = 25;" "RCC_OscInitStruct.PLL.PLLM = 8;"
)

call :Search "stm32f4xx_hal_conf.h"
if not %return%=="" (
call :Replace %return% "#define HSE_VALUE ((uint32_t)25000000U)" "#define HSE_VALUE ((uint32_t)8000000U)"
)

call :Search "*.ioc"
if not %return%=="" (
call :Replace %return% "RCC.HSE_VALUE=25000000" "RCC.HSE_VALUE=8000000"
call :Replace %return% "RCC.PLLM=25" "RCC.PLLM=8"
)

echo Replace Completed.
echo Thank You
echo.

pause
exit

REM Replace "File" "Old" "New"
:Replace
(echo Set FSO=Wscript.CreateObject("Scripting.FileSystemObject"^)
echo S=ReadFile("%~1","utf-8"^)
echo S=replace(S,"%~2", "%~3"^)
echo Call WriteToFile("%~1",S,"utf-8"^)
echo Wscript.Quit
echo Function ReadFile(FileUrl, CharSet^)
echo Dim Str
echo Set stm = CreateObject("Adodb.Stream"^)
echo stm.Type = 2
echo stm.mode = 3
echo stm.charset = CharSet
echo stm.Open
echo stm.loadfromfile FileUrl
echo Str = stm.readtext
echo stm.Close
echo Set stm = Nothing
echo ReadFile = Str
echo End Function
echo Function WriteToFile (FileUrl, Str, CharSet^)
echo Set stm = CreateObject("Adodb.Stream"^)
echo stm.Type = 2
echo stm.mode = 3
echo stm.charset = CharSet
echo stm.Open
echo stm.WriteText Str
echo stm.SaveToFile FileUrl, 2
echo stm.flush
echo stm.Close
echo Set stm = Nothing
echo End Function)>Replace.vbs
Replace.vbs
del /f /q Replace.vbs
goto :eof

:Search
set return=""
for %%a in (.) do for /f "delims=" %%b in ('dir /a-d/b/s %%a\%~1') do (
echo Find %%b
set return=%%b
goto :eof
)
goto :eof
Loading

0 comments on commit 5c89e89

Please sign in to comment.