1.修改上下行网口速率为自协商
2.修改下行网口重置后IP为10.21.54.8,端口为502
3.产线烧录版
This commit is contained in:
2026-09-29 13:54:36 +08:00
parent 50de2b5e41
commit 5d0b33edb5
9 changed files with 3178 additions and 3093 deletions
+2818 -2807
View File
File diff suppressed because it is too large Load Diff
+257 -261
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -135,7 +135,7 @@
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>JL2CM3</Key> <Key>JL2CM3</Key>
<Name>-U602713110 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103CB$Flash\STM32F10x_128.FLM)</Name> <Name>-U602713110 -O78 -S2 -ZTIFSpeedSel5000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(1BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103CB$Flash\STM32F10x_128.FLM)</Name>
</SetRegEntry> </SetRegEntry>
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
@@ -274,7 +274,7 @@
<DebugFlag> <DebugFlag>
<trace>0</trace> <trace>0</trace>
<periodic>1</periodic> <periodic>1</periodic>
<aLwin>1</aLwin> <aLwin>0</aLwin>
<aCover>0</aCover> <aCover>0</aCover>
<aSer1>0</aSer1> <aSer1>0</aSer1>
<aSer2>0</aSer2> <aSer2>0</aSer2>
Binary file not shown.
+2 -2
View File
@@ -18,7 +18,7 @@
#include "proto_modbus_tcp_master.h" #include "proto_modbus_tcp_master.h"
const char *HwVersion = "V2.2"; const char *HwVersion = "V2.2";
char SwVersion[24] = "SECS2 V2.2-V1.007.SJ"; char SwVersion[24] = "SECS2 V2.2-V1.008.SJ";
void TASK_Idle(void); void TASK_Idle(void);
void Task_10ms(void); void Task_10ms(void);
void Task_50ms(void); void Task_50ms(void);
@@ -56,7 +56,7 @@ void App_Init(void)
modbus_tcp.init(); modbus_tcp.init();
Wdg.Feed();
Led.Init(); Led.Init();
key.init(); key.init();
Wdg.Feed(); Wdg.Feed();
+12 -12
View File
@@ -142,29 +142,29 @@ static void bsp_FlashReset(void)
/*客户端主机网络配置*/ /*客户端主机网络配置*/
u16 port_1 = 5000; u16 port_1 = 5000;
u16 port_2 = 502; u16 port_2 = 502;
Usr_Flash.FlashData.IP_Addr_1[0] = 192; Usr_Flash.FlashData.IP_Addr_1[0] = 10;
Usr_Flash.FlashData.IP_Addr_1[1] = 168; Usr_Flash.FlashData.IP_Addr_1[1] = 21;
Usr_Flash.FlashData.IP_Addr_1[2] = 100; Usr_Flash.FlashData.IP_Addr_1[2] = 54;
Usr_Flash.FlashData.IP_Addr_1[3] = 103; Usr_Flash.FlashData.IP_Addr_1[3] = 6;
Usr_Flash.FlashData.Port_1[0] = port_1 >> 8; Usr_Flash.FlashData.Port_1[0] = port_1 >> 8;
Usr_Flash.FlashData.Port_1[1] = port_1 & 0x00ff; Usr_Flash.FlashData.Port_1[1] = port_1 & 0x00ff;
Usr_Flash.FlashData.Sub_Mask_1[0] = 255; Usr_Flash.FlashData.Sub_Mask_1[0] = 255;
Usr_Flash.FlashData.Sub_Mask_1[1] = 255; Usr_Flash.FlashData.Sub_Mask_1[1] = 255;
Usr_Flash.FlashData.Sub_Mask_1[2] = 255; Usr_Flash.FlashData.Sub_Mask_1[2] = 252;
Usr_Flash.FlashData.Sub_Mask_1[3] = 0; Usr_Flash.FlashData.Sub_Mask_1[3] = 0;
Usr_Flash.FlashData.Gateway_IP_1[0] = 192; Usr_Flash.FlashData.Gateway_IP_1[0] = 10;
Usr_Flash.FlashData.Gateway_IP_1[1] = 168; Usr_Flash.FlashData.Gateway_IP_1[1] = 21;
Usr_Flash.FlashData.Gateway_IP_1[2] = 100; Usr_Flash.FlashData.Gateway_IP_1[2] = 54;
Usr_Flash.FlashData.Gateway_IP_1[3] = 1; Usr_Flash.FlashData.Gateway_IP_1[3] = 1;
/*客户端目标IP*/ /*客户端目标IP*/
Usr_Flash.FlashData.IP_Addr_2[0] = 192; Usr_Flash.FlashData.IP_Addr_2[0] = 10;
Usr_Flash.FlashData.IP_Addr_2[1] = 168; Usr_Flash.FlashData.IP_Addr_2[1] = 21;
Usr_Flash.FlashData.IP_Addr_2[2] = 100; Usr_Flash.FlashData.IP_Addr_2[2] = 54;
Usr_Flash.FlashData.IP_Addr_2[3] = 61; Usr_Flash.FlashData.IP_Addr_2[3] = 8;
Usr_Flash.FlashData.Port_2[0] = port_2 >> 8; Usr_Flash.FlashData.Port_2[0] = port_2 >> 8;
Usr_Flash.FlashData.Port_2[1] = port_2 & 0x00ff; Usr_Flash.FlashData.Port_2[1] = port_2 & 0x00ff;
+38 -4
View File
@@ -37,12 +37,12 @@ void bsp_W5500_Socket_Set(bsp_W5500_Class_t *pW5500_Class);
static u8 last_link_status = 0; // 保存上一次链路状态 static u8 last_link_status = 0; // 保存上一次链路状态
bsp_W5500_t W5500 = bsp_W5500_t W5500 =
{ {
.Gateway_IP = {192,168,1,1}, .Gateway_IP = {10,21,54,1},
.Sub_Mask = {255,255,255,0}, .Sub_Mask = {255,255,252,0},
.Phy_Addr = {0x0c,0x29,0xab,0x7c,0x00,0x01}, .Phy_Addr = {0x0c,0x29,0xab,0x7c,0x00,0x01},
//.IP_Addr = {169,254,107,101}, //.IP_Addr = {169,254,107,101},
.IP_Addr = {192,168,1,101}, .IP_Addr = {10,21,54,2},
.Monitor_task = network_monitor_task, .Monitor_task = network_monitor_task,
.Interrupt_Process = bsp_W5500_Interrupt_Process, .Interrupt_Process = bsp_W5500_Interrupt_Process,
@@ -53,7 +53,7 @@ bsp_W5500_t W5500 =
.W5500_Class[0] = .W5500_Class[0] =
{ {
.SocketPort = 0, /*使用端口0*/ .SocketPort = 0, /*使用端口0*/
.ConfigData.Port = {0x13,0x88}, .ConfigData.Port = {0x13,0x8A},
// .ConfigData.DIP = {192,168,1,32}, // .ConfigData.DIP = {192,168,1,32},
// .ConfigData.DPort = {0x03,0x09}, // .ConfigData.DPort = {0x03,0x09},
.Run_Mode = BSP_W5500_PORT_RUN_MODE_TCP_SERVER, .Run_Mode = BSP_W5500_PORT_RUN_MODE_TCP_SERVER,
@@ -463,6 +463,39 @@ void W5500_Hardware_Reset(void)
// while((Read_W5500_1Byte(PHYCFGR)&LINK)==0);//等待以太网连接完成 // while((Read_W5500_1Byte(PHYCFGR)&LINK)==0);//等待以太网连接完成
} }
/*******************************************************************************
* 函数名 : W5500_PHY_Set_100M_FullDuplex
* 描述 : 软件强制 W5500 速率
* 输入 : 无
* 输出 : 无
* 返回值 : 无
* 说明 :
*******************************************************************************/
static void W5500_PHY_Set_100M_FullDuplex(void)
{
u8 cfg;
u8 phy,a;
Wdg.Feed();
/* OPMD=1 软件配置,OPMDC=111 →,自动协商 */
cfg = OPMODE | OPMDC_ALL_AN; /* 0x38 */
/* 步骤1:写 RST=1 + 目标配置,让配置生效 */
Write_W5500_1Byte(PHYCFGR, cfg | RST_PHY); /* 0xD8 */
HAL_Delay(10);
/* 步骤2:写 RST=0 触发 PHY 复位 */
Write_W5500_1Byte(PHYCFGR, cfg); /* 0x58 */
HAL_Delay(10);
/* 步骤3:写 RST=1 结束复位,PHY 按新配置启动 */
Write_W5500_1Byte(PHYCFGR, cfg | RST_PHY); /* 0xD8 */
HAL_Delay(1000); /* 等链路重建,至少 1 秒 */
/* 读回验证 */
phy = Read_W5500_1Byte(PHYCFGR);
a=phy;
}
/******************************************************************************* /*******************************************************************************
* 函数名 : W5500_Init * 函数名 : W5500_Init
* 描述 : 初始化W5500寄存器函数 * 描述 : 初始化W5500寄存器函数
@@ -808,6 +841,7 @@ static void bsp_W5500_Init()
Wdg.Feed(); Wdg.Feed();
W5500_Hardware_Reset(); /*硬件复位W5500*/ W5500_Hardware_Reset(); /*硬件复位W5500*/
W5500_Init(); /*初始化W5500寄存器函数*/ W5500_Init(); /*初始化W5500寄存器函数*/
W5500_PHY_Set_100M_FullDuplex();/*设置网口速率*/
Detect_Gateway(); /*检查网关服务器*/ Detect_Gateway(); /*检查网关服务器*/
for(i=0;i<BSP_W5500_PORT_NUM;i++) for(i=0;i<BSP_W5500_PORT_NUM;i++)
+9
View File
@@ -70,6 +70,15 @@
#define VERR 0x0039 #define VERR 0x0039
/* PHYCFGR OPMDC[2:0] 编码(数据手册 P42) */
#define OPMDC_10M_HALF 0x00 /* 000 */
#define OPMDC_10M_FULL 0x08 /* 001 */
#define OPMDC_100M_HALF 0x10 /* 010 */
#define OPMDC_100M_FULL 0x18 /* 011 */
#define OPMDC_100M_AN 0x20 /* 100 */
#define OPMDC_POWERDOWN 0x30 /* 110 */
#define OPMDC_ALL_AN 0x38 /* 111 */
/********************* Socket Register *******************/ /********************* Socket Register *******************/
#define Sn_MR 0x0000 #define Sn_MR 0x0000
#define MULTI_MFEN 0x80 #define MULTI_MFEN 0x80
+40 -5
View File
@@ -44,10 +44,10 @@ void bsp_W5500_Socket_Set(bsp_W5500_Class_t *pW5500_1_Class);
static u8 last_link_status = 0; // 保存上一次链路状态 static u8 last_link_status = 0; // 保存上一次链路状态
bsp_W5500_t W5500_1 = bsp_W5500_t W5500_1 =
{ {
.Gateway_IP = {192,168,100,1}, .Gateway_IP = {10,21,54,1},
.Sub_Mask = {255,255,255,0}, .Sub_Mask = {255,255,252,0},
.Phy_Addr = {0x0c,0x29,0xab,0x7c,0x00,0x02}, .Phy_Addr = {0x0c,0x29,0xab,0x7c,0x00,0x02},
.IP_Addr = {192,168,100,103}, .IP_Addr = {10,21,54,6},
.Monitor_task = network_monitor_task, .Monitor_task = network_monitor_task,
.Interrupt_Process = bsp_W5500_Interrupt_Process, .Interrupt_Process = bsp_W5500_Interrupt_Process,
@@ -59,7 +59,7 @@ bsp_W5500_t W5500_1 =
{ {
.SocketPort = 0, /* 改为 0,便于中断处理 */ .SocketPort = 0, /* 改为 0,便于中断处理 */
.ConfigData.Port = {0x13,0x88}, // 本地端口 5000(可自定义) .ConfigData.Port = {0x13,0x88}, // 本地端口 5000(可自定义)
.ConfigData.DIP = {192,168,100,41}, // 目标服务器 IP .ConfigData.DIP = {10,21,54,8}, // 目标服务器 IP
.ConfigData.DPort = {0x01,0xF6}, // 目标端口 502 .ConfigData.DPort = {0x01,0xF6}, // 目标端口 502
.Run_Mode = BSP_W5500_PORT_RUN_MODE_TCP_CLIENT, .Run_Mode = BSP_W5500_PORT_RUN_MODE_TCP_CLIENT,
}, },
@@ -467,6 +467,40 @@ static void W5500_Hardware_Reset(void)
// while((Read_W5500_1Byte(PHYCFGR)&LINK)==0);//等待以太网连接完成 // while((Read_W5500_1Byte(PHYCFGR)&LINK)==0);//等待以太网连接完成
} }
/*******************************************************************************
* 函数名 : W5500_PHY_Set_100M_FullDuplex
* 描述 : 软件强制 W5500 速率
* 输入 : 无
* 输出 : 无
* 返回值 : 无
* 说明 :
*******************************************************************************/
static void W5500_PHY_Set_100M_FullDuplex(void)
{
u8 cfg;
u8 phy,a;
Wdg.Feed();
/* OPMD=1 软件配置,OPMDC=111 →,自动协商 */
cfg = OPMODE | OPMDC_ALL_AN; /* 0x38 */
/* 步骤1:写 RST=1 + 目标配置,让配置生效 */
Write_W5500_1Byte(PHYCFGR, cfg | RST_PHY); /* 0xD8 */
HAL_Delay(10);
/* 步骤2:写 RST=0 触发 PHY 复位 */
Write_W5500_1Byte(PHYCFGR, cfg); /* 0x58 */
HAL_Delay(10);
/* 步骤3:写 RST=1 结束复位,PHY 按新配置启动 */
Write_W5500_1Byte(PHYCFGR, cfg | RST_PHY); /* 0xD8 */
HAL_Delay(1000); /* 等链路重建,至少 1 秒 */
/* 读回验证 */
phy = Read_W5500_1Byte(PHYCFGR);
a=phy;
}
/******************************************************************************* /*******************************************************************************
* 函数名 : W5500_Init * 函数名 : W5500_Init
* 描述 : 初始化W5500寄存器函数 * 描述 : 初始化W5500寄存器函数
@@ -811,7 +845,8 @@ static void bsp_W5500_Init()
u8 i; u8 i;
Wdg.Feed(); Wdg.Feed();
W5500_Hardware_Reset(); /*硬件复位W5500*/ W5500_Hardware_Reset(); /*硬件复位W5500*/
W5500_Init(); /*初始化W5500寄存器函数*/ W5500_Init(); /*初始化W5500寄存器函数*/
W5500_PHY_Set_100M_FullDuplex(); /*设置网口速率*/
Detect_Gateway(); /*检查网关服务器*/ Detect_Gateway(); /*检查网关服务器*/