Explorar el Código

Update RT_USING_DFS options and sync new USB host API.

Wayne Lin hace 3 años
padre
commit
8803bf4018

+ 1 - 0
bsp/nuvoton/libraries/m2354/rtt_port/Kconfig

@@ -470,6 +470,7 @@ config SOC_SERIES_M2354
     menuconfig BSP_USING_SDH
         bool "Enable Secure Digital Host Controller(SDH)"
         select RT_USING_DFS
+        select DFS_USING_POSIX
 
         if BSP_USING_SDH
             config BSP_USING_SDH0

+ 24 - 23
bsp/nuvoton/libraries/m2354/rtt_port/drv_sdh.c

@@ -19,14 +19,12 @@
 #include <drv_pdma.h>
 #include <string.h>
 
-#if defined(RT_USING_DFS)
-    #include <dfs_fs.h>
-    #include <dfs_file.h>
-    #include <unistd.h>
-    #include <stdio.h>
-    #include <sys/stat.h>
-    #include <sys/statfs.h>
-#endif
+#include <dfs_fs.h>
+#include <dfs_file.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
 
 /* Private define ---------------------------------------------------------------*/
 
@@ -236,11 +234,13 @@ static rt_size_t nu_sdh_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_siz
 {
     rt_uint32_t ret = 0;
     nu_sdh_t sdh = (nu_sdh_t)dev;
+    rt_err_t result;
 
     RT_ASSERT(dev != RT_NULL);
     RT_ASSERT(buffer != RT_NULL);
 
-    rt_sem_take(&sdh->lock, RT_WAITING_FOREVER);
+    result = rt_sem_take(&sdh->lock, RT_WAITING_FOREVER);
+    RT_ASSERT(result == RT_EOK);
 
     /* Check alignment. */
     if (((uint32_t)buffer & 0x03) != 0)
@@ -281,7 +281,8 @@ exit_nu_sdh_read:
         sdh->pbuf = RT_NULL;
     }
 
-    rt_sem_release(&sdh->lock);
+    result = rt_sem_release(&sdh->lock);
+    RT_ASSERT(result == RT_EOK);
 
     if (ret == Successful)
         return blk_nb;
@@ -295,11 +296,13 @@ static rt_size_t nu_sdh_write(rt_device_t dev, rt_off_t pos, const void *buffer,
 {
     rt_uint32_t ret = 0;
     nu_sdh_t sdh = (nu_sdh_t)dev;
+    rt_err_t result;
 
     RT_ASSERT(dev != RT_NULL);
     RT_ASSERT(buffer != RT_NULL);
 
-    rt_sem_take(&sdh->lock, RT_WAITING_FOREVER);
+    result = rt_sem_take(&sdh->lock, RT_WAITING_FOREVER);
+    RT_ASSERT(result == RT_EOK);
 
     /* Check alignment. */
     if (((uint32_t)buffer & 0x03) != 0)
@@ -338,7 +341,8 @@ exit_nu_sdh_write:
         sdh->pbuf = RT_NULL;
     }
 
-    rt_sem_release(&sdh->lock);
+    result = rt_sem_release(&sdh->lock);
+    RT_ASSERT(result == RT_EOK);
 
     if (ret == Successful) return blk_nb;
 
@@ -393,7 +397,8 @@ static int rt_hw_sdh_init(void)
         /* Private */
         nu_sdh_arr[i].dev.user_data = (void *)&nu_sdh_arr[i];
 
-        rt_sem_init(&nu_sdh_arr[i].lock, "sdhlock", 1, RT_IPC_FLAG_FIFO);
+        ret = rt_sem_init(&nu_sdh_arr[i].lock, "sdhlock", 1, RT_IPC_FLAG_FIFO);
+        RT_ASSERT(ret == RT_EOK);
 
         SDH_Open(nu_sdh_arr[i].base, CardDetect_From_GPIO);
 
@@ -402,6 +407,7 @@ static int rt_hw_sdh_init(void)
             NVIC_EnableIRQ(SDH0_IRQn);
 
         nu_sdh_arr[i].pbuf = RT_NULL;
+
         ret = rt_device_register(&nu_sdh_arr[i].dev, nu_sdh_arr[i].name, flags);
         RT_ASSERT(ret == RT_EOK);
     }
@@ -415,8 +421,6 @@ static rt_bool_t nu_sdh_hotplug_is_mounted(const char *mounting_path)
 {
     rt_bool_t ret = RT_FALSE;
 
-#if defined(RT_USING_DFS)
-
     struct dfs_filesystem *psFS = dfs_filesystem_lookup(mounting_path);
     if (psFS == RT_NULL)
     {
@@ -431,8 +435,6 @@ static rt_bool_t nu_sdh_hotplug_is_mounted(const char *mounting_path)
         ret = RT_FALSE;
     }
 
-#endif
-
 exit_nu_sdh_hotplug_is_mounted:
 
     return ret;
@@ -442,8 +444,6 @@ static rt_err_t nu_sdh_hotplug_mount(nu_sdh_t sdh)
     rt_err_t ret = RT_ERROR;
     DIR *t;
 
-#if defined(RT_USING_DFS)
-
     if (nu_sdh_hotplug_is_mounted(sdh->mounted_point) == RT_TRUE)
     {
         ret = RT_EOK;
@@ -491,7 +491,6 @@ static rt_err_t nu_sdh_hotplug_mount(nu_sdh_t sdh)
 
 exit_nu_sdh_hotplug_mount:
 
-#endif
     return -(ret);
 }
 
@@ -499,7 +498,6 @@ static rt_err_t nu_sdh_hotplug_unmount(nu_sdh_t sdh)
 {
     rt_err_t ret = RT_ERROR;
 
-#if defined(RT_USING_DFS)
     if (nu_sdh_hotplug_is_mounted(sdh->mounted_point) == RT_FALSE)
     {
         ret = RT_EOK;
@@ -516,7 +514,6 @@ static rt_err_t nu_sdh_hotplug_unmount(nu_sdh_t sdh)
         rt_kprintf("Succeed to unmount %s.\n", sdh->mounted_point);
         ret = RT_EOK;
     }
-#endif
 
 exit_nu_sdh_hotplug_unmount:
 
@@ -585,7 +582,11 @@ static void sdh_hotplugger(void *param)
 
 int mnt_init_sdcard_hotplug(void)
 {
-    rt_thread_init(&sdh_tid, "hotplug", sdh_hotplugger, NULL, sdh_stack, sizeof(sdh_stack), RT_THREAD_PRIORITY_MAX - 2, 10);
+    rt_err_t result;
+
+    result = rt_thread_init(&sdh_tid, "hotplug", sdh_hotplugger, NULL, sdh_stack, sizeof(sdh_stack), RT_THREAD_PRIORITY_MAX - 2, 10);
+    RT_ASSERT(result == RT_EOK);
+
     rt_thread_startup(&sdh_tid);
 
     return 0;

+ 1 - 1
bsp/nuvoton/libraries/m2354/rtt_port/drv_usbhost.c

@@ -469,7 +469,7 @@ static void int_xfer_done_cb(UTR_T *psUTR)
         msg.type = USB_MSG_CALLBACK;
         msg.content.cb.function = pipe->callback;
         msg.content.cb.context = pipe;
-        rt_usbh_event_signal(&msg);
+        rt_usbh_event_signal(&s_sUSBHDev.uhcd, &msg);
     }
 
 exit_int_xfer_done_cb:

+ 1 - 0
bsp/nuvoton/libraries/m480/rtt_port/Kconfig

@@ -447,6 +447,7 @@ config SOC_SERIES_M480
     menuconfig BSP_USING_SDH
         bool "Enable Secure Digital Host Controller(SDH)"
         select RT_USING_DFS
+        select DFS_USING_POSIX
 
         if BSP_USING_SDH
             config BSP_USING_SDH0

+ 6 - 17
bsp/nuvoton/libraries/m480/rtt_port/drv_sdh.c

@@ -19,14 +19,12 @@
 #include <drv_pdma.h>
 #include <string.h>
 
-#if defined(RT_USING_DFS)
-    #include <dfs_fs.h>
-    #include <dfs_file.h>
-    #include <unistd.h>
-    #include <stdio.h>
-    #include <sys/stat.h>
-    #include <sys/statfs.h>
-#endif
+#include <dfs_fs.h>
+#include <dfs_file.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
 
 /* Private define ---------------------------------------------------------------*/
 
@@ -457,8 +455,6 @@ static rt_bool_t nu_sdh_hotplug_is_mounted(const char *mounting_path)
 {
     rt_bool_t ret = RT_FALSE;
 
-#if defined(RT_USING_DFS)
-
     struct dfs_filesystem *psFS = dfs_filesystem_lookup(mounting_path);
     if (psFS == RT_NULL)
     {
@@ -473,8 +469,6 @@ static rt_bool_t nu_sdh_hotplug_is_mounted(const char *mounting_path)
         ret = RT_FALSE;
     }
 
-#endif
-
 exit_nu_sdh_hotplug_is_mounted:
 
     return ret;
@@ -484,8 +478,6 @@ static rt_err_t nu_sdh_hotplug_mount(nu_sdh_t sdh)
     rt_err_t ret = RT_ERROR;
     DIR *t;
 
-#if defined(RT_USING_DFS)
-
     if (nu_sdh_hotplug_is_mounted(sdh->mounted_point) == RT_TRUE)
     {
         ret = RT_EOK;
@@ -533,7 +525,6 @@ static rt_err_t nu_sdh_hotplug_mount(nu_sdh_t sdh)
 
 exit_nu_sdh_hotplug_mount:
 
-#endif
     return -(ret);
 }
 
@@ -541,7 +532,6 @@ static rt_err_t nu_sdh_hotplug_unmount(nu_sdh_t sdh)
 {
     rt_err_t ret = RT_ERROR;
 
-#if defined(RT_USING_DFS)
     if (nu_sdh_hotplug_is_mounted(sdh->mounted_point) == RT_FALSE)
     {
         ret = RT_EOK;
@@ -558,7 +548,6 @@ static rt_err_t nu_sdh_hotplug_unmount(nu_sdh_t sdh)
         rt_kprintf("Succeed to unmount %s.\n", sdh->mounted_point);
         ret = RT_EOK;
     }
-#endif
 
 exit_nu_sdh_hotplug_unmount:
 

+ 1 - 1
bsp/nuvoton/libraries/m480/rtt_port/drv_usbhost.c

@@ -472,7 +472,7 @@ static void int_xfer_done_cb(UTR_T *psUTR)
         msg.type = USB_MSG_CALLBACK;
         msg.content.cb.function = pipe->callback;
         msg.content.cb.context = pipe;
-        rt_usbh_event_signal(&msg);
+        rt_usbh_event_signal(&s_sUSBHDev.uhcd, &msg);
     }
 
 exit_int_xfer_done_cb:

+ 1 - 0
bsp/nuvoton/libraries/n9h30/rtt_port/Kconfig

@@ -273,6 +273,7 @@ config SOC_SERIES_N9H30
     menuconfig BSP_USING_SDH
         bool "Enable Secure Digital Host Controller(SDH)"
         select RT_USING_DFS
+        select DFS_USING_POSIX
 
         if BSP_USING_SDH
 

+ 6 - 18
bsp/nuvoton/libraries/n9h30/rtt_port/drv_sdh.c

@@ -19,14 +19,12 @@
 #include "NuMicro.h"
 #include <drv_sys.h>
 
-#if defined(RT_USING_DFS)
-    #include <dfs_fs.h>
-    #include <dfs_file.h>
-    #include <unistd.h>
-    #include <stdio.h>
-    #include <sys/stat.h>
-    #include <sys/statfs.h>
-#endif
+#include <dfs_fs.h>
+#include <dfs_file.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
 
 /* Private define ---------------------------------------------------------------*/
 
@@ -602,8 +600,6 @@ static rt_bool_t nu_sdh_hotplug_is_mounted(const char *mounting_path)
 {
     rt_bool_t ret = RT_FALSE;
 
-#if defined(RT_USING_DFS)
-
     struct dfs_filesystem *psFS = dfs_filesystem_lookup(mounting_path);
     if (psFS == RT_NULL)
     {
@@ -620,15 +616,11 @@ static rt_bool_t nu_sdh_hotplug_is_mounted(const char *mounting_path)
 
 exit_nu_sdh_hotplug_is_mounted:
 
-#endif
-
     return ret;
 }
 static rt_err_t nu_sdh_hotplug_mount(nu_sdh_t sdh)
 {
     rt_err_t ret = RT_ERROR;
-
-#if defined(RT_USING_DFS)
     DIR *t;
 
     if (nu_sdh_hotplug_is_mounted(sdh->mounted_point) == RT_TRUE)
@@ -678,7 +670,6 @@ static rt_err_t nu_sdh_hotplug_mount(nu_sdh_t sdh)
 
 exit_nu_sdh_hotplug_mount:
 
-#endif
     return -(ret);
 }
 
@@ -686,7 +677,6 @@ static rt_err_t nu_sdh_hotplug_unmount(nu_sdh_t sdh)
 {
     rt_err_t ret = RT_ERROR;
 
-#if defined(RT_USING_DFS)
     if (nu_sdh_hotplug_is_mounted(sdh->mounted_point) == RT_FALSE)
     {
         ret = RT_EOK;
@@ -706,8 +696,6 @@ static rt_err_t nu_sdh_hotplug_unmount(nu_sdh_t sdh)
 
 exit_nu_sdh_hotplug_unmount:
 
-#endif
-
     return -(ret);
 }
 

+ 4 - 4
bsp/nuvoton/libraries/n9h30/rtt_port/drv_usbhost.c

@@ -425,7 +425,7 @@ static int nu_bulk_xfer(
     UTR_T *psUTR,
     int timeouts)
 {
-    #define TIMEOUT_RETRY 3
+#define TIMEOUT_RETRY 3
 
     int retry = TIMEOUT_RETRY;
     int ret = usbh_bulk_xfer(psUTR);
@@ -435,9 +435,9 @@ static int nu_bulk_xfer(
         return ret;
     }
 
-    while ( retry > 0 )
+    while (retry > 0)
     {
-        if ( rt_completion_wait(&(psPortDev->utr_completion), timeouts) != 0 )
+        if (rt_completion_wait(&(psPortDev->utr_completion), timeouts) != 0)
         {
             rt_uint32_t level;
 
@@ -513,7 +513,7 @@ static void int_xfer_done_cb(UTR_T *psUTR)
         msg.type = USB_MSG_CALLBACK;
         msg.content.cb.function = pipe->callback;
         msg.content.cb.context = pipe;
-        rt_usbh_event_signal(&msg);
+        rt_usbh_event_signal(&s_sUSBHDev.uhcd, &msg);
     }
 
 exit_int_xfer_done_cb:

+ 1 - 0
bsp/nuvoton/libraries/nuc980/rtt_port/Kconfig

@@ -353,6 +353,7 @@ config SOC_SERIES_NUC980
     menuconfig BSP_USING_SDH
         bool "Enable Secure Digital Host Controller(SDH)"
         select RT_USING_DFS
+        select DFS_USING_POSIX
 
         if BSP_USING_SDH
             config BSP_USING_SDH0

+ 6 - 18
bsp/nuvoton/libraries/nuc980/rtt_port/drv_sdh.c

@@ -20,14 +20,12 @@
 #include <drv_pdma.h>
 #include <drv_sys.h>
 
-#if defined(RT_USING_DFS)
-    #include <dfs_fs.h>
-    #include <dfs_file.h>
-    #include <unistd.h>
-    #include <stdio.h>
-    #include <sys/stat.h>
-    #include <sys/statfs.h>
-#endif
+#include <dfs_fs.h>
+#include <dfs_file.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
 
 /* Private define ---------------------------------------------------------------*/
 
@@ -458,8 +456,6 @@ static rt_bool_t nu_sdh_hotplug_is_mounted(const char *mounting_path)
 {
     rt_bool_t ret = RT_FALSE;
 
-#if defined(RT_USING_DFS)
-
     struct dfs_filesystem *psFS = dfs_filesystem_lookup(mounting_path);
     if (psFS == RT_NULL)
     {
@@ -476,15 +472,11 @@ static rt_bool_t nu_sdh_hotplug_is_mounted(const char *mounting_path)
 
 exit_nu_sdh_hotplug_is_mounted:
 
-#endif
-
     return ret;
 }
 static rt_err_t nu_sdh_hotplug_mount(nu_sdh_t sdh)
 {
     rt_err_t ret = RT_ERROR;
-
-#if defined(RT_USING_DFS)
     DIR *t;
 
     if (nu_sdh_hotplug_is_mounted(sdh->mounted_point) == RT_TRUE)
@@ -534,7 +526,6 @@ static rt_err_t nu_sdh_hotplug_mount(nu_sdh_t sdh)
 
 exit_nu_sdh_hotplug_mount:
 
-#endif
     return -(ret);
 }
 
@@ -542,7 +533,6 @@ static rt_err_t nu_sdh_hotplug_unmount(nu_sdh_t sdh)
 {
     rt_err_t ret = RT_ERROR;
 
-#if defined(RT_USING_DFS)
     if (nu_sdh_hotplug_is_mounted(sdh->mounted_point) == RT_FALSE)
     {
         ret = RT_EOK;
@@ -562,8 +552,6 @@ static rt_err_t nu_sdh_hotplug_unmount(nu_sdh_t sdh)
 
 exit_nu_sdh_hotplug_unmount:
 
-#endif
-
     return -(ret);
 }
 

+ 4 - 4
bsp/nuvoton/libraries/nuc980/rtt_port/drv_usbhost.c

@@ -425,7 +425,7 @@ static int nu_bulk_xfer(
     UTR_T *psUTR,
     int timeouts)
 {
-    #define TIMEOUT_RETRY 3
+#define TIMEOUT_RETRY 3
 
     int retry = TIMEOUT_RETRY;
     int ret = usbh_bulk_xfer(psUTR);
@@ -435,9 +435,9 @@ static int nu_bulk_xfer(
         return ret;
     }
 
-    while ( retry > 0 )
+    while (retry > 0)
     {
-        if ( rt_completion_wait(&(psPortDev->utr_completion), timeouts) != 0 )
+        if (rt_completion_wait(&(psPortDev->utr_completion), timeouts) != 0)
         {
             rt_uint32_t level;
 
@@ -513,7 +513,7 @@ static void int_xfer_done_cb(UTR_T *psUTR)
         msg.type = USB_MSG_CALLBACK;
         msg.content.cb.function = pipe->callback;
         msg.content.cb.context = pipe;
-        rt_usbh_event_signal(&msg);
+        rt_usbh_event_signal(&s_sUSBHDev.uhcd, &msg);
     }
 
 exit_int_xfer_done_cb:

+ 6 - 8
bsp/nuvoton/nk-980iot/applications/mnt.c

@@ -21,14 +21,12 @@
 #define DBG_COLOR
 #include <rtdbg.h>
 
-#if defined(RT_USING_DFS)
-    #include <dfs_fs.h>
-    #include <dfs_file.h>
-    #include <unistd.h>
-    #include <stdio.h>
-    #include <sys/stat.h>
-    #include <sys/statfs.h>
-#endif
+#include <dfs_fs.h>
+#include <dfs_file.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
 
 #if defined(PKG_USING_FAL)
     #include <fal.h>

+ 6 - 8
bsp/nuvoton/nk-n9h30/applications/mnt.c

@@ -21,14 +21,12 @@
 #define DBG_COLOR
 #include <rtdbg.h>
 
-#if defined(RT_USING_DFS)
-    #include <dfs_fs.h>
-    #include <dfs_file.h>
-    #include <unistd.h>
-    #include <stdio.h>
-    #include <sys/stat.h>
-    #include <sys/statfs.h>
-#endif
+#include <dfs_fs.h>
+#include <dfs_file.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
 
 #if defined(PKG_USING_FAL)
     #include <fal.h>

+ 6 - 8
bsp/nuvoton/nk-rtu980/applications/mnt.c

@@ -21,14 +21,12 @@
 #define DBG_COLOR
 #include <rtdbg.h>
 
-#if defined(RT_USING_DFS)
-    #include <dfs_fs.h>
-    #include <dfs_file.h>
-    #include <unistd.h>
-    #include <stdio.h>
-    #include <sys/stat.h>
-    #include <sys/statfs.h>
-#endif
+#include <dfs_fs.h>
+#include <dfs_file.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
 
 #if defined(PKG_USING_FAL)
     #include <fal.h>

+ 6 - 8
bsp/nuvoton/numaker-iot-m487/applications/mnt.c

@@ -12,14 +12,12 @@
 
 #include <rtthread.h>
 
-#if defined(RT_USING_DFS)
-    #include <dfs_fs.h>
-    #include <dfs_file.h>
-    #include <unistd.h>
-    #include <stdio.h>
-    #include <sys/stat.h>
-    #include <sys/statfs.h>
-#endif
+#include <dfs_fs.h>
+#include <dfs_file.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
 
 #if defined(PKG_USING_FAL)
     #include <fal.h>

+ 6 - 8
bsp/nuvoton/numaker-m032ki/applications/mnt.c

@@ -12,14 +12,12 @@
 
 #include <rtthread.h>
 
-#if defined(RT_USING_DFS)
-    #include <dfs_fs.h>
-    #include <dfs_file.h>
-    #include <unistd.h>
-    #include <stdio.h>
-    #include <sys/stat.h>
-    #include <sys/statfs.h>
-#endif
+#include <dfs_fs.h>
+#include <dfs_file.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
 
 #if defined(PKG_USING_FAL)
     #include <fal.h>

+ 6 - 8
bsp/nuvoton/numaker-pfm-m487/applications/mnt.c

@@ -12,14 +12,12 @@
 
 #include <rtthread.h>
 
-#if defined(RT_USING_DFS)
-    #include <dfs_fs.h>
-    #include <dfs_file.h>
-    #include <unistd.h>
-    #include <stdio.h>
-    #include <sys/stat.h>
-    #include <sys/statfs.h>
-#endif
+#include <dfs_fs.h>
+#include <dfs_file.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
 
 #if defined(PKG_USING_FAL)
     #include <fal.h>