Commits

Sven Schnelle  committed ed7ea92

Add CDC descriptors to debugdevice_full_duplex

Signed-off-by: Sven Schnelle <svens@stackframe.org>

  • Participants
  • Parent commits a5fd08d

Comments (0)

Files changed (2)

File examples/debugdevice_full_duplex/debugdev.c

 				break;
 			IOA |= DRDY_OUT;
 
-			if(IOA & DVALID_IN)
-				state = TX_STATE_DATA;
-			break;
+			if(!(IOA & DVALID_IN))
+				break;
+			state = TX_STATE_DATA;
+			/* intentional fall through */
 
 		case TX_STATE_DATA:
 			last = IOA & DLAST_IN;
 			EP6FIFOBUF[offset] = INPUTDATA;
 			IOA &= ~DRDY_OUT;
 			state = TX_STATE_ACK;
-			break;
+			/* intentional fall through */
 
 		case TX_STATE_ACK:
 			if (IOA & DVALID_IN)
 	ENABLE_HISPEED();
 	ENABLE_USBRESET();
 
+	/* INT endpoint */
+	EP1INCFG = bmVALID | (3 << 4);
+	SYNCDELAY();
+
 	/* BULK IN endpoint EP2 */
 	EP2CFG = 0xA2; // 10100010
 	SYNCDELAY();
 
 	/* BULK OUT endpoint EP6 */
-	EP6CFG = 0xE2; // 11100010
+	EP6CFG = 0xE2;
 	SYNCDELAY();
 
 	/* disable all other endpoints */
 
-	EP1INCFG &= ~bmVALID;
-	SYNCDELAY();
 
 	EP1OUTCFG &= ~bmVALID;
 	SYNCDELAY();

File examples/debugdevice_full_duplex/dscr.a51

 	.db	dev_dscr_end-_dev_dscr    ; len
 	.db	DSCR_DEVICE_TYPE		  ; type
 	.dw	0x0002					  ; usb 2.0
-	.db	0xff  					  ; class (vendor specific)
-	.db	0					  ; subclass (vendor specific)
-	.db	0					  ; protocol (vendor specific)
-	.db	64						  ; packet size (ep0)
+	.db	0x02  					  ; class (vendor specific)
+	.db	0x00					  ; subclass (vendor specific)
+	.db	0x00					  ; protocol (vendor specific)
+	.db	0x40						  ; packet size (ep0)
 	.dw	0xb404					  ; vendor id
 	.dw	0x1386					  ; product id
 	.dw	0x0100					  ; version id
-	.db	1					  ; manufacturure str idx
-	.db	2				          ; product str idx
-	.db	0				          ; serial str idx
-	.db	1			              ; n configurations
+	.db	0x01					  ; manufacturure str idx
+	.db	0x02				          ; product str idx
+	.db	0x00				          ; serial str idx
+	.db	0x01					  ; n configurations
 dev_dscr_end:
 
 _dev_qual_dscr:
 	.db	dev_qualdscr_end-_dev_qual_dscr
 	.db	DSCR_DEVQUAL_TYPE
 	.dw	0x0002                              ; usb 2.0
-	.db	0xff
+	.db	0x2
 	.db	0x00
 	.db	0x0
 	.db	64                                  ; max packet
-	.db	1									; n configs
-	.db	0									; extra reserved byte
+	.db	1					; n configs
+	.db	0					; extra reserved byte
 dev_qualdscr_end:
 
 _debug_dscr:
     ; can't use .dw because byte order is different
 	.db	(highspd_dscr_realend-_highspd_dscr) % 256 ; total length of config lsb
 	.db	(highspd_dscr_realend-_highspd_dscr) / 256 ; total length of config msb
-	.db	1								 ; n interfaces
+	.db	2								 ; n interfaces
 	.db	1								 ; config number
 	.db	0								 ; config string
 	.db	0x80                             ; attrs = bus powered, no wakeup
 ; NOTE the default TRM actually has more alt interfaces
 ; but you can add them back in if you need them.
 ; here, we just use the default alt setting 1 from the trm
+  	; control endpoints
 	.db	DSCR_INTERFACE_LEN
 	.db	DSCR_INTERFACE_TYPE
-	.db	0				 ; index
-	.db	0				 ; alt setting idx
-	.db	2				 ; n endpoints
-	.db	0xff			 ; class
-	.db	0
-	.db	0
-	.db	3	             ; string index
+	.db	0x00				 ; index
+	.db	0x00				 ; alt setting idx
+	.db	0x01				 ; n endpoints
+	.db	0x02			 	 ; class
+	.db	0x02
+	.db	0x01
+	.db	0x00				; string index
+
+	; CDC header
+	.db	0x05
+	.db	0x24
+	.db	0x00
+	.db	0x10
+	.db	0x01
+
+	; CDC ACM
+	.db	0x04
+	.db	0x24
+	.db	0x02
+	.db	0x00
+
+	; CDC union
+	.db     0x05
+	.db	0x24
+	.db	0x06
+	.db	0x00
+	.db	0x01
+
+	; CDC call managment
+	.db     0x05
+	.db	0x24
+	.db	0x01
+	.db	0x01
+	.db	0x01
+
+; endpoint 1 in
+	.db	DSCR_ENDPOINT_LEN
+	.db	DSCR_ENDPOINT_TYPE
+	.db	0x81				; ep1 dir=IN and address
+	.db	ENDPOINT_TYPE_INT		; type
+	.db	0x40				; max packet LSB
+	.db	0x00				; max packet size=512 bytes
+	.db	0x40				; polling interval
+
+
+	; data endpoints
+	.db	DSCR_INTERFACE_LEN
+	.db	DSCR_INTERFACE_TYPE
+	.db	0x01				; index
+	.db	0x00				; alt setting idx
+	.db	0x02				; n endpoints
+	.db	0x0a				; class
+	.db	0x00
+	.db	0x00
+	.db	0x00				; string index
 
 ; endpoint 2 out
 	.db	DSCR_ENDPOINT_LEN
 	.db	DSCR_ENDPOINT_TYPE
-	.db	0x02				;  ep2 dir=OUT and address
-	.db	ENDPOINT_TYPE_BULK	; type
+	.db	0x02				; ep2 dir=OUT and address
+	.db	ENDPOINT_TYPE_BULK		; type
 	.db	0x00				; max packet LSB
 	.db	0x02				; max packet size=512 bytes
 	.db	0x00				; polling interval
 ; endpoint 6 in
 	.db	DSCR_ENDPOINT_LEN
 	.db	DSCR_ENDPOINT_TYPE
-	.db	0x86				;  ep6 dir=in and address
-	.db	ENDPOINT_TYPE_BULK	; type
+	.db	0x86				; ep6 dir=in and address
+	.db	ENDPOINT_TYPE_BULK		; type
 	.db	0x00				; max packet LSB
 	.db	0x02				; max packet size=512 bytes
 	.db	0x00				; polling interval
     ; can't use .dw because byte order is different
 	.db	(fullspd_dscr_realend-_fullspd_dscr) % 256 ; total length of config lsb
 	.db	(fullspd_dscr_realend-_fullspd_dscr) / 256 ; total length of config msb
-	.db	1								 ; n interfaces
+	.db	2								 ; n interfaces
 	.db	1								 ; config number
 	.db	0								 ; config string
 	.db	0x80                             ; attrs = bus powered, no wakeup
 	.db	0				 ; index
 	.db	0				 ; alt setting idx
 	.db	2				 ; n endpoints
-	.db	0xff			 ; class
-	.db	0xff
-	.db	0xff
+	.db	0x2			 ; class
+	.db	0x2
+	.db	0x1
 	.db	3	             ; string index
 
+	; CDC header
+	.db	0x05
+	.db	0x24
+	.db	0x00
+	.db	0x10
+	.db	0x01
+
+	; CDC ACM
+	.db	0x04
+	.db	0x24
+	.db	0x02
+	.db	0x00
+
+	; CDC union
+	.db     0x05
+	.db	0x24
+	.db	0x06
+	.db	0x00
+	.db	0x01
+
+	; CDC call managment
+	.db     0x05
+	.db	0x24
+	.db	0x01
+	.db	0x01
+	.db	0x01
+
+; endpoint 1 in
+	.db	DSCR_ENDPOINT_LEN
+	.db	DSCR_ENDPOINT_TYPE
+	.db	0x81				; ep1 dir=IN and address
+	.db	ENDPOINT_TYPE_INT		; type
+	.db	0x40				; max packet LSB
+	.db	0x00				; max packet size=512 bytes
+	.db	0x40				; polling interval
+
+
+	; data endpoints
+	.db	DSCR_INTERFACE_LEN
+	.db	DSCR_INTERFACE_TYPE
+	.db	0x01				; index
+	.db	0x00				; alt setting idx
+	.db	0x02				; n endpoints
+	.db	0x0a				; class
+	.db	0x00
+	.db	0x00
+	.db	0x00				; string index
+
 ; endpoint 2 out
 	.db	DSCR_ENDPOINT_LEN
 	.db	DSCR_ENDPOINT_TYPE
-	.db	0x02				;  ep2 dir=OUT and address
-	.db	ENDPOINT_TYPE_BULK	; type
+	.db	0x02				; ep2 dir=OUT and address
+	.db	ENDPOINT_TYPE_BULK		; type
 	.db	0x40				; max packet LSB
 	.db	0x00				; max packet size=64 bytes
 	.db	0x00				; polling interval
 	.db	DSCR_ENDPOINT_LEN
 	.db	DSCR_ENDPOINT_TYPE
 	.db	0x86				;  ep6 dir=in and address
-	.db	ENDPOINT_TYPE_BULK	; type
+	.db	ENDPOINT_TYPE_BULK		; type
 	.db	0x40				; max packet LSB
 	.db	0x00				; max packet size=64 bytes
 	.db	0x00				; polling interval