Interrupt Service Routine (ISR) Flowcharts
13-89
USB Function Module
Figure 13–15. Setup Interrupt Handler
Setup stage handler
End of setup
stage handler
Is a control read
Parse command
Yes
Write Non-ISO TX
FIFO Data
Enable NAK interrupt
by setting
SYSCON1.Nak_En to
1 if not enabled.
Decrement wlenght_
count by number of
bytes written.
Is the request
legal and
supported?
Yes
Set
SYSCON2.Stall_Cm
d to 1 to stall next
EP0 transaction.
wlength_count
>0 ?
Ready to
receive
data?
Want to
go out of
the ISR?
Set
CTRL.Set_FIFO_En
to 1.
Wait until ready
to receive.
Set CTRL.
Set_FIFO_En to 1.
Prepare for control
write stage status
wlength_count =
wlenght
Application-specific
action to cancel any
ongoing transfer
Clear control
flags.
Set control
write flag.
Set control
read flag.
No
No
No
Write EP_NUM register:
– EP_NUM.EP_Num = 0
– EP_NUM.EP_Dir = 0
– EP_NUM.EP_Sel = 0
– EP_NUM.Setup_Sel = 0
Yes
Yes
Yes
No
Write EP_NUM register:
– EP_NUM.EP_Num = 0
– EP_NUM.EP_Dir = 1
– EP_NUM.EP_Sel = 1
– EP_NUM.Setup_Sel = 0
Write EP_NUM register:
– EP_NUM.EP_Num = 0
– EP_NUM.EP_Dir = 1
– EP_NUM.EP_Sel = 0
– EP_NUM.Setup_Sel = 0
?
No