多路烧录时支持单独烧录每1路, 支持SPI Flash一拖四烧录

This commit is contained in:
armfly 2021-03-25 11:42:58 +08:00
parent 76b759e45d
commit a40f6d69d0
32 changed files with 1635 additions and 419 deletions

View File

@ -1,4 +1,19 @@
----------------------------------------------------------------------------
2021-03-25 V1.49 对应PC软件版本 V1.4.6
1.完善脱机烧录功能
- 脱机烧录菜单变更,进入后选择烧录模式,再进入烧录界面,方面单路和多路切换
- 一拖四功能支持单独烧录第2路、单独烧录第3路、单独烧录第4路。
- 脱机烧录的滚码支持64bit整数支持修改递增步长
- PC传送配置文件时TOOL自动切换到烧录状态
- 新增国民技术MCU的烧录支持
2.EMMC磁盘文件更新
- 滚码支持64bit整数支持递增步长设置
- 新增国民技术MCU的配置文件
- 支持单独烧录第2路、单独烧录第3路、单独烧录第4路
- 完善SPI Flash的全片擦除功能
3.提示:建议BOOT升级到V2.01版本完善了U盘拖放升级功能.
----------------------------------------------------------------------------
2021-03-17 V1.48 对应PC软件版本 V1.4.5

Binary file not shown.

View File

@ -180,77 +180,27 @@
<Ww>
<count>0</count>
<WinNumber>1</WinNumber>
<ItemText>g_tModS.TxBuf</ItemText>
<ItemText>g_gMulSwd</ItemText>
</Ww>
<Ww>
<count>1</count>
<WinNumber>1</WinNumber>
<ItemText>g_RecMemo</ItemText>
<ItemText>_pStr</ItemText>
</Ww>
<Ww>
<count>2</count>
<WinNumber>1</WinNumber>
<ItemText>_id</ItemText>
<ItemText>ulInt,0x0A</ItemText>
</Ww>
<Ww>
<count>3</count>
<WinNumber>1</WinNumber>
<ItemText>s_DS18B20_TempReg</ItemText>
<ItemText>ulInt</ItemText>
</Ww>
<Ww>
<count>4</count>
<WinNumber>1</WinNumber>
<ItemText>g_uiTimeHighWord</ItemText>
</Ww>
<Ww>
<count>5</count>
<WinNumber>1</WinNumber>
<ItemText>g_tFLM</ItemText>
</Ww>
<Ww>
<count>6</count>
<WinNumber>1</WinNumber>
<ItemText>timeout</ItemText>
</Ww>
<Ww>
<count>7</count>
<WinNumber>1</WinNumber>
<ItemText>uwTick-timeout</ItemText>
</Ww>
<Ww>
<count>8</count>
<WinNumber>1</WinNumber>
<ItemText>s_lua_prog_buf</ItemText>
</Ww>
<Ww>
<count>9</count>
<WinNumber>1</WinNumber>
<ItemText>s_lua_prog_len</ItemText>
</Ww>
<Ww>
<count>10</count>
<WinNumber>1</WinNumber>
<ItemText>s_lua_prog_buf[0x000038AB]</ItemText>
</Ww>
<Ww>
<count>11</count>
<WinNumber>1</WinNumber>
<ItemText>R0</ItemText>
</Ww>
<Ww>
<count>12</count>
<WinNumber>1</WinNumber>
<ItemText>ack[0]</ItemText>
</Ww>
<Ww>
<count>13</count>
<WinNumber>1</WinNumber>
<ItemText>ack[1]</ItemText>
</Ww>
<Ww>
<count>14</count>
<WinNumber>1</WinNumber>
<ItemText>s_debug</ItemText>
<ItemText>_pIni</ItemText>
</Ww>
</WatchWindow1>
<MemoryWindow1>
@ -275,7 +225,7 @@
<DebugFlag>
<trace>0</trace>
<periodic>1</periodic>
<aLwin>0</aLwin>
<aLwin>1</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
<aSer2>0</aSer2>
@ -1179,7 +1129,7 @@
<Group>
<GroupName>MDK-ARM</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -2975,7 +2925,7 @@
<Group>
<GroupName>Modbus</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -3174,8 +3124,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\User\programmer\stm8_flash.c</PathWithFileName>
<FilenameWithoutPath>stm8_flash.c</FilenameWithoutPath>
<PathWithFileName>..\..\User\programmer\stm8_swim.c</PathWithFileName>
<FilenameWithoutPath>stm8_swim.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@ -3186,8 +3136,8 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\User\programmer\stm8_swim.c</PathWithFileName>
<FilenameWithoutPath>stm8_swim.c</FilenameWithoutPath>
<PathWithFileName>..\..\User\programmer\stm8_flash.c</PathWithFileName>
<FilenameWithoutPath>stm8_flash.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
@ -3907,7 +3857,7 @@
<Group>
<GroupName>DAP_bsp</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -4023,7 +3973,7 @@
<Group>
<GroupName>DAP_Host</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -4103,7 +4053,7 @@
<Group>
<GroupName>ST_USB_Device_Library_Core</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -4147,7 +4097,7 @@
<Group>
<GroupName>ST_USB_Device_Library_Class</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>

View File

@ -1695,16 +1695,16 @@
<FileType>5</FileType>
<FilePath>..\..\User\programmer\SWD_flash.h</FilePath>
</File>
<File>
<FileName>stm8_flash.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\User\programmer\stm8_flash.c</FilePath>
</File>
<File>
<FileName>stm8_swim.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\User\programmer\stm8_swim.c</FilePath>
</File>
<File>
<FileName>stm8_flash.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\User\programmer\stm8_flash.c</FilePath>
</File>
<File>
<FileName>edc_crc_a.asm</FileName>
<FileType>2</FileType>

View File

@ -68,7 +68,7 @@ __Vectors DCD __initial_sp ; Top of Stack
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0x00000148 ; Reserved H7-TOOL APP 固件版本
DCD 0x00000149 ; Reserved H7-TOOL APP 固件版本
DCD 0 ; Reserved 固件小版本
DCD 0 ; Reserved
DCD 0 ; Reserved

View File

@ -13,6 +13,7 @@
#include "ff.h" /* FatFS文件系统模块*/
#include "ff_gen_drv.h"
#include "sd_diskio_dma.h"
#include "bsp.h"
/* Lua程序根目录 */
#define LUA_ROOT_DIR "0:/H7-TOOL/Lua"
@ -37,6 +38,8 @@ typedef struct
char Name[FILE_MAX_NUM][FILE_NAME_MAX_LEN + 1];
uint8_t Count;
char Path[200];
uint16_t Cursor;
}FILE_LIST_T;
/* prog ini文件结构 */
@ -47,7 +50,7 @@ typedef struct
uint32_t ProgramLimit; /* 烧录次数限制 0表示不限制 */
uint32_t ProgrammedCount;
uint32_t ProductSN; /* 产品序号(整数部分) */
int64_t ProductSN; /* 产品序号(整数部分) */
}PROG_INI_T;
@ -82,7 +85,7 @@ void FixFileName(char *_Path);
void ini_ReadString(const char *_IniBuf, const char *_ParamName, char *_OutBuff, int32_t _BuffSize);
int32_t ini_ReadInteger(const char *_IniBuf, const char *_ParamName);
int64_t ini_ReadInteger(const char *_IniBuf, const char *_ParamName);
void ini_WriteString(const char *_IniBuf, const char *_ParamName, const char *_NewStr, uint32_t _IniBufSize);
void ini_WriteInteger(const char *_IniBuf, const char *_ParamName, int _IntValue, uint32_t _IniBufSize);
int32_t ReadProgIniFile(char *_LuaPath, PROG_INI_T *pIni);

View File

@ -75,6 +75,8 @@ enum
MS_EXTEND_MENU_LUA, /* 第2级菜单-LUA程序 */
MS_EXTEND_MENU_REC, /* 第2级菜单-数据记录仪 */
MS_EXTEND_MENU_PROG_MODE, /* 第2级菜单-烧录器 */
MS_LUA_SELECT_FILE, /* 浏览lua文件 */
MS_LUA_EXEC_FILE, /* 执行lua文件 */

View File

@ -207,6 +207,7 @@ typedef struct
uint8_t SaveAlgoToCFile; /* 解析FLM时保存解析结果到C文件仅仅用于debug */
uint8_t ReqWriteBoot; /* 用于PC机通知刷新boot */
uint8_t ReqProgOnce; /* 用于PC机通知TOOL烧录一次*/
uint8_t ReqJump; /* 请求跳转 */
uint8_t UsbEmmcRemoved; /* U盘移除 */

View File

@ -489,7 +489,7 @@ void ini_WriteString(const char *_IniBuf, const char *_ParamName, const char *_N
* : 0
*********************************************************************************************************
*/
int32_t ini_ReadInteger(const char *_IniBuf, const char *_ParamName)
int64_t ini_ReadInteger(const char *_IniBuf, const char *_ParamName)
{
/*
Count = -1
@ -510,7 +510,7 @@ int32_t ini_ReadInteger(const char *_IniBuf, const char *_ParamName)
return 0;
}
return str_to_int3(p + 1);
return str_to_int64(p + 1);
}
/*
@ -694,7 +694,7 @@ int32_t WriteProgIniFile(char *_LuaPath, PROG_INI_T *_pIni)
sprintf(FsReadBuf, "Locked = %d\r\n", _pIni->Locked);
sprintf(&FsReadBuf[strlen(FsReadBuf)], "ProgramLimit = %d\r\n", _pIni->ProgramLimit);
sprintf(&FsReadBuf[strlen(FsReadBuf)], "ProgrammedCount = %d\r\n", _pIni->ProgrammedCount);
sprintf(&FsReadBuf[strlen(FsReadBuf)], "ProductSN = %d\r\n", _pIni->ProductSN);
sprintf(&FsReadBuf[strlen(FsReadBuf)], "ProductSN = %lld\r\n", _pIni->ProductSN);
/* 打开ini文件准备写 */
re = f_open(&g_file, path, FA_WRITE | FA_CREATE_ALWAYS);

View File

@ -54,6 +54,7 @@
extern void status_DS18B20Meter(void);
extern void status_ExtendMenuProg(void);
uint16_t GetStatusIndex(uint16_t _NowStatus);
@ -228,6 +229,10 @@ int main(void)
status_ProgWork();
break;
case MS_EXTEND_MENU_PROG_MODE: /* 脱机下载器 - 菜单选择模式 */
status_ExtendMenuProg();
break;
case MS_PROG_SETTING: /* 脱机下载器 - 参数设置 */
status_ProgSetting();
break;

View File

@ -22,12 +22,11 @@
const uint8_t *g_Menu1_Text[] =
{
" 1 CMSIS-DAP仿真器",
" 2 脱机烧录器(单路)",
" 3 脱机烧录器(多路)",
" 4 LUA小程序",
" 5 数据监视器",
" 6 USB虚拟串口",
" 7 系统设置",
" 2 脱机烧录器",
" 3 LUA小程序",
" 4 数据监视器",
" 5 USB虚拟串口",
" 6 系统设置",
/* 结束符号, 用于菜单函数自动识别菜单项个数 */
"&"
@ -46,6 +45,22 @@ const uint8_t *g_MenuRec_Text[] =
MENU_T g_tMenuRec;
const char *g_MenuProgMode_Text[] =
{
"1 单路(无需1拖4板)",
"2 1拖4(第1-4路)",
"3 1拖3(第1-3路)",
"4 1拖2(第1-2路)",
"5 1拖1(第1路)",
"6 1拖1(第2路)",
"7 1拖1(第3路)",
"8 1拖1(第4路)",
/* 结束符号, 用于菜单函数自动识别菜单项个数 */
"&"
};
MENU_T g_tMenuProgMode;
void JumpToDAPLink(void);
/*
@ -63,7 +78,7 @@ void status_ExtendMenu1(void)
static uint8_t s_MenuInit = 0;
DispHeader("扩展功能");
DispHeader2(8, "扩展功能");
// DispHelpBar("",
// "");
@ -76,7 +91,14 @@ void status_ExtendMenu1(void)
g_tMenu1.Height = MENU_HEIGHT;
g_tMenu1.Width = MENU_WIDTH;
g_tMenu1.LineCap = MENU_CAP;
g_tMenu1.ViewLine = 8;
if (g_LcdHeight == 320)
{
g_tMenu1.ViewLine = 8;
}
else
{
g_tMenu1.ViewLine = 7;
}
g_tMenu1.Font.FontCode = FC_ST_24;
g_tMenu1.Font.Space = 0;
g_tMenu1.RollBackEn = 1; /* 允许回滚 */
@ -84,6 +106,9 @@ void status_ExtendMenu1(void)
g_tMenu1.ActiveBackColor = 0; /* 选中行背景色ID */
LCD_InitMenu(&g_tMenu1, (char **)g_Menu1_Text); /* 初始化菜单结构 */
}
g_tMenu1.Left = MENU_LEFT; /* 横竖屏切换回修改居中坐标 */
LCD_DispMenu(&g_tMenu1);
fRefresh = 1;
@ -119,27 +144,21 @@ void status_ExtendMenu1(void)
}
else if (g_tMenu1.Cursor == 1)
{
g_gMulSwd.MultiMode = 0;
g_MainStatus = MS_PROG_WORK;
g_MainStatus = MS_EXTEND_MENU_PROG_MODE;
}
else if (g_tMenu1.Cursor == 2)
{
g_gMulSwd.MultiMode = g_tParam.MultiProgMode;
g_MainStatus = MS_PROG_WORK;
g_MainStatus = MS_LUA_SELECT_FILE;
}
else if (g_tMenu1.Cursor == 3)
{
g_MainStatus = MS_LUA_SELECT_FILE;
g_MainStatus = MS_EXTEND_MENU_REC;
}
else if (g_tMenu1.Cursor == 4)
{
g_MainStatus = MS_EXTEND_MENU_REC;
}
else if (g_tMenu1.Cursor == 5)
{
g_MainStatus = MS_USB_UART;
}
else if (g_tMenu1.Cursor == 6)
else if (g_tMenu1.Cursor == 5)
{
g_MainStatus = MS_SYSTEM_SET;
}
@ -192,9 +211,10 @@ void status_ExtendMenuRec(void)
g_tMenuRec.ActiveBackColor = 0; /* 选中行背景色ID */
LCD_InitMenu(&g_tMenuRec, (char **)g_MenuRec_Text); /* 初始化菜单结构 */
}
g_tMenuRec.Left = MENU_LEFT; /* 横竖屏切换回修改居中坐标 */
LCD_DispMenu(&g_tMenuRec);
DispHeader("请选择");
DispHeader2(84, "请选择");
// DispHelpBar("",
// "");
@ -264,6 +284,159 @@ void status_ExtendMenuRec(void)
}
}
/*
*********************************************************************************************************
* : status_ExtendMenuProg
* :
* :
* :
*********************************************************************************************************
*/
void status_ExtendMenuProg(void)
{
uint8_t ucKeyCode; /* 按键代码 */
uint8_t fRefresh;
static uint8_t s_MenuInit = 0;
if (s_MenuInit == 0)
{
s_MenuInit = 1;
g_tMenuProgMode.Left = MENU_LEFT;
g_tMenuProgMode.Top = MENU_TOP;
g_tMenuProgMode.Height = MENU_HEIGHT;
g_tMenuProgMode.Width = MENU_WIDTH;
g_tMenuProgMode.LineCap = MENU_CAP;
if (g_LcdHeight == 320)
{
g_tMenuProgMode.ViewLine = 8;
}
else
{
g_tMenuProgMode.ViewLine = 7;
}
g_tMenuProgMode.Font.FontCode = FC_ST_24;
g_tMenuProgMode.Font.Space = 0;
g_tMenuProgMode.RollBackEn = 1; /* 允许回滚 */
g_tMenuProgMode.GBK = 0;
g_tMenuProgMode.ActiveBackColor = 0; /* 选中行背景色ID */
LCD_InitMenu(&g_tMenuProgMode, (char **)g_MenuProgMode_Text); /* 初始化菜单结构 */
}
g_tMenuProgMode.Left = MENU_LEFT; /* 横竖屏切换回修改居中坐标 */
LCD_DispMenu(&g_tMenuProgMode);
DispHeader2(82, "选择烧录模式");
// DispHelpBar("",
// "");
LCD_DispMenu(&g_tMenuProgMode);
fRefresh = 1;
while (g_MainStatus == MS_EXTEND_MENU_PROG_MODE)
{
if (fRefresh) /* 刷新整个界面 */
{
fRefresh = 0;
if (g_tMenuRec.Cursor == 0)
{
;
}
}
bsp_Idle();
ucKeyCode = bsp_GetKey(); /* 读取键值, 无键按下时返回 KEY_NONE = 0 */
if (ucKeyCode != KEY_NONE)
{
/* 有键按下 */
switch (ucKeyCode)
{
case KEY_UP_S: /* S键 上 */
PlayKeyTone();
LCD_MoveUpMenu(&g_tMenuProgMode);
break;
case KEY_LONG_DOWN_S: /* S键 上 */
PlayKeyTone();
g_gMulSwd.SwitchPin = 0;
if (g_tMenuProgMode.Cursor == 0)
{
g_gMulSwd.MultiMode = 0;
g_MainStatus = MS_PROG_WORK;
}
else if (g_tMenuProgMode.Cursor == 1)
{
g_tParam.MultiProgMode = 4;
g_gMulSwd.MultiMode = g_tParam.MultiProgMode;
g_MainStatus = MS_PROG_WORK;
}
else if (g_tMenuProgMode.Cursor == 2)
{
g_tParam.MultiProgMode = 3;
g_gMulSwd.MultiMode = g_tParam.MultiProgMode;
g_MainStatus = MS_PROG_WORK;
}
else if (g_tMenuProgMode.Cursor == 3)
{
g_tParam.MultiProgMode = 2;
g_gMulSwd.MultiMode = g_tParam.MultiProgMode;
g_MainStatus = MS_PROG_WORK;
}
else if (g_tMenuProgMode.Cursor == 4)
{
g_tParam.MultiProgMode = 1;
g_gMulSwd.MultiMode = g_tParam.MultiProgMode;
g_gMulSwd.SwitchPin = 0; /* 只烧写第1通道 */
g_MainStatus = MS_PROG_WORK;
}
else if (g_tMenuProgMode.Cursor == 5)
{
g_tParam.MultiProgMode = 1;
g_gMulSwd.MultiMode = g_tParam.MultiProgMode;
g_gMulSwd.SwitchPin = 1; /* 只烧写第2通道 */
g_MainStatus = MS_PROG_WORK;
}
else if (g_tMenuProgMode.Cursor == 6)
{
g_tParam.MultiProgMode = 1;
g_gMulSwd.MultiMode = g_tParam.MultiProgMode;
g_gMulSwd.SwitchPin = 2; /* 只烧写第3通道 */
g_MainStatus = MS_PROG_WORK;
}
else if (g_tMenuProgMode.Cursor == 7)
{
g_tParam.MultiProgMode = 1;
g_gMulSwd.MultiMode = g_tParam.MultiProgMode;
g_gMulSwd.SwitchPin = 3; /* 只烧写第4通道 */
g_MainStatus = MS_PROG_WORK;
}
break;
case KEY_UP_C: /* C键 下 */
PlayKeyTone();
LCD_MoveDownMenu(&g_tMenuProgMode);
break;
case KEY_LONG_DOWN_C: /* C键长按 */
PlayKeyTone();
g_MainStatus = MS_EXTEND_MENU1;
break;
default:
break;
}
}
}
if (g_MainStatus == MS_PROG_WORK)
{
;
}
}
/*
*********************************************************************************************************
* : JumpToDAPLink

View File

@ -251,11 +251,22 @@ void status_ProgWork(void)
// }
/* 当前烧录模式 */
g_gMulSwd.Error[0] = 0;
g_gMulSwd.Error[1] = 0;
g_gMulSwd.Error[2] = 0;
g_gMulSwd.Error[3] = 0;
if (g_gMulSwd.MultiMode == 0) PG_PrintText("单路模式");
else if (g_gMulSwd.MultiMode == 1) PG_PrintText("多路模式:1路");
else if (g_gMulSwd.MultiMode == 2) PG_PrintText("多路模式:1-2路");
else if (g_gMulSwd.MultiMode == 3) PG_PrintText("多路模式:1-3路");
else if (g_gMulSwd.MultiMode == 4) PG_PrintText("多路模式:1-4路");
else if (g_gMulSwd.MultiMode == 1)
{
if (g_gMulSwd.SwitchPin == 0) PG_PrintText("1拖1,烧录第1路");
else if (g_gMulSwd.SwitchPin == 1) PG_PrintText("1拖1,烧录第2路");
else if (g_gMulSwd.SwitchPin == 2) PG_PrintText("1拖1,烧录第3路");
else if (g_gMulSwd.SwitchPin == 3) PG_PrintText("1拖1,烧录第4路");
}
else if (g_gMulSwd.MultiMode == 2) PG_PrintText("1拖2,烧录第1-2路");
else if (g_gMulSwd.MultiMode == 3) PG_PrintText("1拖3,烧录第1-3路");
else if (g_gMulSwd.MultiMode == 4) PG_PrintText("1拖4,烧录第1-4路");
}
/* V1.36 解决第一次上电第1次烧录失败问题 */
@ -367,6 +378,10 @@ void status_ProgWork(void)
lua_if.c LuaYeildHook()S键终止lua执行
*/
g_gMulSwd.Error[0] = 0;
g_gMulSwd.Error[1] = 0;
g_gMulSwd.Error[2] = 0;
g_gMulSwd.Error[3] = 0;
PG_PrintText("开始烧录...");
if (g_gMulSwd.MultiMode > 0) /* 多路模式 */
@ -677,7 +692,7 @@ void status_ProgWork(void)
}
else
{
g_MainStatus = MS_EXTEND_MENU1;
g_MainStatus = MS_EXTEND_MENU_PROG_MODE;
}
break;
@ -685,6 +700,37 @@ void status_ProgWork(void)
break;
}
}
/* PC控制烧录一次 */
if (g_tVar.ReqProgOnce > 0)
{
/* 进入单路烧录模式, 不烧录 */
if (g_tVar.ReqProgOnce == 1)
{
g_tVar.ReqProgOnce = 2;
g_MainStatus = MS_PROG_WORK;
return; /* 退出烧录状态重新再进入一次烧录状态自动装载一次lua文件 */
}
else if (g_tVar.ReqProgOnce == 2)
{
g_tVar.ReqProgOnce = 0;
}
/* 进入单路烧录模式,并烧录1次 */
if (g_tVar.ReqProgOnce == 3)
{
g_tVar.ReqProgOnce = 4;
g_MainStatus = MS_PROG_WORK;
return; /* 退出烧录状态重新再进入一次烧录状态自动装载一次lua文件 */
}
else if (g_tVar.ReqProgOnce == 4)
{
g_tVar.ReqProgOnce = 0;
/* 烧录一次 */
g_tProg.AutoStart = 0;
fRunOnce = 1;
}
}
}
PERIOD_Start(&g_tRunLed, 1000, 1000, 0); /* LED一直闪烁, 每2秒闪1次 */

View File

@ -55,7 +55,16 @@ void status_SystemSetMain(void)
g_tMenuSys.Height = MENU_HEIGHT;
g_tMenuSys.Width = MENU_WIDTH;
g_tMenuSys.LineCap = MENU_CAP;
g_tMenuSys.ViewLine = 7;
if (g_LcdHeight == 320)
{
g_tMenuSys.ViewLine = 8;
}
else
{
g_tMenuSys.ViewLine = 7;
}
g_tMenuSys.Font.FontCode = FC_ST_24;
// g_tMenuSys.Font.FrontColor = CL_BLACK; /* 字体颜色 */
// g_tMenuSys.Font.BackColor = FORM_BACK_COLOR; /* 文字背景颜色 */

View File

@ -34,6 +34,8 @@
#define KEY_AUTO_C KEY_2_AUTO_UP
#define KEY_DB_C KEY_2_DB_UP
#define KEY_WAKE_UP KEY_DB_S /* 用于唤醒屏幕背光 */
/* 按键ID, 主要用于bsp_KeyState()函数的入口参数 */
typedef enum
{

View File

@ -41,6 +41,7 @@ uint8_t TwoCharToInt(char *_ch);
int str_to_int2(char *_pStr);
int str_to_int3(char *_pStr);
int64_t str_to_int64(char *_pStr);
uint8_t ip_str_decode(char *_ipstr, uint8_t *_out);
uint16_t GetHigh16OfFloat(float _ff);

View File

@ -122,7 +122,7 @@ uint8_t BSP_MMC_Init(void)
200MHz / (2*2) = 50MHz
200MHz / (2*3) = 33MHz
*/
uSdHandle.Init.ClockDiv = 3; /* 2019-12-13 2 -> 3 */
uSdHandle.Init.ClockDiv = 4; /* 2019-12-13 2 -> 3 2021-03-22由3改为4*/
uSdHandle.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE;
uSdHandle.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING;
uSdHandle.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_ENABLE;

View File

@ -954,6 +954,69 @@ int str_to_int3(char *_pStr)
return ulInt;
}
/*
*********************************************************************************************************
* : str_to_int64
* : ASCII码字符串转换成整数 ini文件 TAB自动略过0-9
* : _pStr :ASCII码串tab0-9
* :
*********************************************************************************************************
*/
int64_t str_to_int64(char *_pStr)
{
unsigned char state = 0;
unsigned char flag = 0;
char *p;
int64_t ulInt;
unsigned char ucTemp;
p = _pStr;
ulInt = 0;
while (1)
{
ucTemp = *p++;
if (state == 0)
{
if (ucTemp == ' ' || ucTemp == '\t')
{
continue;
}
else
{
if (ucTemp == '-')
{
flag = 1; /* 是负数 */
}
else
{
ulInt = ulInt * 10 + (ucTemp - '0');
state = 1;
}
}
}
else if (state == 1)
{
if ((ucTemp >= '0') && (ucTemp <= '9'))
{
ulInt = ulInt * 10 + (ucTemp - '0');
}
else
{
break;
}
}
}
if (flag == 1)
{
return -ulInt;
}
return ulInt;
}
/*
*********************************************************************************************************
* : ip_str_decode

View File

@ -212,66 +212,13 @@ uint8_t SWD_TransferFast(uint32_t request, uint32_t *data)
/* Read data */
/* armfly 优化奇偶校验算法 */
val = 0U;
#if 0
{
uint32_t buf[32];
// PD3 = CLK PD4 = DIO
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[0] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[1] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[2] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[3] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[4] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[5] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[6] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[7] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[8] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[9] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[10] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[11] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[12] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[13] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[14] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[15] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[16] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[17] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[18] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[19] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[20] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[21] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[22] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[23] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[24] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[25] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[26] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[27] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[28] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[29] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[30] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
GPIOD->BSRR = (GPIO_PIN_3 << 16U); buf[31] = GPIOD->IDR; GPIOD->BSRR = GPIO_PIN_3;
parity = 0;
for (n = 0; n < 32; n++)
{
val >>= 1;
if (buf[n] & GPIO_PIN_4)
{
val |= 0x80000000;
parity++;
}
}
//parity = GetParity(val);
}
#else
for (n = 32U; n; n--) {
SW_READ_BIT_FAST(bit); /* Read RDATA[0:31] */
val >>= 1;
val |= bit << 31;
}
parity = GetParity(val);
#endif
SW_READ_BIT_FAST(bit); /* Read Parity */

View File

@ -82,38 +82,73 @@
#define MUL_GPIO_SWD GPIOE
#define MUL_GPIO_DIR GPIOG
#define MUL_PIN_SWCLK_1 GPIO_PIN_12
#define MUL_PIN_SWDIO_1 GPIO_PIN_11
#define MUL_PIN_DIR_1 GPIO_PIN_9
#if 1 // 正确引脚
#define MUL_PIN_SWCLK_1 GPIO_PIN_12
#define MUL_PIN_SWDIO_1 GPIO_PIN_11
#define MUL_PIN_DIR_1 GPIO_PIN_9
#define MUL_PIN_SWCLK_2 GPIO_PIN_10
#define MUL_PIN_SWDIO_2 GPIO_PIN_2
#define MUL_PIN_DIR_2 GPIO_PIN_7
#define MUL_PIN_SWCLK_2 GPIO_PIN_10
#define MUL_PIN_SWDIO_2 GPIO_PIN_2
#define MUL_PIN_DIR_2 GPIO_PIN_7
#define MUL_PIN_SWCLK_3 GPIO_PIN_9
#define MUL_PIN_SWDIO_3 GPIO_PIN_4
#define MUL_PIN_DIR_3 GPIO_PIN_12
#define MUL_PIN_SWCLK_3 GPIO_PIN_9
#define MUL_PIN_SWDIO_3 GPIO_PIN_4
#define MUL_PIN_DIR_3 GPIO_PIN_12
#define MUL_PIN_SWCLK_4 GPIO_PIN_6
#define MUL_PIN_SWDIO_4 GPIO_PIN_5
#define MUL_PIN_DIR_4 GPIO_PIN_10
#define MUL_PIN_SWCLK_4 GPIO_PIN_6
#define MUL_PIN_SWDIO_4 GPIO_PIN_5
#define MUL_PIN_DIR_4 GPIO_PIN_10
/* pin bit */
#define MUL_PINB_SWCLK_1 12
#define MUL_PINB_SWDIO_1 11
#define MUL_PINB_DIR_1 9
/* pin bit */
#define MUL_PINB_SWCLK_1 12
#define MUL_PINB_SWDIO_1 11
#define MUL_PINB_DIR_1 9
#define MUL_PINB_SWCLK_2 10
#define MUL_PINB_SWDIO_2 2
#define MUL_PINB_DIR_2 7
#define MUL_PINB_SWCLK_2 10
#define MUL_PINB_SWDIO_2 2
#define MUL_PINB_DIR_2 7
#define MUL_PINB_SWCLK_3 9
#define MUL_PINB_SWDIO_3 4
#define MUL_PINB_DIR_3 12
#define MUL_PINB_SWCLK_3 9
#define MUL_PINB_SWDIO_3 4
#define MUL_PINB_DIR_3 12
#define MUL_PINB_SWCLK_4 6
#define MUL_PINB_SWDIO_4 5
#define MUL_PINB_DIR_4 10
#define MUL_PINB_SWCLK_4 6
#define MUL_PINB_SWDIO_4 5
#define MUL_PINB_DIR_4 10
#else // PORT1 he PORT2交换, 用于测试
#define MUL_PIN_SWCLK_1 GPIO_PIN_10 //GPIO_PIN_12
#define MUL_PIN_SWDIO_1 GPIO_PIN_2 //GPIO_PIN_11
#define MUL_PIN_DIR_1 GPIO_PIN_7 //GPIO_PIN_9
#define MUL_PIN_SWCLK_2 GPIO_PIN_12 //GPIO_PIN_10
#define MUL_PIN_SWDIO_2 GPIO_PIN_11 //GPIO_PIN_2
#define MUL_PIN_DIR_2 GPIO_PIN_9 //GPIO_PIN_7
#define MUL_PIN_SWCLK_3 GPIO_PIN_9
#define MUL_PIN_SWDIO_3 GPIO_PIN_4
#define MUL_PIN_DIR_3 GPIO_PIN_12
#define MUL_PIN_SWCLK_4 GPIO_PIN_6
#define MUL_PIN_SWDIO_4 GPIO_PIN_5
#define MUL_PIN_DIR_4 GPIO_PIN_10
/* pin bit */
#define MUL_PINB_SWCLK_1 10 //12
#define MUL_PINB_SWDIO_1 2 //11
#define MUL_PINB_DIR_1 7 //9
#define MUL_PINB_SWCLK_2 12 //10
#define MUL_PINB_SWDIO_2 11 //2
#define MUL_PINB_DIR_2 9 //7
#define MUL_PINB_SWCLK_3 9
#define MUL_PINB_SWDIO_3 4
#define MUL_PINB_DIR_3 12
#define MUL_PINB_SWCLK_4 6
#define MUL_PINB_SWDIO_4 5
#define MUL_PINB_DIR_4 10
#endif
/* GPIO_MODER寄存器 */
#define MUL_DIO_MODE_MASK_1 ~(3u << (MUL_PINB_SWDIO_1 * 2))
@ -140,6 +175,16 @@
MUL_SWD_T g_gMulSwd = {0};
const uint32_t TablePinDIR[4] = {MUL_PIN_DIR_1, MUL_PIN_DIR_2, MUL_PIN_DIR_3, MUL_PIN_DIR_4};
const uint32_t TablePinSWClK[4] = {MUL_PIN_SWCLK_1, MUL_PIN_SWCLK_2, MUL_PIN_SWCLK_3, MUL_PIN_SWCLK_4};
const uint32_t TablePinSWDIO[4] = {MUL_PIN_SWDIO_1, MUL_PIN_SWDIO_2, MUL_PIN_SWDIO_3, MUL_PIN_SWDIO_4};
const uint32_t TableModeMask[4] = {MUL_DIO_MODE_MASK_1, MUL_DIO_MODE_MASK_2, MUL_DIO_MODE_MASK_3, MUL_DIO_MODE_MASK_4};
const uint32_t TableModeOut[4] = {MUL_DIO_MODE_OUT_1, MUL_DIO_MODE_OUT_2, MUL_DIO_MODE_OUT_3, MUL_DIO_MODE_OUT_4};
const uint32_t TableClk0Dio0[4] = {CLK_0_DIO_0_1, CLK_0_DIO_0_2, CLK_0_DIO_0_3, CLK_0_DIO_0_4};
const uint32_t TableClk0Dio1[4] = {CLK_0_DIO_1_1, CLK_0_DIO_1_2, CLK_0_DIO_1_3, CLK_0_DIO_1_4};
/* 4个SWDIO配置为输出 */
static __forceinline void MUL_PIN_SWDIO_OUT_ENABLE(void)
{
@ -168,26 +213,35 @@ static __forceinline uint32_t MUL_PIN_SWDIO_IN(void)
input = MUL_GPIO_SWD->IDR;
if (input & MUL_PIN_SWDIO_1)
if (g_gMulSwd.MultiMode == 1) /* 多路模式只烧写一路 */
{
ret += 0x00000001;
if (input & TablePinSWDIO[g_gMulSwd.SwitchPin])
{
ret += 0x00000001;
}
}
else
{
if (input & MUL_PIN_SWDIO_1)
{
ret += 0x00000001;
}
if (input & MUL_PIN_SWDIO_2)
{
ret += 0x00000100;
}
if (input & MUL_PIN_SWDIO_2)
{
ret += 0x00000100;
}
if (input & MUL_PIN_SWDIO_3)
{
ret += 0x00010000;
}
if (input & MUL_PIN_SWDIO_4)
{
ret += 0x01000000;
if (input & MUL_PIN_SWDIO_4)
{
ret += 0x01000000;
}
}
return ret;
}
@ -243,8 +297,8 @@ static __forceinline void MUL_PIN_SWCLK_CLR(void)
}
static __forceinline void MUL_SEND_32BIT_FAST(uint32_t val)
{
uint32_t CLK_0_DIO_1 = g_gMulSwd.CLK_0_DIO_1;
uint32_t CLK_0_DIO_0 = g_gMulSwd.CLK_0_DIO_0;
__IO uint32_t CLK_0_DIO_1 = g_gMulSwd.CLK_0_DIO_1;
__IO uint32_t CLK_0_DIO_0 = g_gMulSwd.CLK_0_DIO_0;
MUL_SEND_32BIT_ONCE_FAST();MUL_SEND_32BIT_ONCE_FAST();MUL_SEND_32BIT_ONCE_FAST();MUL_SEND_32BIT_ONCE_FAST();
MUL_SEND_32BIT_ONCE_FAST();MUL_SEND_32BIT_ONCE_FAST();MUL_SEND_32BIT_ONCE_FAST();MUL_SEND_32BIT_ONCE_FAST();
@ -270,8 +324,8 @@ static __forceinline void MUL_SEND_32BIT_FAST(uint32_t val)
}
static __forceinline void MUL_SEND_32BIT_SLOW(uint32_t val)
{
uint32_t CLK_0_DIO_1 = g_gMulSwd.CLK_0_DIO_1;
uint32_t CLK_0_DIO_0 = g_gMulSwd.CLK_0_DIO_0;
__IO uint32_t CLK_0_DIO_1 = g_gMulSwd.CLK_0_DIO_1;
__IO uint32_t CLK_0_DIO_0 = g_gMulSwd.CLK_0_DIO_0;
MUL_SEND_32BIT_ONCE_SLOW();MUL_SEND_32BIT_ONCE_SLOW();MUL_SEND_32BIT_ONCE_SLOW();MUL_SEND_32BIT_ONCE_SLOW();
MUL_SEND_32BIT_ONCE_SLOW();MUL_SEND_32BIT_ONCE_SLOW();MUL_SEND_32BIT_ONCE_SLOW();MUL_SEND_32BIT_ONCE_SLOW();
@ -283,7 +337,27 @@ static __forceinline void MUL_SEND_32BIT_SLOW(uint32_t val)
MUL_SEND_32BIT_ONCE_SLOW();MUL_SEND_32BIT_ONCE_SLOW();MUL_SEND_32BIT_ONCE_SLOW();MUL_SEND_32BIT_ONCE_SLOW();
}
extern uint8_t GetParity(uint32_t data);
//extern uint8_t GetParity(uint32_t data);
static const uint8_t MUL_ParityTable256[256] =
{
# define P2(n) n, n^1, n^1, n
# define P4(n) P2(n), P2(n^1), P2(n^1), P2(n)
# define P6(n) P4(n), P4(n^1), P4(n^1), P4(n)
P6(0), P6(1), P6(1), P6(0)
};
uint8_t MUL_GetParity(uint32_t data)
{
uint8_t parity;
data ^= data >> 16;
data ^= data >> 8;
parity = MUL_ParityTable256[data & 0xff];
return parity;
}
/*
*********************************************************************************************************
@ -298,25 +372,51 @@ void MUL_SWD_GPIOConfig(void)
EIO_D0_Config(ES_GPIO_OUT); /* reset */
EIO_D1_Config(ES_GPIO_IN); /* 输入 */
if (g_gMulSwd.Active[0] == 1)
if (g_gMulSwd.MultiMode == 1) /* 多路模式只烧写一路 */
{
EIO_D8_Config(ES_GPIO_SWD_OUT); /* 用FMC口线做GPIO。因此FMC功能失效 */
EIO_D9_Config(ES_GPIO_SWD_OUT); /* 用FMC口线做GPIO。因此FMC功能失效 */
if (g_gMulSwd.SwitchPin == 0)
{
EIO_D8_Config(ES_GPIO_SWD_OUT);
EIO_D9_Config(ES_GPIO_SWD_OUT);
}
else if (g_gMulSwd.SwitchPin == 1)
{
EIO_D5_Config(ES_GPIO_OUT);
EIO_D7_Config(ES_GPIO_SWD_OUT);
}
else if (g_gMulSwd.SwitchPin == 2)
{
EIO_D4_Config(ES_GPIO_OUT);
EIO_D6_Config(ES_GPIO_SWD_OUT);
}
else if (g_gMulSwd.SwitchPin == 3)
{
EIO_D2_Config(ES_GPIO_OUT);
EIO_D3_Config(ES_GPIO_OUT);
}
}
if (g_gMulSwd.Active[1] == 1)
else
{
EIO_D5_Config(ES_GPIO_OUT);
EIO_D7_Config(ES_GPIO_SWD_OUT); /* 用FMC口线做GPIO。因此FMC功能失效 */
}
if (g_gMulSwd.Active[2] == 1)
{
EIO_D4_Config(ES_GPIO_OUT);
EIO_D6_Config(ES_GPIO_SWD_OUT); /* 用FMC口线做GPIO。因此FMC功能失效 */
}
if (g_gMulSwd.Active[3] == 1)
{
EIO_D2_Config(ES_GPIO_OUT);
EIO_D3_Config(ES_GPIO_OUT);
if (g_gMulSwd.Active[0] == 1)
{
EIO_D8_Config(ES_GPIO_SWD_OUT);
EIO_D9_Config(ES_GPIO_SWD_OUT);
}
if (g_gMulSwd.Active[1] == 1)
{
EIO_D5_Config(ES_GPIO_OUT);
EIO_D7_Config(ES_GPIO_SWD_OUT);
}
if (g_gMulSwd.Active[2] == 1)
{
EIO_D4_Config(ES_GPIO_OUT);
EIO_D6_Config(ES_GPIO_SWD_OUT);
}
if (g_gMulSwd.Active[3] == 1)
{
EIO_D2_Config(ES_GPIO_OUT);
EIO_D3_Config(ES_GPIO_OUT);
}
}
}
@ -351,15 +451,6 @@ void MUL_PORT_SWD_SETUP(void)
* :
*********************************************************************************************************
*/
const uint32_t TablePinDIR[4] = {MUL_PIN_DIR_1, MUL_PIN_DIR_2, MUL_PIN_DIR_3, MUL_PIN_DIR_4};
const uint32_t TablePinSWClK[4] = {MUL_PIN_SWCLK_1, MUL_PIN_SWCLK_2, MUL_PIN_SWCLK_3, MUL_PIN_SWCLK_4};
const uint32_t TablePinSWDIO[4] = {MUL_PIN_SWDIO_1, MUL_PIN_SWDIO_2, MUL_PIN_SWDIO_3, MUL_PIN_SWDIO_4};
const uint32_t TableModeMask[4] = {MUL_DIO_MODE_MASK_1, MUL_DIO_MODE_MASK_2, MUL_DIO_MODE_MASK_3, MUL_DIO_MODE_MASK_4};
const uint32_t TableModeOut[4] = {MUL_DIO_MODE_OUT_1, MUL_DIO_MODE_OUT_2, MUL_DIO_MODE_OUT_3, MUL_DIO_MODE_OUT_4};
const uint32_t TableClk0Dio0[4] = {CLK_0_DIO_0_1, CLK_0_DIO_0_2, CLK_0_DIO_0_3, CLK_0_DIO_0_4};
const uint32_t TableClk0Dio1[4] = {CLK_0_DIO_1_1, CLK_0_DIO_1_2, CLK_0_DIO_1_3, CLK_0_DIO_1_4};
void MUL_RefreshGpioParam(void)
{
@ -372,9 +463,11 @@ void MUL_RefreshGpioParam(void)
uint32_t CLK_0_DIO_1 = 0;
uint8_t i;
for (i = 0; i < 4; i++)
if (g_gMulSwd.MultiMode == 1) /* 烧写1路 */
{
if (g_gMulSwd.Active[i] == 1 && g_gMulSwd.Ignore[i] == 0 && g_gMulSwd.TempIgnore[i] == 0)
i = g_gMulSwd.SwitchPin; /* 硬件端口可切换到1-4中任意一路 */
if (g_gMulSwd.Active[0] == 1 && g_gMulSwd.Ignore[0] == 0 && g_gMulSwd.TempIgnore[0] == 0)
{
DIR_Pins |= TablePinDIR[i];
SWCLK_Pins |= TablePinSWClK[i];
@ -384,14 +477,37 @@ void MUL_RefreshGpioParam(void)
CLK_0_DIO_0 |= TableClk0Dio0[i];
CLK_0_DIO_1 |= TableClk0Dio1[i];
}
g_gMulSwd.DIR_Pins = DIR_Pins;
g_gMulSwd.SWCLK_Pins = SWCLK_Pins;
g_gMulSwd.SWDIO_Pins = SWDIO_Pins;
g_gMulSwd.MODER_Mask = MODER_Mask;
g_gMulSwd.MODER_Out = MODER_Out;
g_gMulSwd.CLK_0_DIO_0 = CLK_0_DIO_0;
g_gMulSwd.CLK_0_DIO_1 = CLK_0_DIO_1;
}
else
{
for (i = 0; i < 4; i++)
{
if (g_gMulSwd.Active[i] == 1 && g_gMulSwd.Ignore[i] == 0 && g_gMulSwd.TempIgnore[i] == 0)
{
DIR_Pins |= TablePinDIR[i];
SWCLK_Pins |= TablePinSWClK[i];
SWDIO_Pins |= TablePinSWDIO[i];
MODER_Mask &= TableModeMask[i];
MODER_Out |= TableModeOut[i];
CLK_0_DIO_0 |= TableClk0Dio0[i];
CLK_0_DIO_1 |= TableClk0Dio1[i];
}
}
g_gMulSwd.DIR_Pins = DIR_Pins;
g_gMulSwd.SWCLK_Pins = SWCLK_Pins;
g_gMulSwd.SWDIO_Pins = SWDIO_Pins;
g_gMulSwd.MODER_Mask = MODER_Mask;
g_gMulSwd.MODER_Out = MODER_Out;
g_gMulSwd.CLK_0_DIO_0 = CLK_0_DIO_0;
g_gMulSwd.CLK_0_DIO_1 = CLK_0_DIO_1;
}
g_gMulSwd.DIR_Pins = DIR_Pins;
g_gMulSwd.SWCLK_Pins = SWCLK_Pins;
g_gMulSwd.SWDIO_Pins = SWDIO_Pins;
g_gMulSwd.MODER_Mask = MODER_Mask;
g_gMulSwd.MODER_Out = MODER_Out;
g_gMulSwd.CLK_0_DIO_0 = CLK_0_DIO_0;
g_gMulSwd.CLK_0_DIO_1 = CLK_0_DIO_1;
}
/*
@ -512,7 +628,7 @@ uint8_t* MUL_SWD_TransferFast(uint32_t request, uint32_t *data)
for (i = 0; i < 4; i++)
{
pb_buf[i] = GetParity(val_buf[i]);
pb_buf[i] = MUL_GetParity(val_buf[i]);
}
MUL_SW_READ_BIT_FAST(bit); /* Read Parity */
@ -556,7 +672,7 @@ uint8_t* MUL_SWD_TransferFast(uint32_t request, uint32_t *data)
val = *data;
/* armfly 优化奇偶校验算法 */
pb = GetParity(val);
pb = MUL_GetParity(val);
MUL_SEND_32BIT_FAST(val);
MUL_SW_WRITE_BIT_FAST(pb); /* Write Parity Bit */
@ -777,7 +893,7 @@ uint8_t* MUL_SWD_TransferSlow(uint32_t request, uint32_t *data)
for (i = 0; i < 4; i++)
{
pb_buf[i] = GetParity(val_buf[i]);
pb_buf[i] = MUL_GetParity(val_buf[i]);
}
MUL_SW_READ_BIT_SLOW(bit); /* Read Parity */
@ -821,7 +937,7 @@ uint8_t* MUL_SWD_TransferSlow(uint32_t request, uint32_t *data)
val = *data;
/* armfly 优化奇偶校验算法 */
pb = GetParity(val);
pb = MUL_GetParity(val);
MUL_SEND_32BIT_SLOW(val);
MUL_SW_WRITE_BIT_SLOW(pb); /* Write Parity Bit */

View File

@ -37,6 +37,8 @@ typedef struct
uint32_t CoreID[4];
uint8_t SwitchPin; /* 0: 1拖1第1路模式1:1拖1第2路 */
}MUL_SWD_T;
extern MUL_SWD_T g_gMulSwd;

View File

@ -963,14 +963,14 @@ static uint8_t JTAG2SWD()
return 0;
}
/* 旧协议J-LINK如此发送 */
if (!swd_switch(0xEDB6)) {
return 0;
}
// /* 旧协议J-LINK如此发送 */
// if (!swd_switch(0xEDB6)) {
// return 0;
// }
if (!swd_reset()) {
return 0;
}
// if (!swd_reset()) {
// return 0;
// }
if (!swd_read_idcode(&tmp)) {
return 0;
@ -995,14 +995,14 @@ static uint8_t JTAG2SWD_2(uint32_t *tmp)
return 0;
}
/* 旧协议J-LINK如此发送 */
if (!swd_switch(0xEDB6)) {
return 0;
}
// /* 旧协议J-LINK如此发送 */
// if (!swd_switch(0xEDB6)) {
// return 0;
// }
if (!swd_reset()) {
return 0;
}
// if (!swd_reset()) {
// return 0;
// }
if (!swd_read_idcode(tmp)) {
return 0;
@ -1748,9 +1748,20 @@ uint8_t swd_enter_debug_program(void)
return 0;
}
if (!swd_write_word(NVIC_AIRCR, VECTKEY | (val & SCB_AIRCR_PRIGROUP_Msk) | soft_reset)) {
printf("error: swd_write_word(NVIC_AIRCR, VECTKEY | (val & SCB_AIRCR_PRIGROUP_Msk) | soft_reset)\r\n");
return 0;
if (!swd_write_word(NVIC_AIRCR, VECTKEY | (val & SCB_AIRCR_PRIGROUP_Msk) | soft_reset))
{
printf("not surport: NVIC_AIRCR soft_reset\r\n");
/* 2021-03-20 国民技术 N32G455, 执行软件复位会返回异常 */
//return 0;
{
uint32_t id;
swd_reset();
if (!swd_read_idcode(&id)) {
return 0;
}
}
}
osDelay(2);

View File

@ -1270,39 +1270,35 @@ static uint8_t MUL_swd_wait_until_halted(void)
float percent;
tt = bsp_CheckRunTime(time1);
if (tt0 != tt)
if (tt > g_tProg.FLMFuncTimeout + addtime)
{
tt0 = tt;
if (tt > g_tProg.FLMFuncTimeout + addtime)
{
uint8_t i;
uint8_t i;
printf("error : swd_wait_until_halted() timeout\r\n");
for (i = 0; i < 4; i++)
{
if (g_gMulSwd.Active[i] == 1)
{
if (ok[i] == 0)
{
g_gMulSwd.Error[i] = 1;
}
}
}
break; /* 超时退出 */
}
else
printf("error : swd_wait_until_halted() timeout\r\n");
for (i = 0; i < 4; i++)
{
if (g_tProg.FLMFuncDispProgress == 1)
if (g_gMulSwd.Active[i] == 1)
{
/* 250ms打印1次 */
if ((tt % 250) == 0)
if (ok[i] == 0)
{
percent = ((float)tt / g_tProg.FLMFuncTimeout) * 100;
PG_PrintPercent(percent, g_tProg.FLMFuncDispAddr);
g_gMulSwd.Error[i] = 1;
}
bsp_Idle();
}
}
break; /* 超时退出 */
}
if (g_tProg.FLMFuncDispProgress == 1)
{
/* 250ms打印1次 */
if (bsp_CheckRunTime(tt0) >= 250)
{
tt0 = bsp_GetRunTime();
percent = ((float)tt / g_tProg.FLMFuncTimeout) * 100;
PG_PrintPercent(percent, g_tProg.FLMFuncDispAddr);
}
bsp_Idle();
}
}
@ -2254,6 +2250,419 @@ uint8_t MUL_swd_set_target_state_sw(TARGET_RESET_STATE state)
*********************************************************************************************************
*/
extern uint8_t swd_freeze_dog(void);
uint8_t MUL_swd_enter_debug_program_sw(void)
{
uint32_t val[4];
uint32_t i;
if (!MUL_swd_init_debug()) {
printf("ERROR:1010 MUL_swd_init_debug()\r\n");
return 0;
}
if (swd_freeze_dog() == 0) /* 如果冻结看门狗时钟失败STM32H7*/
{
if (swd_freeze_dog() == 0)
{
/* 失败 */;
}
}
// Enable debug and halt the core (DHCSR <- 0xA05F0003)
for (i = 0; i < 5; i++)
{
if (MUL_swd_write_word(DBG_HCSR, DBGKEY | C_DEBUGEN | C_HALT) != 0)
{
break;
}
// Target is in invalid state?
MUL_swd_set_target_reset(1);
osDelay(20);
MUL_swd_set_target_reset(0);
osDelay(i * 5);
}
// Wait until core is halted
for (i = 0; i < 500; i++)
{
uint8_t err;
if (!MUL_swd_read_word(DBG_HCSR, val))
{
printf("ERROR:1011 MUL_swd_read_word(DBG_HCSR, val)\r\n");
goto err_quit;
}
err = 0;
if (g_gMulSwd.Active[0] == 1 && ((val[0] & S_HALT) == 0))
{
err = 1;
}
if (g_gMulSwd.Active[1] == 1 && ((val[1] & S_HALT) == 0))
{
err = 1;
}
if (g_gMulSwd.Active[2] == 1 && ((val[2] & S_HALT) == 0))
{
err = 1;
}
if (g_gMulSwd.Active[3] == 1 && ((val[3] & S_HALT) == 0))
{
err = 1;
}
if (err == 0)
{
break;
}
bsp_DelayUS(100);
}
// Enable halt on reset
if (!MUL_swd_write_word(DBG_EMCR, VC_CORERESET)) {
printf("ERROR:1012 MUL_swd_write_word(DBG_EMCR, VC_CORERESET)\r\n");
goto err_quit;
}
// Perform a soft reset
if (!MUL_swd_read_word(NVIC_AIRCR, val)) {
printf("ERROR:1013 MUL_swd_read_word(NVIC_AIRCR, val)\r\n");
goto err_quit;
}
if (!MUL_swd_write_word(NVIC_AIRCR, VECTKEY | (val[0] & SCB_AIRCR_PRIGROUP_Msk) | soft_reset)) {
//printf("ERROR:1014 MUL_swd_write_word(NVIC_AIRCR, VECTKEY | (val[0] & SCB_AIRCR_PRIGROUP_Msk) | soft_reset)\r\n");
printf("not surport: NVIC_AIRCR soft_reset\r\n");
/* 2021-03-20 国民技术 N32G455, 执行软件复位会返回异常 */
//return 0;
{
uint32_t id[4];
MUL_swd_reset();
if (!MUL_swd_read_idcode(id)) {
goto err_quit;
}
/* 需要清除错误标志 */
g_gMulSwd.Error[0] = 0;
g_gMulSwd.Error[1] = 0;
g_gMulSwd.Error[2] = 0;
g_gMulSwd.Error[3] = 0;
}
}
osDelay(2);
for (i = 0; i < 500; i++)
{
uint8_t err;
if (!MUL_swd_read_word(DBG_HCSR, val))
{
printf("ERROR:1015 MUL_swd_read_word(DBG_HCSR, val)\r\n");
goto err_quit;
}
err = 0;
if (g_gMulSwd.Active[0] == 1 && ((val[0] & S_HALT) == 0))
{
err = 1;
}
if (g_gMulSwd.Active[1] == 1 && ((val[1] & S_HALT) == 0))
{
err = 1;
}
if (g_gMulSwd.Active[2] == 1 && ((val[2] & S_HALT) == 0))
{
err = 1;
}
if (g_gMulSwd.Active[3] == 1 && ((val[3] & S_HALT) == 0))
{
err = 1;
}
if (err == 0)
{
break;
}
bsp_DelayUS(100);
}
// Disable halt on reset
if (!MUL_swd_write_word(DBG_EMCR, 0)) {
printf("ERROR:1016 MUL_swd_write_word(DBG_EMCR, 0)\r\n");
goto err_quit;
}
/* 解锁后重读 NVIC_CPUID */
{
uint32_t cpuid[4];
/* NVIC_CPUID = 0xE000ED00 */
if (!MUL_swd_read_word(NVIC_CPUID, cpuid))
{
printf("ERROR:1017 MUL_swd_read_word(NVIC_CPUID, cpuid) error\r\n");
goto err_quit;
}
if (g_gMulSwd.MultiMode >= 1)
{
printf(".NVIC_CPUID1 = %08X, %s\r\n", cpuid[0], swd_arm_core_info(cpuid[0]));
}
if (g_gMulSwd.MultiMode >= 2)
{
printf(".NVIC_CPUID2 = %08X, %s\r\n", cpuid[1], swd_arm_core_info(cpuid[1]));
}
if (g_gMulSwd.MultiMode >= 3)
{
printf(".NVIC_CPUID3 = %08X, %s\r\n", cpuid[2], swd_arm_core_info(cpuid[2]));
}
if (g_gMulSwd.MultiMode >= 4)
{
printf(".NVIC_CPUID4 = %08X, %s\r\n", cpuid[3], swd_arm_core_info(cpuid[3]));
}
{
uint8_t err = 0;
for (i = 0; i < 4; i++)
{
if (g_gMulSwd.Active[i] == 1)
{
if ((cpuid[i] & 0xFF000000) != 0x41000000)
{
err = 1;
}
}
}
if (err == 1)
{
;
}
}
}
return 1;
err_quit:
return 0;
}
uint8_t MUL_swd_enter_debug_program_hw(void)
{
uint32_t val[4];
uint32_t i;
/* 进入编程状态,先复位一次,应对已看门狗低功耗程序的片子 */
MUL_swd_set_target_reset(1);
osDelay(10);
MUL_swd_set_target_reset(0);
if (MUL_swd_init_debug() == 0)
{
printf("ERROR:1018 MUL_swd_init_debug()\r\n");
return 0;
}
osDelay(5);
#if 1
if (swd_freeze_dog() == 0) /* 如果冻结看门狗时钟失败STM32H7*/
{
if (MUL_swd_get_target_reset() == 0)
{
MUL_swd_set_target_reset(1); /* 硬件复位 */
osDelay(g_tProg.SwdResetDelay);
}
if (MUL_swd_init_debug() == 0)
{
printf("ERROR:1019 MUL_swd_init_debug()\r\n");
return 0;
}
if (swd_freeze_dog() == 0)
{
/* 失败 */;
}
}
#endif
// Enable debug and halt the core (DHCSR <- 0xA05F0003)
for (i = 0; i < 10; i++)
{
if (MUL_swd_write_word(DBG_HCSR, DBGKEY | C_DEBUGEN | C_HALT) != 0)
{
break;
}
// Target is in invalid state?
MUL_swd_set_target_reset(1);
osDelay(20);
MUL_swd_set_target_reset(0);
osDelay(i * 5);
}
if (i == 10)
{
printf("ERROR:1020 MUL_swd_write_word(DBG_HCSR, DBGKEY | C_DEBUGEN | C_HALT)\r\n");
return 0;
}
// Enable halt on reset
if (!MUL_swd_write_word(DBG_EMCR, VC_CORERESET)) {
printf("ERROR:1021 MUL_swd_write_word(DBG_EMCR, VC_CORERESET)\r\n");
return 0; /* 超时 */
}
MUL_swd_read_word(DBG_HCSR, val);
if ((val[0] & S_HALT) == 0)
{
if (MUL_swd_get_target_reset() == 0)
{
MUL_swd_set_target_reset(1); /* 硬件复位 */
osDelay(20);
}
if (MUL_swd_get_target_reset() == 1)
{
MUL_swd_set_target_reset(0); /* 退出硬件复位 */
osDelay(g_tProg.SwdResetDelay);
}
}
// Wait until core is halted
for (i = 0; i < 1000; i++)
{
uint8_t err;
if (!MUL_swd_read_word(DBG_HCSR, val))
{
printf("ERROR:1022 MUL_swd_read_word(DBG_HCSR, val)\r\n");
return 0;
}
err = 0;
if (g_gMulSwd.Active[0] == 1 && ((val[0] & S_HALT) == 0))
{
err = 1;
}
if (g_gMulSwd.Active[1] == 1 && ((val[1] & S_HALT) == 0))
{
err = 1;
}
if (g_gMulSwd.Active[2] == 1 && ((val[2] & S_HALT) == 0))
{
err = 1;
}
if (g_gMulSwd.Active[3] == 1 && ((val[3] & S_HALT) == 0))
{
err = 1;
}
if (err == 0)
{
break;
}
bsp_DelayUS(1000);
}
if (i == 1000)
{
printf("ERROR:1023 MUL_swd_read_word(DBG_HCSR, val)\r\n");
return 0;
}
// Disable halt on reset
if (!MUL_swd_write_word(DBG_EMCR, 0))
{
printf("error 7: MUL_swd_write_word(DBG_EMCR, 0)\r\n");
return 0;
}
/* 解锁后重读 NVIC_CPUID */
{
uint32_t cpuid[4];
/* NVIC_CPUID = 0xE000ED00 */
if (!MUL_swd_read_word(NVIC_CPUID, cpuid))
{
printf("ERROR:1024 .MUL_swd_read_word(NVIC_CPUID, cpuid) error\r\n");
return 0;
}
if (g_gMulSwd.MultiMode >= 1)
{
printf(".NVIC_CPUID1 = %08X, %s\r\n", cpuid[0], swd_arm_core_info(cpuid[0]));
}
if (g_gMulSwd.MultiMode >= 2)
{
printf(".NVIC_CPUID2 = %08X, %s\r\n", cpuid[1], swd_arm_core_info(cpuid[1]));
}
if (g_gMulSwd.MultiMode >= 3)
{
printf(".NVIC_CPUID3 = %08X, %s\r\n", cpuid[2], swd_arm_core_info(cpuid[2]));
}
if (g_gMulSwd.MultiMode >= 4)
{
printf(".NVIC_CPUID4 = %08X, %s\r\n", cpuid[3], swd_arm_core_info(cpuid[3]));
}
{
uint8_t err = 0;
for (i = 0; i < 4; i++)
{
if (g_gMulSwd.Active[i] == 1)
{
if ((cpuid[i] & 0xFF000000) != 0x41000000)
{
err = 1;
}
}
}
if (err == 1)
{
;
}
}
}
return 1;
}
uint8_t MUL_swd_enter_debug_program(void)
{
uint8_t ResetMode;
/* --0:自动模式, 1:软件模式 2:硬件UnderReset */
ResetMode = g_tProg.ResetMode;
/* 自动模式暂未实现 */
if (ResetMode == 0)
{
ResetMode = 1;
}
/* 软件复位 */
if (ResetMode == 1)
{
return MUL_swd_enter_debug_program_sw();
}
/* 硬件复位 */
if (ResetMode == 2)
{
return MUL_swd_enter_debug_program_hw();
}
return 0;
}
#endif
#if 0 // 临时备份下代码
uint8_t MUL_swd_enter_debug_program(void)
{
uint32_t val[4];

View File

@ -306,8 +306,7 @@ void lua_do(char *buf)
}
else /* 程序语法或执行错误 */
{
printf(str);
printf("\r\n");
printf("%s\r\n", str);
}
lua_pop(g_Lua, 1); //将错误信息出栈
}

View File

@ -206,6 +206,10 @@ static int h7_ReadCVar(lua_State* L)
{
lua_pushnumber(L, g_tParam.FactoryId);
}
else if (strcmp(pVarName, "MultiProgSwitchPin") == 0)
{
lua_pushnumber(L, g_gMulSwd.SwitchPin);
}
else
{
lua_pushnumber(L, 0); /* 出错 */
@ -456,6 +460,11 @@ static int h7swd_ReadMemory(lua_State* L)
memset(s_lua_read_buf, 0, num);
}
else
{
lua_pushnumber(L, 0); /* 出错 */
return 1;
}
if (num > LUA_READ_LEN_MAX)
{
@ -1606,8 +1615,7 @@ static int h7_PrintText(lua_State* L)
if (g_MainStatus == MS_PROG_WORK)
{
printf(str);
printf("\r\n");
printf("%s\r\n", str);
if (g_MainStatus == MS_PROG_WORK)
{
@ -1768,21 +1776,24 @@ static int h7_ProgBuf_OB(lua_State* L)
{
if (len > 0)
{
DataBuf2[len++] = ~DataBuf2[len - 1];
DataBuf2[len] = ~DataBuf2[len - 1];
len++;
}
}
else if (Address == 0xFFFFFFFE) /* 遇到0xFFFFFFFE,则插入前第2个数据取反的数据 */
{
if (len >= 2)
{
DataBuf2[len++] = ~DataBuf2[len - 2];
DataBuf2[len] = ~DataBuf2[len - 2];
len++;
}
}
else if (Address == 0xFFFFFFFD) /* 遇到0xFFFFFFFD,则插入前第4个数据取反的数据 */
{
if (len >= 4)
{
DataBuf2[len++] = ~DataBuf2[len - 4];
DataBuf2[len] = ~DataBuf2[len - 4];
len++;
}
}
else
@ -2082,10 +2093,18 @@ static int h7_EraseChip(lua_State* L)
lua_pushnumber(L, 1); /* 成功 */
}
}
else
else if (g_tProg.ChipType == CHIP_SPI_FLASH)
{
lua_pushnumber(L, 0); /* 出错 */
if (W25Q_EraseChip() == 0)
{
lua_pushnumber(L, 0); /* 出错 */
}
else
{
lua_pushnumber(L, 1); /* 成功 */
}
}
return 1;
}
@ -2176,7 +2195,7 @@ static int h7_Read_ProductSN(lua_State* L)
*/
static int h7_Write_ProductSN(lua_State* L)
{
uint32_t sn;
int64_t sn;
if (lua_type(L, 1) == LUA_TNUMBER) /* 判断第1个参数 */
{

View File

@ -395,6 +395,11 @@ AI : 示波器 CH1 均值, mV单位
#define JUMP_TO_LINK 5
#define JUMP_TO_UPDATE_BOOT 6 /* 更新boot */
#define JUMP_TO_PROGRAMMER_NOT_DO 7 /* 进入单路烧录模式, 不烧录 */
#define JUMP_TO_PROGRAMMER_DO_ONCE 8 /* 进入单路烧录模式,并烧录1次 */
#define JUMP_TO_USB_UART 9
#define JUMP_TO_USB_ESP32 10
#define JUMP_TO_RTT_VIEWER 11
/* BOOT 程序用的寄存器 */
#define REG03_BOOT_CPU_ID0 0xFF80

View File

@ -1533,6 +1533,36 @@ uint8_t WriteRegValue_06H(uint16_t reg_addr, uint16_t reg_value)
g_tVar.ReqWriteBoot = 1;
g_MainStatus = MS_FILE_MANAGE;
}
else if (reg_value == JUMP_TO_PROGRAMMER_NOT_DO) /* 进入脱机烧录界面, 不执行烧录。 传送文件时执行 */
{
if (g_MainStatus == MS_PROG_WORK)
{
g_tVar.ReqProgOnce = 1; /* 已经在烧录状态, 则重载lua文件后烧录一次 */
}
else
{
g_tVar.ReqProgOnce = 2; /* 其他状态时,进入新状态后会自动重载 */
}
g_MainStatus = MS_PROG_WORK;
bsp_PutKey(KEY_WAKE_UP); /* 任意发一个本状态无用的按键消息,重开背光 */
}
else if (reg_value == JUMP_TO_PROGRAMMER_DO_ONCE) /* 进入脱机烧录界面并烧录1次 */
{
if (g_MainStatus == MS_PROG_WORK)
{
g_tVar.ReqProgOnce = 3; /* 已经在烧录状态, 则重载lua文件后烧录一次 */
}
else
{
g_tVar.ReqProgOnce = 4; /* 其他状态时,进入新状态后会自动重载 */
}
g_MainStatus = MS_PROG_WORK;
bsp_PutKey(KEY_WAKE_UP); /* 任意发一个本状态无用的按键消息,重开背光 */
}
break;
/**************************** 时钟参数 *****************************/

View File

@ -44,6 +44,17 @@ typedef struct
uint8_t TCP_Flag;
} MODS_T;
/* 66H帧子功能码定义 */
enum
{
H66_READ_MEM_INIT = 0, /* 读内存, */
H66_READ_MEM = 1, /* 写内存 */
H66_WRITE_MEM = 2, /* 写内存 */
H66_WRITE_PROG_AUTO_INI = 3, /* 更改脱机烧录缺省启动文件用于PC在线烧录) */
H66_READ_DISP_MEM = 0x0100, /* 读显存 */
};
void uart_rx_isr(void); /* 在 stm8s_it.c 中调用 */
uint8_t AnalyzeCmd(uint8_t *_DispBuf);
uint8_t MODS_Poll(uint8_t *_buf, uint16_t _len);

View File

@ -29,20 +29,12 @@
#include "stm8_swim.h"
#include "n76e003_flash.h"
#include "w25q_flash.h"
/* 66H帧子功能码定义 */
enum
{
H66_READ_MEM_INIT = 0, /* 读内存, */
H66_READ_MEM = 1, /* 写内存 */
H66_WRITE_MEM = 2, /* 写内存 */
H66_READ_DISP_MEM = 0x0100, /* 读显存 */
};
#include "file_lib.h"
static void MODS66_ReadMem(void);
static void MODS66_WriteMem(void);
static void MODS66_ReadDispMem(void);
static void MODS66_WriteProgAutoIni(void);
/*
*********************************************************************************************************
@ -94,6 +86,10 @@ void MODS_66H(void)
{
MODS66_WriteMem();
}
else if (func == H66_WRITE_PROG_AUTO_INI)
{
MODS66_WriteProgAutoIni();
}
else if (func == H66_READ_DISP_MEM)
{
MODS66_ReadDispMem();
@ -295,7 +291,8 @@ static void MODS66_WriteMem(void)
0001 ; ,
- 0pg_init())
- 1 (
- 2
- 2
- 0x0100,
0000 0000 : 4
0020 0000 : 4
...
@ -398,6 +395,84 @@ static void MODS66_WriteMem(void)
}
}
/*
*********************************************************************************************************
* : MODS66_WriteProgAutoIni
* : ini文件
* :
* :
*********************************************************************************************************
*/
static void MODS66_WriteProgAutoIni(void)
{
/*
:
01 ;
66 ;
0001 ; ,
- 0pg_init())
- 1 (
- 2
- 3
- 0x0100,
0000 0000 : 4
0020 0000 : 4
...
CCCC : CRC16
:
01 ;
66 ;
0000 ;
0000 0000 : 4
0020 0000 : 4
00 ; 0OK 1
CCCC : CRC16
*/
uint16_t func; /* 子功能代码 */
uint32_t offset_addr;
uint32_t package_len; /* 本包数据长度 - 文件名长度+1 */
//uint8_t ch_num;
uint8_t *pData;
uint8_t err;
func = BEBufToUint16(&g_tModS.RxBuf[2]);
offset_addr = BEBufToUint32(&g_tModS.RxBuf[4]);
package_len = BEBufToUint32(&g_tModS.RxBuf[8]);
pData = (uint8_t *)&g_tModS.RxBuf[12];
if (package_len > 12 && package_len < 256)
{
SaveProgAutorunFile((const char *)pData);
err = 0;
}
else
{
err = 1;
}
/* 应答数据 */
g_tModS.TxCount = 0;
g_tModS.TxBuf[g_tModS.TxCount++] = g_tParam.Addr485; /* 本机地址 */
g_tModS.TxBuf[g_tModS.TxCount++] = 0x66; /* 功能码 */
g_tModS.TxBuf[g_tModS.TxCount++] = func >> 8;
g_tModS.TxBuf[g_tModS.TxCount++] = func;
g_tModS.TxBuf[g_tModS.TxCount++] = offset_addr >> 24;
g_tModS.TxBuf[g_tModS.TxCount++] = offset_addr >> 16;
g_tModS.TxBuf[g_tModS.TxCount++] = offset_addr >> 8;
g_tModS.TxBuf[g_tModS.TxCount++] = offset_addr >> 0;
g_tModS.TxBuf[g_tModS.TxCount++] = 0 >> 24;
g_tModS.TxBuf[g_tModS.TxCount++] = 0 >> 16;
g_tModS.TxBuf[g_tModS.TxCount++] = 0 >> 8;
g_tModS.TxBuf[g_tModS.TxCount++] = 0 >> 0;
g_tModS.TxBuf[g_tModS.TxCount++] = err; /* 执行结果 */
}
/*
*********************************************************************************************************
* : MODS66_ReadDispMem

View File

@ -339,23 +339,36 @@ void PG_PrintText(char *_str)
/* 输出文本 */
StrUTF8ToGBK(_str, str, sizeof(str));
if (g_gMulSwd.MultiMode > 0) /* 多路模式 */
if (g_gMulSwd.MultiMode > 0) /* 多路模式, 1拖1 */
{
if (g_gMulSwd.Error[0] != 0)
if (g_gMulSwd.MultiMode == 1)
{
strcat(str, " #1");
if (g_gMulSwd.Error[0] != 0)
{
if (g_gMulSwd.SwitchPin == 0) strcat(str, " #1");
else if (g_gMulSwd.SwitchPin == 1) strcat(str, " #2");
else if (g_gMulSwd.SwitchPin == 2) strcat(str, " #3");
else if (g_gMulSwd.SwitchPin == 3) strcat(str, " #4");
}
}
if (g_gMulSwd.Error[1] != 0)
else /* 1拖2,3,4 */
{
strcat(str, " #2");
}
if (g_gMulSwd.Error[2] != 0)
{
strcat(str, " #3");
}
if (g_gMulSwd.Error[3] != 0)
{
strcat(str, " #4");
if (g_gMulSwd.Error[0] != 0)
{
strcat(str, " #1");
}
if (g_gMulSwd.Error[1] != 0)
{
strcat(str, " #2");
}
if (g_gMulSwd.Error[2] != 0)
{
strcat(str, " #3");
}
if (g_gMulSwd.Error[3] != 0)
{
strcat(str, " #4");
}
}
}
@ -364,8 +377,7 @@ void PG_PrintText(char *_str)
DispProgProgress(str, -1, 0xFFFFFFFF); /* -1表示不刷新进度 */
}
strcat(str, "\r\n");
printf(str);
printf("%s\r\n", str);
bsp_Idle();
}

View File

@ -1734,6 +1734,8 @@ uint16_t PG_SWD_EraseChip(uint32_t _FlashAddr)
goto quit;
}
target_flash_uninit();
PG_PrintPercent(100, 0xFFFFFFFF);
quit:

View File

@ -132,6 +132,13 @@ __forceinline void PIN_DELAY_SLOW (uint32_t delay) {
#define W25_SCK_1() BSP_SET_GPIO_1(GPIOD, GPIO_PIN_15)
/* MOSI 四路不同 */
#define W25_MOSI1_PIN GPIO_PIN_0
#define W25_MOSI2_PIN GPIO_PIN_1
#define W25_MOSI3_PIN GPIO_PIN_3
#define W25_MOSI4_PIN GPIO_PIN_4
#define W25_SCK_PIN GPIO_PIN_15
#define W25_MOSI1_0() BSP_SET_GPIO_0(GPIOD, GPIO_PIN_0)
#define W25_MOSI1_1() BSP_SET_GPIO_1(GPIOD, GPIO_PIN_0)
@ -144,8 +151,8 @@ __forceinline void PIN_DELAY_SLOW (uint32_t delay) {
#define W25_MOSI4_0() BSP_SET_GPIO_0(GPIOD, GPIO_PIN_4)
#define W25_MOSI4_1() BSP_SET_GPIO_1(GPIOD, GPIO_PIN_4)
#define W25_MOSI_0_SCK_0() GPIOD->BSRR = (uint32_t)(GPIO_PIN_15 | GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3 | GPIO_PIN_4) << 16
#define W25_MOSI_1_SCK_0() GPIOD->BSRR = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3 | GPIO_PIN_4 | ((uint32_t)GPIO_PIN_15 << 16)
#define __W25_MOSI_0_SCK_0() GPIOD->BSRR = (uint32_t)(GPIO_PIN_15 | GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3 | GPIO_PIN_4) << 16
#define __W25_MOSI_1_SCK_0() GPIOD->BSRR = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3 | GPIO_PIN_4 | ((uint32_t)GPIO_PIN_15 << 16)
/* MISO 四路不同 */
@ -204,10 +211,89 @@ void W25Q_InitHard(void)
/* 选MODE3平时SCK为1 */
W25_SCK_1();
W25_CS_1();
W25Q_UnlockBlock(); /* SST26VFxxx 需要解除块保护 */
}
static void W25_MOSI_0_SCK_0(void)
{
if (g_gMulSwd.MultiMode == 0) /* 单路烧录, */
{
GPIOD->BSRR = (uint32_t)(W25_SCK_PIN | W25_MOSI1_PIN) << 16;
}
else if (g_gMulSwd.MultiMode == 4) /* 1拖4 烧录 */
{
GPIOD->BSRR = (uint32_t)(W25_SCK_PIN | W25_MOSI1_PIN | W25_MOSI2_PIN | W25_MOSI3_PIN | W25_MOSI4_PIN) << 16;
}
else if (g_gMulSwd.MultiMode == 3) /* 1拖3 烧录 */
{
GPIOD->BSRR = (uint32_t)(W25_SCK_PIN | W25_MOSI1_PIN | W25_MOSI2_PIN | W25_MOSI3_PIN) << 16;
}
else if (g_gMulSwd.MultiMode == 2) /* 1拖2 烧录 */
{
GPIOD->BSRR = (uint32_t)(W25_SCK_PIN | W25_MOSI1_PIN | W25_MOSI2_PIN) << 16;
}
else if (g_gMulSwd.MultiMode == 1) /* 1拖1 烧录 */
{
if (g_gMulSwd.SwitchPin == 0)
{
GPIOD->BSRR = (uint32_t)(W25_SCK_PIN | W25_MOSI1_PIN) << 16;
}
else if (g_gMulSwd.SwitchPin == 1)
{
GPIOD->BSRR = (uint32_t)(W25_SCK_PIN | W25_MOSI2_PIN) << 16;
}
else if (g_gMulSwd.SwitchPin == 2)
{
GPIOD->BSRR = (uint32_t)(W25_SCK_PIN | W25_MOSI3_PIN) << 16;
}
else if (g_gMulSwd.SwitchPin == 3)
{
GPIOD->BSRR = (uint32_t)(W25_SCK_PIN | W25_MOSI4_PIN) << 16;
}
}
}
static void W25_MOSI_1_SCK_0(void)
{
if (g_gMulSwd.MultiMode == 0) /* 单路烧录, */
{
GPIOD->BSRR = W25_MOSI1_PIN | ((uint32_t)W25_SCK_PIN << 16);
}
else if (g_gMulSwd.MultiMode == 4) /* 1拖4 烧录 */
{
GPIOD->BSRR = W25_MOSI1_PIN | W25_MOSI2_PIN | W25_MOSI3_PIN | W25_MOSI4_PIN | ((uint32_t)W25_SCK_PIN << 16);
}
else if (g_gMulSwd.MultiMode == 3) /* 1拖3 烧录 */
{
GPIOD->BSRR = W25_MOSI1_PIN | W25_MOSI2_PIN | W25_MOSI3_PIN | ((uint32_t)W25_SCK_PIN << 16);
}
else if (g_gMulSwd.MultiMode == 2) /* 1拖2 烧录 */
{
GPIOD->BSRR = W25_MOSI1_PIN | W25_MOSI2_PIN | ((uint32_t)W25_SCK_PIN << 16);
}
else if (g_gMulSwd.MultiMode == 1) /* 1拖1 烧录 */
{
if (g_gMulSwd.SwitchPin == 0)
{
GPIOD->BSRR = W25_MOSI1_PIN | ((uint32_t)W25_SCK_PIN << 16);
}
else if (g_gMulSwd.SwitchPin == 1)
{
GPIOD->BSRR = W25_MOSI2_PIN | ((uint32_t)W25_SCK_PIN << 16);
}
else if (g_gMulSwd.SwitchPin == 2)
{
GPIOD->BSRR = W25_MOSI3_PIN | ((uint32_t)W25_SCK_PIN << 16);
}
else if (g_gMulSwd.SwitchPin == 3)
{
GPIOD->BSRR = W25_MOSI4_PIN | ((uint32_t)W25_SCK_PIN << 16);
}
}
}
/*
*********************************************************************************************************
* : W25Q_SendBit8Fast
@ -289,23 +375,89 @@ static void W25Q_RaedBit8Fast(uint8_t *_rxbuf)
W25_SCK_1();
gpio = W25_READ_MISO();
if (gpio & W25_MISO1_PIN_A)
if (g_gMulSwd.MultiMode == 0)
{
ret |= 0x00000001;
if (gpio & W25_MISO1_PIN_A)
{
ret |= 0x00000001;
}
}
if (gpio & W25_MISO2_PIN_A)
else if (g_gMulSwd.MultiMode == 4)
{
ret |= 0x00000100;
if (gpio & W25_MISO1_PIN_A)
{
ret |= 0x00000001;
}
if (gpio & W25_MISO2_PIN_A)
{
ret |= 0x00000100;
}
if (gpio & W25_MISO3_PIN_A)
{
ret |= 0x00010000;
}
if (gpio & W25_MISO4_PIN_A)
{
ret |= 0x01000000;
}
}
if (gpio & W25_MISO3_PIN_A)
else if (g_gMulSwd.MultiMode == 3)
{
ret |= 0x00010000;
if (gpio & W25_MISO1_PIN_A)
{
ret |= 0x00000001;
}
if (gpio & W25_MISO2_PIN_A)
{
ret |= 0x00000100;
}
if (gpio & W25_MISO3_PIN_A)
{
ret |= 0x00010000;
}
}
if (gpio & W25_MISO4_PIN_A)
else if (g_gMulSwd.MultiMode == 2)
{
ret |= 0x01000000;
if (gpio & W25_MISO1_PIN_A)
{
ret |= 0x00000001;
}
if (gpio & W25_MISO2_PIN_A)
{
ret |= 0x00000100;
}
}
else if (g_gMulSwd.MultiMode == 1)
{
if (g_gMulSwd.SwitchPin == 0)
{
if (gpio & W25_MISO1_PIN_A)
{
ret |= 0x00000001;
}
}
else if (g_gMulSwd.SwitchPin == 1)
{
if (gpio & W25_MISO2_PIN_A)
{
ret |= 0x00000001;
}
}
else if (g_gMulSwd.SwitchPin == 2)
{
if (gpio & W25_MISO3_PIN_A)
{
ret |= 0x00000001;
}
}
else if (g_gMulSwd.SwitchPin == 3)
{
if (gpio & W25_MISO4_PIN_A)
{
ret |= 0x00000001;
}
}
}
}
_rxbuf[0] = ret;
@ -332,82 +484,158 @@ static void W25Q_RaedBit8FastDaul(uint8_t *_rxbuf)
for (i = 0; i < 4; i++)
{
W25_SCK_0();
if (gpio & W25_MISO1_PIN_B)
if (g_gMulSwd.MultiMode == 0)
{
ret |= 0x00000001;
if (gpio & W25_MISO1_PIN_B)
{
ret |= 0x00000001;
}
if (gpio & W25_MISO1_PIN_A)
{
ret |= 0x00000002;
}
}
if (gpio & W25_MISO1_PIN_A)
else if (g_gMulSwd.MultiMode == 4)
{
ret |= 0x00000002;
if (gpio & W25_MISO1_PIN_B)
{
ret |= 0x00000001;
}
if (gpio & W25_MISO1_PIN_A)
{
ret |= 0x00000002;
}
if (gpio & W25_MISO2_PIN_B)
{
ret |= 0x00000100;
}
if (gpio & W25_MISO2_PIN_A)
{
ret |= 0x00000200;
}
if (gpio & W25_MISO3_PIN_B)
{
ret |= 0x00010000;
}
if (gpio & W25_MISO3_PIN_A)
{
ret |= 0x00020000;
}
if (gpio & W25_MISO4_PIN_B)
{
ret |= 0x01000000;
}
if (gpio & W25_MISO4_PIN_A)
{
ret |= 0x02000000;
}
}
else if (g_gMulSwd.MultiMode == 3)
{
if (gpio & W25_MISO1_PIN_B)
{
ret |= 0x00000001;
}
if (gpio & W25_MISO1_PIN_A)
{
ret |= 0x00000002;
}
if (gpio & W25_MISO2_PIN_B)
{
ret |= 0x00000100;
}
if (gpio & W25_MISO2_PIN_A)
{
ret |= 0x00000200;
}
if (gpio & W25_MISO3_PIN_B)
{
ret |= 0x00010000;
}
if (gpio & W25_MISO3_PIN_A)
{
ret |= 0x00020000;
}
}
else if (g_gMulSwd.MultiMode == 2)
{
if (gpio & W25_MISO1_PIN_B)
{
ret |= 0x00000001;
}
if (gpio & W25_MISO1_PIN_A)
{
ret |= 0x00000002;
}
if (gpio & W25_MISO2_PIN_B)
{
ret |= 0x00000100;
}
if (gpio & W25_MISO2_PIN_A)
{
ret |= 0x00000200;
}
}
else if (g_gMulSwd.MultiMode == 1)
{
if (g_gMulSwd.SwitchPin == 0)
{
if (gpio & W25_MISO1_PIN_B)
{
ret |= 0x00000001;
}
if (gpio & W25_MISO1_PIN_A)
{
ret |= 0x00000002;
}
}
else if (g_gMulSwd.SwitchPin == 1)
{
if (gpio & W25_MISO2_PIN_B)
{
ret |= 0x00000001;
}
if (gpio & W25_MISO2_PIN_A)
{
ret |= 0x00000002;
}
}
else if (g_gMulSwd.SwitchPin == 2)
{
if (gpio & W25_MISO3_PIN_B)
{
ret |= 0x00000001;
}
if (gpio & W25_MISO3_PIN_A)
{
ret |= 0x00000002;
}
}
else if (g_gMulSwd.SwitchPin == 3)
{
if (gpio & W25_MISO4_PIN_B)
{
ret |= 0x00000001;
}
if (gpio & W25_MISO4_PIN_A)
{
ret |= 0x00000002;
}
}
}
if (gpio & W25_MISO2_PIN_B)
{
ret |= 0x00000100;
}
if (gpio & W25_MISO2_PIN_A)
{
ret |= 0x00000200;
}
if (gpio & W25_MISO3_PIN_B)
{
ret |= 0x00010000;
}
if (gpio & W25_MISO3_PIN_A)
{
ret |= 0x00020000;
}
if (gpio & W25_MISO4_PIN_B)
{
ret |= 0x01000000;
}
if (gpio & W25_MISO4_PIN_A)
{
ret |= 0x02000000;
}
ret <<= 2;
W25_SCK_1();
gpio = W25_READ_MISO();
}
if (gpio & W25_MISO1_PIN_B)
{
ret |= 0x00000001;
}
if (gpio & W25_MISO1_PIN_A)
{
ret |= 0x00000002;
}
if (gpio & W25_MISO2_PIN_B)
{
ret |= 0x00000100;
}
if (gpio & W25_MISO2_PIN_A)
{
ret |= 0x00000200;
}
if (gpio & W25_MISO3_PIN_B)
{
ret |= 0x00010000;
}
if (gpio & W25_MISO3_PIN_A)
{
ret |= 0x00020000;
}
if (gpio & W25_MISO4_PIN_B)
{
ret |= 0x01000000;
}
if (gpio & W25_MISO4_PIN_A)
{
ret |= 0x02000000;
}
_rxbuf[0] = ret;
_rxbuf[1] = ret >> 8;
_rxbuf[2] = ret >> 16;
@ -438,21 +666,88 @@ static void W25Q_RaedBit8Slow(uint8_t *_rxbuf)
gpio = W25_READ_MISO();
PIN_DELAY_S();
if (gpio & W25_MISO1_PIN_A)
if (g_gMulSwd.MultiMode == 0)
{
ret |= 0x00000001;
if (gpio & W25_MISO1_PIN_A)
{
ret |= 0x00000001;
}
}
if (gpio & W25_MISO2_PIN_A)
else if (g_gMulSwd.MultiMode == 4)
{
ret |= 0x00000100;
if (gpio & W25_MISO1_PIN_A)
{
ret |= 0x00000001;
}
if (gpio & W25_MISO2_PIN_A)
{
ret |= 0x00000100;
}
if (gpio & W25_MISO3_PIN_A)
{
ret |= 0x00010000;
}
if (gpio & W25_MISO4_PIN_A)
{
ret |= 0x01000000;
}
}
if (gpio & W25_MISO3_PIN_A)
else if (g_gMulSwd.MultiMode == 3)
{
ret |= 0x00010000;
if (gpio & W25_MISO1_PIN_A)
{
ret |= 0x00000001;
}
if (gpio & W25_MISO2_PIN_A)
{
ret |= 0x00000100;
}
if (gpio & W25_MISO3_PIN_A)
{
ret |= 0x00010000;
}
}
if (gpio & W25_MISO4_PIN_A)
else if (g_gMulSwd.MultiMode == 2)
{
ret |= 0x01000000;
if (gpio & W25_MISO1_PIN_A)
{
ret |= 0x00000001;
}
if (gpio & W25_MISO2_PIN_A)
{
ret |= 0x00000100;
}
}
else if (g_gMulSwd.MultiMode == 1)
{
if (g_gMulSwd.SwitchPin == 0)
{
if (gpio & W25_MISO1_PIN_A)
{
ret |= 0x00000001;
}
}
else if (g_gMulSwd.SwitchPin == 1)
{
if (gpio & W25_MISO2_PIN_A)
{
ret |= 0x00000001;
}
}
else if (g_gMulSwd.SwitchPin == 2)
{
if (gpio & W25_MISO3_PIN_A)
{
ret |= 0x00000001;
}
}
else if (g_gMulSwd.SwitchPin == 3)
{
if (gpio & W25_MISO4_PIN_A)
{
ret |= 0x00000001;
}
}
}
}
_rxbuf[0] = ret;
@ -476,6 +771,7 @@ static void W25Q_RaedBit8SlowDaul(uint8_t *_rxbuf)
W25_SCK_1();
PIN_DELAY_S();
gpio = W25_READ_MISO();
if (gpio & W25_MISO1_PIN_B)
{
ret |= 0x00000001;
@ -1239,6 +1535,18 @@ uint8_t W25Q_WaitBusy(uint32_t _timeout)
W25Q_SendAndReadData(txbuf, 1, rxbuf, 1);
if (g_gMulSwd.MultiMode == 0) /* 单路烧录 */
{
if ((rxbuf[0] & WIP_FLAG) != 0)
{
;
}
else
{
return 1; /* OK */
}
}
else /* 多路模式 */
{
uint8_t err = 0;