15#ifndef __USB_DEVICE_H__
16#define __USB_DEVICE_H__
27#define _VENDOR_ID USB_VENDOR_ID
29#define _VENDOR_ID 0x0EFF
33#define _PRODUCT_ID USB_PRODUCT_ID
35#define _PRODUCT_ID 0x0001
39#define MAX_INTF_STR 20
42#define USB_BCD_DEVICE 0x0200
43#define USB_BCD_VERSION 0x0200
44#define EP0_IN_ADDR 0x80
45#define EP0_OUT_ADDR 0x00
46#define EP_HANDLER(ep, func, size) RT_ASSERT(ep != RT_NULL); ep->handler(func, size)
47#define EP_ADDRESS(ep) ep->ep_desc->bEndpointAddress
48#define EP_MAXPACKET(ep) ep->ep_desc->wMaxPacketSize
49#define FUNC_ENABLE(func) do{ \
50 if(func->ops->enable != RT_NULL && \
51 func->enabled == RT_FALSE) \
53 if(func->ops->enable(func) == RT_EOK) \
54 func->enabled = RT_TRUE; \
57#define FUNC_DISABLE(func) do{ \
58 if(func->ops->disable != RT_NULL && \
59 func->enabled == RT_TRUE) \
61 func->enabled = RT_FALSE; \
62 func->ops->disable(func); \
66#define RT_USBD_CLASS_CTRL_CONNECTED (RT_DEVICE_CTRL_BASE(USBDevice) + 0)
300#ifdef RT_USB_DEVICE_COMPOSITE
434 header.
wCount = number_of_proerty;
435 for(index = 0;index < number_of_proerty;index++)
444 for(index = 0;index < number_of_proerty;index++)
rt_weak void * rt_malloc(rt_size_t size)
Allocate a block of memory with a minimum of 'size' bytes.
unsigned short rt_uint16_t
struct rt_list_node rt_list_t
struct uconfig_descriptor cfg_desc
rt_err_t(* suspend)(void)
rt_err_t(* ep0_send_status)(void)
rt_err_t(* ep_enable)(struct uendpoint *ep)
rt_err_t(* set_address)(rt_uint8_t address)
rt_err_t(* set_config)(rt_uint8_t address)
rt_err_t(* ep_clear_stall)(rt_uint8_t address)
rt_ssize_t(* ep_read)(rt_uint8_t address, void *buffer)
rt_err_t(* ep_disable)(struct uendpoint *ep)
rt_ssize_t(* ep_write)(rt_uint8_t address, void *buffer, rt_size_t size)
rt_err_t(* ep_set_stall)(rt_uint8_t address)
rt_ssize_t(* ep_read_prepare)(rt_uint8_t address, void *buffer, rt_size_t size)
const struct udcd_ops * ops
ufunction_t(* rt_usbd_function_create)(udevice_t device)
union udev_msg::@345263171021165250214261121347301063047344353021 content
struct udevice_descriptor dev_desc
usb_os_comp_id_desc_t os_comp_id_desc
struct usb_qualifier_descriptor * dev_qualifier
const char * str_intf[MAX_INTF_STR]
rt_err_t(* rx_indicate)(struct udevice *dev, rt_size_t size)
struct uio_request request
rt_err_t(* sof_handler)(struct ufunction *func)
rt_err_t(* disable)(struct ufunction *func)
rt_err_t(* enable)(struct ufunction *func)
ualtsetting_t curr_setting
UIO_REQUEST_TYPE req_type
const char * bPropertyData
rt_uint32_t dwPropertyDataLength
const char * bPropertyName
rt_uint16_t wPropertyNameLength
struct uiad_descriptor * uiad_desc_t
struct usb_os_comp_id_descriptor * usb_os_comp_id_desc_t
struct usb_os_proerty * usb_os_proerty_t
struct uinterface_descriptor * uintf_desc_t
struct udevice_descriptor * udev_desc_t
struct uendpoint_descriptor * uep_desc_t
struct usb_os_function_comp_id_descriptor * usb_os_func_comp_id_desc_t
ufunction_t rt_usbd_function_new(udevice_t device, udev_desc_t dev_desc, ufunction_ops_t ops)
rt_err_t rt_usbd_ep_set_stall(udevice_t device, uep_t ep)
rt_inline rt_size_t dcd_ep_write(udcd_t dcd, rt_uint8_t address, void *buffer, rt_size_t size)
rt_err_t rt_usbd_event_signal(struct udev_msg *msg)
rt_err_t rt_usbd_function_add_interface(ufunction_t func, uintf_t intf)
rt_err_t rt_usbd_sof_handler(udcd_t dcd)
rt_inline rt_err_t dcd_ep_disable(udcd_t dcd, uep_t ep)
rt_err_t(* udep_handler_t)(struct ufunction *func, rt_size_t size)
int rt_usbd_vcom_class_register(void)
rt_err_t rt_usbd_device_set_os_comp_id_desc(udevice_t device, usb_os_comp_id_desc_t os_comp_id_desc)
rt_inline rt_size_t dcd_ep_read_prepare(udcd_t dcd, rt_uint8_t address, void *buffer, rt_size_t size)
rt_err_t rt_usbd_device_set_controller(udevice_t device, udcd_t dcd)
rt_size_t rt_usbd_io_request(udevice_t device, uep_t ep, uio_request_t req)
uep_t rt_usbd_endpoint_new(uep_desc_t ep_desc, udep_handler_t handler)
uintf_t rt_usbd_find_interface(udevice_t device, rt_uint8_t value, ufunction_t *pfunc)
rt_err_t rt_usbd_ep_clear_stall(udevice_t device, uep_t ep)
rt_err_t rt_usbd_device_set_descriptor(udevice_t device, udev_desc_t dev_desc)
rt_err_t rt_usbd_config_add_function(uconfig_t cfg, ufunction_t func)
rt_inline rt_err_t dcd_ep0_send_status(udcd_t dcd)
ualtsetting_t rt_usbd_altsetting_new(rt_size_t desc_size)
rt_err_t(* uintf_handler_t)(struct ufunction *func, ureq_t setup)
rt_inline void usbd_os_proerty_descriptor_send(ufunction_t func, ureq_t setup, usb_os_proerty_t usb_os_proerty, rt_uint8_t number_of_proerty)
int rt_usbd_ecm_class_register(void)
struct udevice * udevice_t
struct ualtsetting * ualtsetting_t
rt_err_t rt_usbd_interface_add_altsetting(uintf_t intf, ualtsetting_t setting)
rt_inline rt_size_t dcd_ep_read(udcd_t dcd, rt_uint8_t address, void *buffer)
rt_inline rt_err_t dcd_ep_clear_stall(udcd_t dcd, rt_uint8_t address)
int rt_usbd_msc_class_register(void)
rt_err_t rt_usbd_set_feature(udevice_t device, rt_uint16_t value, rt_uint16_t index)
rt_err_t rt_usbd_ep0_set_stall(udevice_t device)
rt_err_t rt_usb_device_init(void)
struct udev_msg * udev_msg_t
rt_err_t rt_usbd_reset_handler(udcd_t dcd)
rt_err_t rt_usbd_ep0_in_handler(udcd_t dcd)
rt_err_t rt_usbd_altsetting_add_endpoint(ualtsetting_t setting, uep_t ep)
rt_err_t rt_usbd_ep0_out_handler(udcd_t dcd, rt_size_t size)
int rt_usbd_winusb_class_register(void)
struct ufunction * ufunction_t
rt_err_t rt_usbd_disconnect_handler(udcd_t dcd)
rt_err_t rt_usbd_connect_handler(udcd_t dcd)
udevice_t rt_usbd_device_new(void)
rt_inline rt_err_t dcd_set_address(udcd_t dcd, rt_uint8_t address)
struct ufunction_ops * ufunction_ops_t
struct uio_request * uio_request_t
rt_err_t rt_usbd_set_altsetting(uintf_t intf, rt_uint8_t value)
uep_t rt_usbd_find_endpoint(udevice_t device, ufunction_t *pfunc, rt_uint8_t ep_addr)
rt_size_t rt_usbd_ep0_read(udevice_t device, void *buffer, rt_size_t size, rt_err_t(*rx_ind)(udevice_t device, rt_size_t size))
rt_err_t rt_usbd_core_init(void)
int rt_usbd_rndis_class_register(void)
uconfig_t rt_usbd_find_config(udevice_t device, rt_uint8_t value)
rt_err_t rt_usbd_device_add_config(udevice_t device, uconfig_t cfg)
struct uconfig * uconfig_t
int rt_usbd_hid_class_register(void)
rt_err_t rt_usbd_os_comp_id_desc_add_os_func_comp_id_desc(usb_os_comp_id_desc_t os_comp_id_desc, usb_os_func_comp_id_desc_t os_func_comp_id_desc)
rt_err_t rt_usbd_ep_in_handler(udcd_t dcd, rt_uint8_t address, rt_size_t size)
rt_inline rt_err_t dcd_set_config(udcd_t dcd, rt_uint8_t address)
rt_size_t rt_usbd_ep0_write(udevice_t device, void *buffer, rt_size_t size)
@ USB_MSG_EP_CLEAR_FEATURE
udevice_t rt_usbd_find_device(udcd_t dcd)
rt_inline rt_err_t dcd_ep_set_stall(udcd_t dcd, rt_uint8_t address)
rt_err_t rt_usbd_ep_out_handler(udcd_t dcd, rt_uint8_t address, rt_size_t size)
rt_err_t rt_usbd_ep0_clear_stall(udevice_t device)
rt_err_t rt_usbd_clear_feature(udevice_t device, rt_uint16_t value, rt_uint16_t index)
rt_err_t rt_usbd_device_set_qualifier(udevice_t device, struct usb_qualifier_descriptor *qualifier)
rt_err_t rt_usbd_set_config(udevice_t device, rt_uint8_t value)
uconfig_t rt_usbd_config_new(void)
rt_err_t rt_usbd_altsetting_config_descriptor(ualtsetting_t setting, const void *desc, rt_off_t intf_pos)
rt_err_t rt_usbd_device_set_string(udevice_t device, const char **ustring)
rt_err_t rt_usbd_device_set_interface_string(udevice_t device, int index, const char *string)
rt_err_t rt_usbd_ep0_setup_handler(udcd_t dcd, struct urequest *setup)
struct uinterface * uintf_t
rt_inline rt_err_t dcd_ep_enable(udcd_t dcd, uep_t ep)
int rt_usbd_class_list_init(void)
rt_err_t rt_usbd_class_register(udclass_t udclass)
struct udclass * udclass_t
uintf_t rt_usbd_interface_new(udevice_t device, uintf_handler_t handler)