diff options
author | Uladzimir Pylinski <barthess@yandex.ru> | 2016-02-17 21:18:15 +0300 |
---|---|---|
committer | Uladzimir Pylinski <barthess@yandex.ru> | 2016-02-17 21:18:15 +0300 |
commit | 31066ddfbffd2ee801e63c090e30929bae5b0e43 (patch) | |
tree | b165f84bc96d0dc961d4e570d1520dde06e5c70b /os/hal/include/usbh/desciter.h | |
parent | d51d9c799f4ed64398f47945329b3138f44c8a37 (diff) | |
parent | 771feb098db86458340ab2665dfb23bef970ace6 (diff) | |
download | ChibiOS-Contrib-31066ddfbffd2ee801e63c090e30929bae5b0e43.tar.gz ChibiOS-Contrib-31066ddfbffd2ee801e63c090e30929bae5b0e43.tar.bz2 ChibiOS-Contrib-31066ddfbffd2ee801e63c090e30929bae5b0e43.zip |
Merge pull request #40 from fpoussin/usb-host-pull
USB-Host Driver
Merged pull request #40 from fpoussin/usb-host-pull
Diffstat (limited to 'os/hal/include/usbh/desciter.h')
-rw-r--r-- | os/hal/include/usbh/desciter.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/os/hal/include/usbh/desciter.h b/os/hal/include/usbh/desciter.h new file mode 100644 index 0000000..52b0c98 --- /dev/null +++ b/os/hal/include/usbh/desciter.h @@ -0,0 +1,63 @@ +/*
+ ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio
+ Copyright (C) 2015 Diego Ismirlian, TISA, (dismirlian (at) google's mail)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+
+#ifndef USBH_DESCITER_H_
+#define USBH_DESCITER_H_
+
+#include "hal.h"
+
+#if HAL_USE_USBH
+
+#include "usbh/defs.h"
+
+
+/* DESCRIPTOR PARSING */
+#define _generic_iterator_fields \
+ const uint8_t *curr; \
+ uint16_t rem; \
+ bool valid;
+
+typedef struct {
+ _generic_iterator_fields
+} generic_iterator_t;
+
+typedef struct {
+ _generic_iterator_fields
+ const usbh_ia_descriptor_t *iad;
+} if_iterator_t;
+
+void cfg_iter_init(generic_iterator_t *icfg, const uint8_t *buff, uint16_t rem);
+void if_iter_init(if_iterator_t *iif, const generic_iterator_t *icfg);
+void ep_iter_init(generic_iterator_t *iep, const if_iterator_t *iif);
+void cs_iter_init(generic_iterator_t *ics, const generic_iterator_t *iter);
+void if_iter_next(if_iterator_t *iif);
+void ep_iter_next(generic_iterator_t *iep);
+void cs_iter_next(generic_iterator_t *ics);
+static inline const usbh_config_descriptor_t *cfg_get(generic_iterator_t *icfg) {
+ return (const usbh_config_descriptor_t *)icfg->curr;
+}
+static inline const usbh_interface_descriptor_t *if_get(if_iterator_t *iif) {
+ return (const usbh_interface_descriptor_t *)iif->curr;
+}
+static inline const usbh_endpoint_descriptor_t *ep_get(generic_iterator_t *iep) {
+ return (const usbh_endpoint_descriptor_t *)iep->curr;
+}
+
+#endif
+
+#endif /* USBH_DESCITER_H_ */
|