Changeset 040ab02 in mainline for uspace/drv/usbhub/port_status.h


Ignore:
Timestamp:
2011-04-05T19:45:52Z (13 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
90d0522
Parents:
3bb6b35
Message:

usb hub global over-current and power changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhub/port_status.h

    r3bb6b35 r040ab02  
    4949
    5050/**
     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 */
     58typedef uint32_t usb_hub_status_t;
     59
     60/**
    5161 * set values in request to be it a port status request
    5262 * @param request
     
    5868        request->index = port;
    5969        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 */
     80static inline void usb_hub_set_hub_status_request(
     81usb_device_request_setup_packet_t * request
     82){
     83        request->index = 0;
     84        request->request_type = USB_HUB_REQ_TYPE_GET_HUB_STATUS;
    6085        request->request = USB_HUB_REQUEST_GET_STATUS;
    6186        request->value = 0;
     
    242267}
    243268
     269/** get i`th bit of hub status */
     270static 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 */
     276static 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
    244285//device connnected on port
    245286static inline bool usb_port_dev_connected(usb_port_status_t * status){
     
    368409}
    369410
     411//local power status
     412static inline bool usb_hub_local_power_lost(usb_hub_status_t * status){
     413        return usb_hub_get_bit(status,0);
     414}
     415
     416static 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
     422static inline bool usb_hub_over_current(usb_hub_status_t * status){
     423        return usb_hub_get_bit(status,1);
     424}
     425
     426static 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
     432static inline bool usb_hub_local_power_change(usb_hub_status_t * status){
     433        return usb_hub_get_bit(status,16);
     434}
     435
     436static 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
     442static inline bool usb_hub_over_current_change(usb_hub_status_t * status){
     443        return usb_hub_get_bit(status,17);
     444}
     445
     446static 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}
    370450
    371451
Note: See TracChangeset for help on using the changeset viewer.