File tree 9 files changed +36
-17
lines changed
9 files changed +36
-17
lines changed Original file line number Diff line number Diff line change @@ -792,6 +792,10 @@ endif
792
792
@$(MD5SUM) test.hex
793
793
$(TINYGO) build -size short -o test.hex -target=feather-nrf52840 examples/usb-midi
794
794
@$(MD5SUM) test.hex
795
+ $(TINYGO) build -size short -o test.hex -target=pico examples/usb-storage
796
+ @$(MD5SUM) test.hex
797
+ $(TINYGO) build -size short -o test.hex -target=pico2 examples/usb-storage
798
+ @$(MD5SUM) test.hex
795
799
$(TINYGO) build -size short -o test.hex -target=nrf52840-s140v6-uf2-generic examples/machinetest
796
800
@$(MD5SUM) test.hex
797
801
ifneq ($(STM32 ) , 0)
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "machine"
5
+ "machine/usb/msc"
6
+ "time"
7
+ )
8
+
9
+ func main () {
10
+ msc .Port (machine .Flash )
11
+
12
+ for {
13
+ time .Sleep (2 * time .Second )
14
+ }
15
+ }
Original file line number Diff line number Diff line change @@ -179,10 +179,9 @@ func handleUSBIRQ(intr interrupt.Interrupt) {
179
179
setEPINTFLAG (i , epFlags )
180
180
if (epFlags & sam .USB_DEVICE_EPINTFLAG_TRCPT0 ) > 0 {
181
181
buf := handleEndpointRx (i )
182
- if usbRxHandler [i ] != nil {
183
- usbRxHandler [ i ]( buf )
182
+ if usbRxHandler [i ] == nil || usbRxHandler [ i ]( buf ) {
183
+ AckUsbOutTransfer ( i )
184
184
}
185
- handleEndpointRxComplete (i )
186
185
} else if (epFlags & sam .USB_DEVICE_EPINTFLAG_TRCPT1 ) > 0 {
187
186
if usbTxHandler [i ] != nil {
188
187
usbTxHandler [i ]()
@@ -402,7 +401,8 @@ func handleEndpointRx(ep uint32) []byte {
402
401
return udd_ep_out_cache_buffer [ep ][:count ]
403
402
}
404
403
405
- func handleEndpointRxComplete (ep uint32 ) {
404
+ // AckUsbOutTransfer is called to acknowledge the completion of a USB OUT transfer.
405
+ func AckUsbOutTransfer (ep uint32 ) {
406
406
// set byte count to zero
407
407
usbEndpointDescriptors [ep ].DeviceDescBank [0 ].PCKSIZE .ClearBits (usb_DEVICE_PCKSIZE_BYTE_COUNT_Mask << usb_DEVICE_PCKSIZE_BYTE_COUNT_Pos )
408
408
Original file line number Diff line number Diff line change @@ -182,10 +182,9 @@ func handleUSBIRQ(intr interrupt.Interrupt) {
182
182
setEPINTFLAG (i , epFlags )
183
183
if (epFlags & sam .USB_DEVICE_ENDPOINT_EPINTFLAG_TRCPT0 ) > 0 {
184
184
buf := handleEndpointRx (i )
185
- if usbRxHandler [i ] != nil {
186
- usbRxHandler [ i ]( buf )
185
+ if usbRxHandler [i ] == nil || usbRxHandler [ i ]( buf ) {
186
+ AckUsbOutTransfer ( i )
187
187
}
188
- handleEndpointRxComplete (i )
189
188
} else if (epFlags & sam .USB_DEVICE_ENDPOINT_EPINTFLAG_TRCPT1 ) > 0 {
190
189
if usbTxHandler [i ] != nil {
191
190
usbTxHandler [i ]()
@@ -405,7 +404,8 @@ func handleEndpointRx(ep uint32) []byte {
405
404
return udd_ep_out_cache_buffer [ep ][:count ]
406
405
}
407
406
408
- func handleEndpointRxComplete (ep uint32 ) {
407
+ // AckUsbOutTransfer is called to acknowledge the completion of a USB OUT transfer.
408
+ func AckUsbOutTransfer (ep uint32 ) {
409
409
// set byte count to zero
410
410
usbEndpointDescriptors [ep ].DeviceDescBank [0 ].PCKSIZE .ClearBits (usb_DEVICE_PCKSIZE_BYTE_COUNT_Mask << usb_DEVICE_PCKSIZE_BYTE_COUNT_Pos )
411
411
Original file line number Diff line number Diff line change @@ -193,10 +193,9 @@ func handleUSBIRQ(interrupt.Interrupt) {
193
193
if nrf .USBD .EVENTS_ENDEPOUT [i ].Get () > 0 {
194
194
nrf .USBD .EVENTS_ENDEPOUT [i ].Set (0 )
195
195
buf := handleEndpointRx (uint32 (i ))
196
- if usbRxHandler [i ] != nil {
197
- usbRxHandler [ i ]( buf )
196
+ if usbRxHandler [i ] == nil || usbRxHandler [ i ]( buf ) {
197
+ AckUsbOutTransfer ( uint32 ( i ) )
198
198
}
199
- handleEndpointRxComplete (uint32 (i ))
200
199
exitCriticalSection ()
201
200
}
202
201
}
@@ -291,7 +290,8 @@ func handleEndpointRx(ep uint32) []byte {
291
290
return udd_ep_out_cache_buffer [ep ][:count ]
292
291
}
293
292
294
- func handleEndpointRxComplete (ep uint32 ) {
293
+ // AckUsbOutTransfer is called to acknowledge the completion of a USB OUT transfer.
294
+ func AckUsbOutTransfer (ep uint32 ) {
295
295
// set ready for next data
296
296
nrf .USBD .SIZE .EPOUT [ep ].Set (0 )
297
297
}
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ func handleUSBIRQ(intr interrupt.Interrupt) {
96
96
if s2 & (1 << (i * 2 + 1 )) > 0 {
97
97
buf := handleEndpointRx (uint32 (i ))
98
98
if usbRxHandler [i ] == nil || usbRxHandler [i ](buf ) {
99
- AckEndpointRxMessage (uint32 (i ))
99
+ AckUsbOutTransfer (uint32 (i ))
100
100
}
101
101
}
102
102
}
Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ func handleUSBIRQ(intr interrupt.Interrupt) {
99
99
if s2 & (1 << (i * 2 + 1 )) > 0 {
100
100
buf := handleEndpointRx (uint32 (i ))
101
101
if usbRxHandler [i ] == nil || usbRxHandler [i ](buf ) {
102
- AckEndpointRxMessage (uint32 (i ))
102
+ AckUsbOutTransfer (uint32 (i ))
103
103
}
104
104
}
105
105
}
Original file line number Diff line number Diff line change @@ -115,8 +115,8 @@ func handleEndpointRx(ep uint32) []byte {
115
115
return _usbDPSRAM .EPxBuffer [ep ].Buffer0 [:sz ]
116
116
}
117
117
118
- // AckEndpointRxMessage is called to acknowledge the completion of a delayed USB OUT transfer.
119
- func AckEndpointRxMessage (ep uint32 ) {
118
+ // AckUsbOutTransfer is called to acknowledge the completion of a USB OUT transfer.
119
+ func AckUsbOutTransfer (ep uint32 ) {
120
120
ep = ep & 0x7F
121
121
setEPDataPID (ep , ! epXdata0 [ep ])
122
122
}
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ func (m *msc) processTasks() {
132
132
// Acknowledge the received data from the host
133
133
m .queuedBytes = 0
134
134
m .taskQueued = false
135
- machine .AckEndpointRxMessage (usb .MSC_ENDPOINT_OUT )
135
+ machine .AckUsbOutTransfer (usb .MSC_ENDPOINT_OUT )
136
136
}
137
137
time .Sleep (10 * time .Microsecond )
138
138
}
You can’t perform that action at this time.
0 commit comments