Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion builder/sizes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestBinarySize(t *testing.T) {
// microcontrollers
{"hifive1b", "examples/echo", 3817, 299, 0, 2252},
{"microbit", "examples/serial", 2820, 356, 8, 2248},
{"wioterminal", "examples/pininterrupt", 7330, 1550, 120, 7248},
{"wioterminal", "examples/pininterrupt", 7930, 1650, 132, 7472},

// TODO: also check wasm. Right now this is difficult, because
// wasm binaries are run through wasm-opt and therefore the
Expand Down
13 changes: 0 additions & 13 deletions src/machine/machine_atsamd21_usb.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,6 @@ const (
NumberOfUSBEndpoints = 8
)

var (
endPoints = []uint32{
usb.CONTROL_ENDPOINT: usb.ENDPOINT_TYPE_CONTROL,
usb.CDC_ENDPOINT_ACM: (usb.ENDPOINT_TYPE_INTERRUPT | usb.EndpointIn),
usb.CDC_ENDPOINT_OUT: (usb.ENDPOINT_TYPE_BULK | usb.EndpointOut),
usb.CDC_ENDPOINT_IN: (usb.ENDPOINT_TYPE_BULK | usb.EndpointIn),
usb.HID_ENDPOINT_IN: (usb.ENDPOINT_TYPE_DISABLE), // Interrupt In
usb.HID_ENDPOINT_OUT: (usb.ENDPOINT_TYPE_DISABLE), // Interrupt Out
usb.MIDI_ENDPOINT_IN: (usb.ENDPOINT_TYPE_DISABLE), // Bulk In
usb.MIDI_ENDPOINT_OUT: (usb.ENDPOINT_TYPE_DISABLE), // Bulk Out
}
)

// Configure the USB peripheral. The config is here for compatibility with the UART interface.
func (dev *USBDevice) Configure(config UARTConfig) {
if dev.initcomplete {
Expand Down
13 changes: 0 additions & 13 deletions src/machine/machine_atsamd51_usb.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,6 @@ const (
NumberOfUSBEndpoints = 8
)

var (
endPoints = []uint32{
usb.CONTROL_ENDPOINT: usb.ENDPOINT_TYPE_CONTROL,
usb.CDC_ENDPOINT_ACM: (usb.ENDPOINT_TYPE_INTERRUPT | usb.EndpointIn),
usb.CDC_ENDPOINT_OUT: (usb.ENDPOINT_TYPE_BULK | usb.EndpointOut),
usb.CDC_ENDPOINT_IN: (usb.ENDPOINT_TYPE_BULK | usb.EndpointIn),
usb.HID_ENDPOINT_IN: (usb.ENDPOINT_TYPE_DISABLE), // Interrupt In
usb.HID_ENDPOINT_OUT: (usb.ENDPOINT_TYPE_DISABLE), // Interrupt Out
usb.MIDI_ENDPOINT_IN: (usb.ENDPOINT_TYPE_DISABLE), // Bulk In
usb.MIDI_ENDPOINT_OUT: (usb.ENDPOINT_TYPE_DISABLE), // Bulk Out
}
)

// Configure the USB peripheral. The config is here for compatibility with the UART interface.
func (dev *USBDevice) Configure(config UARTConfig) {
if dev.initcomplete {
Expand Down
11 changes: 0 additions & 11 deletions src/machine/machine_nrf52840_usb.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,6 @@ var (
epinen uint32
epouten uint32
easyDMABusy volatile.Register8

endPoints = []uint32{
usb.CONTROL_ENDPOINT: usb.ENDPOINT_TYPE_CONTROL,
usb.CDC_ENDPOINT_ACM: (usb.ENDPOINT_TYPE_INTERRUPT | usb.EndpointIn),
usb.CDC_ENDPOINT_OUT: (usb.ENDPOINT_TYPE_BULK | usb.EndpointOut),
usb.CDC_ENDPOINT_IN: (usb.ENDPOINT_TYPE_BULK | usb.EndpointIn),
usb.HID_ENDPOINT_IN: (usb.ENDPOINT_TYPE_DISABLE), // Interrupt In
usb.HID_ENDPOINT_OUT: (usb.ENDPOINT_TYPE_DISABLE), // Interrupt Out
usb.MIDI_ENDPOINT_IN: (usb.ENDPOINT_TYPE_DISABLE), // Bulk In
usb.MIDI_ENDPOINT_OUT: (usb.ENDPOINT_TYPE_DISABLE), // Bulk Out
}
)

// enterCriticalSection is used to protect access to easyDMA - only one thing
Expand Down
11 changes: 0 additions & 11 deletions src/machine/machine_rp2_usb.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@ var (
data []byte
pid uint32
}

endPoints = []uint32{
usb.CONTROL_ENDPOINT: usb.ENDPOINT_TYPE_CONTROL,
usb.CDC_ENDPOINT_ACM: (usb.ENDPOINT_TYPE_INTERRUPT | usb.EndpointIn),
usb.CDC_ENDPOINT_OUT: (usb.ENDPOINT_TYPE_BULK | usb.EndpointOut),
usb.CDC_ENDPOINT_IN: (usb.ENDPOINT_TYPE_BULK | usb.EndpointIn),
usb.HID_ENDPOINT_IN: (usb.ENDPOINT_TYPE_DISABLE), // Interrupt In
usb.HID_ENDPOINT_OUT: (usb.ENDPOINT_TYPE_DISABLE), // Interrupt Out
usb.MIDI_ENDPOINT_IN: (usb.ENDPOINT_TYPE_DISABLE), // Bulk In
usb.MIDI_ENDPOINT_OUT: (usb.ENDPOINT_TYPE_DISABLE), // Bulk Out
}
)

func initEndpoint(ep, config uint32) {
Expand Down
29 changes: 25 additions & 4 deletions src/machine/usb.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,21 @@ type USBDevice struct {
InitEndpointComplete bool
}

type usbEndpointEntry struct {
Endpoint uint32
Config uint32
}

var (
USBDev = &USBDevice{}
USBCDC Serialer

endPoints = []usbEndpointEntry{
{
Endpoint: usb.CONTROL_ENDPOINT,
Config: usb.ENDPOINT_TYPE_CONTROL,
},
}
)

func initUSB() {
Expand Down Expand Up @@ -277,8 +289,11 @@ func handleStandardSetup(setup usb.Setup) bool {

case usb.SET_CONFIGURATION:
if setup.BmRequestType&usb.REQUEST_RECIPIENT == usb.REQUEST_DEVICE {
for i := 1; i < len(endPoints); i++ {
initEndpoint(uint32(i), endPoints[i])
for _, entry := range endPoints {
if entry.Endpoint == usb.CONTROL_ENDPOINT {
continue
}
initEndpoint(uint32(entry.Endpoint), entry.Config)
}

usbConfiguration = setup.WValueL
Expand Down Expand Up @@ -359,12 +374,18 @@ func ConfigureUSBEndpoint(desc descriptor.Descriptor, epSettings []usb.EndpointC

for _, ep := range epSettings {
if ep.IsIn {
endPoints[ep.Index] = uint32(ep.Type | usb.EndpointIn)
endPoints = append(endPoints, usbEndpointEntry{
Endpoint: uint32(ep.Index),
Config: uint32(ep.Type | usb.EndpointIn),
})
if ep.TxHandler != nil {
usbTxHandler[ep.Index] = ep.TxHandler
}
} else {
endPoints[ep.Index] = uint32(ep.Type | usb.EndpointOut)
endPoints = append(endPoints, usbEndpointEntry{
Endpoint: uint32(ep.Index),
Config: uint32(ep.Type | usb.EndpointOut),
})
if ep.RxHandler != nil {
usbRxHandler[ep.Index] = func(b []byte) bool {
ep.RxHandler(b)
Expand Down
Loading