Ver Fonte

clean up

- remove TUD_WEBUSB_URL_DESCRIPTOR to avoid flexible array member (C++
forbid in strict mode)
- remove unused TUD_DESC_STRLEN/TUD_DESC_STR_HEADER/TUD_DESC_STR_HEADER
hathach há 6 anos atrás
pai
commit
30de17a830

+ 2 - 2
examples/device/cdc_msc_hid/src/usb_descriptors.c

@@ -209,8 +209,8 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index)
     }
     }
   }
   }
 
 
-  // first byte is len, second byte is string type
-  _desc_str[0] = TUD_DESC_STR_HEADER(chr_count);
+  // first byte is length (including header), second byte is string type
+  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
 
 
   return _desc_str;
   return _desc_str;
 }
 }

+ 2 - 2
examples/device/cdc_msc_hid_freertos/src/usb_descriptors.c

@@ -210,8 +210,8 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index)
     }
     }
   }
   }
 
 
-  // first byte is len, second byte is string type
-  _desc_str[0] = TUD_DESC_STR_HEADER(chr_count);
+  // first byte is length (including header), second byte is string type
+  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
 
 
   return _desc_str;
   return _desc_str;
 }
 }

+ 2 - 2
examples/device/hid_generic_inout/src/usb_descriptors.c

@@ -162,8 +162,8 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index)
     }
     }
   }
   }
 
 
-  // first byte is len, second byte is string type
-  _desc_str[0] = TUD_DESC_STR_HEADER(chr_count);
+  // first byte is length (including header), second byte is string type
+  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
 
 
   return _desc_str;
   return _desc_str;
 }
 }

+ 2 - 2
examples/device/midi_test/src/usb_descriptors.c

@@ -149,8 +149,8 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index)
     }
     }
   }
   }
 
 
-  // first byte is len, second byte is string type
-  _desc_str[0] = TUD_DESC_STR_HEADER(chr_count);
+  // first byte is length (including header), second byte is string type
+  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
 
 
   return _desc_str;
   return _desc_str;
 }
 }

+ 2 - 2
examples/device/msc_dual_lun/src/usb_descriptors.c

@@ -147,8 +147,8 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index)
     }
     }
   }
   }
 
 
-  // first byte is len, second byte is string type
-  _desc_str[0] = TUD_DESC_STR_HEADER(chr_count);
+  // first byte is length (including header), second byte is string type
+  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
 
 
   return _desc_str;
   return _desc_str;
 }
 }

+ 2 - 2
examples/device/webusb_serial/src/usb_descriptors.c

@@ -230,8 +230,8 @@ uint16_t const* tud_descriptor_string_cb(uint8_t index)
     }
     }
   }
   }
 
 
-  // first byte is len, second byte is string type
-  _desc_str[0] = TUD_DESC_STR_HEADER(chr_count);
+  // first byte is length (including header), second byte is string type
+  _desc_str[0] = (TUSB_DESC_STRING << 8 ) | (2*chr_count + 2);
 
 
   return _desc_str;
   return _desc_str;
 }
 }

+ 0 - 9
src/common/tusb_types.h

@@ -469,15 +469,6 @@ static inline uint8_t tu_desc_len(void const* desc)
   return ((uint8_t const*) desc)[DESC_OFFSET_LEN];
   return ((uint8_t const*) desc)[DESC_OFFSET_LEN];
 }
 }
 
 
-// Length of the string descriptors in bytes with slen characters
-#define TUD_DESC_STRLEN(_chr_count)      (2*(_chr_count) + 2)
-
-// Header of string descriptors with len + string type
-#define TUD_DESC_STR_HEADER(_chr_count)  ( (uint16_t) ( (TUSB_DESC_STRING << 8 ) | TUD_DESC_STRLEN(_chr_count)) )
-
-// Convert comma-separated string to descriptor unicode format
-#define TUD_DESC_STRCONV( ... )     (const uint16_t[]) { TUD_DESC_STR_HEADER(TU_ARGS_NUM(__VA_ARGS__)), __VA_ARGS__ }
-
 #ifdef __cplusplus
 #ifdef __cplusplus
  }
  }
 #endif
 #endif

+ 0 - 5
src/device/usbd.h

@@ -143,11 +143,6 @@ TU_ATTR_WEAK bool tud_vendor_control_complete_cb(uint8_t rhport, tusb_control_re
   0xDF, 0x60, 0xDD, 0xD8, 0x89, 0x45, 0xC7, 0x4C, \
   0xDF, 0x60, 0xDD, 0xD8, 0x89, 0x45, 0xC7, 0x4C, \
   0x9C, 0xD2, 0x65, 0x9D, 0x9E, 0x64, 0x8A, 0x9F
   0x9C, 0xD2, 0x65, 0x9D, 0x9E, 0x64, 0x8A, 0x9F
 
 
-//------------- WebUSB URL -------------//
-// used to init tusb_desc_webusb_url_t
-#define TUD_WEBUSB_URL_DESCRIPTOR(_scheme, _url) \
-  { 3 + sizeof(_url) - 1, 3, _scheme, _url }
-
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+
 // Configuration & Interface Descriptor Templates
 // Configuration & Interface Descriptor Templates
 //--------------------------------------------------------------------+
 //--------------------------------------------------------------------+