Skip to content

Commit 1ee2866

Browse files
committed
Update USBTester for simplified read handling
Remove read_start and replace read_finish with read to match the new USBDevice API.
1 parent 9feda72 commit 1ee2866

File tree

2 files changed

+3
-19
lines changed

2 files changed

+3
-19
lines changed

TESTS/usb_device/basic/USBTester.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,6 @@ void USBTester::callback_set_configuration(uint8_t configuration)
148148
endpoint_add(bulk_in, MAX_EP_SIZE, USB_EP_TYPE_BULK);
149149
endpoint_add(bulk_out, MAX_EP_SIZE, USB_EP_TYPE_BULK, &USBTester::epbulk_out_callback);
150150

151-
read_start(int_out);
152-
read_start(bulk_out);
153-
154151
complete_set_configuration(true);
155152
}
156153

@@ -167,9 +164,6 @@ void USBTester::callback_set_interface(uint16_t interface, uint8_t alternate)
167164
endpoint_add(bulk_in, MAX_EP_SIZE, USB_EP_TYPE_BULK);
168165
endpoint_add(bulk_out, MAX_EP_SIZE, USB_EP_TYPE_BULK, &USBTester::epbulk_out_callback);
169166

170-
read_start(int_out);
171-
read_start(bulk_out);
172-
173167
complete_set_interface(true);
174168
return;
175169
}
@@ -184,9 +178,6 @@ void USBTester::callback_set_interface(uint16_t interface, uint8_t alternate)
184178
endpoint_add(bulk_in, MIN_EP_SIZE, USB_EP_TYPE_BULK);
185179
endpoint_add(bulk_out, MIN_EP_SIZE, USB_EP_TYPE_BULK, &USBTester::epbulk_out_callback);
186180

187-
read_start(int_out);
188-
read_start(bulk_out);
189-
190181
complete_set_interface(true);
191182
return;
192183
}
@@ -362,10 +353,7 @@ void USBTester::epint_out_callback(usb_ep_t endpoint)
362353
uint8_t buffer[65];
363354
uint32_t size = 0;
364355

365-
if (!read_finish(endpoint, buffer, sizeof(buffer), &size)) {
366-
return;
367-
}
368-
if (!read_start(endpoint)) {
356+
if (!read(endpoint, buffer, sizeof(buffer), &size)) {
369357
return;
370358
}
371359
}
@@ -374,10 +362,7 @@ void USBTester::epbulk_out_callback(usb_ep_t endpoint)
374362
uint8_t buffer[65];
375363
uint32_t size = 0;
376364

377-
if (!read_finish(endpoint, buffer, sizeof(buffer), &size)) {
378-
return;
379-
}
380-
if (!read_start(endpoint)) {
365+
if (!read(endpoint, buffer, sizeof(buffer), &size)) {
381366
return;
382367
}
383368
}

usb/device/USBDevice/USBDevice.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,8 +866,6 @@ void USBDevice::out(usb_ep_t endpoint)
866866
endpoint_info_t *info = &_endpoint_info[EP_TO_INDEX(endpoint)];
867867

868868
info->pending += 1;
869-
_phy->endpoint_read(endpoint, info->max_packet_size);
870-
871869
if (info->callback) {
872870
(this->*(info->callback))(endpoint);
873871
}
@@ -1229,6 +1227,7 @@ bool USBDevice::read(usb_ep_t endpoint, uint8_t *buffer, uint32_t max_size, uint
12291227
bool ret = _phy->endpoint_read_result(endpoint, buffer, max_size, size);
12301228
if (ret) {
12311229
info->pending -= 1;
1230+
_phy->endpoint_read(endpoint, info->max_packet_size);
12321231
}
12331232

12341233
unlock();

0 commit comments

Comments
 (0)