From 05aafac28b47cc2888f7e47064022b0c3d30fce8 Mon Sep 17 00:00:00 2001 From: Russ Butler Date: Wed, 14 Mar 2018 18:38:16 -0500 Subject: [PATCH] Update USBTester for simplified read handling Remove read_start and replace read_finish with read to match the new USBDevice API. --- TESTS/usb_device/basic/USBTester.cpp | 19 ++----------------- usb/device/USBDevice/USBDevice.cpp | 3 +-- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/TESTS/usb_device/basic/USBTester.cpp b/TESTS/usb_device/basic/USBTester.cpp index 1f26fce2f1..5ccd7c6822 100644 --- a/TESTS/usb_device/basic/USBTester.cpp +++ b/TESTS/usb_device/basic/USBTester.cpp @@ -148,9 +148,6 @@ void USBTester::callback_set_configuration(uint8_t configuration) endpoint_add(bulk_in, MAX_EP_SIZE, USB_EP_TYPE_BULK); endpoint_add(bulk_out, MAX_EP_SIZE, USB_EP_TYPE_BULK, &USBTester::epbulk_out_callback); - read_start(int_out); - read_start(bulk_out); - complete_set_configuration(true); } @@ -167,9 +164,6 @@ void USBTester::callback_set_interface(uint16_t interface, uint8_t alternate) endpoint_add(bulk_in, MAX_EP_SIZE, USB_EP_TYPE_BULK); endpoint_add(bulk_out, MAX_EP_SIZE, USB_EP_TYPE_BULK, &USBTester::epbulk_out_callback); - read_start(int_out); - read_start(bulk_out); - complete_set_interface(true); return; } @@ -184,9 +178,6 @@ void USBTester::callback_set_interface(uint16_t interface, uint8_t alternate) endpoint_add(bulk_in, MIN_EP_SIZE, USB_EP_TYPE_BULK); endpoint_add(bulk_out, MIN_EP_SIZE, USB_EP_TYPE_BULK, &USBTester::epbulk_out_callback); - read_start(int_out); - read_start(bulk_out); - complete_set_interface(true); return; } @@ -362,10 +353,7 @@ void USBTester::epint_out_callback(usb_ep_t endpoint) uint8_t buffer[65]; uint32_t size = 0; - if (!read_finish(endpoint, buffer, sizeof(buffer), &size)) { - return; - } - if (!read_start(endpoint)) { + if (!read(endpoint, buffer, sizeof(buffer), &size)) { return; } } @@ -374,10 +362,7 @@ void USBTester::epbulk_out_callback(usb_ep_t endpoint) uint8_t buffer[65]; uint32_t size = 0; - if (!read_finish(endpoint, buffer, sizeof(buffer), &size)) { - return; - } - if (!read_start(endpoint)) { + if (!read(endpoint, buffer, sizeof(buffer), &size)) { return; } } diff --git a/usb/device/USBDevice/USBDevice.cpp b/usb/device/USBDevice/USBDevice.cpp index d8cf7ee729..c99b9824ef 100644 --- a/usb/device/USBDevice/USBDevice.cpp +++ b/usb/device/USBDevice/USBDevice.cpp @@ -866,8 +866,6 @@ void USBDevice::out(usb_ep_t endpoint) endpoint_info_t *info = &_endpoint_info[EP_TO_INDEX(endpoint)]; info->pending += 1; - _phy->endpoint_read(endpoint, info->max_packet_size); - if (info->callback) { (this->*(info->callback))(endpoint); } @@ -1229,6 +1227,7 @@ bool USBDevice::read(usb_ep_t endpoint, uint8_t *buffer, uint32_t max_size, uint bool ret = _phy->endpoint_read_result(endpoint, buffer, max_size, size); if (ret) { info->pending -= 1; + _phy->endpoint_read(endpoint, info->max_packet_size); } unlock();