AN050
GD32 USBFS&USBHS Firmware Library User Guide
53
Interrupt Flag
Description
Operation Mode
HCIF
Host channels interrupt flag
Host Mode
HPIF
Host port interrupt flag
Host Mode
ISOONCIF/PXNCIF Periodic transfer Not Complete Interrupt
flag /Isochronous OUT transfer Not
Complete Interrupt Flag
Host or device mode
NPTXFEIF
Non-Periodic Tx FIFO empty interrupt
flag
Host Mode
RXFNEIF
Rx FIFO non-empty interrupt flag
Host or device mode
SOF
Start of frame
Host or device mode
OTGIF
OTG interrupt flag
Host or device mode
MFIF
Mode fault interrupt flag
Host or device mode
Data receiving processing is mainly implemented in below function
static
uint32_t
usbh_int_rxfifonoempty
(
usb_core_driver
*
udev
)
{
uint32_t
count
=
0U
;
__IO
uint8_t
pp_num
=
0U
;
__IO
uint32_t
rx_stat
=
0U
;
/* disable the RX status queue level interrupt */
udev
->
regs
.
gr
->
GINTEN
&=
~
GINTEN_RXFNEIE
;
rx_stat
=
udev
->
regs
.
gr
->
GRSTATP
;
pp_num
=
(
uint8_t
)(
rx_stat
&
GRSTATRP_CNUM
);
switch
((
rx_stat
&
GRSTATRP_RPCKST
)
>>
17U
)
{
case
GRXSTS_PKTSTS_IN
:
count
=
(
rx_stat
&
GRSTATRP_BCOUNT
)
>>
4U
;
/* read the data into the host buffer. */
if
((
count
>
0U
)
&&
(
NULL
!=
udev
->
host
.
pipe
[
pp_num
].
xfer_buf
))
{
(
void
)
usb_rxfifo_read
(&
udev
->
regs
,
udev
->
host
.
pipe
[
pp_num
].
xfer_buf
,
(
uint16_t
)
count
); // read FIFO
/* manage multiple transfer packet */
udev
->
host
.
pipe
[
pp_num
].
xfer_buf
+=
count
;
udev
->
host
.
pipe
[
pp_num
].
xfer_count
+=
count
;
udev
->
host
.
backup_xfercount
[
pp_num
]
=
udev
->
host
.
pipe
[
pp_num
].
xfer_count
;
if
(
udev
->
regs
.
pr
[
pp_num
]->
HCHLEN
&
HCHLEN_PCNT
)
{
/* re-activate the channel when more packets are expected */