"完成了433多数据同时接收的时候的冲突问题,解决了网络未连接会卡死整个程序的问题“
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
#include "wiz_platform.h"
|
||||
#include "wizchip_conf.h"
|
||||
#include "dhcp.h"
|
||||
#include "main.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -93,57 +94,60 @@ void wiz_delete_timer(void (*func)(void))
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief wiz timer event handler
|
||||
* @brief wiz timer event handler (using HAL_GetTick)
|
||||
*
|
||||
* You must add this function to your 1ms timer interrupt
|
||||
*
|
||||
*/
|
||||
void wiz_timer_handler(void)
|
||||
{
|
||||
static uint32_t last_tick = 0;
|
||||
uint32_t current_tick = HAL_GetTick();
|
||||
|
||||
wiz_delay_ms_count++;
|
||||
struct wiz_timer *temp = wiz_timer_head;
|
||||
while (temp != NULL)
|
||||
{
|
||||
temp->count_time++;
|
||||
if (temp->count_time >= temp->trigger_time)
|
||||
if (current_tick != last_tick) {
|
||||
last_tick = current_tick;
|
||||
struct wiz_timer *temp = wiz_timer_head;
|
||||
while (temp != NULL)
|
||||
{
|
||||
temp->count_time = 0;
|
||||
temp->func();
|
||||
temp->count_time++;
|
||||
if (temp->count_time >= temp->trigger_time)
|
||||
{
|
||||
temp->count_time = 0;
|
||||
temp->func();
|
||||
}
|
||||
temp = temp->next;
|
||||
}
|
||||
temp = temp->next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Delay function in milliseconds
|
||||
* @brief Delay function in milliseconds (using HAL_GetTick)
|
||||
* @param nms :Delay Time
|
||||
*/
|
||||
void wiz_user_delay_ms(uint32_t nms)
|
||||
{
|
||||
wiz_delay_ms_count = 0;
|
||||
while (wiz_delay_ms_count < nms)
|
||||
{
|
||||
uint32_t start = HAL_GetTick();
|
||||
while ((HAL_GetTick() - start) < nms) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check the WIZCHIP version
|
||||
* @brief Check the WIZCHIP version (with timeout)
|
||||
*/
|
||||
void wizchip_version_check(void)
|
||||
{
|
||||
uint8_t error_count = 0;
|
||||
while (1)
|
||||
uint32_t start_tick = HAL_GetTick();
|
||||
while ((HAL_GetTick() - start_tick) < 5000)
|
||||
{
|
||||
wiz_user_delay_ms(1000);
|
||||
wiz_user_delay_ms(100);
|
||||
if (getVERSIONR() != W5500_VERSION)
|
||||
{
|
||||
error_count++;
|
||||
if (error_count > 5)
|
||||
{
|
||||
printf("error, W5500 version is 0x%02x, but read W5500 version value = 0x%02x\r\n", W5500_VERSION, getVERSIONR());
|
||||
while (1)
|
||||
;
|
||||
printf("WARN: W5500 version check failed, SPI may be disconnected\r\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -165,25 +169,26 @@ void wiz_print_phy_info(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Ethernet Link Detection
|
||||
* @brief Ethernet Link Detection (with timeout)
|
||||
*/
|
||||
void wiz_phy_link_check(void)
|
||||
{
|
||||
uint8_t phy_link_status;
|
||||
do
|
||||
uint32_t start_tick = HAL_GetTick();
|
||||
|
||||
while ((HAL_GetTick() - start_tick) < 10000)
|
||||
{
|
||||
wiz_user_delay_ms(1000);
|
||||
wiz_user_delay_ms(500);
|
||||
ctlwizchip(CW_GET_PHYLINK, (void *)&phy_link_status);
|
||||
if (phy_link_status == PHY_LINK_ON)
|
||||
{
|
||||
printf("PHY link\r\n");
|
||||
wiz_print_phy_info();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("PHY no link\r\n");
|
||||
}
|
||||
} while (phy_link_status == PHY_LINK_OFF);
|
||||
}
|
||||
|
||||
printf("WARN: PHY link timeout, using static config\r\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user