Changeset 040ab02 in mainline for uspace/drv/usbhub/port_status.h
- Timestamp:
- 2011-04-05T19:45:52Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 90d0522
- Parents:
- 3bb6b35
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbhub/port_status.h
r3bb6b35 r040ab02 49 49 50 50 /** 51 * structure holding hub status and changes flags. 52 * should not be accessed directly, use supplied getter/setter methods. 53 * 54 * For more information refer to table 11.16.2.5 in 55 * "Universal Serial Bus Specification Revision 1.1" 56 * 57 */ 58 typedef uint32_t usb_hub_status_t; 59 60 /** 51 61 * set values in request to be it a port status request 52 62 * @param request … … 58 68 request->index = port; 59 69 request->request_type = USB_HUB_REQ_TYPE_GET_PORT_STATUS; 70 request->request = USB_HUB_REQUEST_GET_STATUS; 71 request->value = 0; 72 request->length = 4; 73 } 74 75 /** 76 * set values in request to be it a port status request 77 * @param request 78 * @param port 79 */ 80 static inline void usb_hub_set_hub_status_request( 81 usb_device_request_setup_packet_t * request 82 ){ 83 request->index = 0; 84 request->request_type = USB_HUB_REQ_TYPE_GET_HUB_STATUS; 60 85 request->request = USB_HUB_REQUEST_GET_STATUS; 61 86 request->value = 0; … … 242 267 } 243 268 269 /** get i`th bit of hub status */ 270 static inline bool usb_hub_get_bit(usb_hub_status_t * status, int idx) 271 { 272 return (((*status)>>(idx))%2); 273 } 274 275 /** set i`th bit of hub status */ 276 static inline void usb_hub_set_bit( 277 usb_hub_status_t * status, int idx, bool value) 278 { 279 (*status) = value? 280 ((*status)|(1<<(idx))): 281 ((*status)&(~(1<<(idx)))); 282 } 283 284 244 285 //device connnected on port 245 286 static inline bool usb_port_dev_connected(usb_port_status_t * status){ … … 368 409 } 369 410 411 //local power status 412 static inline bool usb_hub_local_power_lost(usb_hub_status_t * status){ 413 return usb_hub_get_bit(status,0); 414 } 415 416 static inline void usb_hub_set_local_power_lost(usb_port_status_t * status, 417 bool power_lost){ 418 usb_hub_set_bit(status,0,power_lost); 419 } 420 421 //over current ocndition 422 static inline bool usb_hub_over_current(usb_hub_status_t * status){ 423 return usb_hub_get_bit(status,1); 424 } 425 426 static inline void usb_hub_set_over_current(usb_port_status_t * status, 427 bool over_current){ 428 usb_hub_set_bit(status,1,over_current); 429 } 430 431 //local power change 432 static inline bool usb_hub_local_power_change(usb_hub_status_t * status){ 433 return usb_hub_get_bit(status,16); 434 } 435 436 static inline void usb_hub_set_local_power_change(usb_port_status_t * status, 437 bool change){ 438 usb_hub_set_bit(status,16,change); 439 } 440 441 //local power status 442 static inline bool usb_hub_over_current_change(usb_hub_status_t * status){ 443 return usb_hub_get_bit(status,17); 444 } 445 446 static inline void usb_hub_set_over_current_change(usb_port_status_t * status, 447 bool change){ 448 usb_hub_set_bit(status,17,change); 449 } 370 450 371 451
Note:
See TracChangeset
for help on using the changeset viewer.