Skip to content

Commit d926cac

Browse files
committed
chore: EPINTENSET doesn't need special handling
1 parent dc0a715 commit d926cac

File tree

2 files changed

+25
-71
lines changed

2 files changed

+25
-71
lines changed

src/machine/machine_atsamd21_usb.go

Lines changed: 16 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func initEndpoint(ep, config uint32) {
224224
setEPCFGEPType1(ep, (usb.ENDPOINT_TYPE_INTERRUPT + 1))
225225

226226
// Set interrupt enable
227-
setEPINTENSETTRCPT1(ep, sam.USB_DEVICE_EPINTENSET_TRCPT1)
227+
setEPINTENSET(ep, sam.USB_DEVICE_EPINTENSET_TRCPT1)
228228

229229
case usb.ENDPOINT_TYPE_BULK | usb.EndpointOut:
230230
// set packet size
@@ -237,7 +237,7 @@ func initEndpoint(ep, config uint32) {
237237
setEPCFGEPType0(ep, (usb.ENDPOINT_TYPE_BULK + 1))
238238

239239
// receive interrupts when current transfer complete
240-
setEPINTENSETTRCPT0(ep, sam.USB_DEVICE_EPINTENSET_TRCPT0)
240+
setEPINTENSET(ep, sam.USB_DEVICE_EPINTENSET_TRCPT0)
241241

242242
// set byte count to zero, we have not received anything yet
243243
usbEndpointDescriptors[ep].DeviceDescBank[0].PCKSIZE.ClearBits(usb_DEVICE_PCKSIZE_BYTE_COUNT_Mask << usb_DEVICE_PCKSIZE_BYTE_COUNT_Pos)
@@ -256,7 +256,7 @@ func initEndpoint(ep, config uint32) {
256256
setEPCFGEPType0(ep, (usb.ENDPOINT_TYPE_INTERRUPT + 1))
257257

258258
// receive interrupts when current transfer complete
259-
setEPINTENSETTRCPT0(ep, sam.USB_DEVICE_EPINTENSET_TRCPT0)
259+
setEPINTENSET(ep, sam.USB_DEVICE_EPINTENSET_TRCPT0)
260260

261261
// set byte count to zero, we have not received anything yet
262262
usbEndpointDescriptors[ep].DeviceDescBank[0].PCKSIZE.ClearBits(usb_DEVICE_PCKSIZE_BYTE_COUNT_Mask << usb_DEVICE_PCKSIZE_BYTE_COUNT_Pos)
@@ -278,7 +278,7 @@ func initEndpoint(ep, config uint32) {
278278
setEPSTATUSCLR(ep, sam.USB_DEVICE_EPSTATUSCLR_BK1RDY)
279279

280280
// Set interrupt enable
281-
setEPINTENSETTRCPT1(ep, sam.USB_DEVICE_EPINTENSET_TRCPT1)
281+
setEPINTENSET(ep, sam.USB_DEVICE_EPINTENSET_TRCPT1)
282282

283283
case usb.ENDPOINT_TYPE_CONTROL:
284284
// Control OUT
@@ -312,7 +312,7 @@ func initEndpoint(ep, config uint32) {
312312
setEPSTATUSSET(ep, sam.USB_DEVICE_EPSTATUSSET_BK0RDY)
313313

314314
// Enable Setup-Received interrupt
315-
setEPINTENSETRXSTP(0, sam.USB_DEVICE_EPINTENSET_RXSTP)
315+
setEPINTENSET(0, sam.USB_DEVICE_EPINTENSET_RXSTP)
316316
}
317317
}
318318

@@ -486,6 +486,7 @@ func getEPCFG(ep uint32) uint8 {
486486
}
487487
}
488488

489+
// Configure output endpoint in EPCFG
489490
func setEPCFGEPType0(ep uint32, val uint8) {
490491
switch ep {
491492
case 0:
@@ -509,6 +510,7 @@ func setEPCFGEPType0(ep uint32, val uint8) {
509510
}
510511
}
511512

513+
// Configure input endpoint in EPCFG
512514
func setEPCFGEPType1(ep uint32, val uint8) {
513515
switch ep {
514516
case 0:
@@ -670,67 +672,25 @@ func setEPINTENCLR(ep uint32, val uint8) {
670672
}
671673
}
672674

673-
func setEPINTENSETRXSTP(ep uint32, val uint8) {
675+
func setEPINTENSET(ep uint32, val uint8) {
674676
switch ep {
675677
case 0:
676-
sam.USB_DEVICE.SetEPINTENSET0_RXSTP(val)
678+
sam.USB_DEVICE.EPINTENSET0.Set(val)
677679
case 1:
678-
sam.USB_DEVICE.SetEPINTENSET1_RXSTP(val)
680+
sam.USB_DEVICE.EPINTENSET1.Set(val)
679681
case 2:
680-
sam.USB_DEVICE.SetEPINTENSET2_RXSTP(val)
682+
sam.USB_DEVICE.EPINTENSET2.Set(val)
681683
case 3:
682-
sam.USB_DEVICE.SetEPINTENSET3_RXSTP(val)
684+
sam.USB_DEVICE.EPINTENSET3.Set(val)
683685
case 4:
684-
sam.USB_DEVICE.SetEPINTENSET4_RXSTP(val)
686+
sam.USB_DEVICE.EPINTENSET4.Set(val)
685687
case 5:
686-
sam.USB_DEVICE.SetEPINTENSET5_RXSTP(val)
688+
sam.USB_DEVICE.EPINTENSET5.Set(val)
687689
case 6:
688-
sam.USB_DEVICE.SetEPINTENSET6_RXSTP(val)
690+
sam.USB_DEVICE.EPINTENSET6.Set(val)
689691
case 7:
690-
sam.USB_DEVICE.SetEPINTENSET7_RXSTP(val)
692+
sam.USB_DEVICE.EPINTENSET7.Set(val)
691693
default:
692694
return
693695
}
694696
}
695-
696-
func setEPINTENSETTRCPT0(ep uint32, val uint8) {
697-
switch ep {
698-
case 0:
699-
sam.USB_DEVICE.SetEPINTENSET0_TRCPT0(val)
700-
case 1:
701-
sam.USB_DEVICE.SetEPINTENSET1_TRCPT0(val)
702-
case 2:
703-
sam.USB_DEVICE.SetEPINTENSET2_TRCPT0(val)
704-
case 3:
705-
sam.USB_DEVICE.SetEPINTENSET3_TRCPT0(val)
706-
case 4:
707-
sam.USB_DEVICE.SetEPINTENSET4_TRCPT0(val)
708-
case 5:
709-
sam.USB_DEVICE.SetEPINTENSET5_TRCPT0(val)
710-
case 6:
711-
sam.USB_DEVICE.SetEPINTENSET6_TRCPT0(val)
712-
case 7:
713-
sam.USB_DEVICE.SetEPINTENSET7_TRCPT0(val)
714-
}
715-
}
716-
717-
func setEPINTENSETTRCPT1(ep uint32, val uint8) {
718-
switch ep {
719-
case 0:
720-
sam.USB_DEVICE.SetEPINTENSET0_TRCPT1(val)
721-
case 1:
722-
sam.USB_DEVICE.SetEPINTENSET1_TRCPT1(val)
723-
case 2:
724-
sam.USB_DEVICE.SetEPINTENSET2_TRCPT1(val)
725-
case 3:
726-
sam.USB_DEVICE.SetEPINTENSET3_TRCPT1(val)
727-
case 4:
728-
sam.USB_DEVICE.SetEPINTENSET4_TRCPT1(val)
729-
case 5:
730-
sam.USB_DEVICE.SetEPINTENSET5_TRCPT1(val)
731-
case 6:
732-
sam.USB_DEVICE.SetEPINTENSET6_TRCPT1(val)
733-
case 7:
734-
sam.USB_DEVICE.SetEPINTENSET7_TRCPT1(val)
735-
}
736-
}

src/machine/machine_atsamd51_usb.go

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ func initEndpoint(ep, config uint32) {
227227
setEPCFGEPType1(ep, (usb.ENDPOINT_TYPE_INTERRUPT + 1))
228228

229229
// Set interrupt enable
230-
setEPINTENSETTRCPT1(ep, sam.USB_DEVICE_ENDPOINT_EPINTENSET_TRCPT1)
230+
setEPINTENSET(ep, sam.USB_DEVICE_ENDPOINT_EPINTENSET_TRCPT1)
231231

232232
case usb.ENDPOINT_TYPE_BULK | usb.EndpointOut:
233233
// set packet size
@@ -240,7 +240,7 @@ func initEndpoint(ep, config uint32) {
240240
setEPCFGEPType0(ep, (usb.ENDPOINT_TYPE_BULK + 1))
241241

242242
// receive interrupts when current transfer complete
243-
setEPINTENSETTRCPT0(ep, sam.USB_DEVICE_ENDPOINT_EPINTENSET_TRCPT0)
243+
setEPINTENSET(ep, sam.USB_DEVICE_ENDPOINT_EPINTENSET_TRCPT0)
244244

245245
// set byte count to zero, we have not received anything yet
246246
usbEndpointDescriptors[ep].DeviceDescBank[0].PCKSIZE.ClearBits(usb_DEVICE_PCKSIZE_BYTE_COUNT_Mask << usb_DEVICE_PCKSIZE_BYTE_COUNT_Pos)
@@ -259,7 +259,7 @@ func initEndpoint(ep, config uint32) {
259259
setEPCFGEPType0(ep, (usb.ENDPOINT_TYPE_INTERRUPT + 1))
260260

261261
// receive interrupts when current transfer complete
262-
setEPINTENSETTRCPT0(ep, sam.USB_DEVICE_ENDPOINT_EPINTENSET_TRCPT0)
262+
setEPINTENSET(ep, sam.USB_DEVICE_ENDPOINT_EPINTENSET_TRCPT0)
263263

264264
// set byte count to zero, we have not received anything yet
265265
usbEndpointDescriptors[ep].DeviceDescBank[0].PCKSIZE.ClearBits(usb_DEVICE_PCKSIZE_BYTE_COUNT_Mask << usb_DEVICE_PCKSIZE_BYTE_COUNT_Pos)
@@ -281,7 +281,7 @@ func initEndpoint(ep, config uint32) {
281281
setEPSTATUSCLR(ep, sam.USB_DEVICE_ENDPOINT_EPSTATUSCLR_BK1RDY)
282282

283283
// Set interrupt enable
284-
setEPINTENSETTRCPT1(ep, sam.USB_DEVICE_ENDPOINT_EPINTENSET_TRCPT1)
284+
setEPINTENSET(ep, sam.USB_DEVICE_ENDPOINT_EPINTENSET_TRCPT1)
285285

286286
case usb.ENDPOINT_TYPE_CONTROL:
287287
// Control OUT
@@ -315,7 +315,7 @@ func initEndpoint(ep, config uint32) {
315315
setEPSTATUSSET(ep, sam.USB_DEVICE_ENDPOINT_EPSTATUSSET_BK0RDY)
316316

317317
// Enable Setup-Received interrupt
318-
setEPINTENSETRXSTP(0, sam.USB_DEVICE_ENDPOINT_EPINTENSET_RXSTP)
318+
setEPINTENSET(0, sam.USB_DEVICE_ENDPOINT_EPINTENSET_RXSTP)
319319
}
320320
}
321321

@@ -470,10 +470,12 @@ func getEPCFG(ep uint32) uint8 {
470470
return sam.USB_DEVICE.DEVICE_ENDPOINT[ep].EPCFG.Get()
471471
}
472472

473+
// Configure output endpoint in EPCFG
473474
func setEPCFGEPType0(ep uint32, val uint8) {
474475
sam.USB_DEVICE.DEVICE_ENDPOINT[ep].SetEPCFG_EPTYPE0(val)
475476
}
476477

478+
// Configure input endpoint in EPCFG
477479
func setEPCFGEPType1(ep uint32, val uint8) {
478480
sam.USB_DEVICE.DEVICE_ENDPOINT[ep].SetEPCFG_EPTYPE1(val)
479481
}
@@ -502,14 +504,6 @@ func setEPINTENCLR(ep uint32, val uint8) {
502504
sam.USB_DEVICE.DEVICE_ENDPOINT[ep].EPINTENCLR.Set(val)
503505
}
504506

505-
func setEPINTENSETRXSTP(ep uint32, val uint8) {
506-
sam.USB_DEVICE.DEVICE_ENDPOINT[ep].SetEPINTENSET_RXSTP(val)
507-
}
508-
509-
func setEPINTENSETTRCPT0(ep uint32, val uint8) {
510-
sam.USB_DEVICE.DEVICE_ENDPOINT[ep].SetEPINTENSET_TRCPT0(val)
511-
}
512-
513-
func setEPINTENSETTRCPT1(ep uint32, val uint8) {
514-
sam.USB_DEVICE.DEVICE_ENDPOINT[ep].SetEPINTENSET_TRCPT1(val)
507+
func setEPINTENSET(ep uint32, val uint8) {
508+
sam.USB_DEVICE.DEVICE_ENDPOINT[ep].EPINTENSET.Set(val)
515509
}

0 commit comments

Comments
 (0)