Skip to content

Commit 7cde64a

Browse files
committed
post-development refactoring of USB code
1 parent de529e3 commit 7cde64a

File tree

5 files changed

+259
-325
lines changed

5 files changed

+259
-325
lines changed

cores/xmega/CDC.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const DeviceDescriptor _cdcDeviceDescriptor PROGMEM =
8888
64, // packet size (64)
8989
USB_VID, // vendor ID for the USB device
9090
USB_PID, // product ID for the USB device
91-
0x100, // this indicates USB version 1.0
91+
0x100, // device release version as BCD (1.00)
9292
USB_STRING_INDEX_MANUFACTURER, // string index for mfg
9393
USB_STRING_INDEX_PRODUCT, // string index for product name
9494
USB_STRING_INDEX_SERIAL, // string index for serial number (0 for 'none')
@@ -124,7 +124,7 @@ const CDCDescriptor _cdcInterface = // needs to be no more than 55 bytes in leng
124124
D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_ACM), // IN endpoint for CDC_ENDPOINT_ACM
125125
USB_ENDPOINT_TYPE_INTERRUPT, // INTERRUPT type
126126
0x10, // max packet size 16
127-
0x40), // interval 64
127+
0x40), // interval 64 frames i.e. 64 msec (see USB spec table 9-13)
128128

129129
// SECOND INTERFACE
130130
// CDC data interface (endpoints 1, 2)
@@ -137,12 +137,12 @@ const CDCDescriptor _cdcInterface = // needs to be no more than 55 bytes in leng
137137
D_ENDPOINT(USB_ENDPOINT_OUT(CDC_ENDPOINT_OUT), // OUT endpoint, index 'CDC_ENDPOINT_OUT'
138138
USB_ENDPOINT_TYPE_BULK, // BULK data transfers
139139
0x40, // max packet size 64
140-
0), // interval 0
140+
1), // interval 1 (was 0)
141141

142142
D_ENDPOINT(USB_ENDPOINT_IN (CDC_ENDPOINT_IN), // IN endpoint, index 'CDC_ENDPOINT_IN'
143143
USB_ENDPOINT_TYPE_BULK, // BULK data transfers
144144
0x40, // max packet size 64
145-
0) // interval 0
145+
0) // interval 0 (apparently not needed)
146146
};
147147

148148
void WEAK CDC_Reset(void)

cores/xmega/USBAPI.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,13 @@ bool USB_IsSendQFull(uint8_t ep); // this returns TRUE if there are too
261261
bool USB_IsStalled(uint8_t ep); // this tells me I'm 'stalled' (BULK IN, INTERRUPT, CONTROL)
262262
int USB_Send(uint8_t ep, const void* data, // send endpoint data. bSendNow marks it "to send"
263263
int len, uint8_t bSendNow);
264-
int USB_Recv(uint8_t ep, void* data, // 'receive' data from endpoint receive queue.
264+
int USB_Recv(uint8_t ep, void* data, // 'receive' data from endpoint receive queue. returns < 0 on error, or # of bytes
265265
int len);
266266
int USB_Recv(uint8_t ep); // 'receive' one byte of data from endpoint receive queue
267267
void USB_Flush(uint8_t ep); // 'sends' all pending data by marking the buffers "to send"
268268

269269
uint16_t GetFrameNumber(void); // a debug API to obtain the latest USB frame number
270+
uint8_t USB_GetEPType(uint8_t nEP); // another debug API to return endpoint type by index
270271

271272
#endif
272273

0 commit comments

Comments
 (0)