Skip to content

Commit 8803bf4

Browse files
committed
Update RT_USING_DFS options and sync new USB host API.
1 parent 6481998 commit 8803bf4

File tree

18 files changed

+92
-134
lines changed

18 files changed

+92
-134
lines changed

bsp/nuvoton/libraries/m2354/rtt_port/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ config SOC_SERIES_M2354
470470
menuconfig BSP_USING_SDH
471471
bool "Enable Secure Digital Host Controller(SDH)"
472472
select RT_USING_DFS
473+
select DFS_USING_POSIX
473474

474475
if BSP_USING_SDH
475476
config BSP_USING_SDH0

bsp/nuvoton/libraries/m2354/rtt_port/drv_sdh.c

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@
1919
#include <drv_pdma.h>
2020
#include <string.h>
2121

22-
#if defined(RT_USING_DFS)
23-
#include <dfs_fs.h>
24-
#include <dfs_file.h>
25-
#include <unistd.h>
26-
#include <stdio.h>
27-
#include <sys/stat.h>
28-
#include <sys/statfs.h>
29-
#endif
22+
#include <dfs_fs.h>
23+
#include <dfs_file.h>
24+
#include <unistd.h>
25+
#include <stdio.h>
26+
#include <sys/stat.h>
27+
#include <sys/statfs.h>
3028

3129
/* Private define ---------------------------------------------------------------*/
3230

@@ -236,11 +234,13 @@ static rt_size_t nu_sdh_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_siz
236234
{
237235
rt_uint32_t ret = 0;
238236
nu_sdh_t sdh = (nu_sdh_t)dev;
237+
rt_err_t result;
239238

240239
RT_ASSERT(dev != RT_NULL);
241240
RT_ASSERT(buffer != RT_NULL);
242241

243-
rt_sem_take(&sdh->lock, RT_WAITING_FOREVER);
242+
result = rt_sem_take(&sdh->lock, RT_WAITING_FOREVER);
243+
RT_ASSERT(result == RT_EOK);
244244

245245
/* Check alignment. */
246246
if (((uint32_t)buffer & 0x03) != 0)
@@ -281,7 +281,8 @@ static rt_size_t nu_sdh_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_siz
281281
sdh->pbuf = RT_NULL;
282282
}
283283

284-
rt_sem_release(&sdh->lock);
284+
result = rt_sem_release(&sdh->lock);
285+
RT_ASSERT(result == RT_EOK);
285286

286287
if (ret == Successful)
287288
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,
295296
{
296297
rt_uint32_t ret = 0;
297298
nu_sdh_t sdh = (nu_sdh_t)dev;
299+
rt_err_t result;
298300

299301
RT_ASSERT(dev != RT_NULL);
300302
RT_ASSERT(buffer != RT_NULL);
301303

302-
rt_sem_take(&sdh->lock, RT_WAITING_FOREVER);
304+
result = rt_sem_take(&sdh->lock, RT_WAITING_FOREVER);
305+
RT_ASSERT(result == RT_EOK);
303306

304307
/* Check alignment. */
305308
if (((uint32_t)buffer & 0x03) != 0)
@@ -338,7 +341,8 @@ static rt_size_t nu_sdh_write(rt_device_t dev, rt_off_t pos, const void *buffer,
338341
sdh->pbuf = RT_NULL;
339342
}
340343

341-
rt_sem_release(&sdh->lock);
344+
result = rt_sem_release(&sdh->lock);
345+
RT_ASSERT(result == RT_EOK);
342346

343347
if (ret == Successful) return blk_nb;
344348

@@ -393,7 +397,8 @@ static int rt_hw_sdh_init(void)
393397
/* Private */
394398
nu_sdh_arr[i].dev.user_data = (void *)&nu_sdh_arr[i];
395399

396-
rt_sem_init(&nu_sdh_arr[i].lock, "sdhlock", 1, RT_IPC_FLAG_FIFO);
400+
ret = rt_sem_init(&nu_sdh_arr[i].lock, "sdhlock", 1, RT_IPC_FLAG_FIFO);
401+
RT_ASSERT(ret == RT_EOK);
397402

398403
SDH_Open(nu_sdh_arr[i].base, CardDetect_From_GPIO);
399404

@@ -402,6 +407,7 @@ static int rt_hw_sdh_init(void)
402407
NVIC_EnableIRQ(SDH0_IRQn);
403408

404409
nu_sdh_arr[i].pbuf = RT_NULL;
410+
405411
ret = rt_device_register(&nu_sdh_arr[i].dev, nu_sdh_arr[i].name, flags);
406412
RT_ASSERT(ret == RT_EOK);
407413
}
@@ -415,8 +421,6 @@ static rt_bool_t nu_sdh_hotplug_is_mounted(const char *mounting_path)
415421
{
416422
rt_bool_t ret = RT_FALSE;
417423

418-
#if defined(RT_USING_DFS)
419-
420424
struct dfs_filesystem *psFS = dfs_filesystem_lookup(mounting_path);
421425
if (psFS == RT_NULL)
422426
{
@@ -431,8 +435,6 @@ static rt_bool_t nu_sdh_hotplug_is_mounted(const char *mounting_path)
431435
ret = RT_FALSE;
432436
}
433437

434-
#endif
435-
436438
exit_nu_sdh_hotplug_is_mounted:
437439

438440
return ret;
@@ -442,8 +444,6 @@ static rt_err_t nu_sdh_hotplug_mount(nu_sdh_t sdh)
442444
rt_err_t ret = RT_ERROR;
443445
DIR *t;
444446

445-
#if defined(RT_USING_DFS)
446-
447447
if (nu_sdh_hotplug_is_mounted(sdh->mounted_point) == RT_TRUE)
448448
{
449449
ret = RT_EOK;
@@ -491,15 +491,13 @@ static rt_err_t nu_sdh_hotplug_mount(nu_sdh_t sdh)
491491

492492
exit_nu_sdh_hotplug_mount:
493493

494-
#endif
495494
return -(ret);
496495
}
497496

498497
static rt_err_t nu_sdh_hotplug_unmount(nu_sdh_t sdh)
499498
{
500499
rt_err_t ret = RT_ERROR;
501500

502-
#if defined(RT_USING_DFS)
503501
if (nu_sdh_hotplug_is_mounted(sdh->mounted_point) == RT_FALSE)
504502
{
505503
ret = RT_EOK;
@@ -516,7 +514,6 @@ static rt_err_t nu_sdh_hotplug_unmount(nu_sdh_t sdh)
516514
rt_kprintf("Succeed to unmount %s.\n", sdh->mounted_point);
517515
ret = RT_EOK;
518516
}
519-
#endif
520517

521518
exit_nu_sdh_hotplug_unmount:
522519

@@ -585,7 +582,11 @@ static void sdh_hotplugger(void *param)
585582

586583
int mnt_init_sdcard_hotplug(void)
587584
{
588-
rt_thread_init(&sdh_tid, "hotplug", sdh_hotplugger, NULL, sdh_stack, sizeof(sdh_stack), RT_THREAD_PRIORITY_MAX - 2, 10);
585+
rt_err_t result;
586+
587+
result = rt_thread_init(&sdh_tid, "hotplug", sdh_hotplugger, NULL, sdh_stack, sizeof(sdh_stack), RT_THREAD_PRIORITY_MAX - 2, 10);
588+
RT_ASSERT(result == RT_EOK);
589+
589590
rt_thread_startup(&sdh_tid);
590591

591592
return 0;

bsp/nuvoton/libraries/m2354/rtt_port/drv_usbhost.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ static void int_xfer_done_cb(UTR_T *psUTR)
469469
msg.type = USB_MSG_CALLBACK;
470470
msg.content.cb.function = pipe->callback;
471471
msg.content.cb.context = pipe;
472-
rt_usbh_event_signal(&msg);
472+
rt_usbh_event_signal(&s_sUSBHDev.uhcd, &msg);
473473
}
474474

475475
exit_int_xfer_done_cb:

bsp/nuvoton/libraries/m480/rtt_port/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ config SOC_SERIES_M480
447447
menuconfig BSP_USING_SDH
448448
bool "Enable Secure Digital Host Controller(SDH)"
449449
select RT_USING_DFS
450+
select DFS_USING_POSIX
450451

451452
if BSP_USING_SDH
452453
config BSP_USING_SDH0

bsp/nuvoton/libraries/m480/rtt_port/drv_sdh.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@
1919
#include <drv_pdma.h>
2020
#include <string.h>
2121

22-
#if defined(RT_USING_DFS)
23-
#include <dfs_fs.h>
24-
#include <dfs_file.h>
25-
#include <unistd.h>
26-
#include <stdio.h>
27-
#include <sys/stat.h>
28-
#include <sys/statfs.h>
29-
#endif
22+
#include <dfs_fs.h>
23+
#include <dfs_file.h>
24+
#include <unistd.h>
25+
#include <stdio.h>
26+
#include <sys/stat.h>
27+
#include <sys/statfs.h>
3028

3129
/* Private define ---------------------------------------------------------------*/
3230

@@ -457,8 +455,6 @@ static rt_bool_t nu_sdh_hotplug_is_mounted(const char *mounting_path)
457455
{
458456
rt_bool_t ret = RT_FALSE;
459457

460-
#if defined(RT_USING_DFS)
461-
462458
struct dfs_filesystem *psFS = dfs_filesystem_lookup(mounting_path);
463459
if (psFS == RT_NULL)
464460
{
@@ -473,8 +469,6 @@ static rt_bool_t nu_sdh_hotplug_is_mounted(const char *mounting_path)
473469
ret = RT_FALSE;
474470
}
475471

476-
#endif
477-
478472
exit_nu_sdh_hotplug_is_mounted:
479473

480474
return ret;
@@ -484,8 +478,6 @@ static rt_err_t nu_sdh_hotplug_mount(nu_sdh_t sdh)
484478
rt_err_t ret = RT_ERROR;
485479
DIR *t;
486480

487-
#if defined(RT_USING_DFS)
488-
489481
if (nu_sdh_hotplug_is_mounted(sdh->mounted_point) == RT_TRUE)
490482
{
491483
ret = RT_EOK;
@@ -533,15 +525,13 @@ static rt_err_t nu_sdh_hotplug_mount(nu_sdh_t sdh)
533525

534526
exit_nu_sdh_hotplug_mount:
535527

536-
#endif
537528
return -(ret);
538529
}
539530

540531
static rt_err_t nu_sdh_hotplug_unmount(nu_sdh_t sdh)
541532
{
542533
rt_err_t ret = RT_ERROR;
543534

544-
#if defined(RT_USING_DFS)
545535
if (nu_sdh_hotplug_is_mounted(sdh->mounted_point) == RT_FALSE)
546536
{
547537
ret = RT_EOK;
@@ -558,7 +548,6 @@ static rt_err_t nu_sdh_hotplug_unmount(nu_sdh_t sdh)
558548
rt_kprintf("Succeed to unmount %s.\n", sdh->mounted_point);
559549
ret = RT_EOK;
560550
}
561-
#endif
562551

563552
exit_nu_sdh_hotplug_unmount:
564553

bsp/nuvoton/libraries/m480/rtt_port/drv_usbhost.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ static void int_xfer_done_cb(UTR_T *psUTR)
472472
msg.type = USB_MSG_CALLBACK;
473473
msg.content.cb.function = pipe->callback;
474474
msg.content.cb.context = pipe;
475-
rt_usbh_event_signal(&msg);
475+
rt_usbh_event_signal(&s_sUSBHDev.uhcd, &msg);
476476
}
477477

478478
exit_int_xfer_done_cb:

bsp/nuvoton/libraries/n9h30/rtt_port/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ config SOC_SERIES_N9H30
273273
menuconfig BSP_USING_SDH
274274
bool "Enable Secure Digital Host Controller(SDH)"
275275
select RT_USING_DFS
276+
select DFS_USING_POSIX
276277

277278
if BSP_USING_SDH
278279

bsp/nuvoton/libraries/n9h30/rtt_port/drv_sdh.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@
1919
#include "NuMicro.h"
2020
#include <drv_sys.h>
2121

22-
#if defined(RT_USING_DFS)
23-
#include <dfs_fs.h>
24-
#include <dfs_file.h>
25-
#include <unistd.h>
26-
#include <stdio.h>
27-
#include <sys/stat.h>
28-
#include <sys/statfs.h>
29-
#endif
22+
#include <dfs_fs.h>
23+
#include <dfs_file.h>
24+
#include <unistd.h>
25+
#include <stdio.h>
26+
#include <sys/stat.h>
27+
#include <sys/statfs.h>
3028

3129
/* Private define ---------------------------------------------------------------*/
3230

@@ -602,8 +600,6 @@ static rt_bool_t nu_sdh_hotplug_is_mounted(const char *mounting_path)
602600
{
603601
rt_bool_t ret = RT_FALSE;
604602

605-
#if defined(RT_USING_DFS)
606-
607603
struct dfs_filesystem *psFS = dfs_filesystem_lookup(mounting_path);
608604
if (psFS == RT_NULL)
609605
{
@@ -620,15 +616,11 @@ static rt_bool_t nu_sdh_hotplug_is_mounted(const char *mounting_path)
620616

621617
exit_nu_sdh_hotplug_is_mounted:
622618

623-
#endif
624-
625619
return ret;
626620
}
627621
static rt_err_t nu_sdh_hotplug_mount(nu_sdh_t sdh)
628622
{
629623
rt_err_t ret = RT_ERROR;
630-
631-
#if defined(RT_USING_DFS)
632624
DIR *t;
633625

634626
if (nu_sdh_hotplug_is_mounted(sdh->mounted_point) == RT_TRUE)
@@ -678,15 +670,13 @@ static rt_err_t nu_sdh_hotplug_mount(nu_sdh_t sdh)
678670

679671
exit_nu_sdh_hotplug_mount:
680672

681-
#endif
682673
return -(ret);
683674
}
684675

685676
static rt_err_t nu_sdh_hotplug_unmount(nu_sdh_t sdh)
686677
{
687678
rt_err_t ret = RT_ERROR;
688679

689-
#if defined(RT_USING_DFS)
690680
if (nu_sdh_hotplug_is_mounted(sdh->mounted_point) == RT_FALSE)
691681
{
692682
ret = RT_EOK;
@@ -706,8 +696,6 @@ static rt_err_t nu_sdh_hotplug_unmount(nu_sdh_t sdh)
706696

707697
exit_nu_sdh_hotplug_unmount:
708698

709-
#endif
710-
711699
return -(ret);
712700
}
713701

bsp/nuvoton/libraries/n9h30/rtt_port/drv_usbhost.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ static int nu_bulk_xfer(
425425
UTR_T *psUTR,
426426
int timeouts)
427427
{
428-
#define TIMEOUT_RETRY 3
428+
#define TIMEOUT_RETRY 3
429429

430430
int retry = TIMEOUT_RETRY;
431431
int ret = usbh_bulk_xfer(psUTR);
@@ -435,9 +435,9 @@ static int nu_bulk_xfer(
435435
return ret;
436436
}
437437

438-
while ( retry > 0 )
438+
while (retry > 0)
439439
{
440-
if ( rt_completion_wait(&(psPortDev->utr_completion), timeouts) != 0 )
440+
if (rt_completion_wait(&(psPortDev->utr_completion), timeouts) != 0)
441441
{
442442
rt_uint32_t level;
443443

@@ -513,7 +513,7 @@ static void int_xfer_done_cb(UTR_T *psUTR)
513513
msg.type = USB_MSG_CALLBACK;
514514
msg.content.cb.function = pipe->callback;
515515
msg.content.cb.context = pipe;
516-
rt_usbh_event_signal(&msg);
516+
rt_usbh_event_signal(&s_sUSBHDev.uhcd, &msg);
517517
}
518518

519519
exit_int_xfer_done_cb:

bsp/nuvoton/libraries/nuc980/rtt_port/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ config SOC_SERIES_NUC980
353353
menuconfig BSP_USING_SDH
354354
bool "Enable Secure Digital Host Controller(SDH)"
355355
select RT_USING_DFS
356+
select DFS_USING_POSIX
356357

357358
if BSP_USING_SDH
358359
config BSP_USING_SDH0

0 commit comments

Comments
 (0)