clean up, use BLEDIS_MANUFACTURER and BLEDIS_MODEL for USB Manufacturer and Product string

This commit is contained in:
hathach 2019-11-11 15:50:28 +07:00
parent c6d02901b3
commit 8a979d33bc
6 changed files with 18 additions and 61 deletions

View File

@ -67,24 +67,4 @@
#define USB_DESC_VID 0x239A #define USB_DESC_VID 0x239A
#define USB_DESC_UF2_PID 0x003B #define USB_DESC_UF2_PID 0x003B
#define USB_STRING_DESCRIPTORS { \
/* 0: is supported language = English */ \
TUD_DESC_STRCONV(0x0409), \
\
/* 1: Manufacturer */ \
TUD_DESC_STRCONV('E','l','e','c','t','r','o','n','u','t',' ','L','a','b','s'), \
\
/* 2: Product */ \
TUD_DESC_STRCONV('P','a','p','y','r', ' ', 'D','F','U'), \
\
/* 3: Serials TODO use chip ID */ \
usb_desc_str_serial, \
\
/* 4: CDC Interface */ \
TUD_DESC_STRCONV('P','a','p','y','r',' ','S','e','r','i','a','l'), \
\
/* 5: MSC Interface */ \
TUD_DESC_STRCONV('P','a','p','y','r',' ','U','F','2'), \
}
#endif // PPAPYR_H #endif // PPAPYR_H

View File

@ -52,7 +52,7 @@ void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16
(void) lun; (void) lun;
const char vid[] = "Adafruit"; const char vid[] = "Adafruit";
const char pid[] = "Bluefruit UF2"; const char pid[] = "nRF UF2";
const char rev[] = "1.0"; const char rev[] = "1.0";
memcpy(vendor_id , vid, strlen(vid)); memcpy(vendor_id , vid, strlen(vid));

View File

@ -134,42 +134,19 @@ void usb_desc_init(bool cdc_only)
// STRING DESCRIPTORS // STRING DESCRIPTORS
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
#ifndef USB_STRING_DESCRIPTORS
#define USB_STRING_DESCRIPTORS { \
/* 0: is supported language = English */ \
TUD_DESC_STRCONV(0x0409), \
\
/* 1: Manufacturer */ \
TUD_DESC_STRCONV('A','d','a','f','r','u','i','t',' ','I','n','d','u','s','t','r','i','e','s'), \
\
/* 2: Product */ \
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','n','R','F','5','2','8','4','0', ' ', 'D','F','U'), \
\
/* 3: Serials TODO use chip ID */ \
usb_desc_str_serial, \
\
/* 4: CDC Interface */ \
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','S','e','r','i','a','l'), \
\
/* 5: MSC Interface */ \
TUD_DESC_STRCONV('B','l','u','e','f','r','u','i','t',' ','U','F','2'), \
}
#endif
// array of pointer to string descriptors // array of pointer to string descriptors
char const* string_desc_arr [] = char const* string_desc_arr [] =
{ {
(const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409) (const char[]) { 0x09, 0x04 }, // 0: is supported language is English (0x0409)
"Adafruit Industries", // 1: Manufacturer BLEDIS_MANUFACTURER, // 1: Manufacturer
"Bluefruit DFU", // 2: Product BLEDIS_MODEL, // 2: Product
desc_str_serial, // 3: Serials, should use chip ID desc_str_serial, // 3: Serials, should use chip ID
"Bluefruit Serial", // 4: CDC Interface "nRF Serial", // 4: CDC Interface
"Bluefruit UF2", // 5: MSC Interface "nRF UF2", // 5: MSC Interface
}; };
// up to 32 unicode characters (header make it 33) // up to 64 unicode characters
static uint16_t _desc_str[33]; static uint16_t _desc_str[64+1];
// Invoked when received GET STRING DESCRIPTOR request // Invoked when received GET STRING DESCRIPTOR request
// Application return pointer to descriptor, whose contents must exist long enough for transfer to complete // Application return pointer to descriptor, whose contents must exist long enough for transfer to complete