Changeset df6ded8 in mainline for uspace/lib/usb/include


Ignore:
Timestamp:
2018-02-28T16:37:50Z (8 years ago)
Author:
Jakub Jermar <jakub@…>
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)
Message:

Merge github.com:helenos-xhci-team/helenos

This commit merges support for USB 3 and generally refactors, fixes,
extends and cleans up the existing USB framework.

Notable additions and features:

  • new host controller driver has been implemented to control various xHC models (among others, NEC Renesas uPD720200)
  • isochronous data transfer mode
  • support for explicit USB device removal
  • USB tablet driver
Location:
uspace/lib/usb/include/usb
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/classes/hub.h

    rf5e5f73 rdf6ded8  
    11/*
    22 * Copyright (c) 2010 Matus Dekanek
     3 * Copyright (c) 2018 Ondrej Hlavaty
    34 * All rights reserved.
    45 *
     
    4849        USB_HUB_FEATURE_HUB_OVER_CURRENT = 1,
    4950        USB_HUB_FEATURE_PORT_CONNECTION = 0,
    50         USB_HUB_FEATURE_PORT_ENABLE = 1,
    51         USB_HUB_FEATURE_PORT_SUSPEND = 2,
     51        USB2_HUB_FEATURE_PORT_ENABLE = 1,
     52        USB2_HUB_FEATURE_PORT_SUSPEND = 2,
    5253        USB_HUB_FEATURE_PORT_OVER_CURRENT = 3,
    5354        USB_HUB_FEATURE_PORT_RESET = 4,
     55        USB3_HUB_FEATURE_PORT_LINK_STATE = 5,
    5456        USB_HUB_FEATURE_PORT_POWER = 8,
    55         USB_HUB_FEATURE_PORT_LOW_SPEED = 9,
    56         USB_HUB_FEATURE_PORT_HIGH_SPEED = 10,
     57        USB2_HUB_FEATURE_PORT_LOW_SPEED = 9,
    5758        USB_HUB_FEATURE_C_PORT_CONNECTION = 16,
    58         USB_HUB_FEATURE_C_PORT_ENABLE = 17,
    59         USB_HUB_FEATURE_C_PORT_SUSPEND = 18,
     59        USB2_HUB_FEATURE_C_PORT_ENABLE = 17,
     60        USB2_HUB_FEATURE_C_PORT_SUSPEND = 18,
    6061        USB_HUB_FEATURE_C_PORT_OVER_CURRENT = 19,
    6162        USB_HUB_FEATURE_C_PORT_RESET = 20,
    62         USB_HUB_FEATURE_PORT_TEST = 21,
    63         USB_HUB_FEATURE_PORT_INDICATOR = 22
     63        USB2_HUB_FEATURE_PORT_TEST = 21,
     64        USB2_HUB_FEATURE_PORT_INDICATOR = 22,
     65        USB3_HUB_FEATURE_C_PORT_LINK_STATE = 25,
     66        USB3_HUB_FEATURE_BH_PORT_RESET = 28,
     67        USB3_HUB_FEATURE_C_BH_PORT_RESET = 29,
    6468        /* USB_HUB_FEATURE_ = , */
    6569} usb_hub_class_feature_t;
    6670
     71/**
     72 * Dword holding port status and changes flags.
     73 *
     74 * For more information refer to tables 11-15 and 11-16 in
     75 * "Universal Serial Bus Specification Revision 1.1" pages 274 and 277
     76 * (290 and 293 in pdf)
     77 *
     78 * Beware that definition of bits changed between USB 2 and 3,
     79 * so some fields are prefixed with USB2 or USB3 instead.
     80 */
     81typedef uint32_t usb_port_status_t;
     82
     83#define USB_HUB_PORT_STATUS_BIT(bit)  (uint32_usb2host(1 << (bit)))
     84#define USB_HUB_PORT_STATUS_CONNECTION          USB_HUB_PORT_STATUS_BIT(0)
     85#define USB_HUB_PORT_STATUS_ENABLE              USB_HUB_PORT_STATUS_BIT(1)
     86#define USB2_HUB_PORT_STATUS_SUSPEND            USB_HUB_PORT_STATUS_BIT(2)
     87#define USB_HUB_PORT_STATUS_OC                  USB_HUB_PORT_STATUS_BIT(3)
     88#define USB_HUB_PORT_STATUS_RESET               USB_HUB_PORT_STATUS_BIT(4)
     89
     90#define USB2_HUB_PORT_STATUS_POWER              USB_HUB_PORT_STATUS_BIT(8)
     91#define USB2_HUB_PORT_STATUS_LOW_SPEED          USB_HUB_PORT_STATUS_BIT(9)
     92#define USB3_HUB_PORT_STATUS_POWER              USB_HUB_PORT_STATUS_BIT(9)
     93#define USB2_HUB_PORT_STATUS_HIGH_SPEED         USB_HUB_PORT_STATUS_BIT(10)
     94#define USB2_HUB_PORT_STATUS_TEST               USB_HUB_PORT_STATUS_BIT(11)
     95#define USB2_HUB_PORT_STATUS_INDICATOR          USB_HUB_PORT_STATUS_BIT(12)
     96
     97#define USB_HUB_PORT_STATUS_C_CONNECTION        USB_HUB_PORT_STATUS_BIT(16)
     98#define USB2_HUB_PORT_STATUS_C_ENABLE           USB_HUB_PORT_STATUS_BIT(17)
     99#define USB2_HUB_PORT_STATUS_C_SUSPEND          USB_HUB_PORT_STATUS_BIT(18)
     100#define USB_HUB_PORT_STATUS_C_OC                USB_HUB_PORT_STATUS_BIT(19)
     101#define USB_HUB_PORT_STATUS_C_RESET             USB_HUB_PORT_STATUS_BIT(20)
     102#define USB3_HUB_PORT_STATUS_C_BH_RESET         USB_HUB_PORT_STATUS_BIT(21)
     103#define USB3_HUB_PORT_STATUS_C_LINK_STATE       USB_HUB_PORT_STATUS_BIT(22)
     104#define USB3_HUB_PORT_STATUS_C_CONFIG_ERROR     USB_HUB_PORT_STATUS_BIT(23)
    67105
    68106/** Header of standard hub descriptor without the "variadic" part. */
     
    71109        uint8_t length;
    72110
    73         /** Descriptor type (0x29). */
     111        /** Descriptor type (0x29 or 0x2a for superspeed hub). */
    74112        uint8_t descriptor_type;
    75113
     
    116154#define HUB_CHAR_OC_PER_PORT_FLAG       (1 << 3)
    117155#define HUB_CHAR_NO_OC_FLAG             (1 << 4)
     156
     157/* These are invalid for superspeed hub */
    118158#define HUB_CHAR_TT_THINK_16            (1 << 5)
    119159#define HUB_CHAR_TT_THINK_8             (1 << 6)
     
    138178         */
    139179        uint8_t max_current;
    140 } __attribute__ ((packed)) usb_hub_descriptor_header_t;
     180} __attribute__((packed)) usb_hub_descriptor_header_t;
    141181
    142182/** One bit for the device and one bit for every port */
    143183#define STATUS_BYTES(ports) ((1 + ports + 7) / 8)
    144184
    145 /**     @brief usb hub specific request types.
    146  *
    147  *      For more information see Universal Serial Bus Specification Revision 1.1 chapter 11.16.2
     185/**
     186 * @brief usb hub specific request types.
    148187 */
    149188typedef enum {
    150     /** This request resets a value reported in the hub status. */
    151     USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE = 0x20,
    152     /** This request resets a value reported in the port status. */
    153     USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE = 0x23,
    154     /** This is an optional per-port diagnostic request that returns the bus state value, as sampled at the last EOF2 point. */
    155     USB_HUB_REQ_TYPE_GET_STATE = 0xA3,
    156     /** This request returns the hub descriptor. */
    157     USB_HUB_REQ_TYPE_GET_DESCRIPTOR = 0xA0,
    158     /** This request returns the current hub status and the states that have changed since the previous acknowledgment. */
    159     USB_HUB_REQ_TYPE_GET_HUB_STATUS = 0xA0,
    160     /** This request returns the current port status and the current value of the port status change bits. */
    161     USB_HUB_REQ_TYPE_GET_PORT_STATUS = 0xA3,
    162     /** This request overwrites the hub descriptor. */
    163     USB_HUB_REQ_TYPE_SET_DESCRIPTOR = 0x20,
    164     /** This request sets a value reported in the hub status. */
    165     USB_HUB_REQ_TYPE_SET_HUB_FEATURE = 0x20,
    166     /** This request sets a value reported in the port status. */
    167     USB_HUB_REQ_TYPE_SET_PORT_FEATURE = 0x23
     189        /** This request resets a value reported in the hub status. */
     190        USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE = 0x20,
     191        /** This request resets a value reported in the port status. */
     192        USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE = 0x23,
     193        /**
     194         * This is an optional per-port diagnostic request that returns the bus
     195         * state value, as sampled at the last EOF2 point.
     196         */
     197        USB_HUB_REQ_TYPE_GET_STATE = 0xA3,
     198        /** This request returns the hub descriptor. */
     199        USB_HUB_REQ_TYPE_GET_DESCRIPTOR = 0xA0,
     200        /**
     201         * This request returns the current hub status and the states that have
     202         * changed since the previous acknowledgment.
     203         */
     204        USB_HUB_REQ_TYPE_GET_HUB_STATUS = 0xA0,
     205        /**
     206         * This request returns the current port status and the current value of the
     207         * port status change bits.
     208         */
     209        USB_HUB_REQ_TYPE_GET_PORT_STATUS = 0xA3,
     210        /** This request overwrites the hub descriptor. */
     211        USB_HUB_REQ_TYPE_SET_DESCRIPTOR = 0x20,
     212        /** This request sets a value reported in the hub status. */
     213        USB_HUB_REQ_TYPE_SET_HUB_FEATURE = 0x20,
     214        /**
     215         * This request sets the value that the hub uses to determine the index
     216         * into the Route String Index for the hub.
     217         */
     218        USB_HUB_REQ_TYPE_SET_HUB_DEPTH = 0x20,
     219        /** This request sets a value reported in the port status. */
     220        USB_HUB_REQ_TYPE_SET_PORT_FEATURE = 0x23,
    168221} usb_hub_bm_request_type_t;
    169222
    170 /** @brief hub class request codes*/
    171 /// \TODO these are duplicit to standart descriptors
     223/**
     224 * @brief hub class request codes
     225 */
    172226typedef enum {
    173     /**  */
    174     USB_HUB_REQUEST_GET_STATUS = 0,
    175     /** */
    176     USB_HUB_REQUEST_CLEAR_FEATURE = 1,
    177     /** USB 1.0 only */
    178     USB_HUB_REQUEST_GET_STATE = 2,
    179     /** */
    180     USB_HUB_REQUEST_SET_FEATURE = 3,
    181     /** */
    182     USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
    183     /** */
    184     USB_HUB_REQUEST_SET_DESCRIPTOR = 7,
    185     /** */
    186     USB_HUB_REQUEST_CLEAR_TT_BUFFER = 8,
    187     /** */
    188     USB_HUB_REQUEST_RESET_TT = 9,
    189     /** */
    190     USB_HUB_GET_TT_STATE = 10,
    191     /** */
    192     USB_HUB_STOP_TT = 11,
     227        USB_HUB_REQUEST_GET_STATUS = 0,
     228        USB_HUB_REQUEST_CLEAR_FEATURE = 1,
     229        /** USB 1.0 only */
     230        USB_HUB_REQUEST_GET_STATE = 2,
     231        USB_HUB_REQUEST_SET_FEATURE = 3,
     232        USB_HUB_REQUEST_GET_DESCRIPTOR = 6,
     233        USB_HUB_REQUEST_SET_DESCRIPTOR = 7,
     234        USB_HUB_REQUEST_CLEAR_TT_BUFFER = 8,
     235        USB_HUB_REQUEST_RESET_TT = 9,
     236        USB_HUB_GET_TT_STATE = 10,
     237        USB_HUB_STOP_TT = 11,
     238        /** USB 3+ only */
     239        USB_HUB_REQUEST_SET_HUB_DEPTH = 12,
    193240} usb_hub_request_t;
    194241
    195242/**
    196  *      Maximum size of usb hub descriptor in bytes
     243 * Maximum size of usb hub descriptor in bytes
    197244 */
    198245/* 7 (basic size) + 2*32 (port bitmasks) */
  • uspace/lib/usb/include/usb/descriptor.h

    rf5e5f73 rdf6ded8  
    11/*
    22 * Copyright (c) 2010 Vojtech Horky
     3 * Copyright (c) 2018 Michal Staruch, Ondrej Hlavaty
    34 * All rights reserved.
    45 *
     
    4950        USB_DESCTYPE_OTHER_SPEED_CONFIGURATION = 7,
    5051        USB_DESCTYPE_INTERFACE_POWER = 8,
     52        /* USB 3.0 types */
     53        USB_DESCTYPE_OTG = 9,
     54        USB_DESCTYPE_DEBUG = 0xa,
     55        USB_DESCTYPE_IFACE_ASSOC = 0xb,
     56        USB_DESCTYPE_BOS = 0xf,
     57        USB_DESCTYPE_DEVICE_CAP = 0x10,
    5158        /* Class specific */
    5259        USB_DESCTYPE_HID = 0x21,
     
    5461        USB_DESCTYPE_HID_PHYSICAL = 0x23,
    5562        USB_DESCTYPE_HUB = 0x29,
     63        USB_DESCTYPE_SSPEED_HUB = 0x2a,
     64        USB_DESCTYPE_SSPEED_EP_COMPANION = 0x30
    5665        /* USB_DESCTYPE_ = */
    5766} usb_descriptor_type_t;
     
    92101        /** Number of possible configurations. */
    93102        uint8_t configuration_count;
    94 } __attribute__ ((packed)) usb_standard_device_descriptor_t;
     103} __attribute__((packed)) usb_standard_device_descriptor_t;
    95104
    96105/** USB device qualifier decriptor is basically a cut down version of the device
     
    120129        uint8_t configuration_count;
    121130        uint8_t reserved;
    122 } __attribute__ ((packed)) usb_standard_device_qualifier_descriptor_t;
     131} __attribute__((packed)) usb_standard_device_qualifier_descriptor_t;
    123132
    124133/** Standard USB configuration descriptor.
     
    147156         */
    148157        uint8_t max_power;
    149 } __attribute__ ((packed)) usb_standard_configuration_descriptor_t;
     158} __attribute__((packed)) usb_standard_configuration_descriptor_t;
    150159
    151160/** USB Other Speed Configuration descriptor shows values that would change
     
    182191        /** String descriptor describing this interface. */
    183192        uint8_t str_interface;
    184 } __attribute__ ((packed)) usb_standard_interface_descriptor_t;
     193} __attribute__((packed)) usb_standard_interface_descriptor_t;
    185194
    186195/** Standard USB endpoint descriptor.
     
    193202        /** Endpoint address together with data flow direction. */
    194203        uint8_t endpoint_address;
     204#define USB_ED_GET_EP(ed)       ((ed).endpoint_address & 0xf)
     205#define USB_ED_GET_DIR(ed)      (!(((ed).endpoint_address >> 7) & 0x1))
     206
    195207        /** Endpoint attributes.
    196208         * Includes transfer type (usb_transfer_type_t).
    197209         */
    198210        uint8_t attributes;
     211#define USB_ED_GET_TRANSFER_TYPE(ed)    ((ed).attributes & 0x3)
    199212        /** Maximum packet size.
    200213         * Lower 10 bits represent the actuall size
     
    202215         * HS INT and ISO transfers. */
    203216        uint16_t max_packet_size;
    204 
    205 #define ED_MPS_PACKET_SIZE_MASK  0x3ff
    206 #define ED_MPS_PACKET_SIZE_GET(value) \
    207         ((value) & ED_MPS_PACKET_SIZE_MASK)
    208 #define ED_MPS_TRANS_OPPORTUNITIES_GET(value) \
    209         ((((value) >> 10) & 0x3) + 1)
    210 
    211         /** Polling interval in milliseconds.
    212          * Ignored for bulk and control endpoints.
    213          * Isochronous endpoints must use value 1.
    214          * Interrupt endpoints any value from 1 to 255.
     217#define USB_ED_GET_MPS(ed) \
     218        (uint16_usb2host((ed).max_packet_size) & 0x7ff)
     219#define USB_ED_GET_ADD_OPPS(ed) \
     220        ((uint16_usb2host((ed).max_packet_size) >> 11) & 0x3)
     221        /** Polling interval. Different semantics for various (speed, type)
     222         * pairs.
    215223         */
    216224        uint8_t poll_interval;
    217 } __attribute__ ((packed)) usb_standard_endpoint_descriptor_t;
     225} __attribute__((packed)) usb_standard_endpoint_descriptor_t;
     226
     227/** Superspeed USB endpoint companion descriptor.
     228 * See USB 3 specification, section 9.6.7.
     229 */
     230typedef struct {
     231        /** Size of this descriptor in bytes */
     232        uint8_t length;
     233        /** Descriptor type (USB_DESCTYPE_SSPEED_EP_COMPANION). */
     234        uint8_t descriptor_type;
     235        /** The maximum number of packets the endpoint can send
     236         * or receive as part of a burst. Valid values are from 0 to 15.
     237         * The endpoint can only burst max_burst + 1 packets at a time.
     238         */
     239        uint8_t max_burst;
     240        /** Valid only for bulk and isochronous endpoints.
     241         * For bulk endpoints, this field contains the amount of streams
     242         * supported by the endpoint.
     243         * For isochronous endpoints, this field contains maximum
     244         * number of packets supported within a service interval.
     245         * Warning: the values returned by macros may not make any sense
     246         * for specific endpoint types.
     247         */
     248        uint8_t attributes;
     249#define USB_SSC_MAX_STREAMS(sscd) ((sscd).attributes & 0x1f)
     250#define USB_SSC_MULT(sscd) ((sscd).attributes & 0x3)
     251        /** The total number of bytes this endpoint will transfer
     252         * every service interval (SI).
     253         * This field is only valid for periodic endpoints.
     254         */
     255        uint16_t bytes_per_interval;
     256} __attribute__((packed)) usb_superspeed_endpoint_companion_descriptor_t;
    218257
    219258/** Part of standard USB HID descriptor specifying one class descriptor.
     
    226265        /** Length of class-specific descriptor in bytes. */
    227266        uint16_t length;
    228 } __attribute__ ((packed)) usb_standard_hid_class_descriptor_info_t;
     267} __attribute__((packed)) usb_standard_hid_class_descriptor_info_t;
    229268
    230269/** Standard USB HID descriptor.
     
    257296        /** First mandatory class descriptor (Report) info. */
    258297        usb_standard_hid_class_descriptor_info_t report_desc_info;
    259 } __attribute__ ((packed)) usb_standard_hid_descriptor_t;
     298} __attribute__((packed)) usb_standard_hid_descriptor_t;
    260299
    261300#endif
  • uspace/lib/usb/include/usb/request.h

    rf5e5f73 rdf6ded8  
    11/*
    22 * Copyright (c) 2012 Jan Vesely
     3 * Copyright (c) 2018 Ondrej Hlavaty
    34 * All rights reserved.
    45 *
     
    7172#define USB_ENDPOINT_STATUS_HALTED ((uint16_t)(1 << 0))
    7273
     74/** Size of the USB setup packet */
     75#define USB_SETUP_PACKET_SIZE 8
     76
    7377/** Device request setup packet.
    7478 * The setup packet describes the request.
     
    8286#define SETUP_REQUEST_TYPE_DEVICE_TO_HOST (1 << 7)
    8387#define SETUP_REQUEST_TYPE_HOST_TO_DEVICE (0 << 7)
     88#define SETUP_REQUEST_TYPE_IS_DEVICE_TO_HOST(rt) ((rt) & (1 << 7))
    8489#define SETUP_REQUEST_TYPE_GET_TYPE(rt) ((rt >> 5) & 0x3)
    8590#define SETUP_REQUEST_TYPE_GET_RECIPIENT(rec) (rec & 0x1f)
     
    108113} __attribute__ ((packed)) usb_device_request_setup_packet_t;
    109114
    110 static_assert(sizeof(usb_device_request_setup_packet_t) == 8);
     115static_assert(sizeof(usb_device_request_setup_packet_t) == USB_SETUP_PACKET_SIZE);
    111116
    112 int usb_request_needs_toggle_reset(
    113     const usb_device_request_setup_packet_t *request);
     117#define GET_DEVICE_DESC(size) \
     118{ \
     119        .request_type = SETUP_REQUEST_TYPE_DEVICE_TO_HOST \
     120            | (USB_REQUEST_TYPE_STANDARD << 5) \
     121            | USB_REQUEST_RECIPIENT_DEVICE, \
     122        .request = USB_DEVREQ_GET_DESCRIPTOR, \
     123        .value = uint16_host2usb(USB_DESCTYPE_DEVICE << 8), \
     124        .index = uint16_host2usb(0), \
     125        .length = uint16_host2usb(size), \
     126};
     127
     128#define SET_ADDRESS(address) \
     129{ \
     130        .request_type = SETUP_REQUEST_TYPE_HOST_TO_DEVICE \
     131            | (USB_REQUEST_TYPE_STANDARD << 5) \
     132            | USB_REQUEST_RECIPIENT_DEVICE, \
     133        .request = USB_DEVREQ_SET_ADDRESS, \
     134        .value = uint16_host2usb(address), \
     135        .index = uint16_host2usb(0), \
     136        .length = uint16_host2usb(0), \
     137};
     138
     139#define CTRL_PIPE_MIN_PACKET_SIZE 8
    114140
    115141#endif
  • uspace/lib/usb/include/usb/usb.h

    rf5e5f73 rdf6ded8  
    11/*
    22 * Copyright (c) 2010 Vojtech Horky
     3 * Copyright (c) 2018 Ondrej Hlavaty, Michal Staruch
    34 * All rights reserved.
    45 *
     
    3940#include <stdint.h>
    4041#include <types/common.h>
    41 #include <usb_iface.h>
     42#include <usbhc_iface.h>
    4243
    4344/** Convert 16bit value from native (host) endianness to USB endianness. */
     
    5354#define uint32_usb2host(n) uint32_t_le2host((n))
    5455
    55 const char * usb_str_transfer_type(usb_transfer_type_t t);
    56 const char * usb_str_transfer_type_short(usb_transfer_type_t t);
     56const char *usb_str_transfer_type(usb_transfer_type_t);
     57const char *usb_str_transfer_type_short(usb_transfer_type_t);
    5758
    5859const char *usb_str_direction(usb_direction_t);
     
    6162{
    6263        return (s == USB_SPEED_FULL) || (s == USB_SPEED_LOW);
     64}
     65
     66static inline bool usb_speed_is_valid(const usb_speed_t s)
     67{
     68        return (s >= USB_SPEED_LOW) && (s < USB_SPEED_MAX);
    6369}
    6470
     
    97103static inline bool usb_address_is_valid(usb_address_t a)
    98104{
    99         return (a >= USB_ADDRESS_DEFAULT) && (a <= USB11_ADDRESS_MAX);
     105        return a <= USB11_ADDRESS_MAX;
    100106}
    101107
     
    103109#define USB_ENDPOINT_DEFAULT_CONTROL 0
    104110
    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)
    107116
    108117/** Check USB endpoint for allowed values.
     
    115124static inline bool usb_endpoint_is_valid(usb_endpoint_t ep)
    116125{
    117         return (ep >= USB_ENDPOINT_DEFAULT_CONTROL) &&
    118             (ep < USB11_ENDPOINT_MAX);
     126        return ep < USB_ENDPOINT_MAX;
    119127}
    120128
    121 /** Check USB target for allowed values (address and endpoint).
     129/**
     130 * Check USB target for allowed values (address, endpoint, stream).
    122131 *
    123132 * @param target.
    124133 * @return True, if values are wihtin limits, false otherwise.
    125134 */
    126 static inline bool usb_target_is_valid(usb_target_t target)
     135static inline bool usb_target_is_valid(const usb_target_t *target)
    127136{
    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.
    130141}
    131142
     
    136147 * @return Whether @p a and @p b points to the same pipe on the same device.
    137148 */
    138 static inline int usb_target_same(usb_target_t a, usb_target_t b)
     149static inline bool usb_target_same(usb_target_t a, usb_target_t b)
    139150{
    140         return (a.address == b.address)
    141             && (a.endpoint == b.endpoint);
     151        return (a.address == b.address) && (a.endpoint == b.endpoint);
    142152}
    143 
    144 /** General handle type.
    145  * Used by various USB functions as opaque handle.
    146  */
    147 typedef sysarg_t usb_handle_t;
    148153
    149154/** USB packet identifier. */
     
    161166        USB_PID_SETUP = _MAKE_PID(3, 1),
    162167
    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),
    165170
    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),
    169174
    170         USB_PID_PRE = _MAKE_PID(3 ,0),
     175        USB_PID_PRE = _MAKE_PID(3, 0),
    171176        /* USB_PID_ = _MAKE_PID( ,), */
    172177#undef _MAKE_PID
Note: See TracChangeset for help on using the changeset viewer.