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
+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; // 保存上一次链路状态
bsp_W5500_t W5500_1 =
{
.Gateway_IP = {192,168,100,1},
.Sub_Mask = {255,255,255,0},
.Gateway_IP = {10,21,54,1},
.Sub_Mask = {255,255,252,0},
.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,
.Interrupt_Process = bsp_W5500_Interrupt_Process,
@@ -59,7 +59,7 @@ bsp_W5500_t W5500_1 =
{
.SocketPort = 0, /* 改为 0,便于中断处理 */
.ConfigData.Port = {0x13,0x88}, // 本地端口 5000(可自定义)
.ConfigData.DIP = {192,168,100,41}, // 目标服务器 IP
.ConfigData.DIP = {10,21,54,8}, // 目标服务器 IP
.ConfigData.DPort = {0x01,0xF6}, // 目标端口 502
.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);//等待以太网连接完成
}
/*******************************************************************************
* 函数名 : 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寄存器函数
@@ -811,7 +845,8 @@ static void bsp_W5500_Init()
u8 i;
Wdg.Feed();
W5500_Hardware_Reset(); /*硬件复位W5500*/
W5500_Init(); /*初始化W5500寄存器函数*/
W5500_Init(); /*初始化W5500寄存器函数*/
W5500_PHY_Set_100M_FullDuplex(); /*设置网口速率*/
Detect_Gateway(); /*检查网关服务器*/