
AT32F435/437
Series Reference Manual
2022.11.11
Page 426
Rev 2.03
10.
Configure the HFIR register according to the selected PHY clock value
11.
Select the size of the receive FIFO by setting the OTGFS_GRXFSIZ register
12.
Select the start address and size of the non-periodic transmit FIFO by setting the
OTGFS_GNPTXFSIZ register
13.
Select the start address and size of the periodic transmit FIFO by setting the OTGFS_HPTXFSIZ
register
To communicate with the device, the application must enable and initialize at least one channel according
to OTGFS channel initialization requirements.
21.5.3.2 OTGFS channel initialization
To communicate with the device, the application must enable and initialize at least one channel according
to the following steps:
1. Unmask the following interrupts by setting the OTGFS_GINTMSK register:
Non-periodic transmit FIFO empty for OUT transfers
Non-periodic transmit FIFO half empty for OUT transfers
2.
Unmask the interrupts of the selected channels by setting the OTGFS_HAINTMSK register
3.
Unmask the transfer-related interrupts in the host channel interrupt register by setting the
OTGFS_HCINTMSKx register
4.
Configure the total transfer size (in bytes), and the expected number of the packets (including short
packets) for the OTGFS_HCTSIZx register of the selected channel. The application must configure
the PID bit according to the initial data PID (it is the PID on the first OUT transfer, or to be received
from the first IN transfer)
5.
Configure the transfer size to ensure that the transfer size of the channel is a multiple of the largest
packet size
6.
Configure the OTGFS_HCCHARx register of the selected channel according to the device endpoint
characteristics such as type, speed and direction (the channel cannot be enabled by setting the
enable bit until the application is ready for packet transfer or reception)
21.5.3.3 Halting a channel
The application can disable a channel by writing 0x1 to the CHDIS and CHENA bits in the
OTGFS_HCCHARx register. This enables the host to refresh the summited requests (if any) and
generates a channel halted interrupt. The application cannot re-allocate channels for other transactions
until an interrupt is generated in the OTGFS_HCINTx register (CHHLTD bit). Those transactions that
have already been started on the USB line are not interrupted by the host.
Before disabling a channel, the application must ensure that there is at least one free space available in
the non-periodic request queue (when disabling a non-period channel) or the periodic request queue
(when disabling a periodic channel). The application can refresh the submitted requests when the
request queue is full (before disabling the channel) by setting CHDIS=0x1, and CHENA=0 in the
OTGFS_HCCHARx register.
When there is a transaction input in the request queue, the controller will trigger a RXFLVL interrupt. The
application must generate a channel halted interrupt through the OTGFS_GRXSTSP register.
The application is expected to abort a channel on any of the following conditions:
When an interrupt (XFERC bit) is received in the OTGFS_HCINTx register during a non-periodic
IN transfer
When an STALL , XACTERR , BBLERR or DTGLERR interrupt in the OTGFS_HCINTx register
is received for an IN or OUT channel
When a DISCONINT (device disconnected) interrupt event is received in the OTGFS_GINTSTS
register, the application must check the PRTCONSTS bit in the OTGFS_HPRT register. This is
because when the device is disconnected with the host, the PRTCONSTS bit will be reset in the
OTGFS_HPRT register. The application must initiate a software reset to ensure that all channels
have been cleared. Once the device is reconnected, the host must start a USB reset.
When the application needs to abort a transfer before normal completion