//bool USBHook(Setup& setup) bool USBHook() { Setup& setup = _setup; u8 r = setup.bRequest; // CDC Requests if (CDC_GET_LINE_CODING == r) { Send((const volatile u8*)&_usbLineInfo,7); } else if (CDC_SET_LINE_CODING == r) { WaitOUT(); Recv((volatile u8*)&_usbLineInfo,7); ClearOUT(); } else if (CDC_SET_CONTROL_LINE_STATE == r) { _usbLineInfo.lineState = setup.wValueL; } return true; }
// Does not timeout or cross fifo boundaries // Will only work for transfers <= 64 bytes // TODO int USB_RecvControl(void* d, int len) { WaitOUT(); Recv((u8*)d,len); ClearOUT(); return len; }
int USB_RecvControl(void* d, int len) { WaitOUT(); Recv((uint8_t*)d,len); ClearOUT(); return (len); }
// Does not timeout or cross fifo boundaries // Will only work for transfers <= 64 bytes // TODO int USB_RecvControl(void* d, int len) { WaitOUT(); // NOTE: if the Recv((u8*)d,len); ClearOUT(); // allows me to receive data again return len; }
// Does not timeout or cross fifo boundaries int USB_RecvControl(void* d, int len) { auto length = len; while(length) { // Dont receive more than the USB Control EP has to offer // Use fixed 64 because control EP always have 64 bytes even on 16u2. auto recvLength = length; if(recvLength > 64){ recvLength = 64; } // Write data to fit to the end (not the beginning) of the array WaitOUT(); Recv((u8*)d + len - length, recvLength); ClearOUT(); length -= recvLength; } return len; }