33 CDC __attribute__((weak)) cdc(&ibuf);
43 static volatile LineInfo _usbLineInfo = {
44 57600, 0x00, 0x00, 0x00, 0x00
47 int CDC_GetInterface(uint8_t* interfaceNum) __attribute__ ((weak));
48 bool CDC_Setup(Setup& setup) __attribute__ ((weak));
71 CDC_GetInterface(uint8_t* interfaceNum)
74 return USB_SendControl(TRANSFER_PGM,&_cdcInterface,
sizeof(_cdcInterface));
78 CDC_Setup(Setup& setup)
80 uint8_t r = setup.bRequest;
81 uint8_t requestType = setup.bmRequestType;
85 USB_SendControl(0,(
void*)&_usbLineInfo,7);
92 USB_RecvControl((
void*)&_usbLineInfo,7);
97 _usbLineInfo.lineState = setup.wValueL;
103 if (1200 == _usbLineInfo.dwDTERate) {
106 if ((_usbLineInfo.lineState & 0x01) == 0) {
107 *(uint16_t*) 0x0800 = 0x7777;
108 wdt_enable(WDTO_120MS);
117 *(uint16_t *)0x0800 = 0x0;
125 _usbLineInfo.lineState = 0;
133 CDC::begin(uint32_t baudrate, uint8_t format)
139 if (!USBDevice.attach())
return (
false);
140 for (uint8_t retry = 0; retry < 30; retry++) {
141 if (_usbLineInfo.lineState > 0)
return (
true);
151 while (m_ibuf->room()) {
172 CDC::write(
const void* buf,
size_t size)
174 if ((_usbLineInfo.lineState & 0x01) &&
175 (USB_Send(
CDC_TX, buf, size) != (
int) size))
#define CDC_ACM_INTERFACE
#define REQUEST_HOSTTODEVICE_CLASS_INTERFACE
#define CDC_DATA_INTERFACE_CLASS
#define D_CDCCS(_subtype, _d0, _d1)
#define CDC_SET_LINE_CODING
#define CDC_GET_LINE_CODING
#define USB_ENDPOINT_IN(addr)
void(* delay)(uint32_t ms)
#define USB_ENDPOINT_TYPE_INTERRUPT
static void begin(uint16_t ms=16)
#define D_ENDPOINT(_addr, _attr, _packetSize, _interval)
#define REQUEST_DEVICETOHOST_CLASS_INTERFACE
#define CDC_CALL_MANAGEMENT
#define CDC_COMMUNICATION_INTERFACE_CLASS
#define D_IAD(_firstInterface, _count, _class, _subClass, _protocol)
IOStream & flush(IOStream &outs)
#define USB_ENDPOINT_OUT(addr)
#define CDC_SET_CONTROL_LINE_STATE
#define CDC_DATA_INTERFACE
#define CDC_ABSTRACT_CONTROL_MODEL
static bool is_initiated()
static IOBuffer< UART::RX_BUFFER_MAX > ibuf
#define USB_ENDPOINT_TYPE_BULK
#define CDC_ABSTRACT_CONTROL_MANAGEMENT
#define D_CDCCS4(_subtype, _d0)
#define D_INTERFACE(_n, _numEndpoints, _class, _subClass, _protocol)