tinyusb
usbh_hcd.h
Go to the documentation of this file.
1 /**************************************************************************/
37 /**************************************************************************/
38 
42 #ifndef _TUSB_USBH_HCD_H_
43 #define _TUSB_USBH_HCD_H_
44 
45 #ifdef __cplusplus
46  extern "C" {
47 #endif
48 
49 //--------------------------------------------------------------------+
50 // INCLUDE
51 //--------------------------------------------------------------------+
52 #include "common/common.h"
53 
54 #ifdef _TEST_
55 #include "hcd.h"
56 #include "osal.h"
57 #endif
58 
59 //--------------------------------------------------------------------+
60 // USBH-HCD common data structure
61 //--------------------------------------------------------------------+
62 typedef struct ATTR_ALIGNED(4){
63  uint8_t core_id;
64  uint8_t hub_addr;
65  uint8_t hub_port;
66  uint8_t reserve;
68 
69 typedef struct {
70  //------------- port -------------//
71  uint8_t core_id;
72  uint8_t hub_addr;
73  uint8_t hub_port;
74  uint8_t speed;
75 
76  //------------- device descriptor -------------//
77  uint16_t vendor_id;
78  uint16_t product_id;
79  uint8_t configure_count; // bNumConfigurations alias
80 
81  //------------- configuration descriptor -------------//
82  uint8_t interface_count; // bNumInterfaces alias
83 
84  //------------- device -------------//
85  volatile uint8_t state; // device state, value from enum tusbh_device_state_t
86  uint32_t flag_supported_class; // a bitmap of supported class
87 
88  //------------- control pipe -------------//
89  struct {
90  volatile uint8_t pipe_status;
91 // uint8_t xferred_bytes; TODO not yet necessary
92  tusb_control_request_t request;
93 
94  OSAL_SEM_DEF(semaphore); // TODO move to semaphore pool ?
95  osal_semaphore_handle_t sem_hdl; // used to synchronize with HCD when control xfer complete
96 
97  OSAL_MUTEX_DEF(mutex); // TODO move to mutex pool ?
98  osal_mutex_handle_t mutex_hdl; // used to exclusively occupy control pipe
99  } control;
101 
102 extern usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1]; // including zero-address
103 
104 //--------------------------------------------------------------------+
105 // callback from HCD ISR
106 //--------------------------------------------------------------------+
107 void usbh_xfer_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_event_t event, uint32_t xferred_bytes);
108 void usbh_hcd_rhport_plugged_isr(uint8_t hostid);
109 void usbh_hcd_rhport_unplugged_isr(uint8_t hostid);
110 
111 #ifdef __cplusplus
112  }
113 #endif
114 
115 #endif /* _TUSB_USBH_HCD_H_ */
116 
Definition: std_request.h:49
Definition: hcd.h:55
#define TUSB_CFG_HOST_DEVICE_MAX
Maximum number of device host stack can manage If hub class is not enabled, set this equal to numbe...
Definition: configuration.txt:35
Definition: usbh_hcd.h:62
Definition: usbh_hcd.h:69
#define ATTR_ALIGNED(Bytes)
This attribute specifies a minimum alignment for the variable or structure field, measured in bytes...
Definition: compiler_gcc.h:72