summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2023-05-25 16:53:32 +0700
committerhathach <[email protected]>2023-05-25 16:53:32 +0700
commit26d05d7fc922f3715799f6049556232d5ed5c8e3 (patch)
tree1fd3593e63ad38c65e0a95b072c64ac82d81deb5
parent625c27ca58dc2782da77c210c5d5878ce4b1fc12 (diff)
fix issue with ftdi host driver with status bytes
add workflow_dispatch to all ci workflow
-rw-r--r--.github/workflows/build_aarch64.yml1
-rw-r--r--.github/workflows/build_arm.yml1
-rw-r--r--.github/workflows/build_esp.yml1
-rw-r--r--.github/workflows/build_iar.yml1
-rw-r--r--.github/workflows/build_msp430.yml1
-rw-r--r--.github/workflows/build_renesas.yml1
-rw-r--r--.github/workflows/build_riscv.yml1
-rw-r--r--.github/workflows/build_win_mac.yml1
-rw-r--r--.github/workflows/cifuzz.yml1
-rw-r--r--src/class/cdc/cdc_host.c36
-rw-r--r--src/common/tusb_private.h17
11 files changed, 37 insertions, 25 deletions
diff --git a/.github/workflows/build_aarch64.yml b/.github/workflows/build_aarch64.yml
index cc8ddb070..77d3778d7 100644
--- a/.github/workflows/build_aarch64.yml
+++ b/.github/workflows/build_aarch64.yml
@@ -1,6 +1,7 @@
name: Build AArch64
on:
+ workflow_dispatch:
push:
paths:
- 'src/**'
diff --git a/.github/workflows/build_arm.yml b/.github/workflows/build_arm.yml
index 917c83d74..1db9586af 100644
--- a/.github/workflows/build_arm.yml
+++ b/.github/workflows/build_arm.yml
@@ -1,6 +1,7 @@
name: Build ARM
on:
+ workflow_dispatch:
push:
paths:
- 'src/**'
diff --git a/.github/workflows/build_esp.yml b/.github/workflows/build_esp.yml
index 0a6815ea2..29585cb36 100644
--- a/.github/workflows/build_esp.yml
+++ b/.github/workflows/build_esp.yml
@@ -1,6 +1,7 @@
name: Build ESP
on:
+ workflow_dispatch:
push:
paths:
- 'src/**'
diff --git a/.github/workflows/build_iar.yml b/.github/workflows/build_iar.yml
index a5d24892f..8c3b57e10 100644
--- a/.github/workflows/build_iar.yml
+++ b/.github/workflows/build_iar.yml
@@ -1,6 +1,7 @@
name: Build IAR
on:
+ workflow_dispatch:
push:
paths:
- 'src/**'
diff --git a/.github/workflows/build_msp430.yml b/.github/workflows/build_msp430.yml
index 7cb60dceb..5424a88d6 100644
--- a/.github/workflows/build_msp430.yml
+++ b/.github/workflows/build_msp430.yml
@@ -1,6 +1,7 @@
name: Build MSP430
on:
+ workflow_dispatch:
push:
paths:
- 'src/**'
diff --git a/.github/workflows/build_renesas.yml b/.github/workflows/build_renesas.yml
index ffdeedb71..3f0a4b694 100644
--- a/.github/workflows/build_renesas.yml
+++ b/.github/workflows/build_renesas.yml
@@ -1,6 +1,7 @@
name: Build Renesas
on:
+ workflow_dispatch:
push:
paths:
- 'src/**'
diff --git a/.github/workflows/build_riscv.yml b/.github/workflows/build_riscv.yml
index 87c7b522e..8682d655a 100644
--- a/.github/workflows/build_riscv.yml
+++ b/.github/workflows/build_riscv.yml
@@ -1,6 +1,7 @@
name: Build RISC-V
on:
+ workflow_dispatch:
push:
paths:
- 'src/**'
diff --git a/.github/workflows/build_win_mac.yml b/.github/workflows/build_win_mac.yml
index 4b743a686..45fc62f78 100644
--- a/.github/workflows/build_win_mac.yml
+++ b/.github/workflows/build_win_mac.yml
@@ -1,6 +1,7 @@
name: Build Windows/MacOS
on:
+ workflow_dispatch:
push:
paths:
- 'src/**'
diff --git a/.github/workflows/cifuzz.yml b/.github/workflows/cifuzz.yml
index 7314fd9e6..4c4b12a6b 100644
--- a/.github/workflows/cifuzz.yml
+++ b/.github/workflows/cifuzz.yml
@@ -1,5 +1,6 @@
name: CIFuzz
on:
+ workflow_dispatch:
pull_request:
branches:
- master
diff --git a/src/class/cdc/cdc_host.c b/src/class/cdc/cdc_host.c
index 9ff666ed4..ce9f27c33 100644
--- a/src/class/cdc/cdc_host.c
+++ b/src/class/cdc/cdc_host.c
@@ -550,8 +550,7 @@ void cdch_close(uint8_t daddr)
}
}
-bool cdch_xfer_cb(uint8_t daddr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes)
-{
+bool cdch_xfer_cb(uint8_t daddr, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes) {
// TODO handle stall response, retry failed transfer ...
TU_ASSERT(event == XFER_RESULT_SUCCESS);
@@ -559,41 +558,40 @@ bool cdch_xfer_cb(uint8_t daddr, uint8_t ep_addr, xfer_result_t event, uint32_t
cdch_interface_t * p_cdc = get_itf(idx);
TU_ASSERT(p_cdc);
- if ( ep_addr == p_cdc->stream.tx.ep_addr )
- {
+ if ( ep_addr == p_cdc->stream.tx.ep_addr ) {
// invoke tx complete callback to possibly refill tx fifo
if (tuh_cdc_tx_complete_cb) tuh_cdc_tx_complete_cb(idx);
- if ( 0 == tu_edpt_stream_write_xfer(&p_cdc->stream.tx) )
- {
+ if ( 0 == tu_edpt_stream_write_xfer(&p_cdc->stream.tx) ) {
// If there is no data left, a ZLP should be sent if:
// - xferred_bytes is multiple of EP Packet size and not zero
tu_edpt_stream_write_zlp_if_needed(&p_cdc->stream.tx, xferred_bytes);
}
}
- else if ( ep_addr == p_cdc->stream.rx.ep_addr )
- {
- tu_edpt_stream_read_xfer_complete(&p_cdc->stream.rx, xferred_bytes);
-
+ else if ( ep_addr == p_cdc->stream.rx.ep_addr ) {
#if CFG_TUH_CDC_FTDI
- // FTDI reserve 2 bytes for status
if (p_cdc->serial_drid == SERIAL_DRIVER_FTDI) {
- uint8_t status[2];
- tu_edpt_stream_read(&p_cdc->stream.rx, status, 2);
- (void) status; // TODO handle status
- }
+ // FTDI reserve 2 bytes for status
+ // FTDI status
+// uint8_t status[2] = {
+// p_cdc->stream.rx.ep_buf[0],
+// p_cdc->stream.rx.ep_buf[1]
+// };
+ tu_edpt_stream_read_xfer_complete_offset(&p_cdc->stream.rx, xferred_bytes, 2);
+ }else
#endif
+ {
+ tu_edpt_stream_read_xfer_complete(&p_cdc->stream.rx, xferred_bytes);
+ }
// invoke receive callback
if (tuh_cdc_rx_cb) tuh_cdc_rx_cb(idx);
// prepare for next transfer if needed
tu_edpt_stream_read_xfer(&p_cdc->stream.rx);
- }else if ( ep_addr == p_cdc->ep_notif )
- {
+ }else if ( ep_addr == p_cdc->ep_notif ) {
// TODO handle notification endpoint
- }else
- {
+ }else {
TU_ASSERT(false);
}
diff --git a/src/common/tusb_private.h b/src/common/tusb_private.h
index d5541856c..db1ba974d 100644
--- a/src/common/tusb_private.h
+++ b/src/common/tusb_private.h
@@ -148,21 +148,26 @@ uint32_t tu_edpt_stream_read_xfer(tu_edpt_stream_t* s);
// Must be called in the transfer complete callback
TU_ATTR_ALWAYS_INLINE static inline
-void tu_edpt_stream_read_xfer_complete(tu_edpt_stream_t* s, uint32_t xferred_bytes)
-{
+void tu_edpt_stream_read_xfer_complete(tu_edpt_stream_t* s, uint32_t xferred_bytes) {
tu_fifo_write_n(&s->ff, s->ep_buf, (uint16_t) xferred_bytes);
}
+// Same as tu_edpt_stream_read_xfer_complete but skip the first n bytes
+TU_ATTR_ALWAYS_INLINE static inline
+void tu_edpt_stream_read_xfer_complete_offset(tu_edpt_stream_t* s, uint32_t xferred_bytes, uint32_t skip_offset) {
+ if (skip_offset < xferred_bytes) {
+ tu_fifo_write_n(&s->ff, s->ep_buf + skip_offset, (uint16_t) (xferred_bytes - skip_offset));
+ }
+}
+
// Get the number of bytes available for reading
TU_ATTR_ALWAYS_INLINE static inline
-uint32_t tu_edpt_stream_read_available(tu_edpt_stream_t* s)
-{
+uint32_t tu_edpt_stream_read_available(tu_edpt_stream_t* s) {
return (uint32_t) tu_fifo_count(&s->ff);
}
TU_ATTR_ALWAYS_INLINE static inline
-bool tu_edpt_stream_peek(tu_edpt_stream_t* s, uint8_t* ch)
-{
+bool tu_edpt_stream_peek(tu_edpt_stream_t* s, uint8_t* ch) {
return tu_fifo_peek(&s->ff, ch);
}