Changeset 48a31be in mainline
- Timestamp:
- 2011-09-23T12:30:34Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- aff1880
- Parents:
- d6e2938
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhub/port_status.h
rd6e2938 r48a31be 56 56 #define USB_HUB_PORT_STATUS_POWER (1 << (USB_HUB_FEATURE_PORT_POWER)) 57 57 #define USB_HUB_PORT_STATUS_LOW_SPEED (1 << (USB_HUB_FEATURE_PORT_LOW_SPEED)) 58 #define USB_HUB_PORT_STATUS_HIGH_SPEED (1 << 10) 58 59 59 60 #define USB_HUB_PORT_C_STATUS_CONNECTION \ … … 122 123 123 124 /** 124 * set the device request to be a port enable request125 * @param request126 * @param port127 */128 static inline void usb_hub_set_enable_port_request(129 usb_device_request_setup_packet_t *request, uint16_t port130 ) {131 request->index = port;132 request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;133 request->request = USB_HUB_REQUEST_SET_FEATURE;134 request->value = USB_HUB_FEATURE_C_PORT_ENABLE;135 request->length = 0;136 }137 138 /**139 * enable specified port140 * @param port141 * @return142 */143 static inline usb_device_request_setup_packet_t *144 usb_hub_create_enable_port_request(uint16_t port) {145 usb_device_request_setup_packet_t *result =146 malloc(sizeof (usb_device_request_setup_packet_t));147 usb_hub_set_enable_port_request(result, port);148 return result;149 }150 151 /**152 * set the device request to be a port disable request153 * @param request154 * @param port155 */156 static inline void usb_hub_set_disable_port_request(157 usb_device_request_setup_packet_t *request, uint16_t port158 ) {159 request->index = port;160 request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;161 request->request = USB_HUB_REQUEST_SET_FEATURE;162 request->value = USB_HUB_FEATURE_C_PORT_SUSPEND;163 request->length = 0;164 }165 166 /**167 * disable specified port168 * @param port169 * @return170 */171 static inline usb_device_request_setup_packet_t *172 usb_hub_create_disable_port_request(uint16_t port) {173 usb_device_request_setup_packet_t *result =174 malloc(sizeof (usb_device_request_setup_packet_t));175 usb_hub_set_disable_port_request(result, port);176 return result;177 }178 179 /**180 125 * set the device request to be a port disable request 181 126 * @param request … … 193 138 194 139 /** 195 * disable specified port196 * @param port197 * @return198 */199 static inline usb_device_request_setup_packet_t *200 usb_hub_create_reset_port_request(uint16_t port) {201 usb_device_request_setup_packet_t *result =202 malloc(sizeof (usb_device_request_setup_packet_t));203 usb_hub_set_reset_port_request(result, port);204 return result;205 }206 207 /**208 * set the device request to be a port disable request209 * @param request210 * @param port211 */212 static inline void usb_hub_set_power_port_request(213 usb_device_request_setup_packet_t *request, uint16_t port214 ) {215 request->index = port;216 request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;217 request->request = USB_HUB_REQUEST_SET_FEATURE;218 request->value = USB_HUB_FEATURE_PORT_POWER;219 request->length = 0;220 }221 222 /**223 * set the device request to be a port disable request224 * @param request225 * @param port226 */227 static inline void usb_hub_unset_power_port_request(228 usb_device_request_setup_packet_t *request, uint16_t port229 ) {230 request->index = port;231 request->request_type = USB_HUB_REQ_TYPE_SET_PORT_FEATURE;232 request->request = USB_HUB_REQUEST_CLEAR_FEATURE;233 request->value = USB_HUB_FEATURE_PORT_POWER;234 request->length = 0;235 }236 237 /**238 140 * get i`th bit of port status 239 141 * … … 247 149 248 150 /** 249 * set i`th bit of port status250 *251 * @param status252 * @param idx253 * @param value254 */255 static inline void usb_port_status_set_bit(256 usb_port_status_t * status, int idx, bool value) {257 (*status) = value ?258 ((*status) | (1 << (idx))) :259 ((*status)&(~(1 << (idx))));260 }261 262 /**263 * get i`th bit of hub status264 *265 * @param status266 * @param idx267 * @return268 */269 static inline bool usb_hub_is_status(usb_hub_status_t status, int idx) {270 return (status & (1 << idx)) != 0;271 }272 273 /**274 * set i`th bit of hub status275 *276 * @param status277 * @param idx278 * @param value279 */280 static inline void usb_hub_status_set_bit(281 usb_hub_status_t *status, int idx, bool value) {282 (*status) = value ?283 ((*status) | (1 << (idx))) :284 ((*status)&(~(1 << (idx))));285 }286 287 /**288 * low speed device on the port indicator289 *290 * @param status291 * @return true if low speed device is attached292 */293 static inline bool usb_port_low_speed(usb_port_status_t status) {294 return usb_port_is_status(status, 9);295 }296 297 /**298 * set low speed device connected bit in port status299 *300 * @param status301 * @param low_speed value of the bit302 */303 static inline void usb_port_set_low_speed(usb_port_status_t *status, bool low_speed) {304 usb_port_status_set_bit(status, 9, low_speed);305 }306 307 //high speed device attached308 309 /**310 * high speed device on the port indicator311 *312 * @param status313 * @return true if high speed device is on port314 */315 static inline bool usb_port_high_speed(usb_port_status_t status) {316 return usb_port_is_status(status, 10);317 }318 319 /**320 * set high speed device bit in port status321 *322 * @param status323 * @param high_speed value of the bit324 */325 static inline void usb_port_set_high_speed(usb_port_status_t *status, bool high_speed) {326 usb_port_status_set_bit(status, 10, high_speed);327 }328 329 /**330 151 * speed getter for port status 331 152 * … … 334 155 */ 335 156 static inline usb_speed_t usb_port_speed(usb_port_status_t status) { 336 if ( usb_port_low_speed(status))157 if ((status & USB_HUB_PORT_STATUS_LOW_SPEED) != 0) 337 158 return USB_SPEED_LOW; 338 if ( usb_port_high_speed(status))159 if ((status & USB_HUB_PORT_STATUS_HIGH_SPEED) != 0) 339 160 return USB_SPEED_HIGH; 340 161 return USB_SPEED_FULL;
Note:
See TracChangeset
for help on using the changeset viewer.