Преглед на файлове

当识别不到W5500时,不在初始化函数进行阻塞,调整为核心线程循环检查

ryancw преди 2 години
родител
ревизия
9c09c53caa
променени са 3 файла, в които са добавени 24 реда и са изтрити 22 реда
  1. 22 20
      W5500Client/RyanW5500.c
  2. 1 1
      W5500Client/RyanW5500Socket.c
  3. 1 1
      W5500Client/RyanW5500Store.h

+ 22 - 20
W5500Client/RyanW5500.c

@@ -1,7 +1,7 @@
 #define DBG_ENABLE
 #define DBG_ENABLE
 
 
 #define DBG_SECTION_NAME ("w5500")
 #define DBG_SECTION_NAME ("w5500")
-#define DBG_LEVEL LOG_LVL_DBG
+#define DBG_LEVEL LOG_LVL_INFO
 #define DBG_COLOR
 #define DBG_COLOR
 
 
 #include "RyanW5500Store.h"
 #include "RyanW5500Store.h"
@@ -13,6 +13,7 @@
  */
  */
 void RyanW5500IRQCallback(void *argument)
 void RyanW5500IRQCallback(void *argument)
 {
 {
+    LOG_D("中断");
     rt_event_send(RyanW5500Entry.W5500EventHandle, RyanW5500IRQBit);
     rt_event_send(RyanW5500Entry.W5500EventHandle, RyanW5500IRQBit);
 }
 }
 
 
@@ -146,8 +147,27 @@ static void wizIntDataTask(void *parameter)
             sn_ir = 0;
             sn_ir = 0;
     uint16_t intr = 0;
     uint16_t intr = 0;
     struct netdev *netdev = (struct netdev *)parameter;
     struct netdev *netdev = (struct netdev *)parameter;
-
     platformTimer_t netWorkTimer = {0};
     platformTimer_t netWorkTimer = {0};
+
+    // 检查w5500连接是否正常
+    while (1)
+    {
+        // 超时中断触发为retry_cnt * time_100us * 100us
+        struct wiz_NetTimeout_t net_timeout = {
+            .retry_cnt = 5,      // 重试次数
+            .time_100us = 2000}; // 200ms认为失败
+        ctlnetwork(CN_SET_TIMEOUT, (void *)&net_timeout);
+
+        memset(&net_timeout, 0, sizeof(struct wiz_NetTimeout_t));
+
+        ctlnetwork(CN_GET_TIMEOUT, (void *)&net_timeout);
+        if (5 == net_timeout.retry_cnt && 2000 == net_timeout.time_100us)
+            break;
+
+        LOG_E("Wiznet chip not detected");
+        delay(1000);
+    }
+
     platformTimerCutdown(&netWorkTimer, 0);
     platformTimerCutdown(&netWorkTimer, 0);
 
 
     while (1)
     while (1)
@@ -248,24 +268,6 @@ int RyanW5500Init(wiz_NetInfo *netInfo)
 
 
     netdev = RyanW5500NetdevRegister("RyanW5500"); // W5500
     netdev = RyanW5500NetdevRegister("RyanW5500"); // W5500
     netdev_low_level_set_status(netdev, RT_TRUE);  // 设置网络接口设备状态
     netdev_low_level_set_status(netdev, RT_TRUE);  // 设置网络接口设备状态
-    // 检查w5500连接是否正常
-    while (1)
-    {
-        // 超时中断触发为retry_cnt * time_100us * 100us
-        struct wiz_NetTimeout_t net_timeout = {
-            .retry_cnt = 5,      // 重试次数
-            .time_100us = 2000}; // 200ms认为失败
-        ctlnetwork(CN_SET_TIMEOUT, (void *)&net_timeout);
-
-        memset(&net_timeout, 0, sizeof(struct wiz_NetTimeout_t));
-
-        ctlnetwork(CN_GET_TIMEOUT, (void *)&net_timeout);
-        if (5 == net_timeout.retry_cnt && 2000 == net_timeout.time_100us)
-            break;
-
-        LOG_E("Wiznet chip not detected");
-        delay(1000);
-    }
 
 
     RyanW5500Entry.w5500TaskHandle = rt_thread_create("RyanW5500",    // 线程name
     RyanW5500Entry.w5500TaskHandle = rt_thread_create("RyanW5500",    // 线程name
                                                       wizIntDataTask, // 线程入口函数
                                                       wizIntDataTask, // 线程入口函数

+ 1 - 1
W5500Client/RyanW5500Socket.c

@@ -1,7 +1,7 @@
 #define DBG_ENABLE
 #define DBG_ENABLE
 
 
 #define DBG_SECTION_NAME ("RyanW5500Socket")
 #define DBG_SECTION_NAME ("RyanW5500Socket")
-#define DBG_LEVEL LOG_LVL_DBG
+#define DBG_LEVEL LOG_LVL_INFO
 #define DBG_COLOR
 #define DBG_COLOR
 
 
 #include "RyanW5500Store.h"
 #include "RyanW5500Store.h"

+ 1 - 1
W5500Client/RyanW5500Store.h

@@ -53,7 +53,7 @@ extern "C"
 #define RyanW5500CheckCode(EX, ErrorCode, code)                    \
 #define RyanW5500CheckCode(EX, ErrorCode, code)                    \
     if (!(EX))                                                     \
     if (!(EX))                                                     \
     {                                                              \
     {                                                              \
-        LOG_I("%s:%d ErrorCode: %d, strError: %s",                 \
+        LOG_D("%s:%d ErrorCode: %d, strError: %s",                 \
               __FILE__, __LINE__, ErrorCode, strerror(ErrorCode)); \
               __FILE__, __LINE__, ErrorCode, strerror(ErrorCode)); \
         RyanW5500SetErrno(ErrorCode);                              \
         RyanW5500SetErrno(ErrorCode);                              \
         {                                                          \
         {                                                          \