Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

CYW943907AEVAL1F USB Host Application Explained

lock attach
Attachments are accessible only for community members.

CYW943907AEVAL1F USB Host Application Explained

PriyaM_16
Moderator
Moderator
Moderator
250 replies posted 100 replies posted 50 replies posted

This blog discusses how to configure CYW943907AEVAL1F as a USB host and connect a USB device to it. In this blog, we are connecting a HID mouse to CYW943907AEVAL1F. The attached snip application will initialize USB host class driver to get USB mouse position and mouse key input by the user and print the XY-axis position and button pressed on WICED console.

To test USB host functionality, download the usb_host_hid_mouse snip attached to this blog post. Extract and add the downloaded folder in apps folder of WICED Studio 6.0 or later.

To evaluate USB operation on CYW943907AEVAL1F board, some hardware modifications are needed. Refer to blog post Hardware connections for USB evaluation on CYW943907AEVAL1F for the required changes. You won't be able to program the board with micro USB provided after the hardware modifications are done. You can use Olimex ARM-USB-TINY-H debugger or J-Link Segger to program the CYW943907AEVAL1F EVK.

Make the hardware connections to connect Olimex ARM-USB-TINY-H debugger with CYW943907AEVAL1F board as discussed in post OpenOCD -WICED.

To program your device using JTAG, install the drivers using zadig. Connect Olimex debugger and CYW943907AEVAL1F board to your PC/laptop. You can see JTAG device detected in Device Manager as follows.

pastedImage_1.png

For downloading the application, make the target as follows:

usb_host_hid_mouse-CYW943907AEVAL1F JTAG=Olimex_ARM-USB-TINY-H download run

Connect a mouse to the host through a Micro USB-B to Female type-A connector.

pastedImage_0.png

The WICED console should show the initialization as follows:

pastedImage_2.png

Connect the mouse to the port. The console should show connection details and device enumerations.

pastedImage_4.png

Type hid_mouse to start the test. You should be able to see the XY-axis coordinates and button state on the console:

pastedImage_5.png

The APIs available to configure CYW943907AEVAL1F as USB host are:

1. wiced_result_t wiced_usb_host_init( wiced_usb_user_config_t *config )

This function calls the following USBX driver APIs to initialize USB host:

  • ux_host_stack_initialize(UINT (*system_change_function) (ULONG, UX_HOST_CLASS *)) to initialize the USB host stack.
  • ux_host_stack_class_register(CHAR_PTR class_name, UINT (*class_entry_address) (struct UX_HOST_CLASS_COMMAND_STRUCT *)) to register a USB class to the USB stack. This API is used to register all the host class drivers for USBX implementation. For eg. HUB class, Storage class, HID class, audio class, CDC-ACM class, etc.
  • ux_host_stack_hcd_register(CHAR_PTR hcd_name, UINT (*hcd_function)(struct UX_HCD_STRUCT *), ULONG hcd_param1, ULONG hcd_param2) to register a USB controller to the USB stack. It mainly allocates the memory used by this controller and passes the initialization command to the controller. This API is used to register all the USB20 Host controllers available in the system i.e., OHCI, EHCI

2. static wiced_result_t usb_host_app_event_handler( uint32_t event, void *param1, void *param2 )

This function is an event handler which is called on the occurrence of events like insertion or removal of USB device.

There is an event callback function(wiced_usb_host_usbx_host_evt_callback) in ux_host_stack_initialize. Upon occurrence of an event, wiced_usb_host_usbx_host_evt_callback is called which in turn calls usb_host_app_event_handler to notify the user about specific event.

Attachments
1517 Views
Comments
kima_3203171
Level 1
Level 1

We are testing usb host hid mouse with CYW954907AEVAL1F. However, connecting mouse after initialization does not do anything.

I will ask what is the problem.

Do I need to modify my software?
Or is the hardware wrong?


CYW954907.jpgmouse.jpg

console message.jpg

Contributors