Chinaunix首页 | 论坛 | 博客
  • 博客访问: 177907
  • 博文数量: 34
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 374
  • 用 户 组: 普通用户
  • 注册时间: 2013-10-30 10:46
文章分类

全部博文(34)

文章存档

2018年(5)

2015年(13)

2014年(13)

2013年(3)

我的朋友

分类: 嵌入式

2015-06-15 16:51:28

刚开始接触usb问别人usb端点指的什么,得到的回答:USB数据传输的终点,端点传输单向的,因此一个usb设备接口至少两个端点,用于收发数
据。
在上一篇文章
Linux--usb(7)usb_interface 结构体之 struct usb_host_interface usb描述符 我们熟悉 了结构
usb_host_interface,usb接口
描述符的具体学习。其中的一个元素已经提到端点的信息 struct usb_host_endpoint *endpoint。这一元素指向的便是端点结构体。

include\linux\usb.h
/**
 * struct usb_host_endpoint - host-side endpoint descriptor and queue
 * @desc: descriptor for this endpoint, wMaxPacketSize in native byteorder
 * @ss_ep_comp: SuperSpeed companion descriptor for this endpoint
 * @urb_list: urbs queued to this endpoint; maintained by usbcore
 * @hcpriv: for use by HCD; typically holds hardware dma queue head (QH)
 * with one or more transfer descriptors (TDs) per urb
 * @ep_dev: ep_device for sysfs info
 * @extra: descriptors following this endpoint in the configuration
 * @extralen: how many bytes of "extra" are valid
 * @enabled: URBs may be submitted to this endpoint
 * @streams: number of USB-3 streams allocated on the endpoint
 *
 * USB requests are always queued to a given endpoint, identified by a
 * descriptor within an active interface in a given USB configuration.
 */
struct usb_host_endpoint {
struct usb_endpoint_descriptor desc;  // 端点描述符,四大描述符的第二个隆重登场了
struct usb_ss_ep_comp_descriptor ss_ep_comp; // 端点高速配置描述
struct list_head urb_list; // urb_list,端点要处理的urb队列,包含了执行urb传输所需要的所有信息.urb可是usb通信的主角。和你的usb通信,就得创建一个urb,
                                        // 并且为它赋好值,交给咱们的usb core

void *hcpriv; // 这是提供给HCD(host controller driver)用的。比如等时端点会在里边儿放一个ehci_iso_stream.这个我们以后碰到了在来讨论 (⊙﹏⊙)b
struct ep_device *ep_dev; /* For sysfs info */ // 这个字段是供sysfs用的


unsigned char *extra;   /* Extra descriptors */ // 有关一些额外扩展的描述符的,和struct 里差不多,只是这里的是针对端点  
                                     //的,如果你请求从设备里获得描述符信息,它们会跟在标准的端点描述符后面返回给你。

int extralen;
int enabled; 
int streams;
};

usb端点描述符:\include\uapi\linux\usb\ch9.h 
/* USB_DT_ENDPOINT: Endpoint descriptor */
struct usb_endpoint_descriptor {
__u8  bLength;  // 描述符的字节长度
__u8  bDescriptorType;// 端点描述符的类型,值must be  
USB_DT_ENDPOINT,0x05。

__u8  bEndpointAddress;  // 端点号 端点方向等信息。它的bits 0~3表示的就是端点号,你使用0x0f和它相与就可以得到端点号。不过,开发内核的同志想的
                                          //都很周到,定义好了一个掩码USB_ENDPOINT_NUMBER_MASK,它的值就是0x0f. USB_ENDPOINT_DIR_MASK  0x80 mask出
                                           //端点方向位。
USB_DIR_IN和USB_DIR_OUT,表示端点输入输出方向,note:此处的方向 以host角度描述。

__u8  bmAttributes; //总共8位,其中bit1和bit0 共同称为Transfer Type,即传输类型, 00 表示控制,01 表示等时,10 表示批量,11 表示中断
__le16 wMaxPacketSize;// 传送数据最大包大小
__u8  bInterval;  //USB是轮询式的总线,这个值表达了端点一种美好的期待,希望主机轮询自己的时间间隔不同的传输类型bInterval也有不同的意义。

/* NOTE:  these two are _only_ in audio endpoints. */
/* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */
__u8  bRefresh;
__u8  bSynchAddress;
} __attribute__ ((packed));
#define USB_DT_ENDPOINT_SIZE 7
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */

note:0号端点仍然保持着它特殊的地位,它没有自己的端点描述符


阅读(2761) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~