Skip to content

Commit 6245593

Browse files
committed
chore: move common alias functions to usb.go
1 parent 14459df commit 6245593

File tree

5 files changed

+13
-48
lines changed

5 files changed

+13
-48
lines changed

src/machine/machine_atsamd21_usb.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,6 @@ func (dev *USBDevice) SendUSBInPacket(ep uint32, data []byte) bool {
348348
return true
349349
}
350350

351-
func SendUSBInPacket(ep uint32, data []byte) bool {
352-
return USBDev.SendUSBInPacket(ep, data)
353-
}
354-
355351
// Prevent file size increases: https://github.com/tinygo-org/tinygo/pull/998
356352
//
357353
//go:noinline
@@ -432,18 +428,10 @@ func (dev *USBDevice) AckUsbOutTransfer(ep uint32) {
432428
setEPSTATUSCLR(ep, sam.USB_DEVICE_EPSTATUSCLR_BK0RDY)
433429
}
434430

435-
func AckUsbOutTransfer(ep uint32) {
436-
USBDev.AckUsbOutTransfer(ep)
437-
}
438-
439431
func (dev *USBDevice) SendZlp() {
440432
usbEndpointDescriptors[0].DeviceDescBank[1].PCKSIZE.ClearBits(usb_DEVICE_PCKSIZE_BYTE_COUNT_Mask << usb_DEVICE_PCKSIZE_BYTE_COUNT_Pos)
441433
}
442434

443-
func SendZlp() {
444-
USBDev.SendZlp()
445-
}
446-
447435
func epPacketSize(size uint16) uint32 {
448436
switch size {
449437
case 8:

src/machine/machine_atsamd51_usb.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,6 @@ func (dev *USBDevice) SendUSBInPacket(ep uint32, data []byte) bool {
351351
return true
352352
}
353353

354-
func SendUSBInPacket(ep uint32, data []byte) bool {
355-
return USBDev.SendUSBInPacket(ep, data)
356-
}
357-
358354
// Prevent file size increases: https://github.com/tinygo-org/tinygo/pull/998
359355
//
360356
//go:noinline
@@ -435,18 +431,10 @@ func (dev *USBDevice) AckUsbOutTransfer(ep uint32) {
435431
setEPSTATUSCLR(ep, sam.USB_DEVICE_ENDPOINT_EPSTATUSCLR_BK0RDY)
436432
}
437433

438-
func AckUsbOutTransfer(ep uint32) {
439-
USBDev.AckUsbOutTransfer(ep)
440-
}
441-
442434
func (dev *USBDevice) SendZlp() {
443435
usbEndpointDescriptors[0].DeviceDescBank[1].PCKSIZE.ClearBits(usb_DEVICE_PCKSIZE_BYTE_COUNT_Mask << usb_DEVICE_PCKSIZE_BYTE_COUNT_Pos)
444436
}
445437

446-
func SendZlp() {
447-
USBDev.SendZlp()
448-
}
449-
450438
func epPacketSize(size uint16) uint32 {
451439
switch size {
452440
case 8:

src/machine/machine_nrf52840_usb.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,6 @@ func (dev *USBDevice) SendUSBInPacket(ep uint32, data []byte) bool {
264264
return true
265265
}
266266

267-
func SendUSBInPacket(ep uint32, data []byte) bool {
268-
return USBDev.SendUSBInPacket(ep, data)
269-
}
270-
271267
// Prevent file size increases: https://github.com/tinygo-org/tinygo/pull/998
272268
//
273269
//go:noinline
@@ -313,18 +309,10 @@ func (dev *USBDevice) AckUsbOutTransfer(ep uint32) {
313309
nrf.USBD.SIZE.EPOUT[ep].Set(0)
314310
}
315311

316-
func AckUsbOutTransfer(ep uint32) {
317-
USBDev.AckUsbOutTransfer(ep)
318-
}
319-
320312
func (dev *USBDevice) SendZlp() {
321313
nrf.USBD.TASKS_EP0STATUS.Set(1)
322314
}
323315

324-
func SendZlp() {
325-
USBDev.SendZlp()
326-
}
327-
328316
// Set ENDPOINT_HALT/stall status on a USB IN endpoint.
329317
func (dev *USBDevice) SetStallEPIn(ep uint32) {
330318
// Bit 8 is STALL, Bit 7 is IO (1 for IN), Bits 0-2 are EP number.

src/machine/machine_rp2_usb.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,6 @@ func (dev *USBDevice) SendUSBInPacket(ep uint32, data []byte) bool {
7676
return true
7777
}
7878

79-
func SendUSBInPacket(ep uint32, data []byte) bool {
80-
return USBDev.SendUSBInPacket(ep, data)
81-
}
82-
8379
// Prevent file size increases: https://github.com/tinygo-org/tinygo/pull/998
8480
//
8581
//go:noinline
@@ -138,10 +134,6 @@ func (dev *USBDevice) AckUsbOutTransfer(ep uint32) {
138134
setEPDataPID(ep, !epXdata0[ep])
139135
}
140136

141-
func AckUsbOutTransfer(ep uint32) {
142-
USBDev.AckUsbOutTransfer(ep)
143-
}
144-
145137
// Set the USB endpoint Packet ID to DATA0 or DATA1.
146138
func setEPDataPID(ep uint32, dataOne bool) {
147139
epXdata0[ep] = dataOne
@@ -156,10 +148,6 @@ func (dev *USBDevice) SendZlp() {
156148
sendUSBPacket(0, []byte{}, 0)
157149
}
158150

159-
func SendZlp() {
160-
USBDev.SendZlp()
161-
}
162-
163151
func sendViaEPIn(ep uint32, data []byte, count int) {
164152
// Prepare buffer control register value
165153
val := uint32(count) | usbBuf0CtrlAvail

src/machine/usb.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,3 +371,16 @@ func (d *USBDevice) ConfigureUSBEndpoint(desc descriptor.Descriptor, epSettings
371371
usbSetupHandler[s.Index] = s.Handler
372372
}
373373
}
374+
375+
// Old usb functions kept for compatibility
376+
func AckUsbOutTransfer(ep uint32) {
377+
USBDev.AckUsbOutTransfer(ep)
378+
}
379+
380+
func SendUSBInPacket(ep uint32, data []byte) bool {
381+
return USBDev.SendUSBInPacket(ep, data)
382+
}
383+
384+
func SendZlp() {
385+
USBDev.SendZlp()
386+
}

0 commit comments

Comments
 (0)