From 9e4b855e5309976ead84d6cc65288e0e03f27ba5 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 27 Nov 2024 11:35:21 +0700 Subject: [PATCH] minor clean up --- src/class/cdc/cdc_host.c | 8 ++++---- src/class/hid/hid_host.c | 18 +++++++++--------- src/host/usbh.c | 2 -- src/host/usbh.h | 2 -- test/hil/hil_test.py | 2 +- tools/build.py | 2 +- 6 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/class/cdc/cdc_host.c b/src/class/cdc/cdc_host.c index d92fd875d..e817ebc7e 100644 --- a/src/class/cdc/cdc_host.c +++ b/src/class/cdc/cdc_host.c @@ -78,8 +78,8 @@ typedef struct { } cdch_interface_t; typedef struct { - TUH_EPBUF_DEF(tx_ep_buf, CFG_TUH_CDC_TX_EPSIZE); - TUH_EPBUF_DEF(rx_ep_buf, CFG_TUH_CDC_TX_EPSIZE); + TUH_EPBUF_DEF(tx, CFG_TUH_CDC_TX_EPSIZE); + TUH_EPBUF_DEF(rx, CFG_TUH_CDC_TX_EPSIZE); } cdch_epbuf_t; static cdch_interface_t cdch_data[CFG_TUH_CDC]; @@ -631,11 +631,11 @@ bool cdch_init(void) { cdch_epbuf_t* epbuf = &cdch_epbuf[i]; tu_edpt_stream_init(&p_cdc->stream.tx, true, true, false, p_cdc->stream.tx_ff_buf, CFG_TUH_CDC_TX_BUFSIZE, - epbuf->tx_ep_buf, CFG_TUH_CDC_TX_EPSIZE); + epbuf->tx, CFG_TUH_CDC_TX_EPSIZE); tu_edpt_stream_init(&p_cdc->stream.rx, true, false, false, p_cdc->stream.rx_ff_buf, CFG_TUH_CDC_RX_BUFSIZE, - epbuf->rx_ep_buf, CFG_TUH_CDC_RX_EPSIZE); + epbuf->rx, CFG_TUH_CDC_RX_EPSIZE); } return true; diff --git a/src/class/hid/hid_host.c b/src/class/hid/hid_host.c index 5ce47606d..eef584d74 100644 --- a/src/class/hid/hid_host.c +++ b/src/class/hid/hid_host.c @@ -61,8 +61,8 @@ typedef struct { } hidh_interface_t; typedef struct { - TUH_EPBUF_DEF(epin_buf, CFG_TUH_HID_EPIN_BUFSIZE); - TUH_EPBUF_DEF(epout_buf, CFG_TUH_HID_EPOUT_BUFSIZE); + TUH_EPBUF_DEF(epin, CFG_TUH_HID_EPIN_BUFSIZE); + TUH_EPBUF_DEF(epout, CFG_TUH_HID_EPOUT_BUFSIZE); } hidh_epbuf_t; static hidh_interface_t _hidh_itf[CFG_TUH_HID]; @@ -363,7 +363,7 @@ bool tuh_hid_receive_report(uint8_t daddr, uint8_t idx) { // claim endpoint TU_VERIFY(usbh_edpt_claim(daddr, p_hid->ep_in)); - if (!usbh_edpt_xfer(daddr, p_hid->ep_in, epbuf->epin_buf, p_hid->epin_size)) { + if (!usbh_edpt_xfer(daddr, p_hid->ep_in, epbuf->epin, p_hid->epin_size)) { usbh_edpt_release(daddr, p_hid->ep_in); return false; } @@ -403,16 +403,16 @@ bool tuh_hid_send_report(uint8_t daddr, uint8_t idx, uint8_t report_id, const vo if (report_id == 0) { // No report ID in transmission - memcpy(&epbuf->epout_buf[0], report, len); + memcpy(&epbuf->epout[0], report, len); } else { - epbuf->epout_buf[0] = report_id; - memcpy(&epbuf->epout_buf[1], report, len); + epbuf->epout[0] = report_id; + memcpy(&epbuf->epout[1], report, len); ++len; // 1 more byte for report_id } TU_LOG3_MEM(p_hid->epout_buf, len, 2); - if (!usbh_edpt_xfer(daddr, p_hid->ep_out, epbuf->epout_buf, len)) { + if (!usbh_edpt_xfer(daddr, p_hid->ep_out, epbuf->epout, len)) { usbh_edpt_release(daddr, p_hid->ep_out); return false; } @@ -446,10 +446,10 @@ bool hidh_xfer_cb(uint8_t daddr, uint8_t ep_addr, xfer_result_t result, uint32_t if (dir == TUSB_DIR_IN) { TU_LOG_DRV(" Get Report callback (%u, %u)\r\n", daddr, idx); TU_LOG3_MEM(p_hid->epin_buf, xferred_bytes, 2); - tuh_hid_report_received_cb(daddr, idx, epbuf->epin_buf, (uint16_t) xferred_bytes); + tuh_hid_report_received_cb(daddr, idx, epbuf->epin, (uint16_t) xferred_bytes); } else { if (tuh_hid_report_sent_cb) { - tuh_hid_report_sent_cb(daddr, idx, epbuf->epout_buf, (uint16_t) xferred_bytes); + tuh_hid_report_sent_cb(daddr, idx, epbuf->epout, (uint16_t) xferred_bytes); } } diff --git a/src/host/usbh.c b/src/host/usbh.c index 73753a713..a9a692455 100644 --- a/src/host/usbh.c +++ b/src/host/usbh.c @@ -1477,8 +1477,6 @@ static void process_enumeration(tuh_xfer_t* xfer) { dev->i_product = desc_device->iProduct; dev->i_serial = desc_device->iSerialNumber; - // if (tuh_attach_cb) tuh_attach_cb((tusb_desc_device_t*) _usbh_epbuf.ctrl); - // Get 9-byte for total length uint8_t const config_idx = CONFIG_NUM - 1; TU_LOG_USBH("Get Configuration[0] Descriptor (9 bytes)\r\n"); diff --git a/src/host/usbh.h b/src/host/usbh.h index 20fad284e..72c237573 100644 --- a/src/host/usbh.h +++ b/src/host/usbh.h @@ -96,8 +96,6 @@ typedef union { // APPLICATION CALLBACK //--------------------------------------------------------------------+ -//TU_ATTR_WEAK uint8_t tuh_attach_cb (tusb_desc_device_t const *desc_device); - // Invoked when a device is mounted (configured) TU_ATTR_WEAK void tuh_mount_cb (uint8_t daddr); diff --git a/test/hil/hil_test.py b/test/hil/hil_test.py index f125c0d28..a9f5dc1e1 100755 --- a/test/hil/hil_test.py +++ b/test/hil/hil_test.py @@ -549,7 +549,7 @@ def test_board(board): for f1 in flags_on_list: f1_str = "" if f1 != "": - f1_str = '-' + f1.replace(' ', '-') + f1_str = '-f1_' + f1.replace(' ', '_') for test in test_list: fw_dir = f'{TINYUSB_ROOT}/cmake-build/cmake-build-{name}{f1_str}/{test}' if not os.path.exists(fw_dir): diff --git a/tools/build.py b/tools/build.py index 48666adc4..3a9239bc2 100755 --- a/tools/build.py +++ b/tools/build.py @@ -90,7 +90,7 @@ def cmake_board(board, toolchain, build_flags_on): if len(build_flags_on) > 0: build_flags = ' '.join(f'-D{flag}=1' for flag in build_flags_on) build_flags = f'-DCFLAGS_CLI="{build_flags}"' - build_dir += '-' + '-'.join(build_flags_on) + build_dir += '-f1_' + '_'.join(build_flags_on) family = find_family(board) if family == 'espressif':