Skip to content

Commit ae531a7

Browse files
authored
Merge pull request #1403 from hathach/host-edpt-xfer
Host edpt xfer
2 parents 1915d69 + a270d8d commit ae531a7

File tree

15 files changed

+1340
-917
lines changed

15 files changed

+1340
-917
lines changed

examples/host/bare_api/src/main.c

Lines changed: 286 additions & 74 deletions
Large diffs are not rendered by default.

examples/host/bare_api/src/tusb_config.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@
8181
// 1 hub typically has 4 ports
8282
#define CFG_TUH_DEVICE_MAX (CFG_TUH_HUB ? 4 : 1)
8383

84-
#define CFG_TUH_ENDPOINT_MAX 8
84+
// Max endpoint per device
85+
#define CFG_TUH_ENDPOINT_MAX 8
8586

86-
//------------- HID -------------//
87-
88-
#define CFG_TUH_HID_EP_BUFSIZE 64
87+
// Enable tuh_edpt_xfer() API
88+
#define CFG_TUH_API_EDPT_XFER 1
8989

9090
#ifdef __cplusplus
9191
}

src/class/cdc/cdc_host.c

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -120,32 +120,35 @@ bool tuh_cdc_receive(uint8_t dev_addr, void * p_buffer, uint32_t length, bool is
120120
return usbh_edpt_xfer(dev_addr, ep_in, p_buffer, length);
121121
}
122122

123-
bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_control_xfer_cb_t complete_cb)
123+
bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_xfer_cb_t complete_cb)
124124
{
125125
cdch_data_t const * p_cdc = get_itf(dev_addr);
126126

127-
tuh_control_xfer_t const xfer =
127+
tusb_control_request_t const request =
128128
{
129-
.request =
129+
.bmRequestType_bit =
130130
{
131-
.bmRequestType_bit =
132-
{
133-
.recipient = TUSB_REQ_RCPT_INTERFACE,
134-
.type = TUSB_REQ_TYPE_CLASS,
135-
.direction = TUSB_DIR_OUT
136-
},
137-
.bRequest = CDC_REQUEST_SET_CONTROL_LINE_STATE,
138-
.wValue = (rts ? 2 : 0) | (dtr ? 1 : 0),
139-
.wIndex = p_cdc->itf_num,
140-
.wLength = 0
131+
.recipient = TUSB_REQ_RCPT_INTERFACE,
132+
.type = TUSB_REQ_TYPE_CLASS,
133+
.direction = TUSB_DIR_OUT
141134
},
135+
.bRequest = CDC_REQUEST_SET_CONTROL_LINE_STATE,
136+
.wValue = (rts ? 2 : 0) | (dtr ? 1 : 0),
137+
.wIndex = p_cdc->itf_num,
138+
.wLength = 0
139+
};
142140

141+
tuh_xfer_t xfer =
142+
{
143+
.daddr = dev_addr,
144+
.ep_addr = 0,
145+
.setup = &request,
143146
.buffer = NULL,
144147
.complete_cb = complete_cb,
145-
.user_arg = 0
148+
.user_data = 0
146149
};
147150

148-
return tuh_control_xfer(dev_addr, &xfer);
151+
return tuh_control_xfer(&xfer);
149152
}
150153

151154
//--------------------------------------------------------------------+
@@ -158,6 +161,7 @@ void cdch_init(void)
158161

159162
bool cdch_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *itf_desc, uint16_t max_len)
160163
{
164+
(void) rhport;
161165
(void) max_len;
162166

163167
// Only support ACM subclass
@@ -193,7 +197,7 @@ bool cdch_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *it
193197
// notification endpoint
194198
tusb_desc_endpoint_t const * desc_ep = (tusb_desc_endpoint_t const *) p_desc;
195199

196-
TU_ASSERT( usbh_edpt_open(rhport, dev_addr, desc_ep) );
200+
TU_ASSERT( tuh_edpt_open(dev_addr, desc_ep) );
197201
p_cdc->ep_notif = desc_ep->bEndpointAddress;
198202

199203
drv_len += tu_desc_len(p_desc);
@@ -214,7 +218,7 @@ bool cdch_open(uint8_t rhport, uint8_t dev_addr, tusb_desc_interface_t const *it
214218
tusb_desc_endpoint_t const *desc_ep = (tusb_desc_endpoint_t const *) p_desc;
215219
TU_ASSERT(TUSB_DESC_ENDPOINT == desc_ep->bDescriptorType && TUSB_XFER_BULK == desc_ep->bmAttributes.xfer);
216220

217-
TU_ASSERT(usbh_edpt_open(rhport, dev_addr, desc_ep));
221+
TU_ASSERT(tuh_edpt_open(dev_addr, desc_ep));
218222

219223
if ( tu_edpt_dir(desc_ep->bEndpointAddress) == TUSB_DIR_IN )
220224
{

src/class/cdc/cdc_host.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@
4242
* \defgroup CDC_Serial_Host Host
4343
* @{ */
4444

45-
bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_control_xfer_cb_t complete_cb);
45+
bool tuh_cdc_set_control_line_state(uint8_t dev_addr, bool dtr, bool rts, tuh_xfer_cb_t complete_cb);
4646

47-
static inline bool tuh_cdc_connect(uint8_t dev_addr, tuh_control_xfer_cb_t complete_cb)
47+
static inline bool tuh_cdc_connect(uint8_t dev_addr, tuh_xfer_cb_t complete_cb)
4848
{
4949
return tuh_cdc_set_control_line_state(dev_addr, true, true, complete_cb);
5050
}
5151

52-
static inline bool tuh_cdc_disconnect(uint8_t dev_addr, tuh_control_xfer_cb_t complete_cb)
52+
static inline bool tuh_cdc_disconnect(uint8_t dev_addr, tuh_xfer_cb_t complete_cb)
5353
{
5454
return tuh_cdc_set_control_line_state(dev_addr, false, false, complete_cb);
5555
}

src/class/hid/hid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
/** \defgroup ClassDriver_HID_Common Common Definitions
4444
* @{ */
4545

46-
/// USB HID Descriptor
46+
/// USB HID Descriptor
4747
typedef struct TU_ATTR_PACKED
4848
{
4949
uint8_t bLength; /**< Numeric expression that is the total size of the HID descriptor */

0 commit comments

Comments
 (0)