Przeglądaj źródła

add support for pin names

Evlers 1 rok temu
rodzic
commit
37feba37b2
5 zmienionych plików z 51 dodań i 15 usunięć
  1. 29 6
      Kconfig
  2. 3 2
      README.md
  3. 3 2
      README_CN.md
  4. 9 3
      porting/src/bsp/cybsp.c
  5. 7 2
      porting/src/wlan/whd_wlan.c

+ 29 - 6
Kconfig

@@ -77,13 +77,36 @@ menuconfig PKG_USING_WIFI_HOST_DRIVER
             range 0 8192
             default 5120
 
-        config CYBSP_REG_ON_PIN
-            int "Set the WiFi_REG ON pin"
-            default -1
+        choice
+            prompt "Select the pin name or number"
+            default CYBSP_USING_PIN_NUMBER
+
+            config CYBSP_USING_PIN_NAME
+                bool "Name"
+
+            config CYBSP_USING_PIN_NUMBER
+                bool "Number"
+        endchoice
+
+        if CYBSP_USING_PIN_NAME
+            config CYBSP_REG_ON_PIN_NAME
+                string "Set the WiFi_REG ON pin name"
+                default "PA.0"
 
-        config CYBSP_HOST_WAKE_IRQ_PIN
-            int "Set the HOST_WAKE_IRQ pin"
-            default -1
+            config CYBSP_HOST_WAKE_IRQ_PIN_NAME
+                string "Set the HOST_WAKE_IRQ pin name"
+                default "PA.1"
+        endif
+
+        if CYBSP_USING_PIN_NUMBER
+            config CYBSP_REG_ON_PIN
+                int "Set the WiFi_REG ON pin number"
+                default -1
+
+            config CYBSP_HOST_WAKE_IRQ_PIN
+                int "Set the HOST_WAKE_IRQ pin number"
+                default -1
+        endif
 
         choice
             prompt "Select HOST_WAKE_IRQ event type"

+ 3 - 2
README.md

@@ -28,8 +28,9 @@ RT-Thread online packages  --->                         # Online software packag
 [ ]   Default enable powersave mode                     # The low power mode is selected by default
 (8)   The priority level value of WHD thread            # Configure the priority of the WHD thread
 (5120) The stack size for WHD thread                    # Configure the stack size of the WHD thread
-(49)  Set the WiFi_REG ON pin                           # Set the WiFi_REG ON pin of the module
-(37)  Set the HOST_WAKE_IRQ pin                         # Set the HOST_WAKE_IRQ pin of the module
+      Select the pin name or number (Number)  --->      # Select a pin name or pin number
+(-1)  Set the WiFi_REG ON pin number                    # Set the WiFi_REG ON pin of the module
+(-1)  Set the HOST_WAKE_IRQ pin number                  # Set the HOST_WAKE_IRQ pin of the module
       Select HOST_WAKE_IRQ event type (falling)  --->   # Select the edge of Wake up host
 (2)   Set the interrput priority for HOST_WAKE_IRQ pin  # Set the external interrupt priority
 [ ]   Using thread initialization                       # Create a thread to initialize the driver

+ 3 - 2
README_CN.md

@@ -29,8 +29,9 @@ RT-Thread online packages  --->                         # 在线软件包
 [ ]   Default enable powersave mode                     # 默认启用低功耗模式
 (8)   The priority level value of WHD thread            # 配置WHD线程的优先级
 (5120) The stack size for WHD thread                    # 配置WHD线程的堆栈大小
-(49)  Set the WiFi_REG ON pin                           # 设置模块的WL_REG_ON引脚
-(37)  Set the HOST_WAKE_IRQ pin                         # 设置模块的HOST_WAKE_IRQ引脚
+      Select the pin name or number (Number)  --->      # 选择引脚名称或引脚编号
+(-1)  Set the WiFi_REG ON pin number                    # 设置模块的WL_REG_ON引脚
+(-1)  Set the HOST_WAKE_IRQ pin number                  # 设置模块的HOST_WAKE_IRQ引脚
       Select HOST_WAKE_IRQ event type (falling)  --->   # 选择“唤醒主机”的边沿
 (2)   Set the interrput priority for HOST_WAKE_IRQ pin  # 设置外部中断优先级
 [ ]   Using thread initialization                       # 创建一个线程来初始化驱动

+ 9 - 3
porting/src/bsp/cybsp.c

@@ -25,6 +25,7 @@
  * Date         Author      Notes
  * 2023-12-21   Evlers      first implementation
  * 2024-05-17   Evlers      fixed an bug where a module could not be reset
+ * 2024-05-28   Evlers      add support for pin names
  */
 
 #include "rtthread.h"
@@ -36,13 +37,18 @@
 
 static int cybsp_init(void)
 {
+#ifndef CYBSP_USING_PIN_NAME
+    rt_base_t pin_number = CYBSP_REG_ON_PIN;
+#else
+    rt_base_t pin_number = rt_pin_get(CYBSP_REG_ON_PIN_NAME);
+#endif
     /* configure the wl_reg_on pin */
-    rt_pin_mode(CYBSP_REG_ON_PIN, PIN_MODE_OUTPUT);
+    rt_pin_mode(pin_number, PIN_MODE_OUTPUT);
 
     /* reset modules */
-    rt_pin_write(CYBSP_REG_ON_PIN, PIN_LOW);
+    rt_pin_write(pin_number, PIN_LOW);
     rt_thread_mdelay(2);
-    rt_pin_write(CYBSP_REG_ON_PIN, PIN_HIGH);
+    rt_pin_write(pin_number, PIN_HIGH);
 
     return RT_EOK;
 }

+ 7 - 2
porting/src/wlan/whd_wlan.c

@@ -27,6 +27,7 @@
  * 2024-03-25   Evlers      add configure the mmcsd card scanning wait time
  * 2024-03-25   Evlers      add the function to initialize WiFi using threads
  * 2024-05-27   Evlers      fix the thread initialization bug and deleted the initialization return value
+ * 2024-05-28   Evlers      add support for pin names
  */
 
 #include "rtthread.h"
@@ -540,9 +541,13 @@ static void register_whd_events (void)
 static void whd_init_thread (void *parameter)
 {
     static struct rt_wlan_device wlan_ap, wlan_sta;
-    static const whd_oob_config_t OOB_CONFIG =
+    whd_oob_config_t oob_config =
     {
+#ifndef CYBSP_USING_PIN_NAME
         .host_oob_pin      = CYBSP_HOST_WAKE_IRQ_PIN,
+#else
+        .host_oob_pin      = rt_pin_get(CYBSP_HOST_WAKE_IRQ_PIN_NAME),
+#endif
         .dev_gpio_sel      = 0,
         .is_falling_edge   = (CYBSP_HOST_WAKE_IRQ_EVENT == CYHAL_GPIO_IRQ_FALL) ? WHD_TRUE : WHD_FALSE,
         .intr_priority     = CYBSP_OOB_INTR_PRIORITY
@@ -551,7 +556,7 @@ static void whd_init_thread (void *parameter)
     {
         .sdio_1bit_mode        = WHD_FALSE,
         .high_speed_sdio_clock = WHD_FALSE,
-        .oob_config            = OOB_CONFIG
+        .oob_config            = oob_config
     };
 
     wifi_ap.wlan = &wlan_ap;