diff options
| author | sakumisu <[email protected]> | 2024-05-23 23:14:53 +0800 |
|---|---|---|
| committer | sakumisu <[email protected]> | 2024-05-24 22:49:18 +0800 |
| commit | 865d2f5d96942222a2af3102cf74519c7287dd6c (patch) | |
| tree | 6a2c1e9fb5e9e4b7c1e8f15f59b34d419287f0ca /platform/rtthread | |
| parent | 3336919e0df469fb0ab18f580ecb3d31fdd6f949 (diff) | |
refactor(platform): update platform support
Diffstat (limited to 'platform/rtthread')
| -rw-r--r-- | platform/rtthread/usb_check.c | 17 | ||||
| -rw-r--r-- | platform/rtthread/usb_msh.c | 47 | ||||
| -rw-r--r-- | platform/rtthread/usbh_dfs.c | 241 | ||||
| -rw-r--r-- | platform/rtthread/usbh_lwip.c | 415 |
4 files changed, 720 insertions, 0 deletions
diff --git a/platform/rtthread/usb_check.c b/platform/rtthread/usb_check.c new file mode 100644 index 00000000..d4baf03e --- /dev/null +++ b/platform/rtthread/usb_check.c @@ -0,0 +1,17 @@ +#include "rtthread.h" + +#ifdef PKG_CHERRYUSB_HOST + +#ifndef RT_USING_TIMER_SOFT +#error must enable RT_USING_TIMER_SOFT to support timer callback in thread +#endif + +#if IDLE_THREAD_STACK_SIZE < 2048 +#error "IDLE_THREAD_STACK_SIZE must be greater than 2048" +#endif + +#if RT_TIMER_THREAD_STACK_SIZE < 2048 +#error "RT_TIMER_THREAD_STACK_SIZE must be greater than 2048" +#endif + +#endif diff --git a/platform/rtthread/usb_msh.c b/platform/rtthread/usb_msh.c new file mode 100644 index 00000000..db04e059 --- /dev/null +++ b/platform/rtthread/usb_msh.c @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024, sakumisu + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include "rtthread.h" + +#ifdef PKG_CHERRYUSB_HOST + +#include "usbh_core.h" + +int usbh_init(int argc, char **argv) +{ + uint8_t busid; + uint32_t reg_base; + + if (argc < 3) { + USB_LOG_ERR("please input correct command: usbh_init <busid> <reg_base>\r\n"); + return -1; + } + + busid = atoi(argv[1]); + reg_base = strtoll(argv[2], NULL, 16); + usbh_initialize(busid, reg_base); + + return 0; +} + +int usbh_deinit(int argc, char **argv) +{ + uint8_t busid; + + if (argc < 2) { + USB_LOG_ERR("please input correct command: usbh_deinit <busid>\r\n"); + return -1; + } + + busid = atoi(argv[1]); + usbh_deinitialize(busid); + + return 0; +} + +MSH_CMD_EXPORT(usbh_init, init usb host); +MSH_CMD_EXPORT(usbh_deinit, deinit usb host); +MSH_CMD_EXPORT(lsusb, ls usb devices); +#endif diff --git a/platform/rtthread/usbh_dfs.c b/platform/rtthread/usbh_dfs.c new file mode 100644 index 00000000..968064a6 --- /dev/null +++ b/platform/rtthread/usbh_dfs.c @@ -0,0 +1,241 @@ +/* + * Copyright (c) 2024, sakumisu + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include "usbh_core.h" +#include "usbh_msc.h" + +#include "rtthread.h" +#include <dfs_fs.h> + +#define DEV_FORMAT "/sd%c" + +#ifndef CONFIG_USB_DFS_MOUNT_POINT +#define CONFIG_USB_DFS_MOUNT_POINT "/" +#endif + +#if defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32F7) || \ + defined(SOC_HPM5000) || defined(SOC_HPM6000) || defined(BSP_USING_BL61X) +#ifndef RT_USING_CACHE +#error usbh msc must enable RT_USING_CACHE in this chip +#endif +#if RT_ALIGN_SIZE != 32 && RT_ALIGN_SIZE != 64 +#error usbh msc must set cache line to 32 or 64 +#endif +#endif + +#if defined(BSP_USING_BL61X) +#include "bflb_l1c.h" + +void rt_hw_cpu_dcache_ops(int ops, void *addr, int size) +{ + if (ops == RT_HW_CACHE_FLUSH) { + bflb_l1c_dcache_clean_range(addr, size); + } else { + bflb_l1c_dcache_invalidate_range(addr, size); + } +} +#elif defined(SOC_HPM5000) || defined(SOC_HPM6000) +#include "hpm_l1c_drv.h" + +void rt_hw_cpu_dcache_ops(int ops, void *addr, int size) +{ + if (ops == RT_HW_CACHE_FLUSH) { + l1c_dc_flush((uint32_t)addr, size); + } else { + l1c_dc_invalidate((uint32_t)addr, size); + } +} +#endif + +USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t msc_sector[512]; + +static rt_err_t rt_udisk_init(rt_device_t dev) +{ + return RT_EOK; +} + +static ssize_t rt_udisk_read(rt_device_t dev, rt_off_t pos, void *buffer, + rt_size_t size) +{ + struct usbh_msc *msc_class = (struct usbh_msc *)dev->user_data; + int ret; + +#ifdef RT_USING_CACHE + rt_uint32_t *align_buf; + + if ((uint32_t)buffer & (RT_ALIGN_SIZE - 1)) { + align_buf = rt_malloc_align(size * msc_class->blocksize, RT_ALIGN_SIZE); + if (!align_buf) { + rt_kprintf("msc get align buf failed\n"); + return 0; + } + } else { + align_buf = (rt_uint32_t *)buffer; + } + + ret = usbh_msc_scsi_read10(msc_class, pos, (uint8_t *)align_buf, size); + if (ret < 0) { + rt_kprintf("usb mass_storage read failed\n"); + return 0; + } + rt_hw_cpu_dcache_ops(RT_HW_CACHE_INVALIDATE, align_buf, size * msc_class->blocksize); + if ((uint32_t)buffer & (RT_ALIGN_SIZE - 1)) { + rt_memcpy(buffer, align_buf, size * msc_class->blocksize); + rt_free_align(align_buf); + } +#else + ret = usbh_msc_scsi_read10(msc_class, pos, buffer, size); + if (ret < 0) { + rt_kprintf("usb mass_storage read failed\n"); + return 0; + } +#endif + return size; +} + +static ssize_t rt_udisk_write(rt_device_t dev, rt_off_t pos, const void *buffer, + rt_size_t size) +{ + struct usbh_msc *msc_class = (struct usbh_msc *)dev->user_data; + int ret; + +#ifdef RT_USING_CACHE + rt_uint32_t *align_buf; + + if ((uint32_t)buffer & (RT_ALIGN_SIZE - 1)) { + align_buf = rt_malloc_align(size * msc_class->blocksize, RT_ALIGN_SIZE); + if (!align_buf) { + rt_kprintf("msc get align buf failed\n"); + return 0; + } + + rt_memcpy(align_buf, buffer, size * msc_class->blocksize); + } else { + align_buf = (rt_uint32_t *)buffer; + } + + rt_hw_cpu_dcache_ops(RT_HW_CACHE_FLUSH, align_buf, size * msc_class->blocksize); + ret = usbh_msc_scsi_write10(msc_class, pos, (uint8_t *)align_buf, size); + if (ret < 0) { + rt_kprintf("usb mass_storage write failed\n"); + return 0; + } + if ((uint32_t)buffer & (RT_ALIGN_SIZE - 1)) { + rt_free_align(align_buf); + } +#else + ret = usbh_msc_scsi_write10(msc_class, pos, buffer, size); + if (ret < 0) { + rt_kprintf("usb mass_storage write failed\n"); + return 0; + } +#endif + + return size; +} + +static rt_err_t rt_udisk_control(rt_device_t dev, int cmd, void *args) +{ + /* check parameter */ + RT_ASSERT(dev != RT_NULL); + struct usbh_msc *msc_class = (struct usbh_msc *)dev->user_data; + + if (cmd == RT_DEVICE_CTRL_BLK_GETGEOME) { + struct rt_device_blk_geometry *geometry; + + geometry = (struct rt_device_blk_geometry *)args; + if (geometry == RT_NULL) + return -RT_ERROR; + + geometry->bytes_per_sector = msc_class->blocksize; + geometry->block_size = msc_class->blocksize; + geometry->sector_count = msc_class->blocknum; + } + + return RT_EOK; +} + +#ifdef RT_USING_DEVICE_OPS +const static struct rt_device_ops udisk_device_ops = { + rt_udisk_init, + RT_NULL, + RT_NULL, + rt_udisk_read, + rt_udisk_write, + rt_udisk_control +}; +#endif + +int udisk_init(struct usbh_msc *msc_class) +{ + rt_err_t ret = 0; + rt_uint8_t i; + struct dfs_partition part0; + struct rt_device *dev; + char name[CONFIG_USBHOST_DEV_NAMELEN]; + char mount_point[CONFIG_USBHOST_DEV_NAMELEN]; + + dev = rt_malloc(sizeof(struct rt_device)); + memset(dev, 0, sizeof(struct rt_device)); + + snprintf(name, CONFIG_USBHOST_DEV_NAMELEN, DEV_FORMAT, msc_class->sdchar); + snprintf(mount_point, CONFIG_USBHOST_DEV_NAMELEN, CONFIG_USB_DFS_MOUNT_POINT, msc_class->sdchar); + + ret = usbh_msc_scsi_read10(msc_class, 0, msc_sector, 1); + if (ret != RT_EOK) { + rt_kprintf("usb mass_storage read failed\n"); + return ret; + } + + for (i = 0; i < 16; i++) { + /* Get the first partition */ + ret = dfs_filesystem_get_partition(&part0, msc_sector, i); + if (ret == RT_EOK) { + rt_kprintf("Found partition %d: type = %d, offet=0x%x, size=0x%x\n", + i, part0.type, part0.offset, part0.size); + } else { + break; + } + } + + dev->type = RT_Device_Class_Block; +#ifdef RT_USING_DEVICE_OPS + dev->ops = &udisk_device_ops; +#else + dev->init = rt_udisk_init; + dev->read = rt_udisk_read; + dev->write = rt_udisk_write; + dev->control = rt_udisk_control; +#endif + dev->user_data = msc_class; + + rt_device_register(dev, name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_REMOVABLE | RT_DEVICE_FLAG_STANDALONE); + + ret = dfs_mount(name, mount_point, "elm", 0, 0); + if (ret == 0) { + rt_kprintf("udisk: %s mount successfully\n", name); + } else { + rt_kprintf("udisk: %s mount failed, ret = %d\n", name, ret); + } + + return ret; +} + +void usbh_msc_run(struct usbh_msc *msc_class) +{ + udisk_init(msc_class); +} + +void usbh_msc_stop(struct usbh_msc *msc_class) +{ + char name[CONFIG_USBHOST_DEV_NAMELEN]; + char mount_point[CONFIG_USBHOST_DEV_NAMELEN]; + + snprintf(name, CONFIG_USBHOST_DEV_NAMELEN, DEV_FORMAT, msc_class->sdchar); + snprintf(mount_point, CONFIG_USBHOST_DEV_NAMELEN, CONFIG_USB_DFS_MOUNT_POINT, msc_class->sdchar); + + dfs_unmount(mount_point); + rt_device_unregister(rt_device_find(name)); +} diff --git a/platform/rtthread/usbh_lwip.c b/platform/rtthread/usbh_lwip.c new file mode 100644 index 00000000..2c0c7eaf --- /dev/null +++ b/platform/rtthread/usbh_lwip.c @@ -0,0 +1,415 @@ +/* + * Copyright (c) 2024, sakumisu + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include "netif/etharp.h" +#include "lwip/netif.h" +#include "lwip/pbuf.h" +#include "lwip/tcpip.h" +#if LWIP_DHCP +#include "lwip/dhcp.h" +#include "lwip/prot/dhcp.h" +#endif + +#include <rtthread.h> +#include <rtdevice.h> +#include <netif/ethernetif.h> + +#include "usbh_core.h" + +#include "lwip/opt.h" + +#ifndef RT_USING_LWIP212 +#error must enable RT_USING_LWIP212 +#endif + +#ifndef LWIP_NO_RX_THREAD +#error must enable LWIP_NO_RX_THREAD, we do not use rtthread eth rx thread +#endif + +#ifndef LWIP_NO_TX_THREAD +#warning suggest you to enable LWIP_NO_TX_THREAD, we do not use rtthread eth tx thread +#endif + +#if LWIP_TCPIP_CORE_LOCKING_INPUT !=1 +#warning suggest you to set LWIP_TCPIP_CORE_LOCKING_INPUT to 1, usb handles eth input with own thread +#endif + +#if LWIP_TCPIP_CORE_LOCKING !=1 +#error must set LWIP_TCPIP_CORE_LOCKING to 1 +#endif + +#if PBUF_POOL_BUFSIZE < 1600 +#error PBUF_POOL_BUFSIZE must be larger than 1600 +#endif + +// #define CONFIG_USBHOST_PLATFORM_CDC_ECM +// #define CONFIG_USBHOST_PLATFORM_CDC_RNDIS +// #define CONFIG_USBHOST_PLATFORM_CDC_NCM +// #define CONFIG_USBHOST_PLATFORM_ASIX +// #define CONFIG_USBHOST_PLATFORM_RTL8152 + +void usbh_lwip_eth_input_common(struct netif *netif, uint8_t *buf, uint32_t len) +{ +#if LWIP_TCPIP_CORE_LOCKING_INPUT + pbuf_type type = PBUF_REF; +#else + pbuf_type type = PBUF_POOL; +#endif + err_t err; + struct pbuf *p; + + p = pbuf_alloc(PBUF_RAW, len, type); + if (p != NULL) { +#if LWIP_TCPIP_CORE_LOCKING_INPUT + p->payload = buf; +#else + memcpy(p->payload, buf, len); +#endif + err = netif->input(p, netif); + if (err != ERR_OK) { + pbuf_free(p); + } + } else { + USB_LOG_ERR("No memory to alloc pbuf\r\n"); + } +} + +#ifdef CONFIG_USBHOST_PLATFORM_CDC_ECM +#include "usbh_cdc_ecm.h" + +static struct eth_device g_cdc_ecm_dev; + +static rt_err_t rt_usbh_cdc_ecm_control(rt_device_t dev, int cmd, void *args) +{ + struct usbh_cdc_ecm *cdc_ecm_class = (struct usbh_cdc_ecm *)dev->user_data; + + switch (cmd) { + case NIOCTL_GADDR: + + /* get mac address */ + if (args) + rt_memcpy(args, cdc_ecm_class->mac, 6); + else + return -RT_ERROR; + + break; + + default: + break; + } + + return RT_EOK; +} + +static rt_err_t rt_usbh_cdc_ecm_eth_tx(rt_device_t dev, struct pbuf *p) +{ + int ret = usbh_cdc_ecm_eth_output(p->payload, p->tot_len); + if (ret < 0) { + return -RT_ERROR; + } else { + return RT_EOK; + } +} + +void usbh_cdc_ecm_eth_input(uint8_t *buf, uint32_t buflen) +{ + usbh_lwip_eth_input_common(g_cdc_ecm_dev.netif, buf, buflen); +} + +void usbh_cdc_ecm_run(struct usbh_cdc_ecm *cdc_ecm_class) +{ + memset(&g_cdc_ecm_dev, 0, sizeof(struct eth_device)); + + g_cdc_ecm_dev.parent.control = rt_usbh_cdc_ecm_control; + g_cdc_ecm_dev.eth_rx = NULL; + g_cdc_ecm_dev.eth_tx = rt_usbh_cdc_ecm_eth_tx; + g_cdc_ecm_dev.parent.user_data = cdc_ecm_class; + + eth_device_init(&g_cdc_ecm_dev, "u0"); + eth_device_linkchange(&g_cdc_ecm_dev, RT_TRUE); + + usb_osal_thread_create("usbh_cdc_ecm_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_cdc_ecm_rx_thread, NULL); +} + +void usbh_cdc_ecm_stop(struct usbh_cdc_ecm *cdc_ecm_class) +{ + eth_device_deinit(&g_cdc_ecm_dev); +} +#endif + +#ifdef CONFIG_USBHOST_PLATFORM_CDC_RNDIS +#include "usbh_rndis.h" + +static struct eth_device g_rndis_dev; + +static rt_timer_t keep_timer = RT_NULL; + +static void rndis_dev_keepalive_timeout(void *parameter) +{ + struct usbh_rndis *rndis_class = (struct usbh_rndis *)parameter; + usbh_rndis_keepalive(rndis_class); +} + +static void timer_init(struct usbh_rndis *rndis_class) +{ + keep_timer = rt_timer_create("keep", + rndis_dev_keepalive_timeout, + rndis_class, + 5000, + RT_TIMER_FLAG_PERIODIC | + RT_TIMER_FLAG_SOFT_TIMER); + + rt_timer_start(keep_timer); +} + +static rt_err_t rt_usbh_rndis_control(rt_device_t dev, int cmd, void *args) +{ + struct usbh_rndis *rndis_class = (struct usbh_rndis *)dev->user_data; + + switch (cmd) { + case NIOCTL_GADDR: + + /* get mac address */ + if (args) + rt_memcpy(args, rndis_class->mac, 6); + else + return -RT_ERROR; + + break; + + default: + break; + } + + return RT_EOK; +} + +static rt_err_t rt_usbh_rndis_eth_tx(rt_device_t dev, struct pbuf *p) +{ + int ret = usbh_rndis_eth_output(p->payload, p->tot_len); + if (ret < 0) { + return -RT_ERROR; + } else { + return RT_EOK; + } +} + +void usbh_rndis_eth_input(uint8_t *buf, uint32_t buflen) +{ + usbh_lwip_eth_input_common(g_rndis_dev.netif, buf, buflen); +} + +void usbh_rndis_run(struct usbh_rndis *rndis_class) +{ + memset(&g_rndis_dev, 0, sizeof(struct eth_device)); + + g_rndis_dev.parent.control = rt_usbh_rndis_control; + g_rndis_dev.eth_rx = NULL; + g_rndis_dev.eth_tx = rt_usbh_rndis_eth_tx; + g_rndis_dev.parent.user_data = rndis_class; + + eth_device_init(&g_rndis_dev, "u2"); + eth_device_linkchange(&g_rndis_dev, RT_TRUE); + + usb_osal_thread_create("usbh_rndis_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_rndis_rx_thread, NULL); + //timer_init(rndis_class); +} + +void usbh_rndis_stop(struct usbh_rndis *rndis_class) +{ + eth_device_deinit(&g_rndis_dev); + // rt_timer_stop(keep_timer); + // rt_timer_delete(keep_timer); +} +#endif + +#ifdef CONFIG_USBHOST_PLATFORM_CDC_NCM +#include "usbh_cdc_ncm.h" + +static struct eth_device g_cdc_ncm_dev; + +static rt_err_t rt_usbh_cdc_ncm_control(rt_device_t dev, int cmd, void *args) +{ + struct usbh_cdc_ncm *cdc_ncm_class = (struct usbh_cdc_ncm *)dev->user_data; + + switch (cmd) { + case NIOCTL_GADDR: + + /* get mac address */ + if (args) + rt_memcpy(args, cdc_ncm_class->mac, 6); + else + return -RT_ERROR; + + break; + + default: + break; + } + + return RT_EOK; +} + +static rt_err_t rt_usbh_cdc_ncm_eth_tx(rt_device_t dev, struct pbuf *p) +{ + int ret = usbh_cdc_ncm_eth_output(p->payload, p->tot_len); + if (ret < 0) { + return -RT_ERROR; + } else { + return RT_EOK; + } +} + +void usbh_cdc_ncm_eth_input(uint8_t *buf, uint32_t buflen) +{ + usbh_lwip_eth_input_common(g_cdc_ncm_dev.netif, buf, buflen); +} + +void usbh_cdc_ncm_run(struct usbh_cdc_ncm *cdc_ncm_class) +{ + memset(&g_cdc_ncm_dev, 0, sizeof(struct eth_device)); + + g_cdc_ncm_dev.parent.control = rt_usbh_cdc_ncm_control; + g_cdc_ncm_dev.eth_rx = NULL; + g_cdc_ncm_dev.eth_tx = rt_usbh_cdc_ncm_eth_tx; + g_cdc_ncm_dev.parent.user_data = cdc_ncm_class; + + eth_device_init(&g_cdc_ncm_dev, "u1"); + eth_device_linkchange(&g_cdc_ncm_dev, RT_TRUE); + + usb_osal_thread_create("usbh_cdc_ncm_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_cdc_ncm_rx_thread, NULL); +} + +void usbh_cdc_ncm_stop(struct usbh_cdc_ncm *cdc_ncm_class) +{ + eth_device_deinit(&g_cdc_ncm_dev); +} +#endif + +#ifdef CONFIG_USBHOST_PLATFORM_ASIX +#include "usbh_asix.h" + +static struct eth_device g_asix_dev; + +static rt_err_t rt_usbh_asix_control(rt_device_t dev, int cmd, void *args) +{ + struct usbh_asix *asix_class = (struct usbh_asix *)dev->user_data; + + switch (cmd) { + case NIOCTL_GADDR: + + /* get mac address */ + if (args) + rt_memcpy(args, asix_class->mac, 6); + else + return -RT_ERROR; + + break; + + default: + break; + } + + return RT_EOK; +} + +static rt_err_t rt_usbh_asix_eth_tx(rt_device_t dev, struct pbuf *p) +{ + int ret = usbh_asix_eth_output(p->payload, p->tot_len); + if (ret < 0) { + return -RT_ERROR; + } else { + return RT_EOK; + } +} + +void usbh_asix_eth_input(uint8_t *buf, uint32_t buflen) +{ + usbh_lwip_eth_input_common(g_asix_dev.netif, buf, buflen); +} + +void usbh_asix_run(struct usbh_asix *asix_class) +{ + memset(&g_asix_dev, 0, sizeof(struct eth_device)); + + g_asix_dev.parent.control = rt_usbh_asix_control; + g_asix_dev.eth_rx = NULL; + g_asix_dev.eth_tx = rt_usbh_asix_eth_tx; + g_asix_dev.parent.user_data = asix_class; + + eth_device_init(&g_asix_dev, "u3"); + eth_device_linkchange(&g_asix_dev, RT_TRUE); + + usb_osal_thread_create("usbh_asix_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_asix_rx_thread, NULL); +} + +void usbh_asix_stop(struct usbh_asix *asix_class) +{ + eth_device_deinit(&g_asix_dev); +} +#endif + +#ifdef CONFIG_USBHOST_PLATFORM_RTL8152 +#include "usbh_rtl8152.h" + +static struct eth_device g_rtl8152_dev; + +static rt_err_t rt_usbh_rtl8152_control(rt_device_t dev, int cmd, void *args) +{ + struct usbh_rtl8152 *rtl8152_class = (struct usbh_rtl8152 *)dev->user_data; + + switch (cmd) { + case NIOCTL_GADDR: + + /* get mac address */ + if (args) + rt_memcpy(args, rtl8152_class->mac, 6); + else + return -RT_ERROR; + + break; + + default: + break; + } + + return RT_EOK; +} + +static rt_err_t rt_usbh_rtl8152_eth_tx(rt_device_t dev, struct pbuf *p) +{ + int ret = usbh_rtl8152_eth_output(p->payload, p->tot_len); + if (ret < 0) { + return -RT_ERROR; + } else { + return RT_EOK; + } +} + +void usbh_rtl8152_eth_input(uint8_t *buf, uint32_t buflen) +{ + usbh_lwip_eth_input_common(g_rtl8152_dev.netif, buf, buflen); +} + +void usbh_rtl8152_run(struct usbh_rtl8152 *rtl8152_class) +{ + memset(&g_rtl8152_dev, 0, sizeof(struct eth_device)); + + g_rtl8152_dev.parent.control = rt_usbh_rtl8152_control; + g_rtl8152_dev.eth_rx = NULL; + g_rtl8152_dev.eth_tx = rt_usbh_rtl8152_eth_tx; + g_rtl8152_dev.parent.user_data = rtl8152_class; + + eth_device_init(&g_rtl8152_dev, "u4"); + eth_device_linkchange(&g_rtl8152_dev, RT_TRUE); + + usb_osal_thread_create("usbh_rtl8152_rx", 2048, CONFIG_USBHOST_PSC_PRIO + 1, usbh_rtl8152_rx_thread, NULL); +} + +void usbh_rtl8152_stop(struct usbh_rtl8152 *rtl8152_class) +{ + eth_device_deinit(&g_rtl8152_dev); +} +#endif |
