Changeset e34e77a in mainline
- Timestamp:
- 2011-03-21T14:33:50Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1387692
- Parents:
- 68b5ed6e
- Location:
- uspace/lib/usb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/host/device_keeper.h
r68b5ed6e re34e77a 31 31 */ 32 32 /** @file 33 * @brief UHCI driver 33 * Device keeper structure and functions. 34 * 35 * Typical USB host controller needs to keep track of various settings for 36 * each device that is connected to it. 37 * State of toggle bit, device speed etc. etc. 38 * This structure shall simplify the management. 34 39 */ 35 40 #ifndef LIBUSB_HOST_DEVICE_KEEPER_H … … 39 44 #include <usb/usb.h> 40 45 46 /** Number of USB address for array dimensions. */ 41 47 #define USB_ADDRESS_COUNT (USB11_ADDRESS_MAX + 1) 42 48 49 /** Information about attached USB device. */ 43 50 struct usb_device_info { 44 51 usb_speed_t speed; … … 48 55 }; 49 56 57 /** Host controller device keeper. 58 * You shall not access members directly but only using functions below. 59 */ 50 60 typedef struct { 51 61 struct usb_device_info devices[USB_ADDRESS_COUNT]; … … 57 67 void usb_device_keeper_init(usb_device_keeper_t *instance); 58 68 59 void usb_device_keeper_reserve_default_address( 60 usb_ device_keeper_t *instance, usb_speed_t speed);69 void usb_device_keeper_reserve_default_address(usb_device_keeper_t *instance, 70 usb_speed_t speed); 61 71 62 72 void usb_device_keeper_release_default_address(usb_device_keeper_t *instance); 63 73 64 void usb_device_keeper_reset_if_need( 65 usb_ device_keeper_t *instance, usb_target_t target,66 const u nsigned char*setup_data);74 void usb_device_keeper_reset_if_need(usb_device_keeper_t *instance, 75 usb_target_t target, 76 const uint8_t *setup_data); 67 77 68 int usb_device_keeper_get_toggle( 69 usb_ device_keeper_t *instance, usb_target_t target, usb_direction_t direction);78 int usb_device_keeper_get_toggle(usb_device_keeper_t *instance, 79 usb_target_t target, usb_direction_t direction); 70 80 71 81 int usb_device_keeper_set_toggle(usb_device_keeper_t *instance, 72 82 usb_target_t target, usb_direction_t direction, bool toggle); 73 83 74 usb_address_t device_keeper_get_free_address( 75 usb_ device_keeper_t *instance, usb_speed_t speed);84 usb_address_t device_keeper_get_free_address(usb_device_keeper_t *instance, 85 usb_speed_t speed); 76 86 77 void usb_device_keeper_bind( 78 usb_ device_keeper_t *instance, usb_address_t address, devman_handle_t handle);87 void usb_device_keeper_bind(usb_device_keeper_t *instance, 88 usb_address_t address, devman_handle_t handle); 79 89 80 void usb_device_keeper_release(usb_device_keeper_t *instance, usb_address_t address); 90 void usb_device_keeper_release(usb_device_keeper_t *instance, 91 usb_address_t address); 81 92 82 usb_address_t usb_device_keeper_find( 83 usb_device_keeper_t *instance,devman_handle_t handle);93 usb_address_t usb_device_keeper_find(usb_device_keeper_t *instance, 94 devman_handle_t handle); 84 95 85 usb_speed_t usb_device_keeper_get_speed( 86 usb_device_keeper_t *instance, usb_address_t address); 96 usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance, 97 usb_address_t address); 98 87 99 #endif 88 100 /** -
uspace/lib/usb/src/host/device_keeper.c
r68b5ed6e re34e77a 31 31 */ 32 32 /** @file 33 * @brief UHCI driver33 * Device keeper structure and functions (implementation). 34 34 */ 35 35 #include <assert.h> … … 65 65 * @param[in] speed Speed of the device requesting default address. 66 66 */ 67 void usb_device_keeper_reserve_default_address(usb_device_keeper_t *instance, usb_speed_t speed) 67 void usb_device_keeper_reserve_default_address(usb_device_keeper_t *instance, 68 usb_speed_t speed) 68 69 { 69 70 assert(instance); … … 100 101 * Really ugly one. 101 102 */ 102 void usb_device_keeper_reset_if_need( 103 usb_ device_keeper_t *instance, usb_target_t target, const unsigned char*data)103 void usb_device_keeper_reset_if_need(usb_device_keeper_t *instance, 104 usb_target_t target, const uint8_t *data) 104 105 { 105 106 assert(instance); … … 144 145 * @return Error code 145 146 */ 146 int usb_device_keeper_get_toggle( 147 usb_ device_keeper_t *instance, usb_target_t target, usb_direction_t direction)147 int usb_device_keeper_get_toggle(usb_device_keeper_t *instance, 148 usb_target_t target, usb_direction_t direction) 148 149 { 149 150 assert(instance); … … 207 208 * @return Free address, or error code. 208 209 */ 209 usb_address_t device_keeper_get_free_address( 210 usb_ device_keeper_t *instance, usb_speed_t speed)210 usb_address_t device_keeper_get_free_address(usb_device_keeper_t *instance, 211 usb_speed_t speed) 211 212 { 212 213 assert(instance); … … 241 242 * @param[in] handle Devman handle of the device. 242 243 */ 243 void usb_device_keeper_bind( 244 usb_ device_keeper_t *instance, usb_address_t address, devman_handle_t handle)244 void usb_device_keeper_bind(usb_device_keeper_t *instance, 245 usb_address_t address, devman_handle_t handle) 245 246 { 246 247 assert(instance); … … 258 259 * @param[in] address Device address 259 260 */ 260 void usb_device_keeper_release(usb_device_keeper_t *instance, usb_address_t address) 261 void usb_device_keeper_release(usb_device_keeper_t *instance, 262 usb_address_t address) 261 263 { 262 264 assert(instance); … … 276 278 * @return USB Address, or error code. 277 279 */ 278 usb_address_t usb_device_keeper_find( 279 usb_device_keeper_t *instance,devman_handle_t handle)280 usb_address_t usb_device_keeper_find(usb_device_keeper_t *instance, 281 devman_handle_t handle) 280 282 { 281 283 assert(instance); … … 299 301 * @return USB speed. 300 302 */ 301 usb_speed_t usb_device_keeper_get_speed( 302 usb_ device_keeper_t *instance, usb_address_t address)303 usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance, 304 usb_address_t address) 303 305 { 304 306 assert(instance); … … 307 309 return instance->devices[address].speed; 308 310 } 311 309 312 /** 310 313 * @}
Note:
See TracChangeset
for help on using the changeset viewer.