AN050
GD32 USBFS&USBHS Firmware Library User Guide
37
Figure 5-12. DFU state machine flow chart
0
APP_IDLE
1
APP_DETACH
2
DFU_IDLE
3
DFU_DNLOAD_
SYNC
4
DFU_DNBUSY
9
DFU_UPLOAD_
IDLE
Any State
(
except 0 or 1
)
10
DFU_ERROR
5
DFU_DNLOAD_
IDLE
6
DFU_MANIFES
T_SYNC
State
2,3,5,6,9
8
DFU_MANIFES
T_WAIT_RESET
7
DFU_MANIFEST
DFU_DETACH
DETACH TIMEOUT
State
0,1,2,3,5,6,9,10
State
0,1,2,5,9,10
DFU_DETACH
DFU_GETSTATE
DFU_GETSTATUS
DFU_UPLOAD
USB Reset
Any status except OK
Re-enumration
Corrupt
firmware
DFU_CLRSTATUS
Application Program Mode
DFU Program Mode
USB reset
Power On reset
DFU_UPLOAD
bitcanUpload = 1
DFU_UPLOAD
Short Frame
DFU_DOWNLOAD
(
wLenth>0,
bitcanDownload = 1
)
DFU_GETSTATUS
Block complete
DFU_DOWNLOAD
(
wLenth>0
)
DFU_GETSTATUS
Block in process
Status Poll Timeout
Status Poll Timeout
bitManifestationTolerant = 1
Status Poll Timeout
bitManifestationTolerant = 0
DFU_GETSTATUS
(Manifestation in process)
DFU_DOWNLOAD
(
wLenth=0
)
DFU_GETSTATUS
(manifestation complete and
bitManifestationTolerant = 1)
DFU descriptor introduction
Device descriptor include DFU device VID(0x28e9) and PID(0x0189). In configuration
descriptor set, include DFU corresponding descriptor item, which is shown as
Table 5-12
. DFUrelevant descriptors
Descriptor name
Functional description
usb_desc_dfu_func
DFU function descriptor
DFU device class interface
DFU device class interface is shown in below structure, and structure function is shown in