@@ -255,7 +255,7 @@ func initEndpoint(ep, config uint32) {
255255}
256256
257257// SendUSBInPacket sends a packet for USBHID (interrupt in / bulk in).
258- func SendUSBInPacket (ep uint32 , data []byte ) bool {
258+ func ( dev * USBDevice ) SendUSBInPacket (ep uint32 , data []byte ) bool {
259259 sendUSBPacket (ep , data , 0 )
260260
261261 // clear transfer complete flag
@@ -264,6 +264,10 @@ func 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+
267271// Prevent file size increases: https://github.com/tinygo-org/tinygo/pull/998
268272//
269273//go:noinline
@@ -304,15 +308,47 @@ func handleEndpointRx(ep uint32) []byte {
304308}
305309
306310// AckUsbOutTransfer is called to acknowledge the completion of a USB OUT transfer.
307- func AckUsbOutTransfer (ep uint32 ) {
311+ func ( dev * USBDevice ) AckUsbOutTransfer (ep uint32 ) {
308312 // set ready for next data
309313 nrf .USBD .SIZE .EPOUT [ep ].Set (0 )
310314}
311315
312- func SendZlp () {
316+ func AckUsbOutTransfer (ep uint32 ) {
317+ USBDev .AckUsbOutTransfer (ep )
318+ }
319+
320+ func (dev * USBDevice ) SendZlp () {
313321 nrf .USBD .TASKS_EP0STATUS .Set (1 )
314322}
315323
324+ func SendZlp () {
325+ USBDev .SendZlp ()
326+ }
327+
328+ // Set ENDPOINT_HALT/stall status on a USB IN endpoint.
329+ func (dev * USBDevice ) SetStallEPIn (ep uint32 ) {
330+ // Bit 8 is STALL, Bit 7 is IO (1 for IN), Bits 0-2 are EP number.
331+ nrf .USBD .EPSTALL .Set ((1 << 8 ) | (1 << 7 ) | (ep & 0x7 ))
332+ }
333+
334+ // Set ENDPOINT_HALT/stall status on a USB OUT endpoint.
335+ func (dev * USBDevice ) SetStallEPOut (ep uint32 ) {
336+ // Bit 8 is STALL, Bit 7 is IO (0 for OUT), Bits 0-2 are EP number.
337+ nrf .USBD .EPSTALL .Set ((1 << 8 ) | (0 << 7 ) | (ep & 0x7 ))
338+ }
339+
340+ // Clear the ENDPOINT_HALT/stall on a USB IN endpoint.
341+ func (dev * USBDevice ) ClearStallEPIn (ep uint32 ) {
342+ // Bit 8 is STALL (0 for UnStall), Bit 7 is IO (1 for IN), Bits 0-2 are EP number.
343+ nrf .USBD .EPSTALL .Set ((0 << 8 ) | (1 << 7 ) | (ep & 0x7 ))
344+ }
345+
346+ // Clear the ENDPOINT_HALT/stall on a USB OUT endpoint.
347+ func (dev * USBDevice ) ClearStallEPOut (ep uint32 ) {
348+ // Bit 8 is STALL (0 for UnStall), Bit 7 is IO (0 for OUT), Bits 0-2 are EP number.
349+ nrf .USBD .EPSTALL .Set ((0 << 8 ) | (0 << 7 ) | (ep & 0x7 ))
350+ }
351+
316352func sendViaEPIn (ep uint32 , ptr * byte , count int ) {
317353 nrf .USBD .EPIN [ep ].PTR .Set (
318354 uint32 (uintptr (unsafe .Pointer (ptr ))),
0 commit comments