Changeset 8f62b0f in mainline for uspace/lib/usb/src/hcdhubd.c
- Timestamp:
- 2010-11-21T22:52:34Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f0da4eb2
- Parents:
- c4ba29c7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/hcdhubd.c
rc4ba29c7 r8f62b0f 34 34 */ 35 35 #include <usb/hcdhubd.h> 36 #include <usb/devreq.h> 36 37 #include <usbhc_iface.h> 37 38 #include <driver.h> … … 55 56 .interfaces[USBHC_DEV_IFACE] = &usb_interface 56 57 }; 58 59 static void set_hub_address(usb_hc_device_t *hc, usb_address_t address); 57 60 58 61 /** Callback when new device is detected and must be handled by this driver. … … 98 101 return EOK; 99 102 } else { 103 usb_hc_device_t *hc = list_get_instance(hc_list.next, usb_hc_device_t, link); 104 set_hub_address(hc, 5); 105 100 106 /* 101 107 * We are some (probably deeply nested) hub. … … 103 109 * connected devices. 104 110 */ 111 105 112 return ENOTSUP; 106 113 } 114 } 115 116 /** Sample usage of usb_hc_async functions. 117 * This function sets hub address using standard SET_ADDRESS request. 118 * 119 * @warning This function shall be removed once you are familiar with 120 * the usb_hc_ API. 121 * 122 * @param hc Host controller the hub belongs to. 123 * @param address New hub address. 124 */ 125 static void set_hub_address(usb_hc_device_t *hc, usb_address_t address) 126 { 127 printf("%s: setting hub address to %d\n", hc->generic->name, address); 128 usb_target_t target = {0, 0}; 129 usb_handle_t handle; 130 int rc; 131 132 usb_device_request_setup_packet_t setup_packet = { 133 .request_type = 0, 134 .request = USB_DEVREQ_SET_ADDRESS, 135 .index = 0, 136 .length = 0, 137 }; 138 setup_packet.value = address; 139 140 rc = usb_hc_async_control_write_setup(hc, target, 141 &setup_packet, sizeof(setup_packet), &handle); 142 if (rc != EOK) { 143 return; 144 } 145 146 rc = usb_hc_async_wait_for(handle); 147 if (rc != EOK) { 148 return; 149 } 150 151 rc = usb_hc_async_control_write_status(hc, target, &handle); 152 if (rc != EOK) { 153 return; 154 } 155 156 rc = usb_hc_async_wait_for(handle); 157 if (rc != EOK) { 158 return; 159 } 160 161 printf("%s: hub address changed\n", hc->generic->name); 107 162 } 108 163 … … 211 266 212 267 /* 213 * For testing/debugging purposes only.214 * Try to send some data to default USB address.215 */216 usb_target_t target = {0, 0};217 usb_handle_t handle = 0;218 char *data = (char *) "Hello, World!";219 220 221 (void)usb_hc_async_interrupt_out(dev, target, data, str_length(data), &handle);222 (void)usb_hc_async_wait_for(handle);223 224 /*225 268 * Announce presence of child device. 226 269 */
Note:
See TracChangeset
for help on using the changeset viewer.