RT-Thread RTOS 1.2.0
An open source embedded real-time operating system
载入中...
搜索中...
未找到
usb_host.h 文件参考
#include <rtthread.h>
#include "usb_common.h"
+ usb_host.h 的引用(Include)关系图:

浏览该文件的源代码.

结构体

struct  uclass_driver
 
struct  uprotocal
 
struct  uinstance
 
struct  uhintf
 
struct  upipe
 
struct  uhub
 
struct  uhcd_ops
 
struct  uhcd
 
struct  uhost_msg
 

宏定义

#define USB_MAX_DEVICE   0x20
 
#define USB_MAX_INTERFACE   0x08
 
#define USB_HUB_PORT_NUM   0x04
 
#define SIZEOF_USB_REQUEST   0x08
 
#define DEV_STATUS_IDLE   0x00
 
#define DEV_STATUS_BUSY   0x01
 
#define DEV_STATUS_ERROR   0x02
 
#define UPIPE_STATUS_OK   0x00
 
#define UPIPE_STATUS_STALL   0x01
 
#define UPIPE_STATUS_ERROR   0x02
 
#define USBH_PID_SETUP   0x00
 
#define USBH_PID_DATA   0x01
 

类型定义

typedef struct uclass_driverucd_t
 
typedef struct uprotocaluprotocal_t
 
typedef struct uinstanceuinst_t
 
typedef struct upipeupipe_t
 
typedef struct uhubuhub_t
 
typedef struct uhcd_opsuhcd_ops_t
 
typedef struct uhcduhcd_t
 
typedef enum uhost_msg_type uhost_msg_type
 
typedef struct uhost_msguhost_msg_t
 

枚举

enum  uhost_msg_type { USB_MSG_CONNECT_CHANGE , USB_MSG_CALLBACK }
 

函数

rt_err_t rt_usb_host_init (const char *name)
 
void rt_usbh_hub_init (struct uhcd *hcd)
 
struct uinstancert_usbh_alloc_instance (uhcd_t uhcd)
 
rt_err_t rt_usbh_attatch_instance (struct uinstance *device)
 
rt_err_t rt_usbh_detach_instance (struct uinstance *device)
 
rt_err_t rt_usbh_get_descriptor (struct uinstance *device, rt_uint8_t type, void *buffer, int nbytes)
 
rt_err_t rt_usbh_set_configure (struct uinstance *device, int config)
 
rt_err_t rt_usbh_set_address (struct uinstance *device)
 
rt_err_t rt_usbh_set_interface (struct uinstance *device, int intf)
 
rt_err_t rt_usbh_clear_feature (struct uinstance *device, int endpoint, int feature)
 
rt_err_t rt_usbh_get_interface_descriptor (ucfg_desc_t cfg_desc, int num, uintf_desc_t *intf_desc)
 
rt_err_t rt_usbh_get_endpoint_descriptor (uintf_desc_t intf_desc, int num, uep_desc_t *ep_desc)
 
rt_err_t rt_usbh_class_driver_init (void)
 
rt_err_t rt_usbh_class_driver_register (ucd_t drv)
 
rt_err_t rt_usbh_class_driver_unregister (ucd_t drv)
 
rt_err_t rt_usbh_class_driver_enable (ucd_t drv, void *args)
 
rt_err_t rt_usbh_class_driver_disable (ucd_t drv, void *args)
 
ucd_t rt_usbh_class_driver_find (int class_code, int subclass_code)
 
ucd_t rt_usbh_class_driver_hub (void)
 
ucd_t rt_usbh_class_driver_storage (void)
 
rt_err_t rt_usbh_hub_get_descriptor (struct uinstance *device, rt_uint8_t *buffer, rt_size_t size)
 
rt_err_t rt_usbh_hub_get_status (struct uinstance *device, rt_uint32_t *buffer)
 
rt_err_t rt_usbh_hub_get_port_status (uhub_t uhub, rt_uint16_t port, rt_uint32_t *buffer)
 
rt_err_t rt_usbh_hub_clear_port_feature (uhub_t uhub, rt_uint16_t port, rt_uint16_t feature)
 
rt_err_t rt_usbh_hub_set_port_feature (uhub_t uhub, rt_uint16_t port, rt_uint16_t feature)
 
rt_err_t rt_usbh_hub_reset_port (uhub_t uhub, rt_uint16_t port)
 
rt_err_t rt_usbh_event_signal (uhcd_t uhcd, struct uhost_msg *msg)
 
void rt_usbh_root_hub_connect_handler (struct uhcd *hcd, rt_uint8_t port, rt_bool_t isHS)
 
void rt_usbh_root_hub_disconnect_handler (struct uhcd *hcd, rt_uint8_t port)
 
rt_inline rt_err_t rt_usb_instance_add_pipe (uinst_t inst, upipe_t pipe)
 
rt_inline upipe_t rt_usb_instance_find_pipe (uinst_t inst, rt_uint8_t ep_address)
 
rt_inline rt_err_t rt_usb_hcd_alloc_pipe (uhcd_t hcd, upipe_t *pipe, uinst_t inst, uep_desc_t ep)
 
rt_inline void rt_usb_pipe_add_callback (upipe_t pipe, func_callback callback)
 
rt_inline rt_err_t rt_usb_hcd_free_pipe (uhcd_t hcd, upipe_t pipe)
 
int rt_usb_hcd_pipe_xfer (uhcd_t hcd, upipe_t pipe, void *buffer, int nbytes, int timeout)
 
rt_inline int rt_usb_hcd_setup_xfer (uhcd_t hcd, upipe_t pipe, ureq_t setup, int timeout)
 

宏定义说明

◆ USB_MAX_DEVICE

#define USB_MAX_DEVICE   0x20

在文件 usb_host.h22 行定义.

◆ USB_MAX_INTERFACE

#define USB_MAX_INTERFACE   0x08

在文件 usb_host.h23 行定义.

◆ USB_HUB_PORT_NUM

#define USB_HUB_PORT_NUM   0x04

在文件 usb_host.h24 行定义.

◆ SIZEOF_USB_REQUEST

#define SIZEOF_USB_REQUEST   0x08

在文件 usb_host.h25 行定义.

◆ DEV_STATUS_IDLE

#define DEV_STATUS_IDLE   0x00

在文件 usb_host.h27 行定义.

◆ DEV_STATUS_BUSY

#define DEV_STATUS_BUSY   0x01

在文件 usb_host.h28 行定义.

◆ DEV_STATUS_ERROR

#define DEV_STATUS_ERROR   0x02

在文件 usb_host.h29 行定义.

◆ UPIPE_STATUS_OK

#define UPIPE_STATUS_OK   0x00

在文件 usb_host.h31 行定义.

◆ UPIPE_STATUS_STALL

#define UPIPE_STATUS_STALL   0x01

在文件 usb_host.h32 行定义.

◆ UPIPE_STATUS_ERROR

#define UPIPE_STATUS_ERROR   0x02

在文件 usb_host.h33 行定义.

◆ USBH_PID_SETUP

#define USBH_PID_SETUP   0x00

在文件 usb_host.h35 行定义.

◆ USBH_PID_DATA

#define USBH_PID_DATA   0x01

在文件 usb_host.h36 行定义.

类型定义说明

◆ ucd_t

typedef struct uclass_driver* ucd_t

在文件 usb_host.h54 行定义.

◆ uprotocal_t

typedef struct uprotocal* uprotocal_t

在文件 usb_host.h64 行定义.

◆ uinst_t

typedef struct uinstance* uinst_t

在文件 usb_host.h89 行定义.

◆ upipe_t

typedef struct upipe* upipe_t

在文件 usb_host.h110 行定义.

◆ uhub_t

typedef struct uhub* uhub_t

在文件 usb_host.h125 行定义.

◆ uhcd_ops_t

typedef struct uhcd_ops* uhcd_ops_t

在文件 usb_host.h134 行定义.

◆ uhcd_t

typedef struct uhcd* uhcd_t

在文件 usb_host.h143 行定义.

◆ uhost_msg_type

在文件 usb_host.h150 行定义.

◆ uhost_msg_t

typedef struct uhost_msg* uhost_msg_t

在文件 usb_host.h165 行定义.

枚举类型说明

◆ uhost_msg_type

枚举值
USB_MSG_CONNECT_CHANGE 
USB_MSG_CALLBACK 

在文件 usb_host.h145 行定义.

146{
149};
@ USB_MSG_CONNECT_CHANGE
@ USB_MSG_CALLBACK

函数说明

◆ rt_usb_host_init()

rt_err_t rt_usb_host_init ( const char * name)

◆ rt_usbh_hub_init()

void rt_usbh_hub_init ( struct uhcd * hcd)

◆ rt_usbh_alloc_instance()

struct uinstance * rt_usbh_alloc_instance ( uhcd_t uhcd)

◆ rt_usbh_attatch_instance()

rt_err_t rt_usbh_attatch_instance ( struct uinstance * device)

◆ rt_usbh_detach_instance()

rt_err_t rt_usbh_detach_instance ( struct uinstance * device)

◆ rt_usbh_get_descriptor()

rt_err_t rt_usbh_get_descriptor ( struct uinstance * device,
rt_uint8_t type,
void * buffer,
int nbytes )

◆ rt_usbh_set_configure()

rt_err_t rt_usbh_set_configure ( struct uinstance * device,
int config )

◆ rt_usbh_set_address()

rt_err_t rt_usbh_set_address ( struct uinstance * device)

◆ rt_usbh_set_interface()

rt_err_t rt_usbh_set_interface ( struct uinstance * device,
int intf )

◆ rt_usbh_clear_feature()

rt_err_t rt_usbh_clear_feature ( struct uinstance * device,
int endpoint,
int feature )

◆ rt_usbh_get_interface_descriptor()

rt_err_t rt_usbh_get_interface_descriptor ( ucfg_desc_t cfg_desc,
int num,
uintf_desc_t * intf_desc )

◆ rt_usbh_get_endpoint_descriptor()

rt_err_t rt_usbh_get_endpoint_descriptor ( uintf_desc_t intf_desc,
int num,
uep_desc_t * ep_desc )

◆ rt_usbh_class_driver_init()

rt_err_t rt_usbh_class_driver_init ( void )

◆ rt_usbh_class_driver_register()

rt_err_t rt_usbh_class_driver_register ( ucd_t drv)

◆ rt_usbh_class_driver_unregister()

rt_err_t rt_usbh_class_driver_unregister ( ucd_t drv)

◆ rt_usbh_class_driver_enable()

rt_err_t rt_usbh_class_driver_enable ( ucd_t drv,
void * args )

◆ rt_usbh_class_driver_disable()

rt_err_t rt_usbh_class_driver_disable ( ucd_t drv,
void * args )

◆ rt_usbh_class_driver_find()

ucd_t rt_usbh_class_driver_find ( int class_code,
int subclass_code )

◆ rt_usbh_class_driver_hub()

ucd_t rt_usbh_class_driver_hub ( void )

◆ rt_usbh_class_driver_storage()

ucd_t rt_usbh_class_driver_storage ( void )

◆ rt_usbh_hub_get_descriptor()

rt_err_t rt_usbh_hub_get_descriptor ( struct uinstance * device,
rt_uint8_t * buffer,
rt_size_t size )

◆ rt_usbh_hub_get_status()

rt_err_t rt_usbh_hub_get_status ( struct uinstance * device,
rt_uint32_t * buffer )

◆ rt_usbh_hub_get_port_status()

rt_err_t rt_usbh_hub_get_port_status ( uhub_t uhub,
rt_uint16_t port,
rt_uint32_t * buffer )

◆ rt_usbh_hub_clear_port_feature()

rt_err_t rt_usbh_hub_clear_port_feature ( uhub_t uhub,
rt_uint16_t port,
rt_uint16_t feature )

◆ rt_usbh_hub_set_port_feature()

rt_err_t rt_usbh_hub_set_port_feature ( uhub_t uhub,
rt_uint16_t port,
rt_uint16_t feature )

◆ rt_usbh_hub_reset_port()

rt_err_t rt_usbh_hub_reset_port ( uhub_t uhub,
rt_uint16_t port )

◆ rt_usbh_event_signal()

rt_err_t rt_usbh_event_signal ( uhcd_t uhcd,
struct uhost_msg * msg )

◆ rt_usbh_root_hub_connect_handler()

void rt_usbh_root_hub_connect_handler ( struct uhcd * hcd,
rt_uint8_t port,
rt_bool_t isHS )

◆ rt_usbh_root_hub_disconnect_handler()

void rt_usbh_root_hub_disconnect_handler ( struct uhcd * hcd,
rt_uint8_t port )

◆ rt_usb_instance_add_pipe()

rt_inline rt_err_t rt_usb_instance_add_pipe ( uinst_t inst,
upipe_t pipe )

在文件 usb_host.h215 行定义.

216{
217 RT_ASSERT(inst != RT_NULL);
218 RT_ASSERT(pipe != RT_NULL);
219 rt_list_insert_before(&inst->pipe, &pipe->list);
220 return RT_EOK;
221}
rt_inline void rt_list_insert_before(rt_list_t *l, rt_list_t *n)
insert a node before a list
#define RT_ASSERT(EX)
#define RT_NULL
rt_list_t pipe
rt_list_t list

引用了 uinstance::pipe, RT_ASSERT, rt_list_insert_before() , 以及 RT_NULL.

+ 函数调用图:

◆ rt_usb_instance_find_pipe()

rt_inline upipe_t rt_usb_instance_find_pipe ( uinst_t inst,
rt_uint8_t ep_address )

在文件 usb_host.h222 行定义.

223{
224 rt_list_t * l;
225 for(l = inst->pipe.next;l != &inst->pipe;l = l->next)
226 {
227 if(rt_list_entry(l,struct upipe,list)->ep.bEndpointAddress == ep_address)
228 {
229 return rt_list_entry(l,struct upipe,list);
230 }
231 }
232 return RT_NULL;
233}
#define rt_list_entry(node, type, member)
get the struct for this entry
struct rt_list_node rt_list_t
struct rt_list_node * next

引用了 rt_list_node::next, uinstance::pipe, rt_list_entry , 以及 RT_NULL.

◆ rt_usb_hcd_alloc_pipe()

rt_inline rt_err_t rt_usb_hcd_alloc_pipe ( uhcd_t hcd,
upipe_t * pipe,
uinst_t inst,
uep_desc_t ep )

在文件 usb_host.h234 行定义.

235{
236 *pipe = (upipe_t)rt_malloc(sizeof(struct upipe));
237 if(*pipe == RT_NULL)
238 {
239 return -RT_ERROR;
240 }
241 rt_memset(*pipe,0,sizeof(struct upipe));
242 (*pipe)->inst = inst;
243 rt_memcpy(&(*pipe)->ep,ep,sizeof(struct uendpoint_descriptor));
244 return hcd->ops->open_pipe(*pipe);
245}
rt_weak void * rt_malloc(rt_size_t size)
Allocate a block of memory with a minimum of 'size' bytes.
rt_err_t(* open_pipe)(upipe_t pipe)
uhcd_ops_t ops
struct upipe * upipe_t

引用了 uinstance::hcd, uhcd_ops::open_pipe, uhcd::ops, uinstance::pipe, rt_malloc() , 以及 RT_NULL.

+ 函数调用图:

◆ rt_usb_pipe_add_callback()

rt_inline void rt_usb_pipe_add_callback ( upipe_t pipe,
func_callback callback )

在文件 usb_host.h246 行定义.

247{
248 pipe->callback = callback;
249}
func_callback callback

引用了 uinstance::pipe.

◆ rt_usb_hcd_free_pipe()

rt_inline rt_err_t rt_usb_hcd_free_pipe ( uhcd_t hcd,
upipe_t pipe )

在文件 usb_host.h251 行定义.

252{
253 RT_ASSERT(pipe != RT_NULL);
254 hcd->ops->close_pipe(pipe);
255 rt_free(pipe);
256 return RT_EOK;
257}
rt_weak void rt_free(void *ptr)
This function will release the previously allocated memory block by rt_malloc. The released memory bl...
rt_err_t(* close_pipe)(upipe_t pipe)

引用了 uhcd_ops::close_pipe, uinstance::hcd, uhcd::ops, uinstance::pipe, RT_ASSERT, rt_free() , 以及 RT_NULL.

+ 函数调用图:

◆ rt_usb_hcd_pipe_xfer()

int rt_usb_hcd_pipe_xfer ( uhcd_t hcd,
upipe_t pipe,
void * buffer,
int nbytes,
int timeout )

◆ rt_usb_hcd_setup_xfer()

rt_inline int rt_usb_hcd_setup_xfer ( uhcd_t hcd,
upipe_t pipe,
ureq_t setup,
int timeout )

在文件 usb_host.h260 行定义.

261{
262 return hcd->ops->pipe_xfer(pipe, USBH_PID_SETUP, (void *)setup, 8, timeout);
263}
int(* pipe_xfer)(upipe_t pipe, rt_uint8_t token, void *buffer, int nbytes, int timeout)
#define USBH_PID_SETUP

引用了 uinstance::hcd, uhcd::ops, uinstance::pipe, uhcd_ops::pipe_xfer , 以及 USBH_PID_SETUP.