summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demos/bsp/boards/board_ea4357.c3
-rw-r--r--demos/host/keyboard_app.c1
-rw-r--r--tinyusb/hal/hal_lpc43xx.c2
-rw-r--r--tinyusb/host/usbh.c32
4 files changed, 22 insertions, 16 deletions
diff --git a/demos/bsp/boards/board_ea4357.c b/demos/bsp/boards/board_ea4357.c
index 01f5b3c60..fcc59869d 100644
--- a/demos/bsp/boards/board_ea4357.c
+++ b/demos/bsp/boards/board_ea4357.c
@@ -57,6 +57,9 @@ void board_init(void)
// USB Host Power Enable
// USB0
+ // channel B U20 GPIO26 active low (base board), P2_3 on LPC4357
+ scu_pinmux(0x2, 3, MD_PUP | MD_EZI, FUNC7); // USB0 VBus function
+
// TODO USB1
#if 0
diff --git a/demos/host/keyboard_app.c b/demos/host/keyboard_app.c
index 9bab4c07d..5dee23c31 100644
--- a/demos/host/keyboard_app.c
+++ b/demos/host/keyboard_app.c
@@ -86,6 +86,7 @@ void keyboard_app_task(void)
printf("%c", keycode_to_ascii(keyboard_report.keycode[i]));
}
memclr_(&keyboard_report, sizeof(tusb_keyboard_report_t)); // TODO use callback to synchronize
+ tusbh_hid_keyboard_get_report(dev_addr, 0, (uint8_t*) &keyboard_report);
break;
case TUSB_INTERFACE_STATUS_BUSY:
diff --git a/tinyusb/hal/hal_lpc43xx.c b/tinyusb/hal/hal_lpc43xx.c
index 8cee945fc..7c5678671 100644
--- a/tinyusb/hal/hal_lpc43xx.c
+++ b/tinyusb/hal/hal_lpc43xx.c
@@ -41,6 +41,7 @@
#if MCU == MCU_LPC43XX
#include "lpc43xx_cgu.h"
+#include "lpc43xx_scu.h"
enum {
LPC43XX_USBMODE_DEVICE = 2,
@@ -63,6 +64,7 @@ tusb_error_t hal_init(void)
//------------- reset controller & set role -------------//
hcd_controller_reset(0); // TODO where to place prototype, USB1
+
LPC_USB0->USBMODE_H = LPC43XX_USBMODE_HOST | (LPC43XX_USBMODE_VBUS_HIGH << 5);
hal_interrupt_enable(0); // TODO USB1
diff --git a/tinyusb/host/usbh.c b/tinyusb/host/usbh.c
index 08ab56880..3cf80f6c5 100644
--- a/tinyusb/host/usbh.c
+++ b/tinyusb/host/usbh.c
@@ -290,6 +290,8 @@ OSAL_TASK_DECLARE(usbh_enumeration_task)
)
);
+ hcd_port_reset( usbh_devices[0].core_id ); // reset port after 8 byte descriptor
+
//------------- Set new address -------------//
new_addr = get_new_address();
TASK_ASSERT(new_addr <= TUSB_CFG_HOST_DEVICE_MAX);
@@ -317,8 +319,6 @@ OSAL_TASK_DECLARE(usbh_enumeration_task)
usbh_pipe_control_close(0);
usbh_devices[0].state = TUSB_DEVICE_STATE_UNPLUG;
-// hcd_port_reset( usbh_device_info_pool[new_addr].core_id ); TODO may need to reset device after set address
-
// open control pipe for new address
TASK_ASSERT_STATUS ( usbh_pipe_control_open(new_addr, ((tusb_descriptor_device_t*) enum_data_buffer)->bMaxPacketSize0 ) );
@@ -380,6 +380,20 @@ OSAL_TASK_DECLARE(usbh_enumeration_task)
// update configuration info
usbh_devices[new_addr].interface_count = ((tusb_descriptor_configuration_t*) enum_data_buffer)->bNumInterfaces;
+ //------------- Set Configure -------------//
+ OSAL_SUBTASK_INVOKED_AND_WAIT (
+ usbh_control_xfer_subtask(
+ new_addr,
+ &(tusb_std_request_t)
+ {
+ .bmRequestType = { .direction = TUSB_DIR_HOST_TO_DEV, .type = TUSB_REQUEST_TYPE_STANDARD, .recipient = TUSB_REQUEST_RECIPIENT_DEVICE },
+ .bRequest = TUSB_REQUEST_SET_CONFIGURATION,
+ .wValue = configure_selected
+ },
+ NULL
+ )
+ );
+
//------------- parse configuration & install drivers -------------//
p_desc = enum_data_buffer + sizeof(tusb_descriptor_configuration_t);
@@ -422,20 +436,6 @@ OSAL_TASK_DECLARE(usbh_enumeration_task)
}
}
- //------------- Set Configure -------------//
- OSAL_SUBTASK_INVOKED_AND_WAIT (
- usbh_control_xfer_subtask(
- new_addr,
- &(tusb_std_request_t)
- {
- .bmRequestType = { .direction = TUSB_DIR_HOST_TO_DEV, .type = TUSB_REQUEST_TYPE_STANDARD, .recipient = TUSB_REQUEST_RECIPIENT_DEVICE },
- .bRequest = TUSB_REQUEST_SET_CONFIGURATION,
- .wValue = configure_selected
- },
- NULL
- )
- );
-
usbh_devices[new_addr].state = TUSB_DEVICE_STATE_CONFIGURED;
tusbh_device_mount_succeed_cb(new_addr);