优化获取波特率的方式

This commit is contained in:
fengbh 2024-07-15 01:34:57 +08:00
parent 12fe1b13c7
commit ebf06e4b0c
2 changed files with 9 additions and 4 deletions

View File

@ -17,6 +17,9 @@ else
endif
endif
# set uart baudrate
BAUD := 9600
# set CC TOOL
PACKIHX := packihx
CFLAGS := -DUSE_FLOATS=1
@ -51,9 +54,11 @@ main.hex: $(TARGET)
flash:
-sudo chmod 777 $(COM)
-./reset_mcu.sh $(COM)
-./reset_mcu.sh $(COM) $(BAUD)
-stcgal -P stc89 -p $(COM) main.hex
com:
-minicom -D $(COM) -b $(BAUD)
#led.bin:led.hex
# objcopy -I ihex -O binary led.hex led.bin

View File

@ -16,11 +16,11 @@
# --- ---- --- -----------
# 0.0.01 2024-07-14 Feng Bohan initial version
#===========================================================================
if [ "$#" -ne 1 ]; then
echo "错误:此脚本需要且仅需要一个参数, 作为COM口号"
if [ "$#" -ne 2 ]; then
echo "错误:此脚本需要且仅需要2个参数, 作为COM口号和波特率。"
exit 1 # 使用非零状态码退出表示异常
fi
stty -F $1 speed 9600 cs8 -parenb -cstopb raw -echo -echoe -echok -echoctl -echoke
stty -F $1 speed $2 cs8 -parenb -cstopb raw -echo -echoe -echok -echoctl -echoke
echo -e "RESET!" > $1