From 025ca5345a8ffbb7de3b1c64fb0a5ddbbdacd3b0 Mon Sep 17 00:00:00 2001 From: Diego Ismirlian Date: Sun, 9 Jul 2017 18:30:46 -0300 Subject: USBH: Added mechanism for out-of-tree class driver enumeration --- .../STM32F4xx/USB_HOST/usbh_custom_class_example.h | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.h (limited to 'testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.h') diff --git a/testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.h b/testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.h new file mode 100644 index 0000000..b84f2b7 --- /dev/null +++ b/testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.h @@ -0,0 +1,83 @@ +/* + ChibiOS - Copyright (C) 2006..2017 Giovanni Di Sirio + Copyright (C) 2015..2017 Diego Ismirlian, (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_CUSTOM_H_ +#define USBH_CUSTOM_H_ + +#include "hal_usbh.h" + +#if HAL_USE_USBH + + +/*===========================================================================*/ +/* Driver pre-compile time settings. */ +/*===========================================================================*/ +#define USBH_CUSTOM_CLASS_MAX_INSTANCES 1 + +/*===========================================================================*/ +/* Derived constants and error checks. */ +/*===========================================================================*/ + + +/*===========================================================================*/ +/* Driver data structures and types. */ +/*===========================================================================*/ + +typedef enum { + USBHCUSTOM_STATE_UNINIT = 0, + USBHCUSTOM_STATE_STOP = 1, + USBHCUSTOM_STATE_ACTIVE = 2, + USBHCUSTOM_STATE_READY = 3 +} usbhcustom_state_t; + +typedef struct USBHCustomDriver USBHCustomDriver; + +struct USBHCustomDriver { + /* inherited from abstract class driver */ + _usbh_base_classdriver_data + + uint8_t ifnum; + + usbhcustom_state_t state; +}; + + +/*===========================================================================*/ +/* Driver macros. */ +/*===========================================================================*/ + + +/*===========================================================================*/ +/* External declarations. */ +/*===========================================================================*/ + +extern USBHCustomDriver USBHCUSTOMD[USBH_CUSTOM_CLASS_MAX_INSTANCES]; + +#ifdef __cplusplus +extern "C" { +#endif + /* API goes here */ + + /* global initializer */ + void usbhCustomInit(void); +#ifdef __cplusplus +} +#endif + +#endif + +#endif /* USBH_CUSTOM_H_ */ -- cgit v1.2.3 From 89ecbb7daa7132d8815e7b3507a011348ccd0518 Mon Sep 17 00:00:00 2001 From: Diego Ismirlian Date: Sun, 9 Jul 2017 18:36:07 -0300 Subject: USBH: Cleanup example for out-of-tree driver --- testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.h') diff --git a/testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.h b/testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.h index b84f2b7..3f00fe7 100644 --- a/testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.h +++ b/testhal/STM32/STM32F4xx/USB_HOST/usbh_custom_class_example.h @@ -20,8 +20,7 @@ #include "hal_usbh.h" -#if HAL_USE_USBH - +#if HAL_USE_USBH && HAL_USBH_USE_ADDITIONAL_CLASS_DRIVERS /*===========================================================================*/ /* Driver pre-compile time settings. */ @@ -72,8 +71,6 @@ extern "C" { #endif /* API goes here */ - /* global initializer */ - void usbhCustomInit(void); #ifdef __cplusplus } #endif -- cgit v1.2.3