HelenOS sources
This source file includes following definitions.
- usb_speed_is_11
- usb_speed_is_valid
- usb_address_is_valid
- usb_endpoint_is_valid
- usb_target_is_valid
- usb_target_same
- _MAKE_PID_NIBBLE
- _MAKE_PID_NIBBLE
#ifndef LIBUSB_USB_H_
#define LIBUSB_USB_H_
#include <byteorder.h>
#include <stdbool.h>
#include <stdint.h>
#include <types/common.h>
#include <usbhc_iface.h>
#define uint16_host2usb(n) host2uint16_t_le((n))
#define uint32_host2usb(n) host2uint32_t_le((n))
#define uint16_usb2host(n) uint16_t_le2host((n))
#define uint32_usb2host(n) uint32_t_le2host((n))
const char *usb_str_transfer_type(usb_transfer_type_t);
const char *usb_str_transfer_type_short(usb_transfer_type_t);
const char *usb_str_direction(usb_direction_t);
static inline bool usb_speed_is_11(const usb_speed_t s)
{
return (s == USB_SPEED_FULL) || (s == USB_SPEED_LOW);
}
static inline bool usb_speed_is_valid(const usb_speed_t s)
{
return (s >= USB_SPEED_LOW) && (s < USB_SPEED_MAX);
}
const char *usb_str_speed(usb_speed_t);
typedef enum {
USB_REQUEST_TYPE_STANDARD = 0,
USB_REQUEST_TYPE_CLASS = 1,
USB_REQUEST_TYPE_VENDOR = 2
} usb_request_type_t;
typedef enum {
USB_REQUEST_RECIPIENT_DEVICE = 0,
USB_REQUEST_RECIPIENT_INTERFACE = 1,
USB_REQUEST_RECIPIENT_ENDPOINT = 2,
USB_REQUEST_RECIPIENT_OTHER = 3
} usb_request_recipient_t;
#define USB_ADDRESS_DEFAULT 0
#define USB11_ADDRESS_MAX 127
#define USB_ADDRESS_COUNT (USB11_ADDRESS_MAX + 1)
static inline bool usb_address_is_valid(usb_address_t a)
{
return a <= USB11_ADDRESS_MAX;
}
#define USB_ENDPOINT_DEFAULT_CONTROL 0
#define USB_ENDPOINT_MAX 16
#define USB_ENDPOINT_COUNT (2 * USB_ENDPOINT_MAX)
static inline bool usb_endpoint_is_valid(usb_endpoint_t ep)
{
return ep < USB_ENDPOINT_MAX;
}
static inline bool usb_target_is_valid(const usb_target_t *target)
{
return usb_address_is_valid(target->address) &&
usb_endpoint_is_valid(target->endpoint);
}
static inline bool usb_target_same(usb_target_t a, usb_target_t b)
{
return (a.address == b.address) && (a.endpoint == b.endpoint);
}
typedef enum {
#define _MAKE_PID_NIBBLE(tag, type) \
((uint8_t)(((tag) << 2) | (type)))
#define _MAKE_PID(tag, type) \
( \
_MAKE_PID_NIBBLE(tag, type) \
| (((~_MAKE_PID_NIBBLE(tag, type)) & 0xf) << 4) \
)
USB_PID_OUT = _MAKE_PID(0, 1),
USB_PID_IN = _MAKE_PID(2, 1),
USB_PID_SOF = _MAKE_PID(1, 1),
USB_PID_SETUP = _MAKE_PID(3, 1),
USB_PID_DATA0 = _MAKE_PID(0, 3),
USB_PID_DATA1 = _MAKE_PID(2, 3),
USB_PID_ACK = _MAKE_PID(0, 2),
USB_PID_NAK = _MAKE_PID(2, 2),
USB_PID_STALL = _MAKE_PID(3, 2),
USB_PID_PRE = _MAKE_PID(3, 0),
#undef _MAKE_PID
#undef _MAKE_PID_NIBBLE
} usb_packet_id;
#define USB_HC_CATEGORY "usbhc"
#endif
HelenOS homepage, sources at GitHub