Changeset a90fc0c in mainline
- Timestamp:
- 2011-03-21T15:53:51Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d7186cd
- Parents:
- aaff605
- Location:
- uspace/lib/usb
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/usb.h
raaff605 ra90fc0c 61 61 62 62 const char * usb_str_transfer_type(usb_transfer_type_t t); 63 const char * usb_str_transfer_type_short(usb_transfer_type_t t); 63 64 64 65 /** USB data transfer direction. */ -
uspace/lib/usb/src/usb.c
raaff605 ra90fc0c 36 36 #include <errno.h> 37 37 38 #define ARR_SIZE(arr) (sizeof(arr)/sizeof(arr[0])) 39 38 40 static const char *str_speed[] = { 39 41 "low", … … 41 43 "high" 42 44 }; 43 static size_t str_speed_size = sizeof(str_speed)/sizeof(str_speed[0]); 45 46 static const char *str_transfer_type[] = { 47 "control", 48 "isochronous", 49 "bulk", 50 "interrupt" 51 }; 52 53 static const char *str_transfer_type_short[] = { 54 "ctrl", 55 "iso", 56 "bulk", 57 "intr" 58 }; 44 59 45 60 /** String representation for USB transfer type. … … 48 63 * @return Transfer type as a string (in English). 49 64 */ 50 const char * 65 const char *usb_str_transfer_type(usb_transfer_type_t t) 51 66 { 52 switch (t) { 53 case USB_TRANSFER_ISOCHRONOUS: 54 return "isochronous"; 55 case USB_TRANSFER_INTERRUPT: 56 return "interrupt"; 57 case USB_TRANSFER_CONTROL: 58 return "control"; 59 case USB_TRANSFER_BULK: 60 return "bulk"; 61 default: 62 return "unknown"; 67 if (t >= ARR_SIZE(str_transfer_type)) { 68 return "invalid"; 63 69 } 70 return str_transfer_type[t]; 71 } 72 73 /** String representation for USB transfer type (short version). 74 * 75 * @param t Transfer type. 76 * @return Transfer type as a short string for debugging messages. 77 */ 78 const char *usb_str_transfer_type_short(usb_transfer_type_t t) 79 { 80 if (t >= ARR_SIZE(str_transfer_type_short)) { 81 return "invl"; 82 } 83 return str_transfer_type_short[t]; 64 84 } 65 85 … … 71 91 const char *usb_str_speed(usb_speed_t s) 72 92 { 73 if (s >= str_speed_size) {93 if (s >= ARR_SIZE(str_speed)) { 74 94 return "invalid"; 75 95 }
Note:
See TracChangeset
for help on using the changeset viewer.