diff options
| author | hathach <[email protected]> | 2025-11-12 21:22:25 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2025-11-12 21:22:25 +0700 |
| commit | f11adb02ebc0c594a7114b08585b8af18c3ee6d6 (patch) | |
| tree | f0165f7ec3b276d99dbfd8f087cadb145ff9c9db /src/class/vendor | |
| parent | 8b8f1f80b4f01fc0fc56ad58af9b784e161636b0 (diff) | |
migrate cdc device to use edpt stream API
tu_edpt_stream_open() does not clear fifo, allow for persistent stream when disconnect/reconnect
Diffstat (limited to 'src/class/vendor')
| -rw-r--r-- | src/class/vendor/vendor_device.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/class/vendor/vendor_device.c b/src/class/vendor/vendor_device.c index c916ebe47..7da4d2239 100644 --- a/src/class/vendor/vendor_device.c +++ b/src/class/vendor/vendor_device.c @@ -234,16 +234,18 @@ uint16_t vendord_open(uint8_t rhport, const tusb_desc_interface_t* desc_itf, uin const tusb_desc_endpoint_t* desc_ep = (const tusb_desc_endpoint_t*) p_desc; TU_ASSERT(usbd_edpt_open(rhport, desc_ep)); - // open endpoint stream, skip if already opened + // open endpoint stream, skip if already opened (multiple IN/OUT endpoints) if (tu_edpt_dir(desc_ep->bEndpointAddress) == TUSB_DIR_IN) { - if (p_vendor->tx.stream.ep_addr == 0) { - tu_edpt_stream_open(&p_vendor->tx.stream, desc_ep); - tud_vendor_n_write_flush(itf); + tu_edpt_stream_t *stream_tx = &p_vendor->tx.stream; + if (stream_tx->ep_addr == 0) { + tu_edpt_stream_open(stream_tx, desc_ep); + tu_edpt_stream_write_xfer(rhport, stream_tx); // flush pending data } } else { - if (p_vendor->rx.stream.ep_addr == 0) { - tu_edpt_stream_open(&p_vendor->rx.stream, desc_ep); - TU_ASSERT(tu_edpt_stream_read_xfer(rhport, &p_vendor->rx.stream) > 0, 0); // prepare for incoming data + tu_edpt_stream_t *stream_rx = &p_vendor->rx.stream; + if (stream_rx->ep_addr == 0) { + tu_edpt_stream_open(stream_rx, desc_ep); + TU_ASSERT(tu_edpt_stream_read_xfer(rhport, stream_rx) > 0, 0); // prepare for incoming data } } } |
