Changeset df6ded8 in mainline for uspace/lib/usb/include/usb/usb.h
- Timestamp:
- 2018-02-28T16:37:50Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1b20da0
- Parents:
- f5e5f73 (diff), b2dca8de (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Jakub Jermar <jakub@…> (2018-02-28 16:06:42)
- git-committer:
- Jakub Jermar <jakub@…> (2018-02-28 16:37:50)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/usb.h
rf5e5f73 rdf6ded8 1 1 /* 2 2 * Copyright (c) 2010 Vojtech Horky 3 * Copyright (c) 2018 Ondrej Hlavaty, Michal Staruch 3 4 * All rights reserved. 4 5 * … … 39 40 #include <stdint.h> 40 41 #include <types/common.h> 41 #include <usb _iface.h>42 #include <usbhc_iface.h> 42 43 43 44 /** Convert 16bit value from native (host) endianness to USB endianness. */ … … 53 54 #define uint32_usb2host(n) uint32_t_le2host((n)) 54 55 55 const char * usb_str_transfer_type(usb_transfer_type_tt);56 const char * usb_str_transfer_type_short(usb_transfer_type_tt);56 const char *usb_str_transfer_type(usb_transfer_type_t); 57 const char *usb_str_transfer_type_short(usb_transfer_type_t); 57 58 58 59 const char *usb_str_direction(usb_direction_t); … … 61 62 { 62 63 return (s == USB_SPEED_FULL) || (s == USB_SPEED_LOW); 64 } 65 66 static inline bool usb_speed_is_valid(const usb_speed_t s) 67 { 68 return (s >= USB_SPEED_LOW) && (s < USB_SPEED_MAX); 63 69 } 64 70 … … 97 103 static inline bool usb_address_is_valid(usb_address_t a) 98 104 { 99 return (a >= USB_ADDRESS_DEFAULT) && (a <= USB11_ADDRESS_MAX);105 return a <= USB11_ADDRESS_MAX; 100 106 } 101 107 … … 103 109 #define USB_ENDPOINT_DEFAULT_CONTROL 0 104 110 105 /** Maximum endpoint number in USB 1.1. */ 106 #define USB11_ENDPOINT_MAX 16 111 /** Maximum endpoint number in USB */ 112 #define USB_ENDPOINT_MAX 16 113 114 /** There might be two directions for every endpoint number (except 0) */ 115 #define USB_ENDPOINT_COUNT (2 * USB_ENDPOINT_MAX) 107 116 108 117 /** Check USB endpoint for allowed values. … … 115 124 static inline bool usb_endpoint_is_valid(usb_endpoint_t ep) 116 125 { 117 return (ep >= USB_ENDPOINT_DEFAULT_CONTROL) && 118 (ep < USB11_ENDPOINT_MAX); 126 return ep < USB_ENDPOINT_MAX; 119 127 } 120 128 121 /** Check USB target for allowed values (address and endpoint). 129 /** 130 * Check USB target for allowed values (address, endpoint, stream). 122 131 * 123 132 * @param target. 124 133 * @return True, if values are wihtin limits, false otherwise. 125 134 */ 126 static inline bool usb_target_is_valid( usb_target_ttarget)135 static inline bool usb_target_is_valid(const usb_target_t *target) 127 136 { 128 return usb_address_is_valid(target.address) && 129 usb_endpoint_is_valid(target.endpoint); 137 return usb_address_is_valid(target->address) && 138 usb_endpoint_is_valid(target->endpoint); 139 140 // A 16-bit Stream ID is always valid. 130 141 } 131 142 … … 136 147 * @return Whether @p a and @p b points to the same pipe on the same device. 137 148 */ 138 static inline intusb_target_same(usb_target_t a, usb_target_t b)149 static inline bool usb_target_same(usb_target_t a, usb_target_t b) 139 150 { 140 return (a.address == b.address) 141 && (a.endpoint == b.endpoint); 151 return (a.address == b.address) && (a.endpoint == b.endpoint); 142 152 } 143 144 /** General handle type.145 * Used by various USB functions as opaque handle.146 */147 typedef sysarg_t usb_handle_t;148 153 149 154 /** USB packet identifier. */ … … 161 166 USB_PID_SETUP = _MAKE_PID(3, 1), 162 167 163 USB_PID_DATA0 = _MAKE_PID(0 ,3),164 USB_PID_DATA1 = _MAKE_PID(2 ,3),168 USB_PID_DATA0 = _MAKE_PID(0, 3), 169 USB_PID_DATA1 = _MAKE_PID(2, 3), 165 170 166 USB_PID_ACK = _MAKE_PID(0 ,2),167 USB_PID_NAK = _MAKE_PID(2 ,2),168 USB_PID_STALL = _MAKE_PID(3 ,2),171 USB_PID_ACK = _MAKE_PID(0, 2), 172 USB_PID_NAK = _MAKE_PID(2, 2), 173 USB_PID_STALL = _MAKE_PID(3, 2), 169 174 170 USB_PID_PRE = _MAKE_PID(3 ,0),175 USB_PID_PRE = _MAKE_PID(3, 0), 171 176 /* USB_PID_ = _MAKE_PID( ,), */ 172 177 #undef _MAKE_PID
Note:
See TracChangeset
for help on using the changeset viewer.