@@ -8,6 +8,11 @@ import (
88 "machine/usb/descriptor"
99)
1010
11+ const (
12+ EPxIN = usb .MIDI_ENDPOINT_IN
13+ EPxOUT = usb .MIDI_ENDPOINT_OUT
14+ )
15+
1116func init () {
1217 // vial-gui requires the following magic word.
1318 usb .Serial = "vial:f64c2b3c"
@@ -42,19 +47,19 @@ func init() {
4247 // Descriptor Length: 34 bytes (0x0022)
4348
4449 // Endpoint Descriptor
45- 0x07 , 0x05 , 0x86 , 0x03 , 0x20 , 0x00 , 0x01 ,
50+ 0x07 , 0x05 , 0x80 | EPxIN , 0x03 , 0x20 , 0x00 , 0x01 ,
4651 // Length: 7 bytes
4752 // Descriptor Type: Endpoint (0x05)
48- // Endpoint Address: 0x86 (Endpoint 6 , IN direction)
53+ // Endpoint Address: 0x8x (Endpoint X , IN direction)
4954 // Attributes: 3 (Interrupt transfer type)
5055 // Maximum Packet Size: 32 bytes (0x0020)
5156 // Interval: 1 ms
5257
5358 // Endpoint Descriptor
54- 0x07 , 0x05 , 0x07 , 0x03 , 0x20 , 0x00 , 0x01 ,
59+ 0x07 , 0x05 , 0x00 | EPxOUT , 0x03 , 0x20 , 0x00 , 0x01 ,
5560 // Length: 7 bytes
5661 // Descriptor Type: Endpoint (0x05)
57- // Endpoint Address: 0x07 (Endpoint 7 , OUT direction)
62+ // Endpoint Address: 0x0x (Endpoint X , OUT direction)
5863 // Attributes: 3 (Interrupt transfer type)
5964 // Maximum Packet Size: 32 bytes (0x0020)
6065 // Interval: 1 ms
@@ -83,13 +88,13 @@ func init() {
8388 machine .ConfigureUSBEndpoint (descriptor .CDCHID ,
8489 []usb.EndpointConfig {
8590 {
86- Index : usb . MIDI_ENDPOINT_OUT ,
91+ Index : EPxOUT ,
8792 IsIn : false ,
8893 Type : usb .ENDPOINT_TYPE_INTERRUPT ,
8994 RxHandler : rxHandler ,
9095 },
9196 {
92- Index : usb . MIDI_ENDPOINT_IN ,
97+ Index : EPxIN ,
9398 IsIn : true ,
9499 Type : usb .ENDPOINT_TYPE_INTERRUPT ,
95100 },
@@ -278,7 +283,7 @@ func rxHandler2(b []byte) bool {
278283 default :
279284 return false
280285 }
281- machine .SendUSBInPacket (6 , txb [:32 ])
286+ machine .SendUSBInPacket (EPxIN , txb [:32 ])
282287 //fmt.Printf("Tx % X\n", txb[:32])
283288
284289 return true
0 commit comments