AT32WB415
Series Reference Manual
2022.04.13
Page 322
Ver 2.00
20.5.4.17
Enable synchronous endpoints
After sending a Set interface control command to the device, a host enables the synchronous endpoints.
Then the host can send the initial synchronous IN token in any frame before transmission in the
sequence of BInterval.
Instead, synchronous support in the OTGFS controller is based on a single-transfer level. The application
must re-configure the controller on every frame. The OTGFS controller enables the synchronous
endpoint of the frame before the frame to be transmitted.
For example, to send data on the frame n, enable the endpoint of the frame n-1. Additionally, the OTGFS
controller schedules the synchronous transfers by setting Even/Odd frame bits.
【
Synchronous
IN tramsfer interrupt
】
The following interrupts must be processed to ensure successful scheduling of the synchronous
transfers.
XFERC interrupt in the OTGFS_DIEPINTx register (for endpoints)
OTG INCOMPISOIN interrupt in the OTGFS_GINTSTS register (for global interrupts)
【
Handling synchronous IN transfers
】
The following steps must be performed to handle a synchroniys IN transfer:
1. Unmask the incompISOOUT interrupt in the OTGFS_GINTSTS register by setting the
INCOMISOINMSK interrupt bit in the OTGFS_GINTMSK register
2. Unmask the XFERC interrupt in the OTGFS_DIEPINTx register by setting the XFERCMSK bit in the
OTGFS_DIEPMSK register
3. Enable synchronous endpoints with the following steps:
Program the OTGFS_DIEPTSIZx register
OTGFS_DIEPTSIZx.XFERSIZE= n * OTGFS_DIEPCTLx.MPS + sp, where 0 <= n <= 3 and 0 <=
sp <OTGFS_DIEPCTLx.MPS. When the transfer size in a frame is less than that of the MPS bit in
the OTGFS_DIEPCTLx register, n=0; When the transfer size in a frame is a multiple of that of the
MPS bit in the OTGFS_DIEPCTLx register, sp=0.
OTGFS_DIEPTSIZx.PKTCNT = 0x1
The MC bit in the OTGFS_DIEPTSIZx register is set the same value as that of the PKTCNT bit in
the OTGFS_DIEPTSIZx register.
Program the OTGFS_DIEPCTLx register
Read the OTGFS_DSTS register to determine the current frame number
Program the OTGFS_DIEPCTLx with the maximum packet size (MPS bit)
Set USBACTEP = 0x1 in the OTGFS_DIEPCTLx register
Set EPTYPE = 0x1 in the OTGFS_DIEPCTLx register, marking synchornization
Set the FIFO number of the endpoint through the TXFNUM bit in the OTGFS_DIEPCTLx register
Set CNAK = 0x1 in the OTGFS_DIEPCTLx register
If.SOFFN[0] = 0x0 in OTGFS_DSTS, then SETEVENFR = 0x1 in OTGFS_DIEPCTLx (otherwise,
SETEVENFR = 0x1 in OTGFS_DIEPCTLx)
If SOFFN[0] = 0x1 in OTGFS_DSTS, then SETODDFR = 0x1 in OTGFS_DIEPCTLx (otherwise,
SETODDFR = 0x0 in OTGFS_DIEPCTLx)
Set EPENA = 0x1 in OTGFS_DIEPCTLx
4. Write endpoint data to the corresponding transmit FIFO
For example, write address ranges are as follows:
EP1 corresponding to 0x2000 - 0x2FFC
EP2 corresponding to 0x3000 - 0x3FFC
EP3 corresponding to 0x3000 - 0x3FFC
...
5. Wait for interrupts