1 /* This tests the case where the hub has no power switching. Specific test case
2 is in ux_host_class_hub_ports_power.c. */
3
4 #include "usbx_ux_test_hub.h"
5
6 static unsigned char hub_descriptor_no_power_switching[] = {
7
8 /* Hub Descriptor */
9 0x09, /* bLength */
10 0x29, /* bDescriptorType */
11 0x02, /* bNbrPorts */
12 0x09 | UX_HOST_CLASS_HUB_NO_POWER_SWITCHING, 0x00, /* wHubCharacteristics - no power switching */
13 0x32, /* bPwrOn2PwrGood */
14 0x01, /* bHubContrCurrent */
15 0x00, /* DeviceRemovable */
16 0xff, /* PortPwrCtrlMask */
17
18 };
19
20 static DEVICE_INIT_DATA device_init_data = {
21 .dont_enumerate = 1,
22 .hub_descriptor = hub_descriptor_no_power_switching,
23 .hub_descriptor_length = sizeof(hub_descriptor_no_power_switching),
24 };
25
26 #ifdef CTEST
test_application_define(void * first_unused_memory)27 void test_application_define(void *first_unused_memory)
28 #else
29 void usbx_hub_no_power_switching_test_application_define(void *first_unused_memory)
30 #endif
31 {
32
33 /* Inform user. */
34 printf("Running Hub No Power Switching Test................................. ");
35
36 stepinfo("\n");
37
38 initialize_hub_with_device_init_data(first_unused_memory, &device_init_data);
39 }
40
post_init_host()41 static void post_init_host()
42 {
43
44 /* Add action to match PORT_POWER request. We shouldn't match it, since USBX should never send it. */
45
46 UX_TEST_SETUP port_power_setup = {0};
47 port_power_setup.ux_test_setup_request = UX_SET_FEATURE;
48 port_power_setup.ux_test_setup_type = UX_REQUEST_OUT | UX_REQUEST_TYPE_CLASS | UX_REQUEST_TARGET_OTHER;
49 port_power_setup.ux_test_setup_value = UX_HOST_CLASS_HUB_PORT_POWER;
50
51 UX_TEST_ACTION port_power_match_action = {0};
52 port_power_match_action.usbx_function = UX_TEST_OVERRIDE_UX_HCD_SIM_HOST_ENTRY;
53 port_power_match_action.function = UX_HCD_TRANSFER_REQUEST;
54 port_power_match_action.req_action = UX_TEST_SETUP_MATCH_REQUEST | UX_TEST_SETUP_MATCH_VALUE;
55 port_power_match_action.req_setup = &port_power_setup;
56 port_power_match_action.no_return = 1;
57
58 ux_test_add_action_to_main_list(port_power_match_action);
59
60 UX_TEST_CHECK_SUCCESS(ux_host_stack_hcd_register(_ux_system_host_hcd_simulator_name, _ux_test_hcd_sim_host_initialize, 0, 0));
61 ux_test_wait_for_enum_thread_completion();
62
63 /* Make sure the action ws not matched. */
64 UX_TEST_ASSERT(ux_test_check_actions_empty() == UX_FALSE);
65
66 /* Good. Now clear the actions. */
67 ux_test_clear_main_list_actions();
68 }
69
post_init_device()70 static void post_init_device()
71 {
72 }