From 3493c1c0878db2b2c367fcdd9e69e4dcc104cad6 Mon Sep 17 00:00:00 2001 From: Amir Hammad Date: Tue, 30 Aug 2016 04:02:27 +0200 Subject: fix bmRequestType field - use of defines Signed-off-by: Amir Hammad --- src/usbh_driver_gp_xbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/usbh_driver_gp_xbox.c') diff --git a/src/usbh_driver_gp_xbox.c b/src/usbh_driver_gp_xbox.c index 01cebb5..1bc2498 100644 --- a/src/usbh_driver_gp_xbox.c +++ b/src/usbh_driver_gp_xbox.c @@ -364,7 +364,7 @@ static void poll(void *drvdata, uint32_t time_curr_us) { struct usb_setup_data setup_data; - setup_data.bmRequestType = 0b00000000; + setup_data.bmRequestType = USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_DEVICE; setup_data.bRequest = USB_REQ_SET_CONFIGURATION; setup_data.wValue = gp_xbox->configuration_value; setup_data.wIndex = 0; -- cgit From 4aa69b4eaf44757aa71997e4a59f0889ea6e23f4 Mon Sep 17 00:00:00 2001 From: Amir Hammad Date: Thu, 1 Sep 2016 14:16:17 +0200 Subject: make usbh_packet->data of union type out: const void * in: void * Signed-off-by: Amir Hammad --- src/usbh_driver_gp_xbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/usbh_driver_gp_xbox.c') diff --git a/src/usbh_driver_gp_xbox.c b/src/usbh_driver_gp_xbox.c index 1bc2498..f52621a 100644 --- a/src/usbh_driver_gp_xbox.c +++ b/src/usbh_driver_gp_xbox.c @@ -326,7 +326,7 @@ static void read_gp_xbox_in(gp_xbox_device_t *gp_xbox) usbh_packet_t packet; packet.address = gp_xbox->usbh_device->address; - packet.data = &gp_xbox->buffer[0]; + packet.data.in = &gp_xbox->buffer[0]; packet.datalen = gp_xbox->endpoint_in_maxpacketsize; packet.endpoint_address = gp_xbox->endpoint_in_address; packet.endpoint_size_max = gp_xbox->endpoint_in_maxpacketsize; -- cgit From 58fec7a17ceb6814d64e702e7829556c3ece01e4 Mon Sep 17 00:00:00 2001 From: Amir Hammad Date: Mon, 5 Sep 2016 19:48:56 +0200 Subject: Drop need for the set configuration request in dev drivers Signed-off-by: Amir Hammad --- src/usbh_driver_gp_xbox.c | 66 +++++++---------------------------------------- 1 file changed, 10 insertions(+), 56 deletions(-) (limited to 'src/usbh_driver_gp_xbox.c') diff --git a/src/usbh_driver_gp_xbox.c b/src/usbh_driver_gp_xbox.c index f52621a..92f61b5 100644 --- a/src/usbh_driver_gp_xbox.c +++ b/src/usbh_driver_gp_xbox.c @@ -30,11 +30,9 @@ enum STATES { STATE_INACTIVE, - STATE_READING_COMPLETE, + STATE_INITIAL, STATE_READING_REQUEST, - STATE_SET_CONFIGURATION_REQUEST, - STATE_SET_CONFIGURATION_EMPTY_READ, - STATE_SET_CONFIGURATION_COMPLETE + STATE_READING_COMPLETE, }; #define GP_XBOX_CORRECT_TRANSFERRED_LENGTH 20 @@ -132,7 +130,7 @@ static bool analyze_descriptor(void *drvdata, void *descriptor) } if (gp_xbox->endpoint_in_address) { - gp_xbox->state_next = STATE_SET_CONFIGURATION_REQUEST; + gp_xbox->state_next = STATE_INITIAL; return true; } } @@ -268,45 +266,6 @@ static void event(usbh_device_t *dev, usbh_packet_callback_data_t cb_data) } break; - case STATE_SET_CONFIGURATION_EMPTY_READ: - { - LOG_PRINTF("|empty packet read|"); - switch (cb_data.status) { - case USBH_PACKET_CALLBACK_STATUS_OK: - gp_xbox->state_next = STATE_SET_CONFIGURATION_COMPLETE; - device_xfer_control_read(0, 0, event, dev); - break; - case USBH_PACKET_CALLBACK_STATUS_EFATAL: - case USBH_PACKET_CALLBACK_STATUS_EAGAIN: - case USBH_PACKET_CALLBACK_STATUS_ERRSIZ: - ERROR(cb_data.status); - gp_xbox->state_next = STATE_INACTIVE; - break; - } - } - break; - case STATE_SET_CONFIGURATION_COMPLETE: // Configured - { - switch (cb_data.status) { - case USBH_PACKET_CALLBACK_STATUS_OK: - gp_xbox->state_next = STATE_READING_REQUEST; - gp_xbox->endpoint_in_toggle = 0; - LOG_PRINTF("\ngp_xbox CONFIGURED\n"); - if (gp_xbox_config->notify_connected) { - gp_xbox_config->notify_connected(gp_xbox->device_id); - } - break; - - case USBH_PACKET_CALLBACK_STATUS_EFATAL: - case USBH_PACKET_CALLBACK_STATUS_EAGAIN: - case USBH_PACKET_CALLBACK_STATUS_ERRSIZ: - ERROR(cb_data.status); - gp_xbox->state_next = STATE_INACTIVE; - break; - } - } - break; - case STATE_INACTIVE: { LOG_PRINTF("XBOX inactive"); @@ -360,19 +319,14 @@ static void poll(void *drvdata, uint32_t time_curr_us) } break; - case STATE_SET_CONFIGURATION_REQUEST: + case STATE_INITIAL: { - struct usb_setup_data setup_data; - - setup_data.bmRequestType = USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_DEVICE; - setup_data.bRequest = USB_REQ_SET_CONFIGURATION; - setup_data.wValue = gp_xbox->configuration_value; - setup_data.wIndex = 0; - setup_data.wLength = 0; - - gp_xbox->state_next = STATE_SET_CONFIGURATION_EMPTY_READ; - - device_xfer_control_write_setup(&setup_data, sizeof(setup_data), event, dev); + gp_xbox->state_next = STATE_READING_REQUEST; + gp_xbox->endpoint_in_toggle = 0; + LOG_PRINTF("\ngp_xbox CONFIGURED\n"); + if (gp_xbox_config->notify_connected) { + gp_xbox_config->notify_connected(gp_xbox->device_id); + } } break; -- cgit From decb2d817d806e8ed6e77cf215e4adfef4767a50 Mon Sep 17 00:00:00 2001 From: Amir Hammad Date: Fri, 9 Sep 2016 18:25:28 +0200 Subject: use forward declaration for usbh_dev_driver_t Signed-off-by: Amir Hammad --- src/usbh_driver_gp_xbox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/usbh_driver_gp_xbox.c') diff --git a/src/usbh_driver_gp_xbox.c b/src/usbh_driver_gp_xbox.c index 92f61b5..6393d1b 100644 --- a/src/usbh_driver_gp_xbox.c +++ b/src/usbh_driver_gp_xbox.c @@ -72,7 +72,7 @@ void gp_xbox_driver_init(const gp_xbox_config_t *config) * * */ -static void *init(void *usbh_dev) +static void *init(usbh_device_t *usbh_dev) { if (!initialized) { LOG_PRINTF("\n%s/%d : driver not initialized\n", __FILE__, __LINE__); @@ -89,7 +89,7 @@ static void *init(void *usbh_dev) drvdata->device_id = i; drvdata->endpoint_in_address = 0; drvdata->endpoint_in_toggle = 0; - drvdata->usbh_device = (usbh_device_t *)usbh_dev; + drvdata->usbh_device = usbh_dev; break; } } -- cgit From bacf8ecdbb65774f04fce6ec6cd373a2651ddd67 Mon Sep 17 00:00:00 2001 From: Amir Hammad Date: Sun, 11 Sep 2016 09:44:58 +0200 Subject: xbox: remove warning about unused variable Signed-off-by: Amir Hammad --- src/usbh_driver_gp_xbox.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/usbh_driver_gp_xbox.c') diff --git a/src/usbh_driver_gp_xbox.c b/src/usbh_driver_gp_xbox.c index 6393d1b..d9e6d79 100644 --- a/src/usbh_driver_gp_xbox.c +++ b/src/usbh_driver_gp_xbox.c @@ -310,7 +310,6 @@ static void poll(void *drvdata, uint32_t time_curr_us) (void)time_curr_us; gp_xbox_device_t *gp_xbox = (gp_xbox_device_t *)drvdata; - usbh_device_t *dev = gp_xbox->usbh_device; switch (gp_xbox->state_next) { case STATE_READING_REQUEST: -- cgit From 4415d960c3d1e52573db02be4aee6e22d22809cf Mon Sep 17 00:00:00 2001 From: Amir Hammad Date: Sun, 11 Sep 2016 12:03:20 +0200 Subject: use default case instead of handling other packet statuses explicitely Signed-off-by: Amir Hammad --- src/usbh_driver_gp_xbox.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/usbh_driver_gp_xbox.c') diff --git a/src/usbh_driver_gp_xbox.c b/src/usbh_driver_gp_xbox.c index d9e6d79..957cb3e 100644 --- a/src/usbh_driver_gp_xbox.c +++ b/src/usbh_driver_gp_xbox.c @@ -257,8 +257,7 @@ static void event(usbh_device_t *dev, usbh_packet_callback_data_t cb_data) gp_xbox->state_next = STATE_READING_REQUEST; break; - case USBH_PACKET_CALLBACK_STATUS_EFATAL: - case USBH_PACKET_CALLBACK_STATUS_EAGAIN: + default: ERROR(cb_data.status); gp_xbox->state_next = STATE_INACTIVE; break; -- cgit