fix the damn bug within 10 line of code in keyboard_app.c

This commit is contained in:
hathach 2013-03-29 00:20:27 +07:00
parent d95c6cf2e0
commit e658e67ebe
4 changed files with 22 additions and 16 deletions

View File

@ -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

View File

@ -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:

View File

@ -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

View File

@ -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);