- CDC: all required class-defined requests implemented
- CDC: interrupt endpoint ZLP response added
This commit is contained in:
parent
3e67079427
commit
cb9a3c33ca
14
class/cdc.c
14
class/cdc.c
@ -42,6 +42,8 @@ void usb_cdc_init(const USB_CdcAssignments *as) {
|
||||
cdcs.initialized = true;
|
||||
}
|
||||
|
||||
//static uint8_t replyBuf[sizeof(USB_Cdc_LineCodingStruct)];
|
||||
|
||||
int usb_cdc_process_and_return(USB_CallbackEvent *cbevt) {
|
||||
int ret = -1;
|
||||
switch (cbevt->type) {
|
||||
@ -52,6 +54,16 @@ int usb_cdc_process_and_return(USB_CallbackEvent *cbevt) {
|
||||
//MSG("%u\n", cdcs.line_coding.dwDTERate);
|
||||
ret = 0;
|
||||
break;
|
||||
case USB_CDC_GET_LINE_CODING: // get line coding
|
||||
cbevt->reply_data = (const uint8_t *) &cdcs.line_coding; // expert move: pass the pointer, no copying
|
||||
cbevt->reply_size = sizeof(USB_Cdc_LineCodingStruct);
|
||||
cbevt->reply_valid = true; // the reply has been set to something valid
|
||||
ret = 0;
|
||||
break;
|
||||
case USB_CDC_SEND_BREAK: // send break
|
||||
// do nothing
|
||||
ret = 0;
|
||||
break;
|
||||
case USB_CDC_SET_CONTROL_LINE_STATE: // set control line state
|
||||
memcpy(&cdcs.control_line_state, cbevt->data, sizeof(USB_Cdc_ControlLineStateStruct));
|
||||
//MSG("%u\n", cdcs.control_line_state.D);
|
||||
@ -84,7 +96,7 @@ int usb_cdc_process_and_return(USB_CallbackEvent *cbevt) {
|
||||
|
||||
case USB_CBEVT_IN: {
|
||||
if (cbevt->ep == cdcs.ep_assignments.control_ep) { // if notification feeding is requested
|
||||
//usbcore_write(cdcs.ep_assignments.control_ep, NULL, 0); // send ZLP
|
||||
usbcore_write(cdcs.ep_assignments.control_ep, NULL, 0); // send ZLP
|
||||
ret = 0;
|
||||
} else if (cbevt->ep == cdcs.ep_assignments.data_ep) { // if data are requested
|
||||
//usbcore_write(cdcs.ep_assignments.data_ep, NULL, 0); // send ZLP
|
||||
|
Loading…
x
Reference in New Issue
Block a user