diff options
Diffstat (limited to 'firmware/usbstack/usb_benchmark.c')
-rw-r--r-- | firmware/usbstack/usb_benchmark.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/firmware/usbstack/usb_benchmark.c b/firmware/usbstack/usb_benchmark.c index a6e0e2d3e7..7cd5a3e987 100644 --- a/firmware/usbstack/usb_benchmark.c +++ b/firmware/usbstack/usb_benchmark.c | |||
@@ -22,6 +22,8 @@ | |||
22 | //#define LOGF_ENABLE | 22 | //#define LOGF_ENABLE |
23 | #include "logf.h" | 23 | #include "logf.h" |
24 | 24 | ||
25 | #ifdef USB_BENCHMARK | ||
26 | |||
25 | static int current_length; | 27 | static int current_length; |
26 | 28 | ||
27 | static unsigned char _input_buffer[16384]; | 29 | static unsigned char _input_buffer[16384]; |
@@ -56,8 +58,8 @@ void usb_benchmark_control_request(struct usb_ctrlrequest* req) | |||
56 | logf("bench: read %d", current_length); | 58 | logf("bench: read %d", current_length); |
57 | todo = MIN(usb_max_pkt_size, current_length); | 59 | todo = MIN(usb_max_pkt_size, current_length); |
58 | state = SENDING; | 60 | state = SENDING; |
59 | usb_drv_reset_endpoint(EP_TX, true); | 61 | usb_drv_reset_endpoint(EP_BENCHMARK, true); |
60 | usb_drv_send(EP_TX, &input_buffer, todo); | 62 | usb_drv_send(EP_BENCHMARK, &input_buffer, todo); |
61 | current_length -= todo; | 63 | current_length -= todo; |
62 | break; | 64 | break; |
63 | 65 | ||
@@ -66,13 +68,13 @@ void usb_benchmark_control_request(struct usb_ctrlrequest* req) | |||
66 | current_length = req->wValue * req->wIndex; | 68 | current_length = req->wValue * req->wIndex; |
67 | logf("bench: write %d", current_length); | 69 | logf("bench: write %d", current_length); |
68 | state = RECEIVING; | 70 | state = RECEIVING; |
69 | usb_drv_reset_endpoint(EP_RX, false); | 71 | usb_drv_reset_endpoint(EP_BENCHMARK, false); |
70 | usb_drv_recv(EP_RX, &input_buffer, sizeof _input_buffer); | 72 | usb_drv_recv(EP_BENCHMARK, &input_buffer, sizeof _input_buffer); |
71 | break; | 73 | break; |
72 | } | 74 | } |
73 | } | 75 | } |
74 | 76 | ||
75 | void usb_benchmark_transfer_complete(int endpoint, bool in) | 77 | void usb_benchmark_transfer_complete(bool in) |
76 | { | 78 | { |
77 | (void)in; | 79 | (void)in; |
78 | 80 | ||
@@ -87,26 +89,26 @@ void usb_benchmark_transfer_complete(int endpoint, bool in) | |||
87 | { | 89 | { |
88 | case SENDING: { | 90 | case SENDING: { |
89 | int todo = MIN(usb_max_pkt_size, current_length); | 91 | int todo = MIN(usb_max_pkt_size, current_length); |
90 | if (endpoint == EP_RX) { | 92 | if (in == false) { |
91 | logf("unexpected ep_rx"); | 93 | logf("unexpected ep_rx"); |
92 | break; | 94 | break; |
93 | } | 95 | } |
94 | 96 | ||
95 | logf("bench: %d more tx", current_length); | 97 | logf("bench: %d more tx", current_length); |
96 | usb_drv_send(EP_TX, &input_buffer, todo); | 98 | usb_drv_send(EP_BENCHMARK, &input_buffer, todo); |
97 | current_length -= todo; | 99 | current_length -= todo; |
98 | input_buffer[0]++; | 100 | input_buffer[0]++; |
99 | break; | 101 | break; |
100 | } | 102 | } |
101 | 103 | ||
102 | case RECEIVING: | 104 | case RECEIVING: |
103 | if (endpoint == EP_TX) { | 105 | if (in == true) { |
104 | logf("unexpected ep_tx"); | 106 | logf("unexpected ep_tx"); |
105 | break; | 107 | break; |
106 | } | 108 | } |
107 | 109 | ||
108 | /* re-prime endpoint */ | 110 | /* re-prime endpoint */ |
109 | usb_drv_recv(EP_RX, &input_buffer, sizeof _input_buffer); | 111 | usb_drv_recv(EP_BENCHMARK, &input_buffer, sizeof _input_buffer); |
110 | input_buffer[0]++; | 112 | input_buffer[0]++; |
111 | break; | 113 | break; |
112 | 114 | ||
@@ -123,3 +125,4 @@ static void ack_control(struct usb_ctrlrequest* req) | |||
123 | else | 125 | else |
124 | usb_drv_send(EP_CONTROL, NULL, 0); | 126 | usb_drv_send(EP_CONTROL, NULL, 0); |
125 | } | 127 | } |
128 | #endif /*USB_BENCHMARK*/ | ||