diff options
Diffstat (limited to 'lib/chibios-contrib/os/hal/include/usbh/desciter.h')
-rw-r--r-- | lib/chibios-contrib/os/hal/include/usbh/desciter.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/lib/chibios-contrib/os/hal/include/usbh/desciter.h b/lib/chibios-contrib/os/hal/include/usbh/desciter.h new file mode 100644 index 000000000..bab2f0457 --- /dev/null +++ b/lib/chibios-contrib/os/hal/include/usbh/desciter.h | |||
@@ -0,0 +1,63 @@ | |||
1 | /* | ||
2 | ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio | ||
3 | Copyright (C) 2015..2019 Diego Ismirlian, (dismirlian(at)google's mail) | ||
4 | |||
5 | Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | you may not use this file except in compliance with the License. | ||
7 | You may obtain a copy of the License at | ||
8 | |||
9 | http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | |||
11 | Unless required by applicable law or agreed to in writing, software | ||
12 | distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | See the License for the specific language governing permissions and | ||
15 | limitations under the License. | ||
16 | */ | ||
17 | |||
18 | |||
19 | #ifndef USBH_DESCITER_H_ | ||
20 | #define USBH_DESCITER_H_ | ||
21 | |||
22 | #include "hal.h" | ||
23 | |||
24 | #if HAL_USE_USBH | ||
25 | |||
26 | #include "usbh/defs.h" | ||
27 | |||
28 | |||
29 | /* DESCRIPTOR PARSING */ | ||
30 | #define _generic_iterator_fields \ | ||
31 | const uint8_t *curr; \ | ||
32 | uint16_t rem; \ | ||
33 | bool valid; | ||
34 | |||
35 | typedef struct { | ||
36 | _generic_iterator_fields | ||
37 | } generic_iterator_t; | ||
38 | |||
39 | typedef struct { | ||
40 | _generic_iterator_fields | ||
41 | const usbh_ia_descriptor_t *iad; | ||
42 | } if_iterator_t; | ||
43 | |||
44 | void cfg_iter_init(generic_iterator_t *icfg, const uint8_t *buff, uint16_t rem); | ||
45 | void if_iter_init(if_iterator_t *iif, const generic_iterator_t *icfg); | ||
46 | void ep_iter_init(generic_iterator_t *iep, const if_iterator_t *iif); | ||
47 | void cs_iter_init(generic_iterator_t *ics, const generic_iterator_t *iter); | ||
48 | void if_iter_next(if_iterator_t *iif); | ||
49 | void ep_iter_next(generic_iterator_t *iep); | ||
50 | void cs_iter_next(generic_iterator_t *ics); | ||
51 | static inline const usbh_config_descriptor_t *cfg_get(generic_iterator_t *icfg) { | ||
52 | return (const usbh_config_descriptor_t *)icfg->curr; | ||
53 | } | ||
54 | static inline const usbh_interface_descriptor_t *if_get(if_iterator_t *iif) { | ||
55 | return (const usbh_interface_descriptor_t *)iif->curr; | ||
56 | } | ||
57 | static inline const usbh_endpoint_descriptor_t *ep_get(generic_iterator_t *iep) { | ||
58 | return (const usbh_endpoint_descriptor_t *)iep->curr; | ||
59 | } | ||
60 | |||
61 | #endif | ||
62 | |||
63 | #endif /* USBH_DESCITER_H_ */ | ||