Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 98d06b8 in mainline for uspace/drv/usbhub/port_status.h


Ignore:
Timestamp:
2010-12-10T15:11:24Z (11 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master
Children:
c01255c
Parents:
b5ec347
Message:

hub driver:
connect a new device
init a hub

File:
1 edited

Legend:

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

    rb5ec347 r98d06b8  
    4343 *
    4444 */
    45 typedef uint8_t usb_port_status_t[4];
     45typedef uint32_t usb_port_status_t;
    4646
    4747/**
     
    103103}
    104104
     105/**
     106 * set the device request to be a port disable request
     107 * @param request
     108 * @param port
     109 */
     110static inline void usb_hub_set_disable_port_request(
     111usb_device_request_setup_packet_t * request, uint16_t port
     112){
     113        request->index = port;
     114        request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;
     115        request->request = USB_HUB_REQUEST_SET_FEATURE;
     116        request->value = USB_HUB_FEATURE_C_PORT_SUSPEND;
     117        request->length = 0;
     118}
     119
     120/**
     121 * disable specified port
     122 * @param port
     123 * @return
     124 */
     125static inline usb_device_request_setup_packet_t *
     126usb_hub_create_disable_port_request(uint16_t port){
     127        usb_device_request_setup_packet_t * result =
     128                usb_new(usb_device_request_setup_packet_t);
     129        usb_hub_set_disable_port_request(result,port);
     130        return result;
     131}
     132
     133/**
     134 * set the device request to be a port disable request
     135 * @param request
     136 * @param port
     137 */
     138static inline void usb_hub_set_reset_port_request(
     139usb_device_request_setup_packet_t * request, uint16_t port
     140){
     141        request->index = port;
     142        request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;
     143        request->request = USB_HUB_REQUEST_SET_FEATURE;
     144        request->value = USB_HUB_FEATURE_PORT_RESET;
     145        request->length = 0;
     146}
     147
     148/**
     149 * disable specified port
     150 * @param port
     151 * @return
     152 */
     153static inline usb_device_request_setup_packet_t *
     154usb_hub_create_reset_port_request(uint16_t port){
     155        usb_device_request_setup_packet_t * result =
     156                usb_new(usb_device_request_setup_packet_t);
     157        usb_hub_set_reset_port_request(result,port);
     158        return result;
     159}
     160
     161/**
     162 * set the device request to be a port disable request
     163 * @param request
     164 * @param port
     165 */
     166static inline void usb_hub_set_power_port_request(
     167usb_device_request_setup_packet_t * request, uint16_t port
     168){
     169        request->index = port;
     170        request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;
     171        request->request = USB_HUB_REQUEST_SET_FEATURE;
     172        request->value = USB_HUB_FEATURE_PORT_POWER;
     173        request->length = 0;
     174}
    105175
    106176/** get i`th bit of port status */
    107177static inline bool usb_port_get_bit(usb_port_status_t * status, int idx)
    108178{
    109         return (((*status)[idx/8])>>(idx%8))%2;
     179        return (((*status)>>(idx))%2);
    110180}
    111181
     
    114184        usb_port_status_t * status, int idx, bool value)
    115185{
    116         (*status)[idx/8] = value?
    117                                ((*status)[idx/8]|(1<<(idx%8))):
    118                                ((*status)[idx/8]&(~(1<<(idx%8))));
     186        (*status) = value?
     187                               ((*status)|(1<<(idx))):
     188                               ((*status)&(~(1<<(idx))));
    119189}
    120190
Note: See TracChangeset for help on using the changeset viewer.