From ed70a1efa3335b6bf64c8c6a6f5be4dc25bdd9b7 Mon Sep 17 00:00:00 2001 From: Amir Hammad Date: Fri, 9 Sep 2016 18:36:38 +0200 Subject: Switch to cmake build system * use tinyprintf * ability to configure project via ccmake Signed-off-by: Amir Hammad --- src/demo.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/demo.c') diff --git a/src/demo.c b/src/demo.c index 5d829ac..3fedbd9 100644 --- a/src/demo.c +++ b/src/demo.c @@ -215,8 +215,13 @@ 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 -// usbh_lld_stm32f4_driver_hs, // Make sure USE_STM32F4_USBH_DRIVER_HS 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 0 }; usbh_init(lld_drivers, device_drivers); -- cgit From 3d68ea280790351d0320fc4e712c51b820a5522a Mon Sep 17 00:00:00 2001 From: Amir Hammad Date: Fri, 9 Sep 2016 18:37:22 +0200 Subject: make hid_mouse driver generic HID driver + keyboard support + SET_REPORT commands - usually leds on keyboards (WIP) - missing parsing of HID report descriptor Signed-off-by: Amir Hammad --- src/demo.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src/demo.c') diff --git a/src/demo.c b/src/demo.c index 3fedbd9..995e68c 100644 --- a/src/demo.c +++ b/src/demo.c @@ -23,7 +23,7 @@ #include "usart_helpers.h" /// provides LOG_PRINTF macros used for debugging #include "usbh_core.h" /// provides usbh_init() and usbh_poll() #include "usbh_lld_stm32f4.h" /// provides low level usb host driver for stm32f4 platform -#include "usbh_driver_hid_mouse.h" /// provides usb device driver Human Interface Device - type mouse +#include "usbh_driver_hid.h" /// provides generic usb device driver for Human Interface Device (HID) #include "usbh_driver_hub.h" /// provides usb full speed hub driver (Low speed devices on hub are not supported) #include "usbh_driver_gp_xbox.h" /// provides usb device driver for Gamepad: Microsoft XBOX compatible Controller #include "usbh_driver_ac_midi.h" /// provides usb device driver for midi class devices @@ -116,7 +116,7 @@ static void gpio_setup(void) static const usbh_dev_driver_t *device_drivers[] = { &usbh_hub_driver, - &usbh_hid_mouse_driver, + &usbh_hid_driver, &usbh_gp_xbox_driver, &usbh_midi_driver, 0 @@ -148,17 +148,29 @@ static const gp_xbox_config_t gp_xbox_config = { .notify_disconnected = &gp_xbox_disconnected }; -static void mouse_in_message_handler(uint8_t device_id, const uint8_t *data) +static void hid_in_message_handler(uint8_t device_id, const uint8_t *data, uint32_t length) { (void)device_id; (void)data; + if (length < 4) { + LOG_PRINTF("data too short, type=%d\n", hid_get_type(device_id)); + return; + } + // print only first 4 bytes, since every mouse should have at least these four set. // Report descriptors are not read by driver for now, so we do not know what each byte means - LOG_PRINTF("MOUSE EVENT %02X %02X %02X %02X \n", data[0], data[1], data[2], data[3]); + LOG_PRINTF("HID EVENT %02X %02X %02X %02X \n", data[0], data[1], data[2], data[3]); + if (hid_get_type(device_id) == HID_TYPE_KEYBOARD) { + static int x = 0; + if (x != data[2]) { + x = data[2]; + hid_set_report(device_id, x); + } + } } -static const hid_mouse_config_t mouse_config = { - .mouse_in_message_handler = &mouse_in_message_handler +static const hid_config_t hid_config = { + .hid_in_message_handler = &hid_in_message_handler }; static void midi_in_message_handler(int device_id, uint8_t *data) @@ -200,7 +212,7 @@ int main(void) * * Pass configuration struct where the callbacks are defined */ - hid_mouse_driver_init(&mouse_config); + hid_driver_init(&hid_config); hub_driver_init(); gp_xbox_driver_init(&gp_xbox_config); midi_driver_init(&midi_config); -- cgit From 1d1b697bc6b13b5db1594c3dafe5452b6b2c1668 Mon Sep 17 00:00:00 2001 From: Amir Hammad Date: Thu, 8 Sep 2016 06:27:35 +0200 Subject: use NULL instead of 0 for assigning null pointer Signed-off-by: Amir Hammad --- src/demo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/demo.c') diff --git a/src/demo.c b/src/demo.c index 995e68c..44a94c0 100644 --- a/src/demo.c +++ b/src/demo.c @@ -119,7 +119,7 @@ static const usbh_dev_driver_t *device_drivers[] = { &usbh_hid_driver, &usbh_gp_xbox_driver, &usbh_midi_driver, - 0 + NULL }; static void gp_xbox_update(uint8_t device_id, gp_xbox_packet_t packet) @@ -234,7 +234,7 @@ int main(void) #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 - 0 + NULL }; usbh_init(lld_drivers, device_drivers); gpio_clear(GPIOD, GPIO13); -- cgit From 8946cb522b10465d3fe3a9846158dbff4e924240 Mon Sep 17 00:00:00 2001 From: Amir Hammad Date: Fri, 9 Sep 2016 18:33:26 +0200 Subject: lld: rework low level driver initialization Signed-off-by: Amir Hammad --- src/demo.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/demo.c') diff --git a/src/demo.c b/src/demo.c index 44a94c0..a6b4196 100644 --- a/src/demo.c +++ b/src/demo.c @@ -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); -- cgit