summaryrefslogtreecommitdiff
path: root/components/drivers/usb/cherryusb/platform/rtthread
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2024-06-30 08:01:51 +0800
committerGitHub <[email protected]>2024-06-30 08:01:51 +0800
commitcc853de5f3c75fe557b8601e4b51ec72c64077e5 (patch)
treeabbf2b24bd04b6ae9ae45a888af2f438d99a4592 /components/drivers/usb/cherryusb/platform/rtthread
parentc018a3e3fd701402a4b83da614e79ea5ba66514d (diff)
Update cherryusb to v1.3.1 (#9122)
* fix(hpmicro): remove duplicate usb variable * update(cherryusb): update to v1.3.1
Diffstat (limited to 'components/drivers/usb/cherryusb/platform/rtthread')
-rw-r--r--components/drivers/usb/cherryusb/platform/rtthread/usbh_dfs.c2
-rw-r--r--components/drivers/usb/cherryusb/platform/rtthread/usbh_lwip.c43
2 files changed, 36 insertions, 9 deletions
diff --git a/components/drivers/usb/cherryusb/platform/rtthread/usbh_dfs.c b/components/drivers/usb/cherryusb/platform/rtthread/usbh_dfs.c
index 968064a644..12799e67b2 100644
--- a/components/drivers/usb/cherryusb/platform/rtthread/usbh_dfs.c
+++ b/components/drivers/usb/cherryusb/platform/rtthread/usbh_dfs.c
@@ -16,7 +16,7 @@
#endif
#if defined(SOC_SERIES_STM32H7) || defined(SOC_SERIES_STM32F7) || \
- defined(SOC_HPM5000) || defined(SOC_HPM6000) || defined(BSP_USING_BL61X)
+ defined(SOC_HPM5000) || defined(SOC_HPM6000) || defined(SOC_HPM6E00) || defined(BSP_USING_BL61X)
#ifndef RT_USING_CACHE
#error usbh msc must enable RT_USING_CACHE in this chip
#endif
diff --git a/components/drivers/usb/cherryusb/platform/rtthread/usbh_lwip.c b/components/drivers/usb/cherryusb/platform/rtthread/usbh_lwip.c
index 2c0c7eaf93..360a848953 100644
--- a/components/drivers/usb/cherryusb/platform/rtthread/usbh_lwip.c
+++ b/components/drivers/usb/cherryusb/platform/rtthread/usbh_lwip.c
@@ -32,11 +32,11 @@
#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
+#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
+#if LWIP_TCPIP_CORE_LOCKING != 1
#error must set LWIP_TCPIP_CORE_LOCKING to 1
#endif
@@ -50,6 +50,18 @@
// #define CONFIG_USBHOST_PLATFORM_ASIX
// #define CONFIG_USBHOST_PLATFORM_RTL8152
+void usbh_lwip_eth_output_common(struct pbuf *p, uint8_t *buf)
+{
+ struct pbuf *q;
+ uint8_t *buffer;
+
+ buffer = buf;
+ for (q = p; q != NULL; q = q->next) {
+ usb_memcpy(buffer, q->payload, q->len);
+ buffer += q->len;
+ }
+}
+
void usbh_lwip_eth_input_common(struct netif *netif, uint8_t *buf, uint32_t len)
{
#if LWIP_TCPIP_CORE_LOCKING_INPUT
@@ -65,7 +77,7 @@ void usbh_lwip_eth_input_common(struct netif *netif, uint8_t *buf, uint32_t len)
#if LWIP_TCPIP_CORE_LOCKING_INPUT
p->payload = buf;
#else
- memcpy(p->payload, buf, len);
+ usb_memcpy(p->payload, buf, len);
#endif
err = netif->input(p, netif);
if (err != ERR_OK) {
@@ -105,7 +117,10 @@ static rt_err_t rt_usbh_cdc_ecm_control(rt_device_t dev, int cmd, void *args)
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);
+ int ret;
+
+ usbh_lwip_eth_output_common(p, usbh_cdc_ecm_get_eth_txbuf());
+ ret = usbh_cdc_ecm_eth_output(p->tot_len);
if (ret < 0) {
return -RT_ERROR;
} else {
@@ -188,7 +203,10 @@ static rt_err_t rt_usbh_rndis_control(rt_device_t dev, int cmd, void *args)
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);
+ int ret;
+
+ usbh_lwip_eth_output_common(p, usbh_rndis_get_eth_txbuf());
+ ret = usbh_rndis_eth_output(p->tot_len);
if (ret < 0) {
return -RT_ERROR;
} else {
@@ -254,7 +272,10 @@ static rt_err_t rt_usbh_cdc_ncm_control(rt_device_t dev, int cmd, void *args)
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);
+ int ret;
+
+ usbh_lwip_eth_output_common(p, usbh_cdc_ncm_get_eth_txbuf());
+ ret = usbh_cdc_ncm_eth_output(p->tot_len);
if (ret < 0) {
return -RT_ERROR;
} else {
@@ -317,7 +338,10 @@ static rt_err_t rt_usbh_asix_control(rt_device_t dev, int cmd, void *args)
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);
+ int ret;
+
+ usbh_lwip_eth_output_common(p, usbh_asix_get_eth_txbuf());
+ ret = usbh_asix_eth_output(p->tot_len);
if (ret < 0) {
return -RT_ERROR;
} else {
@@ -380,7 +404,10 @@ static rt_err_t rt_usbh_rtl8152_control(rt_device_t dev, int cmd, void *args)
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);
+ int ret;
+
+ usbh_lwip_eth_output_common(p, usbh_rtl8152_get_eth_txbuf());
+ ret = usbh_rtl8152_eth_output(p->tot_len);
if (ret < 0) {
return -RT_ERROR;
} else {