diff options
author | Amir Hammad <amir.hammad@hotmail.com> | 2016-09-09 18:33:26 +0200 |
---|---|---|
committer | Amir Hammad <amir.hammad@hotmail.com> | 2016-09-11 13:31:48 +0200 |
commit | 8946cb522b10465d3fe3a9846158dbff4e924240 (patch) | |
tree | 42f27a561840d060a212028d3ebc5102ddbfce66 | |
parent | decb2d817d806e8ed6e77cf215e4adfef4767a50 (diff) | |
download | secure-hid-8946cb522b10465d3fe3a9846158dbff4e924240.tar.gz secure-hid-8946cb522b10465d3fe3a9846158dbff4e924240.tar.bz2 secure-hid-8946cb522b10465d3fe3a9846158dbff4e924240.zip |
lld: rework low level driver initialization
Signed-off-by: Amir Hammad <amir.hammad@hotmail.com>
-rw-r--r-- | include/usbh_core.h | 3 | ||||
-rw-r--r-- | include/usbh_lld_stm32f4.h | 4 | ||||
-rw-r--r-- | src/demo.c | 22 | ||||
-rw-r--r-- | src/usbh_core.c | 2 | ||||
-rw-r--r-- | src/usbh_lld_stm32f4.c | 8 |
5 files changed, 20 insertions, 19 deletions
diff --git a/include/usbh_core.h b/include/usbh_core.h index 308d53b..04dbd29 100644 --- a/include/usbh_core.h +++ b/include/usbh_core.h @@ -41,13 +41,14 @@ BEGIN_DECLS
typedef struct _usbh_dev_driver usbh_dev_driver_t;
+typedef struct _usbh_low_level_driver usbh_low_level_driver_t;
/**
* @brief usbh_init
* @param low_level_drivers list of the low level drivers to be used by this library
* @param device_drivers list of the device drivers that could be used with attached devices
*/
-void usbh_init(const void *low_level_drivers[], const usbh_dev_driver_t * const device_drivers[]);
+void usbh_init(const usbh_low_level_driver_t * const low_level_drivers[], const usbh_dev_driver_t * const device_drivers[]);
/**
* @brief usbh_poll
diff --git a/include/usbh_lld_stm32f4.h b/include/usbh_lld_stm32f4.h index ead40cd..33be145 100644 --- a/include/usbh_lld_stm32f4.h +++ b/include/usbh_lld_stm32f4.h @@ -30,8 +30,8 @@ BEGIN_DECLS
// pass this to usbh init
-extern const void *usbh_lld_stm32f4_driver_fs;
-extern const void *usbh_lld_stm32f4_driver_hs;
+extern const usbh_low_level_driver_t usbh_lld_stm32f4_driver_fs;
+extern const usbh_low_level_driver_t usbh_lld_stm32f4_driver_hs;
#ifdef USART_DEBUG
void print_channels(const void *drvdata);
@@ -122,6 +122,17 @@ static const usbh_dev_driver_t *device_drivers[] = { NULL
};
+static const usbh_low_level_driver_t * const lld_drivers[] = {
+#ifdef USE_STM32F4_USBH_DRIVER_FS
+ &usbh_lld_stm32f4_driver_fs, // Make sure USE_STM32F4_USBH_DRIVER_FS is defined in usbh_config.h
+#endif
+
+#ifdef USE_STM32F4_USBH_DRIVER_HS
+ &usbh_lld_stm32f4_driver_hs, // Make sure USE_STM32F4_USBH_DRIVER_HS is defined in usbh_config.h
+#endif
+ NULL
+ };
+
static void gp_xbox_update(uint8_t device_id, gp_xbox_packet_t packet)
{
(void)device_id;
@@ -218,7 +229,6 @@ int main(void) midi_driver_init(&midi_config);
gpio_set(GPIOD, GPIO13);
-
/**
* Pass array of supported low level drivers
* In case of stm32f407, there are up to two supported OTG hosts on one chip.
@@ -226,16 +236,6 @@ int main(void) *
* Pass array of supported device drivers
*/
- const void *lld_drivers[] = {
-#ifdef USE_STM32F4_USBH_DRIVER_FS
- usbh_lld_stm32f4_driver_fs, // Make sure USE_STM32F4_USBH_DRIVER_FS is defined in usbh_config.h
-#endif
-
-#ifdef USE_STM32F4_USBH_DRIVER_HS
- usbh_lld_stm32f4_driver_hs, // Make sure USE_STM32F4_USBH_DRIVER_HS is defined in usbh_config.h
-#endif
- NULL
- };
usbh_init(lld_drivers, device_drivers);
gpio_clear(GPIOD, GPIO13);
diff --git a/src/usbh_core.c b/src/usbh_core.c index 5448d6c..88fd665 100644 --- a/src/usbh_core.c +++ b/src/usbh_core.c @@ -176,7 +176,7 @@ static void device_register(void *descriptors, uint16_t descriptors_len, usbh_de LOG_PRINTF("Device NOT Initialized\n"); } -void usbh_init(const void *low_level_drivers[], const usbh_dev_driver_t * const device_drivers[]) +void usbh_init(const usbh_low_level_driver_t * const low_level_drivers[], const usbh_dev_driver_t * const device_drivers[]) { if (!low_level_drivers) { return; diff --git a/src/usbh_lld_stm32f4.c b/src/usbh_lld_stm32f4.c index aff12c5..5ac26e1 100644 --- a/src/usbh_lld_stm32f4.c +++ b/src/usbh_lld_stm32f4.c @@ -1022,7 +1022,7 @@ static usbh_lld_stm32f4_driver_data_t driver_data_fs = { .channels = channels_fs,
.num_channels = NUM_CHANNELS_FS
};
-static const usbh_low_level_driver_t driver_fs = {
+const usbh_low_level_driver_t usbh_lld_stm32f4_driver_fs = {
.init = init,
.poll = poll,
.read = read,
@@ -1030,7 +1030,6 @@ static const usbh_low_level_driver_t driver_fs = { .root_speed = root_speed,
.driver_data = &driver_data_fs
};
-const void *usbh_lld_stm32f4_driver_fs = &driver_fs;
#endif
// USB High Speed - OTG_HS
@@ -1042,7 +1041,8 @@ static usbh_lld_stm32f4_driver_data_t driver_data_hs = { .channels = channels_hs,
.num_channels = NUM_CHANNELS_HS
};
-static const usbh_low_level_driver_t driver_hs = {
+
+const usbh_low_level_driver_t usbh_lld_stm32f4_driver_hs = {
.init = init,
.poll = poll,
.read = read,
@@ -1050,5 +1050,5 @@ static const usbh_low_level_driver_t driver_hs = { .root_speed = root_speed,
.driver_data = &driver_data_hs
};
-const void *usbh_lld_stm32f4_driver_hs = &driver_hs;
+
#endif
|