4.6 USB Host
Hardware Setting
¾
Check if 2,3 of J-USB- and J-USB+ short
¾
Connect with a USB mouse
Flowchart
The following flowchart illuminates the procedure to implement USB host function, which
can catch the position of a USB mouse, it is not a certain flow of a function, but provides
a clue to study and understand the sample code.
Start
Initialize system
clock
Initialize timer
Init USB host
Enumeration
Mouse data
process
Display mouse
data
SystemInit ( )
main ( )
minihost_init( )
USB_Handler ( )
USBF_Handler ( )
get_mouse_data ( )
Main()
Figure 4-9: USB Host Sample Code Flowchart
Usage
1) Make the hardware setting
2) Enable definition “Debug” in the code
3) Run the code.
4) Move the USB mouse, and watch the mouse position in the terminal IO window as
following figure. (Debug viewer window in Keil IDE)
Figure 4-10: USB Mouse Position Display
19