void setString(uint8* out, const usb_descriptor_string* defaultDescriptor, const char* s, uint32 maxLength) { if (s == NULL) { uint8 n = defaultDescriptor->bLength; uint8 m = USB_DESCRIPTOR_STRING_LEN(maxLength); if (n > m) n = m; memcpy(out, defaultDescriptor, n); out[0] = n; } else { uint32 n = strlen(s); if (n > maxLength) n = maxLength; out[0] = (uint8)USB_DESCRIPTOR_STRING_LEN(n); out[1] = USB_DESCRIPTOR_TYPE_STRING; for (uint32 i=0; i<n; i++) { out[2 + 2*i] = (uint8)s[i]; out[2 + 1 + 2*i] = 0; } } }
*/ voidFuncPtrUsb userUsbInterrupt = NULL; ONE_DESCRIPTOR Device_Descriptor = { (uint8*)&usbVcomDescriptor_Device, sizeof(USB_Descriptor_Device) }; ONE_DESCRIPTOR Config_Descriptor = { (uint8*)&usbVcomDescriptor_Config, 0x43//sizeof(USB_Descriptor_Config) }; ONE_DESCRIPTOR String_Descriptor[3] = { {(uint8*)&usbVcomDescriptor_LangID, USB_DESCRIPTOR_STRING_LEN(1)}, {(uint8*)&usbVcomDescriptor_iManufacturer,USB_DESCRIPTOR_STRING_LEN(8)}, //[ROBOTIS]changed to support cm-900 by [email protected] {(uint8*)&usbVcomDescriptor_iProduct, USB_DESCRIPTOR_STRING_LEN(24)} }; uint8 last_request = 0; USB_Line_Coding line_coding = { bitrate: 115200, format: 0x00, /* stop bits-1 */ paritytype: 0x00, datatype: 0x08 }; uint8 vcomBufferRx[VCOM_RX_BUFLEN]; volatile uint32 countTx = 0;
#include "usb_config.h" #include "usb.h" #include "usb_hardware.h" ONE_DESCRIPTOR Device_Descriptor = { (uint8*)&usbVcomDescriptor_Device, sizeof(USB_Descriptor_Device) }; ONE_DESCRIPTOR Config_Descriptor = { (uint8*)&usbVcomDescriptor_Config, 0x43//sizeof(USB_Descriptor_Config) }; ONE_DESCRIPTOR String_Descriptor[3] = { {(uint8*)&usbVcomDescriptor_LangID, USB_DESCRIPTOR_STRING_LEN(1)}, #if 0 {(uint8*)&usbVcomDescriptor_iManufacturer,USB_DESCRIPTOR_STRING_LEN(8)}, {(uint8*)&usbVcomDescriptor_iProduct, USB_DESCRIPTOR_STRING_LEN(8)} #endif #if 1 {(uint8*)&usbVcomDescriptor_iManufacturer,USB_DESCRIPTOR_STRING_LEN(18)}, {(uint8*)&usbVcomDescriptor_iProduct, USB_DESCRIPTOR_STRING_LEN(24)} #endif }; uint8 last_request = 0; USB_Line_Coding line_coding = { bitrate: 115200, format: 0x00, /* stop bits-1 */