diff options
Diffstat (limited to 'os')
-rw-r--r-- | os/hal/include/hal_usbh.h | 6 | ||||
-rw-r--r-- | os/hal/include/usbh/dev/aoa.h | 4 | ||||
-rw-r--r-- | os/hal/include/usbh/dev/ftdi.h | 7 | ||||
-rw-r--r-- | os/hal/include/usbh/dev/hid.h | 6 | ||||
-rw-r--r-- | os/hal/include/usbh/dev/hub.h | 4 | ||||
-rw-r--r-- | os/hal/include/usbh/dev/msd.h | 3 | ||||
-rw-r--r-- | os/hal/include/usbh/dev/uvc.h | 8 | ||||
-rw-r--r-- | os/hal/src/hal_usbh.c | 42 | ||||
-rw-r--r-- | os/hal/src/usbh/hal_usbh_aoa.c | 8 | ||||
-rw-r--r-- | os/hal/src/usbh/hal_usbh_ftdi.c | 15 | ||||
-rw-r--r-- | os/hal/src/usbh/hal_usbh_hid.c | 8 | ||||
-rw-r--r-- | os/hal/src/usbh/hal_usbh_hub.c | 21 | ||||
-rw-r--r-- | os/hal/src/usbh/hal_usbh_msd.c | 18 | ||||
-rw-r--r-- | os/hal/src/usbh/hal_usbh_uvc.c | 38 |
14 files changed, 85 insertions, 103 deletions
diff --git a/os/hal/include/hal_usbh.h b/os/hal/include/hal_usbh.h index b8c229a..f6e78e9 100644 --- a/os/hal/include/hal_usbh.h +++ b/os/hal/include/hal_usbh.h @@ -48,6 +48,10 @@ #define HAL_USBH_USE_HID FALSE #endif +#ifndef HAL_USBH_USE_ADDITIONAL_CLASS_DRIVERS +#define HAL_USBH_USE_ADDITIONAL_CLASS_DRIVERS FALSE +#endif + #define HAL_USBH_USE_IAD HAL_USBH_USE_UVC #if (HAL_USE_USBH == TRUE) || defined(__DOXYGEN__) @@ -402,8 +406,10 @@ extern "C" { typedef struct usbh_classdriver_vmt usbh_classdriver_vmt_t; struct usbh_classdriver_vmt { + void (*init)(void); usbh_baseclassdriver_t *(*load)(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem); void (*unload)(usbh_baseclassdriver_t *drv); + /* TODO: add power control, suspend, etc */ }; struct usbh_classdriverinfo { diff --git a/os/hal/include/usbh/dev/aoa.h b/os/hal/include/usbh/dev/aoa.h index 636768a..a7f1c1b 100644 --- a/os/hal/include/usbh/dev/aoa.h +++ b/os/hal/include/usbh/dev/aoa.h @@ -140,12 +140,8 @@ extern USBHAOADriver USBHAOAD[HAL_USBHAOA_MAX_INSTANCES]; extern "C" { #endif /* AOA device driver */ - void usbhaoaObjectInit(USBHAOADriver *aoap); void usbhaoaChannelStart(USBHAOADriver *aoap); void usbhaoaChannelStop(USBHAOADriver *aoap); - - /* global initializer */ - void usbhaoaInit(void); #ifdef __cplusplus } #endif diff --git a/os/hal/include/usbh/dev/ftdi.h b/os/hal/include/usbh/dev/ftdi.h index bfa3103..eedb056 100644 --- a/os/hal/include/usbh/dev/ftdi.h +++ b/os/hal/include/usbh/dev/ftdi.h @@ -138,16 +138,9 @@ extern USBHFTDIPortDriver FTDIPD[HAL_USBHFTDI_MAX_PORTS]; #ifdef __cplusplus
extern "C" {
#endif
- /* FTDI device driver */
- void usbhftdiObjectInit(USBHFTDIDriver *ftdip);
-
/* FTDI port driver */
- void usbhftdipObjectInit(USBHFTDIPortDriver *ftdipp);
void usbhftdipStart(USBHFTDIPortDriver *ftdipp, const USBHFTDIPortConfig *config);
void usbhftdipStop(USBHFTDIPortDriver *ftdipp);
-
- /* global initializer */
- void usbhftdiInit(void);
#ifdef __cplusplus
}
#endif
diff --git a/os/hal/include/usbh/dev/hid.h b/os/hal/include/usbh/dev/hid.h index 0d6b894..1dbc486 100644 --- a/os/hal/include/usbh/dev/hid.h +++ b/os/hal/include/usbh/dev/hid.h @@ -112,9 +112,6 @@ extern USBHHIDDriver USBHHIDD[HAL_USBHHID_MAX_INSTANCES]; #ifdef __cplusplus extern "C" { #endif - /* HID Driver */ - void usbhHIDObjectInit(USBHHIDDriver *hidp); - /* HID Common API */ usbh_urbstatus_t usbhhidGetReport(USBHHIDDriver *hidp, uint8_t report_id, usbhhid_reporttype_t report_type, @@ -136,9 +133,6 @@ extern "C" { } void usbhhidStart(USBHHIDDriver *hidp, const USBHHIDConfig *cfg); - - /* global initializer */ - void usbhhidInit(void); #ifdef __cplusplus } #endif diff --git a/os/hal/include/usbh/dev/hub.h b/os/hal/include/usbh/dev/hub.h index 924ebec..406fbaf 100644 --- a/os/hal/include/usbh/dev/hub.h +++ b/os/hal/include/usbh/dev/hub.h @@ -88,10 +88,6 @@ static inline usbh_urbstatus_t usbhhubSetFeaturePort(usbh_port_t *port, uint8_t 0);
}
-void usbhhubObjectInit(USBHHubDriver *hubdp);
-
-void usbhhubInit(void);
-
#else
static inline usbh_urbstatus_t usbhhubControlRequest(USBHDriver *host,
diff --git a/os/hal/include/usbh/dev/msd.h b/os/hal/include/usbh/dev/msd.h index 4eef6d6..f73836f 100644 --- a/os/hal/include/usbh/dev/msd.h +++ b/os/hal/include/usbh/dev/msd.h @@ -109,9 +109,6 @@ extern "C" { bool usbhmsdLUNGetInfo(USBHMassStorageLUNDriver *lunp, BlockDeviceInfo *bdip);
bool usbhmsdLUNIsInserted(USBHMassStorageLUNDriver *lunp);
bool usbhmsdLUNIsProtected(USBHMassStorageLUNDriver *lunp);
-
- /* global initializer */
- void usbhmsdInit(void);
#ifdef __cplusplus
}
#endif
diff --git a/os/hal/include/usbh/dev/uvc.h b/os/hal/include/usbh/dev/uvc.h index c68a082..bc46a71 100644 --- a/os/hal/include/usbh/dev/uvc.h +++ b/os/hal/include/usbh/dev/uvc.h @@ -394,9 +394,6 @@ extern USBHUVCDriver USBHUVCD[HAL_USBHUVC_MAX_INSTANCES]; #ifdef __cplusplus extern "C" { #endif - - void usbhuvcObjectInit(USBHUVCDriver *uvcd); - static inline usbhuvc_state_t usbhuvcGetState(USBHUVCDriver *uvcd) { return uvcd->state; } @@ -457,11 +454,6 @@ extern "C" { static inline void usbhuvcFreeStatusMessage(USBHUVCDriver *uvcdp, usbhuvc_message_status_t *msg) { chPoolFree(&uvcdp->mp_status, msg); } - - - /* global initializer */ - void usbhuvcInit(void); - #ifdef __cplusplus } #endif diff --git a/os/hal/src/hal_usbh.c b/os/hal/src/hal_usbh.c index 9e6c8eb..d0d3cb7 100644 --- a/os/hal/src/hal_usbh.c +++ b/os/hal/src/hal_usbh.c @@ -66,6 +66,12 @@ static void _classdriver_process_device(usbh_device_t *dev); static bool _classdriver_load(usbh_device_t *dev, uint8_t class, uint8_t subclass, uint8_t protocol, uint8_t *descbuff, uint16_t rem); +#if HAL_USBH_USE_ADDITIONAL_CLASS_DRIVERS +#include "usbh_additional_class_drivers.h" +#ifndef HAL_USBH_ADDITIONAL_CLASS_DRIVERS +#error "Must define HAL_USBH_ADDITIONAL_CLASS_DRIVERS" +#endif +#endif /*===========================================================================*/ /* Checks. */ @@ -105,28 +111,6 @@ void usbhObjectInit(USBHDriver *usbh) { #endif } -void usbhInit(void) { -#if HAL_USBH_USE_FTDI - usbhftdiInit(); -#endif -#if HAL_USBH_USE_AOA - usbhaoaInit(); -#endif -#if HAL_USBH_USE_MSD - usbhmsdInit(); -#endif -#if HAL_USBH_USE_HID - usbhhidInit(); -#endif -#if HAL_USBH_USE_UVC - usbhuvcInit(); -#endif -#if HAL_USBH_USE_HUB - usbhhubInit(); -#endif - usbh_lld_init(); -} - void usbhStart(USBHDriver *usbh) { usbDbgInit(usbh); @@ -1236,6 +1220,7 @@ void usbhMainLoop(USBHDriver *usbh) { static usbh_baseclassdriver_t *iad_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem); static void iad_unload(usbh_baseclassdriver_t *drv); static const usbh_classdriver_vmt_t usbhiadClassDriverVMT = { + NULL, iad_load, iad_unload }; @@ -1290,8 +1275,11 @@ static void iad_unload(usbh_baseclassdriver_t *drv) { /*===========================================================================*/ /* Class driver loader. */ /*===========================================================================*/ - static const usbh_classdriverinfo_t *usbh_classdrivers_lookup[] = { +#if HAL_USBH_USE_ADDITIONAL_CLASS_DRIVERS + /* user-defined out of tree class drivers */ + HAL_USBH_ADDITIONAL_CLASS_DRIVERS +#endif #if HAL_USBH_USE_FTDI &usbhftdiClassDriverInfo, #endif @@ -1431,6 +1419,14 @@ exit: } } +void usbhInit(void) { + uint8_t i; + for (i = 0; i < sizeof_array(usbh_classdrivers_lookup); i++) { + if (usbh_classdrivers_lookup[i]->vmt->init) { + usbh_classdrivers_lookup[i]->vmt->init(); + } + } +} #endif diff --git a/os/hal/src/usbh/hal_usbh_aoa.c b/os/hal/src/usbh/hal_usbh_aoa.c index 1fa49f8..db348c0 100644 --- a/os/hal/src/usbh/hal_usbh_aoa.c +++ b/os/hal/src/usbh/hal_usbh_aoa.c @@ -124,8 +124,10 @@ USBHAOADriver USBHAOAD[HAL_USBHAOA_MAX_INSTANCES]; static usbh_baseclassdriver_t *_aoa_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem); static void _aoa_unload(usbh_baseclassdriver_t *drv); +static void _aoa_init(void); static const usbh_classdriver_vmt_t class_driver_vmt = { + _aoa_init, _aoa_load, _aoa_unload }; @@ -658,7 +660,7 @@ static bool _send_string(usbh_device_t *dev, uint8_t index, const char *string) return HAL_SUCCESS; } -void usbhaoaObjectInit(USBHAOADriver *aoap) { +static void _object_init(USBHAOADriver *aoap) { osalDbgCheck(aoap != NULL); memset(aoap, 0, sizeof(*aoap)); aoap->info = &usbhaoaClassDriverInfo; @@ -668,10 +670,10 @@ void usbhaoaObjectInit(USBHAOADriver *aoap) { aoap->channel.state = USBHAOA_CHANNEL_STATE_STOP; } -void usbhaoaInit(void) { +static void _aoa_init(void) { uint8_t i; for (i = 0; i < HAL_USBHAOA_MAX_INSTANCES; i++) { - usbhaoaObjectInit(&USBHAOAD[i]); + _object_init(&USBHAOAD[i]); } } diff --git a/os/hal/src/usbh/hal_usbh_ftdi.c b/os/hal/src/usbh/hal_usbh_ftdi.c index ce96958..9822969 100644 --- a/os/hal/src/usbh/hal_usbh_ftdi.c +++ b/os/hal/src/usbh/hal_usbh_ftdi.c @@ -62,16 +62,19 @@ #define uerr(f, ...) do {} while(0) #endif +static void _ftdip_object_init(USBHFTDIPortDriver *ftdipp); /*===========================================================================*/ /* USB Class driver loader for FTDI */ /*===========================================================================*/ USBHFTDIDriver USBHFTDID[HAL_USBHFTDI_MAX_INSTANCES]; +static void _ftdi_init(void); static usbh_baseclassdriver_t *_ftdi_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem); static void _ftdi_unload(usbh_baseclassdriver_t *drv); static const usbh_classdriver_vmt_t class_driver_vmt = { + _ftdi_init, _ftdi_load, _ftdi_unload }; @@ -229,7 +232,7 @@ static void _ftdi_unload(usbh_baseclassdriver_t *drv) { osalSysLock(); while (ftdipp) { USBHFTDIPortDriver *next = ftdipp->next; - usbhftdipObjectInit(ftdipp); + _ftdip_object_init(ftdipp); ftdipp = next; } osalSysUnlock(); @@ -700,27 +703,27 @@ void usbhftdipStart(USBHFTDIPortDriver *ftdipp, const USBHFTDIPortConfig *config osalMutexUnlock(&ftdipp->ftdip->mtx); } -void usbhftdiObjectInit(USBHFTDIDriver *ftdip) { +static void _ftdi_object_init(USBHFTDIDriver *ftdip) { osalDbgCheck(ftdip != NULL); memset(ftdip, 0, sizeof(*ftdip)); ftdip->info = &usbhftdiClassDriverInfo; osalMutexObjectInit(&ftdip->mtx); } -void usbhftdipObjectInit(USBHFTDIPortDriver *ftdipp) { +static void _ftdip_object_init(USBHFTDIPortDriver *ftdipp) { osalDbgCheck(ftdipp != NULL); memset(ftdipp, 0, sizeof(*ftdipp)); ftdipp->vmt = &async_channel_vmt; ftdipp->state = USBHFTDIP_STATE_STOP; } -void usbhftdiInit(void) { +static void _ftdi_init(void) { uint8_t i; for (i = 0; i < HAL_USBHFTDI_MAX_INSTANCES; i++) { - usbhftdiObjectInit(&USBHFTDID[i]); + _ftdi_object_init(&USBHFTDID[i]); } for (i = 0; i < HAL_USBHFTDI_MAX_PORTS; i++) { - usbhftdipObjectInit(&FTDIPD[i]); + _ftdip_object_init(&FTDIPD[i]); } } diff --git a/os/hal/src/usbh/hal_usbh_hid.c b/os/hal/src/usbh/hal_usbh_hid.c index e98dff7..4b20fd3 100644 --- a/os/hal/src/usbh/hal_usbh_hid.c +++ b/os/hal/src/usbh/hal_usbh_hid.c @@ -74,10 +74,12 @@ USBHHIDDriver USBHHIDD[HAL_USBHHID_MAX_INSTANCES]; +static void _hid_init(void); static usbh_baseclassdriver_t *_hid_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem); static void _hid_unload(usbh_baseclassdriver_t *drv); static const usbh_classdriver_vmt_t class_driver_vmt = { + _hid_init, _hid_load, _hid_unload }; @@ -305,17 +307,17 @@ usbh_urbstatus_t usbhhidSetProtocol(USBHHIDDriver *hidp, uint8_t protocol) { protocol, hidp->ifnum, 0, NULL); } -void usbhhidObjectInit(USBHHIDDriver *hidp) { +static void _hid_object_init(USBHHIDDriver *hidp) { osalDbgCheck(hidp != NULL); memset(hidp, 0, sizeof(*hidp)); hidp->info = &usbhhidClassDriverInfo; hidp->state = USBHHID_STATE_STOP; } -void usbhhidInit(void) { +static void _hid_init(void) { uint8_t i; for (i = 0; i < HAL_USBHHID_MAX_INSTANCES; i++) { - usbhhidObjectInit(&USBHHIDD[i]); + _hid_object_init(&USBHHIDD[i]); } } diff --git a/os/hal/src/usbh/hal_usbh_hub.c b/os/hal/src/usbh/hal_usbh_hub.c index 3a84175..c9bbe9b 100644 --- a/os/hal/src/usbh/hal_usbh_hub.c +++ b/os/hal/src/usbh/hal_usbh_hub.c @@ -63,12 +63,15 @@ USBHHubDriver USBHHUBD[HAL_USBHHUB_MAX_INSTANCES]; static usbh_port_t USBHPorts[HAL_USBHHUB_MAX_PORTS]; -static usbh_baseclassdriver_t *hub_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem); -static void hub_unload(usbh_baseclassdriver_t *drv); +static void _hub_init(void); +static usbh_baseclassdriver_t *_hub_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem); +static void _hub_unload(usbh_baseclassdriver_t *drv); static const usbh_classdriver_vmt_t usbhhubClassDriverVMT = { - hub_load, - hub_unload + _hub_init, + _hub_load, + _hub_unload }; + const usbh_classdriverinfo_t usbhhubClassDriverInfo = { 0x09, 0x00, -1, "HUB", &usbhhubClassDriverVMT }; @@ -137,7 +140,7 @@ static void _urb_complete(usbh_urb_t *urb) { usbhURBSubmitI(urb); } -static usbh_baseclassdriver_t *hub_load(usbh_device_t *dev, +static usbh_baseclassdriver_t *_hub_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem) { int i; @@ -261,7 +264,7 @@ alloc_ok: return (usbh_baseclassdriver_t *)hubdp; } -static void hub_unload(usbh_baseclassdriver_t *drv) { +static void _hub_unload(usbh_baseclassdriver_t *drv) { osalDbgCheck(drv != NULL); USBHHubDriver *const hubdp = (USBHHubDriver *)drv; @@ -283,16 +286,16 @@ static void hub_unload(usbh_baseclassdriver_t *drv) { } -void usbhhubObjectInit(USBHHubDriver *hubdp) { +static void _object_init(USBHHubDriver *hubdp) { osalDbgCheck(hubdp != NULL); memset(hubdp, 0, sizeof(*hubdp)); hubdp->info = &usbhhubClassDriverInfo; } -void usbhhubInit(void) { +static void _hub_init(void) { uint8_t i; for (i = 0; i < HAL_USBHHUB_MAX_INSTANCES; i++) { - usbhhubObjectInit(&USBHHUBD[i]); + _object_init(&USBHHUBD[i]); } } diff --git a/os/hal/src/usbh/hal_usbh_msd.c b/os/hal/src/usbh/hal_usbh_msd.c index 061c754..f2a4e39 100644 --- a/os/hal/src/usbh/hal_usbh_msd.c +++ b/os/hal/src/usbh/hal_usbh_msd.c @@ -62,7 +62,7 @@ #define uerr(f, ...) do {} while(0) #endif -static void usbhmsdLUNObjectDeinit(USBHMassStorageLUNDriver *lunp); +static void _lun_object_deinit(USBHMassStorageLUNDriver *lunp); /*===========================================================================*/ /* USB Class driver loader for MSD */ @@ -70,10 +70,12 @@ static void usbhmsdLUNObjectDeinit(USBHMassStorageLUNDriver *lunp); USBHMassStorageDriver USBHMSD[HAL_USBHMSD_MAX_INSTANCES]; +static void _msd_init(void); static usbh_baseclassdriver_t *_msd_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem); static void _msd_unload(usbh_baseclassdriver_t *drv); static const usbh_classdriver_vmt_t class_driver_vmt = { + _msd_init, _msd_load, _msd_unload }; @@ -205,7 +207,7 @@ static void _msd_unload(usbh_baseclassdriver_t *drv) { /* disconnect all LUNs */ while (lunp) { usbhmsdLUNDisconnect(lunp); - usbhmsdLUNObjectDeinit(lunp); + _lun_object_deinit(lunp); lunp = lunp->next; } @@ -682,7 +684,7 @@ static const struct USBHMassStorageDriverVMT blk_vmt = { (bool (*)(void *, BlockDeviceInfo *))usbhmsdLUNGetInfo }; -static void usbhmsdLUNObjectDeinit(USBHMassStorageLUNDriver *lunp) { +static void _lun_object_deinit(USBHMassStorageLUNDriver *lunp) { osalDbgCheck(lunp != NULL); osalMutexLock(&lunp->mtx); lunp->msdp = NULL; @@ -692,7 +694,7 @@ static void usbhmsdLUNObjectDeinit(USBHMassStorageLUNDriver *lunp) { osalMutexUnlock(&lunp->mtx); } -static void usbhmsdLUNObjectInit(USBHMassStorageLUNDriver *lunp) { +static void _lun_object_init(USBHMassStorageLUNDriver *lunp) { osalDbgCheck(lunp != NULL); memset(lunp, 0, sizeof(*lunp)); lunp->vmt = &blk_vmt; @@ -954,19 +956,19 @@ bool usbhmsdLUNIsProtected(USBHMassStorageLUNDriver *lunp) { return FALSE; } -static void usbhmsdObjectInit(USBHMassStorageDriver *msdp) { +static void _msd_object_init(USBHMassStorageDriver *msdp) { osalDbgCheck(msdp != NULL); memset(msdp, 0, sizeof(*msdp)); msdp->info = &usbhmsdClassDriverInfo; } -void usbhmsdInit(void) { +static void _msd_init(void) { uint8_t i; for (i = 0; i < HAL_USBHMSD_MAX_INSTANCES; i++) { - usbhmsdObjectInit(&USBHMSD[i]); + _msd_object_init(&USBHMSD[i]); } for (i = 0; i < HAL_USBHMSD_MAX_LUNS; i++) { - usbhmsdLUNObjectInit(&MSBLKD[i]); + _lun_object_init(&MSBLKD[i]); } } #endif diff --git a/os/hal/src/usbh/hal_usbh_uvc.c b/os/hal/src/usbh/hal_usbh_uvc.c index b0507a0..ac3663e 100644 --- a/os/hal/src/usbh/hal_usbh_uvc.c +++ b/os/hal/src/usbh/hal_usbh_uvc.c @@ -66,14 +66,15 @@ USBHUVCDriver USBHUVCD[HAL_USBHUVC_MAX_INSTANCES]; - -static usbh_baseclassdriver_t *uvc_load(usbh_device_t *dev, +static void _uvc_init(void); +static usbh_baseclassdriver_t *_uvc_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem); -static void uvc_unload(usbh_baseclassdriver_t *drv); +static void _uvc_unload(usbh_baseclassdriver_t *drv); static const usbh_classdriver_vmt_t class_driver_vmt = { - uvc_load, - uvc_unload + _uvc_init, + _uvc_load, + _uvc_unload }; const usbh_classdriverinfo_t usbhuvcClassDriverInfo = { 0x0e, 0x03, 0x00, "UVC", &class_driver_vmt @@ -512,17 +513,7 @@ uint32_t usbhuvcEstimateRequiredEPSize(USBHUVCDriver *uvcdp, const uint8_t *form return (sz * mul) / div + 12; } -void usbhuvcObjectInit(USBHUVCDriver *uvcdp) { - osalDbgCheck(uvcdp != NULL); - memset(uvcdp, 0, sizeof(*uvcdp)); - uvcdp->info = &usbhuvcClassDriverInfo; - chMBObjectInit(&uvcdp->mb, uvcdp->mb_buff, HAL_USBHUVC_MAX_MAILBOX_SZ); - chMtxObjectInit(&uvcdp->mtx); - uvcdp->state = USBHUVC_STATE_STOP; -} - - -static usbh_baseclassdriver_t *uvc_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem) { +static usbh_baseclassdriver_t *_uvc_load(usbh_device_t *dev, const uint8_t *descriptor, uint16_t rem) { USBHUVCDriver *uvcdp; uint8_t i; @@ -710,7 +701,7 @@ alloc_ok: return (usbh_baseclassdriver_t *)uvcdp; } -static void uvc_unload(usbh_baseclassdriver_t *drv) { +static void _uvc_unload(usbh_baseclassdriver_t *drv) { USBHUVCDriver *const uvcdp = (USBHUVCDriver *)drv; usbhuvcStreamStop(uvcdp); @@ -727,10 +718,19 @@ static void uvc_unload(usbh_baseclassdriver_t *drv) { osalSysUnlock(); } -void usbhuvcInit(void) { +static void _object_init(USBHUVCDriver *uvcdp) { + osalDbgCheck(uvcdp != NULL); + memset(uvcdp, 0, sizeof(*uvcdp)); + uvcdp->info = &usbhuvcClassDriverInfo; + chMBObjectInit(&uvcdp->mb, uvcdp->mb_buff, HAL_USBHUVC_MAX_MAILBOX_SZ); + chMtxObjectInit(&uvcdp->mtx); + uvcdp->state = USBHUVC_STATE_STOP; +} + +static void _uvc_init(void) { uint8_t i; for (i = 0; i < HAL_USBHUVC_MAX_INSTANCES; i++) { - usbhuvcObjectInit(&USBHUVCD[i]); + _object_init(&USBHUVCD[i]); } } |