备份-通讯计数
This commit is contained in:
parent
70dd5b57b2
commit
d2628866f4
|
@ -148,30 +148,30 @@ void start_lwip_task(void const *argument)
|
|||
for (;;)
|
||||
{
|
||||
// osThreadTerminate(NULL);
|
||||
uint32_t phyreg = 0;
|
||||
uint8_t tcp_hart_num = 0;
|
||||
HAL_ETH_ReadPHYRegister(&heth, 0x00, PHY_BSR, &phyreg);
|
||||
if (((phyreg >> 2) & 0x1) != 0x1) // PHY_BSR寄存器的第2位表示PHY是否连接 PHY_LINKED_STATUS
|
||||
{
|
||||
/* When the netif link is down this function must be called */
|
||||
// uint32_t phyreg = 0;
|
||||
// uint8_t tcp_hart_num = 0;
|
||||
// HAL_ETH_ReadPHYRegister(&heth, 0x00, PHY_BSR, &phyreg);
|
||||
// if (((phyreg >> 2) & 0x1) != 0x1) // PHY_BSR寄存器的第2位表示PHY是否连接 PHY_LINKED_STATUS
|
||||
// {
|
||||
// /* When the netif link is down this function must be called */
|
||||
|
||||
netif_set_link_down(&gnetif);
|
||||
netif_set_down(&gnetif); // 热插拔下线时调用
|
||||
for (tcp_hart_num = 0; tcp_hart_num < TCP_MAX; tcp_hart_num++)
|
||||
{
|
||||
if (tcp_echo_flags[tcp_hart_num] == 1)
|
||||
{
|
||||
tcp_abort(server_pcb_hart[tcp_hart_num]); // 热插拔下线时调用
|
||||
tcp_echo_flags[tcp_hart_num] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* When the netif is fully configured this function must be called */
|
||||
netif_set_link_up(&gnetif);
|
||||
netif_set_up(&gnetif); // 热插拔上线时调用
|
||||
}
|
||||
// netif_set_link_down(&gnetif);
|
||||
// netif_set_down(&gnetif); // 热插拔下线时调用
|
||||
// for (tcp_hart_num = 0; tcp_hart_num < TCP_MAX; tcp_hart_num++)
|
||||
// {
|
||||
// if (tcp_echo_flags[tcp_hart_num] == 1)
|
||||
// {
|
||||
// tcp_abort(server_pcb_hart[tcp_hart_num]); // 热插拔下线时调用
|
||||
// tcp_echo_flags[tcp_hart_num] = 0;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// /* When the netif is fully configured this function must be called */
|
||||
// netif_set_link_up(&gnetif);
|
||||
// netif_set_up(&gnetif); // 热插拔上线时调用
|
||||
// }
|
||||
ch438_interrupt_handler_data_ch438_chip_1();
|
||||
ch438_interrupt_handler_data_ch438_chip_2();
|
||||
|
||||
|
@ -218,8 +218,32 @@ void start_ch438_task(void const *argument)
|
|||
ch438_init();
|
||||
for (;;)
|
||||
{
|
||||
osThreadTerminate(NULL);
|
||||
// vTaskDelay(500);
|
||||
// osThreadTerminate(NULL);
|
||||
uint32_t phyreg = 0;
|
||||
uint8_t tcp_hart_num = 0;
|
||||
HAL_ETH_ReadPHYRegister(&heth, 0x00, PHY_BSR, &phyreg);
|
||||
if (((phyreg >> 2) & 0x1) != 0x1) // PHY_BSR寄存器的第2位表示PHY是否连接 PHY_LINKED_STATUS
|
||||
{
|
||||
/* When the netif link is down this function must be called */
|
||||
|
||||
netif_set_link_down(&gnetif);
|
||||
netif_set_down(&gnetif); // 热插拔下线时调用
|
||||
for (tcp_hart_num = 0; tcp_hart_num < TCP_MAX; tcp_hart_num++)
|
||||
{
|
||||
if (tcp_echo_flags[tcp_hart_num] == 1)
|
||||
{
|
||||
tcp_abort(server_pcb_hart[tcp_hart_num]); // 热插拔下线时调用
|
||||
tcp_echo_flags[tcp_hart_num] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* When the netif is fully configured this function must be called */
|
||||
netif_set_link_up(&gnetif);
|
||||
netif_set_up(&gnetif); // 热插拔上线时调用
|
||||
}
|
||||
vTaskDelay(500);
|
||||
}
|
||||
/* USER CODE END start_ch438_task */
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@
|
|||
<SetRegEntry>
|
||||
<Number>0</Number>
|
||||
<Key>ST-LINKIII-KEIL_SWO</Key>
|
||||
<Name>-UB -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407ZGTx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
|
||||
<Name>-UB -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407ZGTx$CMSIS\Flash\STM32F4xx_1024.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2</Name>
|
||||
</SetRegEntry>
|
||||
</TargetDriverDllRegistry>
|
||||
<Breakpoint/>
|
||||
|
@ -251,6 +251,13 @@
|
|||
<ItemText>ch438_1_int_flag</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<WatchWindow2>
|
||||
<Ww>
|
||||
<count>0</count>
|
||||
<WinNumber>2</WinNumber>
|
||||
<ItemText>\\valve_debugging\../User/application/src/tcpserverc.c\tcp_times,0x0A</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow2>
|
||||
<MemoryWindow1>
|
||||
<Mm>
|
||||
<WinNumber>1</WinNumber>
|
||||
|
@ -273,7 +280,7 @@
|
|||
<DebugFlag>
|
||||
<trace>0</trace>
|
||||
<periodic>1</periodic>
|
||||
<aLwin>1</aLwin>
|
||||
<aLwin>0</aLwin>
|
||||
<aCover>0</aCover>
|
||||
<aSer1>0</aSer1>
|
||||
<aSer2>0</aSer2>
|
||||
|
@ -373,7 +380,7 @@
|
|||
<GroupNumber>2</GroupNumber>
|
||||
<FileNumber>4</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>../Core/Src/freertos.c</PathWithFileName>
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
<TargetCommonOption>
|
||||
<Device>STM32F407ZGTx</Device>
|
||||
<Vendor>STMicroelectronics</Vendor>
|
||||
<PackID>Keil.STM32F4xx_DFP.2.12.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack</PackURL>
|
||||
<PackID>Keil.STM32F4xx_DFP.2.16.0</PackID>
|
||||
<PackURL>http://www.keil.com/pack/</PackURL>
|
||||
<Cpu>IRAM(0x20000000-0x2001BFFF) IRAM2(0x2001C000-0x2001FFFF) IROM(0x8000000-0x80FFFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4") TZ</Cpu>
|
||||
<FlashUtilSpec></FlashUtilSpec>
|
||||
<StartupFile></StartupFile>
|
||||
|
@ -186,6 +186,7 @@
|
|||
<RvdsVP>2</RvdsVP>
|
||||
<RvdsMve>0</RvdsMve>
|
||||
<RvdsCdeCp>0</RvdsCdeCp>
|
||||
<nBranchProt>0</nBranchProt>
|
||||
<hadIRAM2>1</hadIRAM2>
|
||||
<hadIROM2>0</hadIROM2>
|
||||
<StupSel>8</StupSel>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -37,7 +37,6 @@ static err_t tcpecho_recv_hart1(void *arg, struct tcp_pcb *tpcb, struct pbuf *p,
|
|||
tcp_recved(tpcb, p->tot_len); // 读取数据的控制块 得到所有数据的长度
|
||||
server_pcb_hart[TCP_HART1] = tpcb; // 直接赋值
|
||||
memcpy(hart_uart[TCP_HART1].tx_data, (int *)p->payload, p->tot_len);
|
||||
HAL_GPIO_TogglePin(PE5_LED_GPIO_Port, PE5_LED_Pin); // 接收数据时,LED闪烁
|
||||
ch438_send_data(TCP_HART1, hart_uart[TCP_HART1].tx_data, p->tot_len);
|
||||
tcp_times[TCP_HART1]++;
|
||||
pbuf_free(p);
|
||||
|
@ -139,6 +138,7 @@ static err_t tcpecho_recv_hart6(void *arg, struct tcp_pcb *tpcb, struct pbuf *p,
|
|||
server_pcb_hart[TCP_HART6] = tpcb; // 直接赋值
|
||||
memcpy(hart_uart[TCP_HART6].tx_data, (int *)p->payload, p->tot_len);
|
||||
ch438_send_data(TCP_HART6, hart_uart[TCP_HART6].tx_data, p->tot_len);
|
||||
tcp_times[TCP_HART6]++;
|
||||
pbuf_free(p);
|
||||
}
|
||||
else if (err == ERR_OK) // 检测到对方主动关闭连接时,也会调用recv函数,此时p为空
|
||||
|
@ -158,6 +158,7 @@ static err_t tcpecho_recv_hart7(void *arg, struct tcp_pcb *tpcb, struct pbuf *p,
|
|||
server_pcb_hart[TCP_HART7] = tpcb; // 直接赋值
|
||||
memcpy(hart_uart[TCP_HART7].tx_data, (int *)p->payload, p->tot_len);
|
||||
ch438_send_data(TCP_HART7, hart_uart[TCP_HART7].tx_data, p->tot_len);
|
||||
tcp_times[TCP_HART7]++;
|
||||
pbuf_free(p);
|
||||
}
|
||||
else if (err == ERR_OK) // 检测到对方主动关闭连接时,也会调用recv函数,此时p为空
|
||||
|
@ -177,6 +178,7 @@ static err_t tcpecho_recv_hart8(void *arg, struct tcp_pcb *tpcb, struct pbuf *p,
|
|||
server_pcb_hart[TCP_HART8] = tpcb; // 直接赋值
|
||||
memcpy(hart_uart[TCP_HART8].tx_data, (int *)p->payload, p->tot_len);
|
||||
ch438_send_data(TCP_HART8, hart_uart[TCP_HART8].tx_data, p->tot_len);
|
||||
tcp_times[TCP_HART8]++;
|
||||
pbuf_free(p);
|
||||
}
|
||||
else if (err == ERR_OK) // 检测到对方主动关闭连接时,也会调用recv函数,此时p为空
|
||||
|
@ -196,6 +198,7 @@ static err_t tcpecho_recv_hart9(void *arg, struct tcp_pcb *tpcb, struct pbuf *p,
|
|||
server_pcb_hart[TCP_HART9] = tpcb; // 直接赋值
|
||||
memcpy(hart_uart[TCP_HART9].tx_data, (int *)p->payload, p->tot_len);
|
||||
ch438_send_data(TCP_HART9, hart_uart[TCP_HART9].tx_data, p->tot_len);
|
||||
tcp_times[TCP_HART9]++;
|
||||
pbuf_free(p);
|
||||
}
|
||||
else if (err == ERR_OK) // 检测到对方主动关闭连接时,也会调用recv函数,此时p为空
|
||||
|
@ -215,6 +218,7 @@ static err_t tcpecho_recv_hart10(void *arg, struct tcp_pcb *tpcb, struct pbuf *p
|
|||
server_pcb_hart[TCP_HART10] = tpcb; // 直接赋值
|
||||
memcpy(hart_uart[TCP_HART10].tx_data, (int *)p->payload, p->tot_len);
|
||||
ch438_send_data(TCP_HART10, hart_uart[TCP_HART10].tx_data, p->tot_len);
|
||||
tcp_times[TCP_HART10]++;
|
||||
pbuf_free(p);
|
||||
}
|
||||
else if (err == ERR_OK) // 检测到对方主动关闭连接时,也会调用recv函数,此时p为空
|
||||
|
@ -234,6 +238,7 @@ static err_t tcpecho_recv_hart11(void *arg, struct tcp_pcb *tpcb, struct pbuf *p
|
|||
server_pcb_hart[TCP_HART11] = tpcb; // 直接赋值
|
||||
memcpy(hart_uart[TCP_HART11].tx_data, (int *)p->payload, p->tot_len);
|
||||
ch438_send_data(TCP_HART11, hart_uart[TCP_HART11].tx_data, p->tot_len);
|
||||
tcp_times[TCP_HART11]++;
|
||||
pbuf_free(p);
|
||||
}
|
||||
else if (err == ERR_OK) // 检测到对方主动关闭连接时,也会调用recv函数,此时p为空
|
||||
|
@ -253,6 +258,7 @@ static err_t tcpecho_recv_hart12(void *arg, struct tcp_pcb *tpcb, struct pbuf *p
|
|||
server_pcb_hart[TCP_HART12] = tpcb; // 直接赋值
|
||||
memcpy(hart_uart[TCP_HART12].tx_data, (int *)p->payload, p->tot_len);
|
||||
ch438_send_data(TCP_HART12, hart_uart[TCP_HART12].tx_data, p->tot_len);
|
||||
tcp_times[TCP_HART12]++;
|
||||
pbuf_free(p);
|
||||
}
|
||||
else if (err == ERR_OK) // 检测到对方主动关闭连接时,也会调用recv函数,此时p为空
|
||||
|
@ -272,6 +278,7 @@ static err_t tcpecho_recv_hart13(void *arg, struct tcp_pcb *tpcb, struct pbuf *p
|
|||
server_pcb_hart[TCP_HART13] = tpcb; // 直接赋值
|
||||
memcpy(hart_uart[TCP_HART13].tx_data, (int *)p->payload, p->tot_len);
|
||||
ch438_send_data(TCP_HART13, hart_uart[TCP_HART13].tx_data, p->tot_len);
|
||||
tcp_times[TCP_HART13]++;
|
||||
pbuf_free(p);
|
||||
}
|
||||
else if (err == ERR_OK) // 检测到对方主动关闭连接时,也会调用recv函数,此时p为空
|
||||
|
@ -291,6 +298,7 @@ static err_t tcpecho_recv_hart14(void *arg, struct tcp_pcb *tpcb, struct pbuf *p
|
|||
server_pcb_hart[TCP_HART14] = tpcb; // 直接赋值
|
||||
memcpy(hart_uart[TCP_HART14].tx_data, (int *)p->payload, p->tot_len);
|
||||
ch438_send_data(TCP_HART14, hart_uart[TCP_HART14].tx_data, p->tot_len);
|
||||
tcp_times[TCP_HART14]++;
|
||||
pbuf_free(p);
|
||||
}
|
||||
else if (err == ERR_OK) // 检测到对方主动关闭连接时,也会调用recv函数,此时p为空
|
||||
|
@ -310,6 +318,7 @@ static err_t tcpecho_recv_hart15(void *arg, struct tcp_pcb *tpcb, struct pbuf *p
|
|||
server_pcb_hart[TCP_HART15] = tpcb; // 直接赋值
|
||||
memcpy(hart_uart[TCP_HART15].tx_data, (int *)p->payload, p->tot_len);
|
||||
ch438_send_data(TCP_HART15, hart_uart[TCP_HART15].tx_data, p->tot_len);
|
||||
tcp_times[TCP_HART15]++;
|
||||
pbuf_free(p);
|
||||
}
|
||||
else if (err == ERR_OK) // 检测到对方主动关闭连接时,也会调用recv函数,此时p为空
|
||||
|
@ -329,6 +338,7 @@ static err_t tcpecho_recv_hart16(void *arg, struct tcp_pcb *tpcb, struct pbuf *p
|
|||
server_pcb_hart[TCP_HART16] = tpcb; // 直接赋值
|
||||
memcpy(hart_uart[TCP_HART16].tx_data, (int *)p->payload, p->tot_len);
|
||||
ch438_send_data(TCP_HART16, hart_uart[TCP_HART16].tx_data, p->tot_len);
|
||||
tcp_times[TCP_HART16]++;
|
||||
pbuf_free(p);
|
||||
}
|
||||
else if (err == ERR_OK) // 检测到对方主动关闭连接时,也会调用recv函数,此时p为空
|
||||
|
@ -568,7 +578,7 @@ void tcp_echo_init(void)
|
|||
|
||||
void user_send_data_hart(uint8_t ch, uint8_t *data, uint16_t len)
|
||||
{
|
||||
|
||||
HAL_GPIO_TogglePin(PE5_LED_GPIO_Port, PE5_LED_Pin); // 接收数据时,LED闪烁
|
||||
tcp_write(server_pcb_hart[ch], data, len, 1);
|
||||
}
|
||||
// void user_send_data_hart9(uint8_t *data, uint16_t len)
|
||||
|
|
Loading…
Reference in New Issue