Просмотр исходного кода

update: get mps by usbd_get_ep_mps

sakumisu 1 год назад
Родитель
Сommit
d23a8a8d00

+ 6 - 12
class/cdc/usbd_cdc_ecm.c

@@ -13,12 +13,6 @@
 /* Describe EndPoints configuration */
 static struct usbd_endpoint cdc_ecm_ep_data[3];
 
-#ifdef CONFIG_USB_HS
-#define CDC_ECM_MAX_PACKET_SIZE 512
-#else
-#define CDC_ECM_MAX_PACKET_SIZE 64
-#endif
-
 static USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_cdc_ecm_rx_buffer[CONFIG_CDC_ECM_ETH_MAX_SEGSZE];
 static USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_cdc_ecm_tx_buffer[CONFIG_CDC_ECM_ETH_MAX_SEGSZE];
 static USB_NOCACHE_RAM_SECTION USB_MEM_ALIGNX uint8_t g_cdc_ecm_notify_buf[16];
@@ -89,7 +83,7 @@ static int cdc_ecm_class_interface_request_handler(uint8_t busid, struct usb_set
 
     switch (setup->bRequest) {
         case CDC_REQUEST_SET_ETHERNET_PACKET_FILTER:
-            /* bit0 Promiscuous 
+            /* bit0 Promiscuous
              * bit1 ALL Multicast
              * bit2 Directed
              * bit3 Broadcast
@@ -119,7 +113,7 @@ void cdc_ecm_notify_handler(uint8_t busid, uint8_t event, void *arg)
             g_cdc_ecm_rx_data_buffer = NULL;
             break;
         case USBD_EVENT_CONFIGURED:
-            usbd_ep_start_read(0, cdc_ecm_ep_data[CDC_ECM_OUT_EP_IDX].ep_addr, &g_cdc_ecm_rx_buffer[g_cdc_ecm_rx_data_length], CDC_ECM_MAX_PACKET_SIZE);
+            usbd_ep_start_read(0, cdc_ecm_ep_data[CDC_ECM_OUT_EP_IDX].ep_addr, &g_cdc_ecm_rx_buffer[g_cdc_ecm_rx_data_length], usbd_get_ep_mps(busid, cdc_ecm_ep_data[CDC_ECM_OUT_EP_IDX].ep_addr));
             break;
 
         default:
@@ -131,17 +125,17 @@ void cdc_ecm_bulk_out(uint8_t busid, uint8_t ep, uint32_t nbytes)
 {
     g_cdc_ecm_rx_data_length += nbytes;
 
-    if (nbytes < CDC_ECM_MAX_PACKET_SIZE) {
+    if (nbytes < usbd_get_ep_mps(busid, ep)) {
         g_cdc_ecm_rx_data_buffer = g_cdc_ecm_rx_buffer;
         usbd_cdc_ecm_data_recv_done(g_cdc_ecm_rx_buffer, g_cdc_ecm_rx_data_length);
     } else {
-        usbd_ep_start_read(0, ep, &g_cdc_ecm_rx_buffer[g_cdc_ecm_rx_data_length], CDC_ECM_MAX_PACKET_SIZE);
+        usbd_ep_start_read(0, ep, &g_cdc_ecm_rx_buffer[g_cdc_ecm_rx_data_length], usbd_get_ep_mps(busid, ep));
     }
 }
 
 void cdc_ecm_bulk_in(uint8_t busid, uint8_t ep, uint32_t nbytes)
 {
-    if ((nbytes % CDC_ECM_MAX_PACKET_SIZE) == 0 && nbytes) {
+    if ((nbytes % usbd_get_ep_mps(busid, ep)) == 0 && nbytes) {
         /* send zlp */
         usbd_ep_start_write(0, ep, NULL, 0);
     } else {
@@ -173,7 +167,7 @@ void usbd_cdc_ecm_start_read_next(void)
 {
     g_cdc_ecm_rx_data_length = 0;
     g_cdc_ecm_rx_data_buffer = NULL;
-    usbd_ep_start_read(0, cdc_ecm_ep_data[CDC_ECM_OUT_EP_IDX].ep_addr, g_cdc_ecm_rx_buffer, CDC_ECM_MAX_PACKET_SIZE);
+    usbd_ep_start_read(0, cdc_ecm_ep_data[CDC_ECM_OUT_EP_IDX].ep_addr, g_cdc_ecm_rx_buffer, usbd_get_ep_mps(busid, cdc_ecm_ep_data[CDC_ECM_OUT_EP_IDX].ep_addr));
 }
 
 #ifdef CONFIG_USBDEV_CDC_ECM_USING_LWIP

+ 7 - 14
class/wireless/usbd_rndis.c

@@ -17,18 +17,6 @@ static struct usbd_endpoint rndis_ep_data[3];
 #define RNDIS_INQUIRY_PUT(src, len)   (memcpy(infomation_buffer, src, len))
 #define RNDIS_INQUIRY_PUT_LE32(value) (*(uint32_t *)infomation_buffer = (value))
 
-#ifdef CONFIG_USB_HS
-#define RNDIS_MAX_PACKET_SIZE 512
-#else
-#define RNDIS_MAX_PACKET_SIZE 64
-#endif
-
-#ifndef CONFIG_USB_HS
-#define RNDIS_LINK_SPEED 12000000 /* Link baudrate (12Mbit/s for USB-FS) */
-#else
-#define RNDIS_LINK_SPEED 480000000 /* Link baudrate (480Mbit/s for USB-HS) */
-#endif
-
 /* Device data structure */
 struct usbd_rndis_priv {
     uint32_t drv_version;
@@ -255,7 +243,12 @@ static int rndis_query_cmd_handler(uint8_t *data, uint32_t len)
             infomation_len = 4;
             break;
         case OID_GEN_LINK_SPEED:
-            RNDIS_INQUIRY_PUT_LE32(RNDIS_LINK_SPEED / 100);
+            if (usbd_get_ep_mps(0, rndis_ep_data[RNDIS_OUT_EP_IDX].ep_addr) > 64) {
+                RNDIS_INQUIRY_PUT_LE32(480000000 / 100);
+            } else {
+                RNDIS_INQUIRY_PUT_LE32(12000000 / 100);
+            }
+
             infomation_len = 4;
             break;
         case OID_GEN_CURRENT_PACKET_FILTER:
@@ -469,7 +462,7 @@ void rndis_bulk_out(uint8_t busid, uint8_t ep, uint32_t nbytes)
 
 void rndis_bulk_in(uint8_t busid, uint8_t ep, uint32_t nbytes)
 {
-    if ((nbytes % RNDIS_MAX_PACKET_SIZE) == 0 && nbytes) {
+    if ((nbytes % usbd_get_ep_mps(busid, ep)) == 0 && nbytes) {
         /* send zlp */
         usbd_ep_start_write(0, ep, NULL, 0);
     } else {

+ 1 - 1
demo/cdc_acm_hid_msc_template.c

@@ -277,7 +277,7 @@ void usbd_cdc_acm_bulk_in(uint8_t busid, uint8_t ep, uint32_t nbytes)
 {
     USB_LOG_RAW("actual in len:%d\r\n", nbytes);
 
-    if ((nbytes % CDC_MAX_MPS) == 0 && nbytes) {
+    if ((nbytes % usbd_get_ep_mps(busid, ep)) == 0 && nbytes) {
         /* send zlp */
         usbd_ep_start_write(busid, CDC_IN_EP, NULL, 0);
     } else {

+ 1 - 1
demo/cdc_acm_msc_template.c

@@ -287,7 +287,7 @@ void usbd_cdc_acm_bulk_in(uint8_t busid, uint8_t ep, uint32_t nbytes)
 {
     USB_LOG_RAW("actual in len:%d\r\n", nbytes);
 
-    if ((nbytes % CDC_MAX_MPS) == 0 && nbytes) {
+    if ((nbytes % usbd_get_ep_mps(busid, ep)) == 0 && nbytes) {
         /* send zlp */
         usbd_ep_start_write(busid, CDC_IN_EP, NULL, 0);
     } else {

+ 1 - 1
demo/cdc_acm_template.c

@@ -152,7 +152,7 @@ void usbd_cdc_acm_bulk_in(uint8_t busid, uint8_t ep, uint32_t nbytes)
 {
     USB_LOG_RAW("actual in len:%d\r\n", nbytes);
 
-    if ((nbytes % CDC_MAX_MPS) == 0 && nbytes) {
+    if ((nbytes % usbd_get_ep_mps(busid, ep)) == 0 && nbytes) {
         /* send zlp */
         usbd_ep_start_write(busid, CDC_IN_EP, NULL, 0);
     } else {

+ 3 - 3
demo/winusb1.0_template.c

@@ -87,7 +87,7 @@ __ALIGN_BEGIN const uint8_t WINUSB_IF0_WCIDProperties [142] __ALIGN_END = {
   0x00, 0x01,                                       /* bcdVersion */
   0x05, 0x00,                                       /* wIndex */
   0x01, 0x00,                                       /* wCount */
-  
+
   ///////////////////////////////////////
   /// registry propter descriptor
   ///////////////////////////////////////
@@ -122,7 +122,7 @@ __ALIGN_BEGIN const uint8_t WINUSB_IF1_WCIDProperties [142] __ALIGN_END = {
   0x00, 0x01,                                       /* bcdVersion */
   0x05, 0x00,                                       /* wIndex */
   0x01, 0x00,                                       /* wCount */
-  
+
   ///////////////////////////////////////
   /// registry propter descriptor
   ///////////////////////////////////////
@@ -424,7 +424,7 @@ void usbd_winusb_in2(uint8_t busid, uint8_t ep, uint32_t nbytes)
 {
     USB_LOG_RAW("actual in len:%d\r\n", nbytes);
 
-    if ((nbytes % WINUSB_EP_MPS) == 0 && nbytes) {
+    if ((nbytes % usbd_get_ep_mps(busid, ep)) == 0 && nbytes) {
         /* send zlp */
         usbd_ep_start_write(busid, WINUSB_IN_EP2, NULL, 0);
     } else {

+ 1 - 1
demo/winusb2.0_cdc_template.c

@@ -275,7 +275,7 @@ void usbd_winusb_in(uint8_t busid, uint8_t ep, uint32_t nbytes)
 {
     USB_LOG_RAW("actual in len:%d\r\n", nbytes);
 
-    if ((nbytes % WINUSB_EP_MPS) == 0 && nbytes) {
+    if ((nbytes % usbd_get_ep_mps(busid, ep)) == 0 && nbytes) {
         /* send zlp */
         usbd_ep_start_write(busid, WINUSB_IN_EP, NULL, 0);
     } else {

+ 1 - 1
demo/winusb2.0_hid_template.c

@@ -311,7 +311,7 @@ void usbd_winusb_in(uint8_t busid, uint8_t ep, uint32_t nbytes)
 {
     USB_LOG_RAW("actual in len:%d\r\n", nbytes);
 
-    if ((nbytes % WINUSB_EP_MPS) == 0 && nbytes) {
+    if ((nbytes % usbd_get_ep_mps(busid, ep)) == 0 && nbytes) {
         /* send zlp */
         usbd_ep_start_write(busid, WINUSB_IN_EP, NULL, 0);
     } else {