Просмотр исходного кода

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

hathach 13 лет назад
Родитель
Сommit
e658e67ebe
4 измененных файлов с 22 добавлено и 16 удалено
  1. 3 0
      demos/bsp/boards/board_ea4357.c
  2. 1 0
      demos/host/keyboard_app.c
  3. 2 0
      tinyusb/hal/hal_lpc43xx.c
  4. 16 16
      tinyusb/host/usbh.c

+ 3 - 0
demos/bsp/boards/board_ea4357.c

@@ -57,6 +57,9 @@ void board_init(void)
 
 
   // USB Host Power Enable
   // USB Host Power Enable
   // USB0
   // 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
   // TODO USB1
 
 
 #if 0
 #if 0

+ 1 - 0
demos/host/keyboard_app.c

@@ -86,6 +86,7 @@ void keyboard_app_task(void)
               printf("%c", keycode_to_ascii(keyboard_report.keycode[i]));
               printf("%c", keycode_to_ascii(keyboard_report.keycode[i]));
           }
           }
           memclr_(&keyboard_report, sizeof(tusb_keyboard_report_t)); // TODO use callback to synchronize
           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;
         break;
 
 
         case TUSB_INTERFACE_STATUS_BUSY:
         case TUSB_INTERFACE_STATUS_BUSY:

+ 2 - 0
tinyusb/hal/hal_lpc43xx.c

@@ -41,6 +41,7 @@
 #if MCU == MCU_LPC43XX
 #if MCU == MCU_LPC43XX
 
 
 #include "lpc43xx_cgu.h"
 #include "lpc43xx_cgu.h"
+#include "lpc43xx_scu.h"
 
 
 enum {
 enum {
   LPC43XX_USBMODE_DEVICE = 2,
   LPC43XX_USBMODE_DEVICE = 2,
@@ -63,6 +64,7 @@ tusb_error_t hal_init(void)
 
 
   //------------- reset controller & set role -------------//
   //------------- reset controller & set role -------------//
   hcd_controller_reset(0); // TODO where to place prototype, USB1
   hcd_controller_reset(0); // TODO where to place prototype, USB1
+
   LPC_USB0->USBMODE_H = LPC43XX_USBMODE_HOST | (LPC43XX_USBMODE_VBUS_HIGH << 5);
   LPC_USB0->USBMODE_H = LPC43XX_USBMODE_HOST | (LPC43XX_USBMODE_VBUS_HIGH << 5);
 
 
   hal_interrupt_enable(0); // TODO USB1
   hal_interrupt_enable(0); // TODO USB1

+ 16 - 16
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 -------------//
   //------------- Set new address -------------//
   new_addr = get_new_address();
   new_addr = get_new_address();
   TASK_ASSERT(new_addr <= TUSB_CFG_HOST_DEVICE_MAX);
   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_pipe_control_close(0);
   usbh_devices[0].state = TUSB_DEVICE_STATE_UNPLUG;
   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
   // open control pipe for new address
   TASK_ASSERT_STATUS ( usbh_pipe_control_open(new_addr, ((tusb_descriptor_device_t*) enum_data_buffer)->bMaxPacketSize0 ) );
   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
   // update configuration info
   usbh_devices[new_addr].interface_count = ((tusb_descriptor_configuration_t*) enum_data_buffer)->bNumInterfaces;
   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 -------------//
   //------------- parse configuration & install drivers -------------//
   p_desc = enum_data_buffer + sizeof(tusb_descriptor_configuration_t);
   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;
   usbh_devices[new_addr].state = TUSB_DEVICE_STATE_CONFIGURED;
   tusbh_device_mount_succeed_cb(new_addr);
   tusbh_device_mount_succeed_cb(new_addr);