change endpoint and class handler

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2475 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
sc943313837@gmail.com 2012-12-12 16:36:23 +00:00
parent 405977d3ca
commit 834355c76b

View File

@ -10,8 +10,12 @@
* Change Logs:
* Date Author Notes
* 2012-10-01 Yi Qiu first version
* 2012-12-12 heyuanjie87 change endpoint and class handler
*/
#ifndef __USB_DEVICE_H__
#define __USB_DEVICE_H__
#include <rtthread.h>
#include "usb_common.h"
@ -22,6 +26,7 @@
#define USB_BCD_DEVICE 0x0200 /* USB Specification Release Number in Binary-Coded Decimal */
#define USB_BCD_VERSION 0x0200 /* USB 2.0 */
struct uclass;
struct udevice;
struct uendpoint;
@ -47,12 +52,14 @@ struct udcd
};
typedef struct udcd* udcd_t;
typedef rt_err_t (*udep_handler_t)(struct udevice* device, struct uclass* cls, rt_size_t size);
struct uendpoint
{
rt_list_t list;
rt_uint8_t* buffer;
uep_desc_t ep_desc;
rt_err_t (*handler)(struct udevice* device, rt_size_t size);
udep_handler_t handler;
rt_bool_t is_stall;
void* user_data;
};
@ -79,9 +86,9 @@ typedef struct uinterface* uintf_t;
struct uclass_ops
{
rt_err_t (*run)(struct udevice* device);
rt_err_t (*stop)(struct udevice* device);
rt_err_t (*sof_handler)(struct udevice* device);
rt_err_t (*run)(struct udevice* device, struct uclass* cls);
rt_err_t (*stop)(struct udevice* device, struct uclass* cls);
rt_err_t (*sof_handler)(struct udevice* device, struct uclass* cls);
};
typedef struct uclass_ops* uclass_ops_t;
@ -89,7 +96,7 @@ struct uclass
{
rt_list_t list;
uclass_ops_t ops;
void* eps;
struct udevice* device;
udev_desc_t dev_desc;
#ifdef RT_USB_DEVICE_COMPOSITE
@ -154,8 +161,7 @@ uclass_t rt_usbd_class_create(udevice_t device, udev_desc_t dev_desc,
uclass_ops_t ops);
uintf_t rt_usbd_interface_create(udevice_t device,
rt_err_t (*handler)(struct udevice*, ureq_t setup));
uep_t rt_usbd_endpoint_create(uep_desc_t ep_desc,
rt_err_t (*handler)(udevice_t device, rt_size_t size));
uep_t rt_usbd_endpoint_create(uep_desc_t ep_desc, udep_handler_t handler);
ualtsetting_t rt_usbd_altsetting_create(uintf_desc_t intf_desc, rt_size_t desc_size);
rt_err_t rt_usbd_core_init(void);
@ -175,7 +181,7 @@ rt_err_t rt_usbd_set_altsetting(uintf_t intf, rt_uint8_t value);
udevice_t rt_usbd_find_device(udcd_t dcd);
uconfig_t rt_usbd_find_config(udevice_t device, rt_uint8_t value);
uintf_t rt_usbd_find_interface(udevice_t device, rt_uint8_t value);
uep_t rt_usbd_find_endpoint(udevice_t device, rt_uint8_t ep_addr);
uep_t rt_usbd_find_endpoint(udevice_t device, uclass_t* pcls, rt_uint8_t ep_addr);
uclass_t rt_usbd_class_mstorage_create(udevice_t device);
uclass_t rt_usbd_class_cdc_create(udevice_t device);
@ -256,3 +262,4 @@ rt_inline rt_size_t dcd_ep_write(udcd_t dcd, uep_t ep, void *buffer,
return dcd->ops->ep_write(ep, buffer, size);
}
#endif