AN050
GD32 USBFS&USBHS Firmware Library User Guide
24
return
1U
;
}
In OUT endpoint interrupt handler function, depending on the interrupt flag register,
out_endp_intr function judge the event of OUT endpoint interrupt, which include transfer
finished interrupt and setup phase finished interrupt. After corresponding OUT endpoint
interrupt event generated, MCU execute the corresponding interrupt handler function through
polling interrupt flag.
The interrupt handler function of IN endpoint is shown as below:
static
uint32_t
usbd_int_epin
(
usb_core_driver
*
udev
)
{
uint32_t
epintnum
=
0U
;
uint8_t
ep_num
=
0U
;
for
(
epintnum
=
usb_iepintnum_read
(
udev
);
epintnum
;
epintnum
>>=
1
,
ep_num
++)
{
if
(
epintnum
&
0x1U
)
{
__IO
uint32_t
iepintr
=
usb_iepintr_read
(
udev
,
ep_num
);
if
(
iepintr
&
DIEPINTF_TF
)
{
udev
->
regs
.
er_in
[
ep_num
]->
DIEPINTF
=
DIEPINTF_TF
;
/* data transmission is completed */
(
void
)
usbd_in_transc
(
udev
,
ep_num
); // IN
transaction
if
((
uint8_t
)
USB_USE_DMA
==
udev
->
bp
.
transfer_mode
)
{
if
((
0U
==
ep_num
)
&&
((
uint8_t
)
USB_CTL_STATUS_IN
==
udev
->
dev
.
control
.
ctl_state
))
{
usb_ctlep_startout
(
udev
);
}
}
}
if
(
iepintr
&
DIEPINTF_TXFE
)
{
usbd_emptytxfifo_write
(
udev
,
(
uint32_t
)
ep_num
); // write FIFO
udev
->
regs
.
er_in
[
ep_num
]->
DIEPINTF
=
DIEPINTF_TXFE
;
}
}
}
return
1U
;
}