Changeset 432a269 in mainline for uspace/lib/usb/include/usb/usb.h


Ignore:
Timestamp:
2011-09-16T21:13:57Z (13 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3a11f17
Parents:
c0e53ff (diff), fd07e526 (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.
Message:

Merge mainline changes

File:
1 edited

Legend:

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

    rc0e53ff r432a269  
    3636#define LIBUSB_USB_H_
    3737
     38#include <bool.h>
    3839#include <sys/types.h>
    3940#include <byteorder.h>
     
    105106 * Negative values could be used to indicate error.
    106107 */
    107 typedef int usb_address_t;
     108typedef int16_t usb_address_t;
    108109
    109110/** Default USB address. */
     
    115116 * Negative values could be used to indicate error.
    116117 */
    117 typedef int usb_endpoint_t;
     118typedef int16_t usb_endpoint_t;
    118119
    119120/** Maximum endpoint number in USB 1.1.
     
    125126 * Pair address + endpoint is identification of transaction recipient.
    126127 */
    127 typedef struct {
    128         usb_address_t address;
    129         usb_endpoint_t endpoint;
     128typedef union {
     129        struct {
     130                usb_address_t address;
     131                usb_endpoint_t endpoint;
     132        } __attribute__((packed));
     133        uint32_t packed;
    130134} usb_target_t;
     135
     136/** Check USB target for allowed values (address and endpoint).
     137 *
     138 * @param target.
     139 * @return True, if values are wihtin limits, false otherwise.
     140 */
     141static inline bool usb_target_is_valid(usb_target_t target)
     142{
     143        return !(target.endpoint > 15 || target.endpoint < 0
     144            || target.address >= USB11_ADDRESS_MAX || target.address < 0);
     145}
    131146
    132147/** Compare USB targets (addresses and endpoints).
Note: See TracChangeset for help on using the changeset viewer.