int SingleAbsoluteMouse_::getInterface(uint8_t* interfaceCount) { *interfaceCount += 1; // uses 1 HIDDescriptor hidInterface = { D_INTERFACE(pluggedInterface, 1, USB_DEVICE_CLASS_HUMAN_INTERFACE, HID_SUBCLASS_NONE, HID_PROTOCOL_NONE), D_HIDREPORT(sizeof(_hidSingleReportDescriptorAbsoluteMouse)), D_ENDPOINT(USB_ENDPOINT_IN(pluggedEndpoint), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x01) }; return USB_SendControl(0, &hidInterface, sizeof(hidInterface)); }
static volatile LineInfo _usbLineInfo = { 57600, 0x00, 0x00, 0x00, 0x00 }; #define WEAK __attribute__ ((weak)) extern const CDCDescriptor _cdcInterface PROGMEM; const CDCDescriptor _cdcInterface = { D_IAD(0,2,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,1), // CDC communication interface D_INTERFACE(CDC_ACM_INTERFACE,1,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,0), D_CDCCS(CDC_HEADER,0x10,0x01), // Header (1.10 bcd) D_CDCCS(CDC_CALL_MANAGEMENT,1,1), // Device handles call management (not) D_CDCCS4(CDC_ABSTRACT_CONTROL_MANAGEMENT,6), // SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported D_CDCCS(CDC_UNION,CDC_ACM_INTERFACE,CDC_DATA_INTERFACE), // Communication interface is master, data interface is slave 0 D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_ACM),USB_ENDPOINT_TYPE_INTERRUPT,0x10,0x40), // CDC data interface D_INTERFACE(CDC_DATA_INTERFACE,2,CDC_DATA_INTERFACE_CLASS,0,0), D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,USB_EP_SIZE,0), D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,USB_EP_SIZE,0) }; int WEAK CDC_GetInterface(u8* interfaceNum) { interfaceNum[0] += 2; // uses 2 return USB_SendControl(TRANSFER_PGM,&_cdcInterface,sizeof(_cdcInterface)); } bool WEAK CDC_Setup(Setup& setup) {
0x09, 0x01, // usage 0x81, 0x02, // Input (array) 0x95, 64, // report count RX 0x09, 0x02, // usage 0x91, 0x02, // Output (array) 0xC0 // end collection #endif }; extern const HIDDescriptor _hidInterface PROGMEM; const HIDDescriptor _hidInterface = { D_INTERFACE(HID_INTERFACE,1,3,0,0), D_HIDREPORT(sizeof(_hidReportDescriptor)), D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x01) }; //================================================================================ //================================================================================ // Driver u8 _hid_protocol = 1; u8 _hid_idle = 1; #define WEAK __attribute__ ((weak)) int WEAK HID_GetInterface(u8* interfaceNum) { interfaceNum[0] += 1; // uses 1 return USB_SendControl(TRANSFER_PGM,&_hidInterface,sizeof(_hidInterface));
// FIRST INTERFACE // CDC communication interface (endpoint 0) D_INTERFACE(CDC_ACM_INTERFACE, // 'n' 1, // number of endpoints CDC_COMMUNICATION_INTERFACE_CLASS, // interface class CDC_ABSTRACT_CONTROL_MODEL, // interface sub-class 0), // protocol // these headers describe the supported interfaces D_CDCCS(CDC_HEADER,0x10,0x01), // CDCCS InterfaceDescriptor Header (1.10 bcd) - version 1.10? // D_CDCCS(CDC_CALL_MANAGEMENT,1,1), // Device handles call management (seems to be optional) D_CDCCS4(CDC_ABSTRACT_CONTROL_MANAGEMENT,6), // SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported D_CDCCS(CDC_UNION,CDC_ACM_INTERFACE,CDC_DATA_INTERFACE), // Communication interface is master, data interface is slave 0 (?) D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_ACM), // IN endpoint for CDC_ENDPOINT_ACM USB_ENDPOINT_TYPE_INTERRUPT, // INTERRUPT type 0x10, // max packet size 16 0x40), // interval 64 frames i.e. 64 msec (see USB spec table 9-13) // SECOND INTERFACE // CDC data interface (endpoints 1, 2) D_INTERFACE(CDC_DATA_INTERFACE, // 'n' 2, // number of endpoints CDC_DATA_INTERFACE_CLASS, // interface class 0, // interface sub-class 0), // protocol D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT), // OUT endpoint, index 'CDC_ENDPOINT_OUT' USB_ENDPOINT_TYPE_BULK, // BULK data transfers 0x40, // max packet size 64 1), // interval 1 (was 0)
{ interfaceNum[0] += 1; // uses 1 return USB_SendControl(TRANSFER_PGM,&_acInterface,sizeof(_acInterface)); } extern const MIDIDescriptor _midiInterface PROGMEM; const MIDIDescriptor _midiInterface = { D_INTERFACE(MIDI_INTERFACE,MIDI_ENDPOINT_COUNT,CLASS_AUDIO,SUBCLASS_MIDISTREAMING,0), {7, TYPE_CS_INTERFACE, SUBTYPE_HEADER, 0x0100, 34}, {6, TYPE_CS_INTERFACE, SUBTYPE_MIDI_IN_JACK, JACK_EMBEDDED, JACK1, 0x00}, {9, TYPE_CS_INTERFACE, SUBTYPE_MIDI_OUT_JACK, JACK_EMBEDDED, JACK2, 1, JACK3, 1, 0x00}, {6, TYPE_CS_INTERFACE, SUBTYPE_MIDI_IN_JACK, JACK_EXTERNAL, JACK3, 0x00}, {9, TYPE_CS_INTERFACE, SUBTYPE_MIDI_OUT_JACK, JACK_EXTERNAL, JACK4, 1, JACK1, 1, 0x00}, { D_ENDPOINT(USB_ENDPOINT_OUT(MIDI_ENDPOINT_OUT), USB_ENDPOINT_TYPE_BULK, 0x0040, 0x00), { 5, 0x25, 0x01, 0x01, JACK1 } }, { D_ENDPOINT(USB_ENDPOINT_IN(MIDI_ENDPOINT_IN), USB_ENDPOINT_TYPE_BULK, 0x0040, 0x00), { 5, 0x25, 0x01, 0x01, JACK2 } } }; int WEAK MIDI_GetInterface(u8* interfaceNum) { interfaceNum[0] += 1; // uses 1 return USB_SendControl(TRANSFER_PGM,&_midiInterface,sizeof(_midiInterface)); }
Config USB_ConfigDescriptor = { D_CONFIG(sizeof(Config),INTERFACE_COUNT), #ifdef CDC_ENABLED // CDC { D_IAD(0,2,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,1), // CDC communication interface D_INTERFACE(CDC_ACM_INTERFACE,1,CDC_COMMUNICATION_INTERFACE_CLASS,CDC_ABSTRACT_CONTROL_MODEL,0), D_CDCCS(CDC_HEADER,0x10,0x01), // Header (1.10 bcd) D_CDCCS(CDC_CALL_MANAGEMENT,1,1), // Device handles call management D_CDCCS4(CDC_ABSTRACT_CONTROL_MANAGEMENT,2), // SET_LINE_CODING, GET_LINE_CODING, SET_CONTROL_LINE_STATE supported D_CDCCS(CDC_UNION,CDC_ACM_INTERFACE,CDC_DATA_INTERFACE), // Communication interface is master, data interface is slave 0 D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_ACM),USB_ENDPOINT_TYPE_INTERRUPT,0x10,0x40), // CDC data interface D_INTERFACE(CDC_DATA_INTERFACE,2,CDC_DATA_INTERFACE_CLASS,0,0), D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,0x40,0), D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,0x40,0) }, #endif // HID { D_INTERFACE(HID_INTERFACE,1,3,0,0), D_HIDREPORT(30), D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x40) } };
#ifdef HID_SYSTEM_ENABLE HID_REPORT_SYSTEMCONTROL(HID_REPORTID_SYSTEMCONTROL), #endif #ifdef HID_GAMEPAD_ENABLE HID_REPORT_GAMEPAD(HID_REPORTID_GAMEPAD), #endif #endif }; extern const HIDDescriptor _hidInterface PROGMEM; const HIDDescriptor _hidInterface = { D_INTERFACE(HID_INTERFACE, 1, 3, 0, 0), D_HIDREPORT(sizeof(_hidReportDescriptor)), // edit by NicoHood D_ENDPOINT(USB_ENDPOINT_IN(HID_ENDPOINT_INT), USB_ENDPOINT_TYPE_INTERRUPT, USB_EP_SIZE, 0x01) }; #if defined(HID_KEYBOARD_LEDS_ENABLED) volatile uint8_t hid_keyboard_leds = 0; #endif //================================================================================ //================================================================================ // Driver u8 _hid_protocol = 1; u8 _hid_idle = 1; int WEAK HID_GetInterface(u8* interfaceNum) {