|
1 | 1 | # pyOCD debugger |
2 | 2 | # Copyright (c) 2006-2020 Arm Limited |
| 3 | +# Copyright (c) 2020 Patrick Huesmann |
3 | 4 | # SPDX-License-Identifier: Apache-2.0 |
4 | 5 | # |
5 | 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
@@ -271,14 +272,25 @@ def __call__(self, interface): |
271 | 272 | # Must have either 1 or 2 endpoints. |
272 | 273 | if interface.bNumEndpoints not in (1, 2): |
273 | 274 | return False |
274 | | - |
275 | | - # Endpoint 0 must be interrupt in. |
276 | | - if not check_ep(interface, 0, usb.util.ENDPOINT_IN, usb.util.ENDPOINT_TYPE_INTR): |
277 | | - return False |
278 | | - |
279 | | - # Endpoint 1 is optional. If present it must be interrupt out. |
280 | | - if (interface.bNumEndpoints == 2) \ |
281 | | - and not check_ep(interface, 1, usb.util.ENDPOINT_OUT, usb.util.ENDPOINT_TYPE_INTR): |
| 275 | + |
| 276 | + endpoint_attrs = [ |
| 277 | + (usb.util.endpoint_direction(ep.bEndpointAddress), |
| 278 | + usb.util.endpoint_type(ep.bmAttributes)) |
| 279 | + for ep in interface |
| 280 | + ] |
| 281 | + |
| 282 | + # Possible combinations of endpoints |
| 283 | + ENDPOINT_ATTRS_ALLOWED = [ |
| 284 | + # One interrupt endpoint IN |
| 285 | + [(usb.util.ENDPOINT_IN, usb.util.ENDPOINT_TYPE_INTR)], |
| 286 | + # Two interrupt endpoints, first one IN, second one OUT |
| 287 | + [(usb.util.ENDPOINT_IN, usb.util.ENDPOINT_TYPE_INTR), |
| 288 | + (usb.util.ENDPOINT_OUT, usb.util.ENDPOINT_TYPE_INTR)], |
| 289 | + # Two interrupt endpoints, first one OUT, second one IN |
| 290 | + [(usb.util.ENDPOINT_OUT, usb.util.ENDPOINT_TYPE_INTR), |
| 291 | + (usb.util.ENDPOINT_IN, usb.util.ENDPOINT_TYPE_INTR)], |
| 292 | + ] |
| 293 | + if endpoint_attrs not in ENDPOINT_ATTRS_ALLOWED: |
282 | 294 | return False |
283 | 295 |
|
284 | 296 | # All checks passed, this is a CMSIS-DAPv2 interface! |
|
0 commit comments