refine hid host driver

This commit is contained in:
hathach 2013-09-20 16:20:28 +07:00
parent d8907c9a2b
commit 52ae0afeb6
9 changed files with 53 additions and 61 deletions

View File

@ -66,8 +66,8 @@
#include "oem_base_board/pca9532.h" // LEDs #include "oem_base_board/pca9532.h" // LEDs
//#define CFG_PRINTF_TARGET PRINTF_TARGET_SWO #define CFG_PRINTF_TARGET PRINTF_TARGET_SWO
#define CFG_PRINTF_TARGET PRINTF_TARGET_UART //#define CFG_PRINTF_TARGET PRINTF_TARGET_UART
/*========================================================================= /*=========================================================================
HARDWARE MAC ADDRESS HARDWARE MAC ADDRESS

View File

@ -331,7 +331,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>96</TopLine> <TopLine>97</TopLine>
<CurrentLine>102</CurrentLine> <CurrentLine>102</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\src\main.c</PathWithFileName> <PathWithFileName>..\src\main.c</PathWithFileName>
@ -379,8 +379,8 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>41</TopLine> <TopLine>43</TopLine>
<CurrentLine>50</CurrentLine> <CurrentLine>55</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\src\mouse_app.c</PathWithFileName> <PathWithFileName>..\src\mouse_app.c</PathWithFileName>
<FilenameWithoutPath>mouse_app.c</FilenameWithoutPath> <FilenameWithoutPath>mouse_app.c</FilenameWithoutPath>
@ -833,9 +833,9 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>51</ColumnNumber> <ColumnNumber>52</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>348</TopLine> <TopLine>349</TopLine>
<CurrentLine>355</CurrentLine> <CurrentLine>355</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\lpc43xx\CMSIS_LPC43xx_DriverLib\src\lpc43xx_uart.c</PathWithFileName> <PathWithFileName>..\..\bsp\lpc43xx\CMSIS_LPC43xx_DriverLib\src\lpc43xx_uart.c</PathWithFileName>
@ -939,7 +939,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>149</TopLine> <TopLine>150</TopLine>
<CurrentLine>151</CurrentLine> <CurrentLine>151</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s</PathWithFileName> <PathWithFileName>..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s</PathWithFileName>
@ -1075,7 +1075,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>27</ColumnNumber> <ColumnNumber>27</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>22</TopLine> <TopLine>23</TopLine>
<CurrentLine>29</CurrentLine> <CurrentLine>29</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\vendor\freertos\freertos\Source\portable\RVDS\ARM_CM4F\port.c</PathWithFileName> <PathWithFileName>..\..\..\vendor\freertos\freertos\Source\portable\RVDS\ARM_CM4F\port.c</PathWithFileName>

View File

@ -392,10 +392,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>54</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>170</TopLine> <TopLine>171</TopLine>
<CurrentLine>175</CurrentLine> <CurrentLine>191</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\src\main.c</PathWithFileName> <PathWithFileName>..\src\main.c</PathWithFileName>
<FilenameWithoutPath>main.c</FilenameWithoutPath> <FilenameWithoutPath>main.c</FilenameWithoutPath>
@ -426,7 +426,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>20</ColumnNumber> <ColumnNumber>20</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>117</TopLine> <TopLine>120</TopLine>
<CurrentLine>129</CurrentLine> <CurrentLine>129</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\src\keyboard_app.c</PathWithFileName> <PathWithFileName>..\src\keyboard_app.c</PathWithFileName>
@ -442,7 +442,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>119</TopLine> <TopLine>122</TopLine>
<CurrentLine>131</CurrentLine> <CurrentLine>131</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\src\mouse_app.c</PathWithFileName> <PathWithFileName>..\src\mouse_app.c</PathWithFileName>
@ -498,7 +498,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>2</ColumnNumber> <ColumnNumber>2</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>138</TopLine> <TopLine>139</TopLine>
<CurrentLine>146</CurrentLine> <CurrentLine>146</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\boards\embedded_artists\board_ea4357.c</PathWithFileName> <PathWithFileName>..\..\bsp\boards\embedded_artists\board_ea4357.c</PathWithFileName>
@ -514,7 +514,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>1</ColumnNumber> <ColumnNumber>1</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>100</TopLine> <TopLine>101</TopLine>
<CurrentLine>106</CurrentLine> <CurrentLine>106</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\boards\printf_retarget.c</PathWithFileName> <PathWithFileName>..\..\bsp\boards\printf_retarget.c</PathWithFileName>
@ -712,10 +712,10 @@
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>0</tvExp>
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>30</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>1</TopLine> <TopLine>1</TopLine>
<CurrentLine>21</CurrentLine> <CurrentLine>1</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\host\usbh.c</PathWithFileName> <PathWithFileName>..\..\..\tinyusb\host\usbh.c</PathWithFileName>
<FilenameWithoutPath>usbh.c</FilenameWithoutPath> <FilenameWithoutPath>usbh.c</FilenameWithoutPath>
@ -730,7 +730,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>47</ColumnNumber> <ColumnNumber>47</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>1</TopLine> <TopLine>4</TopLine>
<CurrentLine>13</CurrentLine> <CurrentLine>13</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\host\ehci\ehci.c</PathWithFileName> <PathWithFileName>..\..\..\tinyusb\host\ehci\ehci.c</PathWithFileName>
@ -778,7 +778,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>8</ColumnNumber> <ColumnNumber>8</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>58</TopLine> <TopLine>68</TopLine>
<CurrentLine>77</CurrentLine> <CurrentLine>77</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\hal\hal_lpc43xx.c</PathWithFileName> <PathWithFileName>..\..\..\tinyusb\hal\hal_lpc43xx.c</PathWithFileName>
@ -842,7 +842,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>28</ColumnNumber> <ColumnNumber>28</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>15</TopLine> <TopLine>23</TopLine>
<CurrentLine>32</CurrentLine> <CurrentLine>32</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\class\cdc_host.c</PathWithFileName> <PathWithFileName>..\..\..\tinyusb\class\cdc_host.c</PathWithFileName>
@ -1002,7 +1002,7 @@
<Focus>0</Focus> <Focus>0</Focus>
<ColumnNumber>0</ColumnNumber> <ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<TopLine>145</TopLine> <TopLine>146</TopLine>
<CurrentLine>151</CurrentLine> <CurrentLine>151</CurrentLine>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s</PathWithFileName> <PathWithFileName>..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s</PathWithFileName>

View File

@ -69,7 +69,7 @@
#define TUSB_CFG_CONFIGURATION_MAX 1 #define TUSB_CFG_CONFIGURATION_MAX 1
//------------- USBD -------------// //------------- USBD -------------//
#define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 256 #define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 255
//------------- CLASS -------------// //------------- CLASS -------------//
#define TUSB_CFG_HOST_HUB 0 #define TUSB_CFG_HOST_HUB 0

View File

@ -153,7 +153,7 @@ tusb_error_t control_xfer_stub(uint8_t dev_addr, const tusb_control_request_t *
case 4: // get full-length configuration descriptor case 4: // get full-length configuration descriptor
TEST_ASSERT_EQUAL(TUSB_REQUEST_GET_DESCRIPTOR, p_request->bRequest); TEST_ASSERT_EQUAL(TUSB_REQUEST_GET_DESCRIPTOR, p_request->bRequest);
TEST_ASSERT_EQUAL(TUSB_DESC_TYPE_CONFIGURATION, p_request->wValue >> 8); TEST_ASSERT_EQUAL(TUSB_DESC_TYPE_CONFIGURATION, p_request->wValue >> 8);
TEST_ASSERT_EQUAL(desc_configuration.configuration.wTotalLength, p_request->wLength); TEST_ASSERT_EQUAL(TUSB_CFG_HOST_ENUM_BUFFER_SIZE, p_request->wLength);
memcpy(data, &desc_configuration, p_request->wLength); memcpy(data, &desc_configuration, p_request->wLength);
break; break;

View File

@ -69,7 +69,7 @@
#define TUSB_CFG_HOST_DEVICE_MAX 2 #define TUSB_CFG_HOST_DEVICE_MAX 2
#define TUSB_CFG_CONFIGURATION_MAX 2 #define TUSB_CFG_CONFIGURATION_MAX 2
#define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 256 #define TUSB_CFG_HOST_ENUM_BUFFER_SIZE 255
//------------- CLASS -------------// //------------- CLASS -------------//
#define TUSB_CFG_HOST_HID_KEYBOARD 1 #define TUSB_CFG_HOST_HID_KEYBOARD 1

View File

@ -104,8 +104,9 @@ typedef ATTR_PREPACKED struct ATTR_PACKED {
typedef ATTR_PACKED_STRUCT(struct) typedef ATTR_PACKED_STRUCT(struct)
{ {
uint8_t buttons; /**< buttons mask for currently pressed buttons in the mouse. */ uint8_t buttons; /**< buttons mask for currently pressed buttons in the mouse. */
int8_t x; /**< Current delta x movement of the mouse. */ int8_t x; /**< Current delta x movement of the mouse. */
int8_t y; /**< Current delta y movement on the mouse. */ int8_t y; /**< Current delta y movement on the mouse. */
int8_t wheel; /**< Current delta wheel movement on the mouse. */
} tusb_mouse_report_t; } tusb_mouse_report_t;
/** /**

View File

@ -197,7 +197,10 @@ void hidh_init(void)
#endif #endif
} }
//uint8_t report_descriptor[256] TUSB_CFG_ATTR_USBRAM; #if 0
uint8_t report_descriptor[256] TUSB_CFG_ATTR_USBRAM;
#endif
tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length) tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t const *p_interface_desc, uint16_t *p_length)
{ {
tusb_error_t error; tusb_error_t error;
@ -215,41 +218,29 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
OSAL_SUBTASK_BEGIN OSAL_SUBTASK_BEGIN
#if 0
//------------- SET IDLE request -------------// //------------- SET IDLE request -------------//
// TODO this request can be stalled by device (indicate not supported), // TODO this request can be stalled by device (indicate not supported),
// until we have clear stall handler, temporarily disable it. // until we have clear stall handler, temporarily disable it.
// OSAL_SUBTASK_INVOKED_AND_WAIT( OSAL_SUBTASK_INVOKED_AND_WAIT(
// usbh_control_xfer_subtask( usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_HOST_TO_DEV, TUSB_REQUEST_TYPE_CLASS, TUSB_REQUEST_RECIPIENT_INTERFACE),
// dev_addr, HID_REQUEST_CONTROL_SET_IDLE, 0, p_interface_desc->bInterfaceNumber,
// &(tusb_control_request_t) 0, NULL ),
// { error
// .bmRequestType = { .direction = TUSB_DIR_HOST_TO_DEV, .type = TUSB_REQUEST_TYPE_CLASS, .recipient = TUSB_REQUEST_RECIPIENT_INTERFACE }, );
// .bRequest = HID_REQUEST_CONTROL_SET_IDLE,
// .wValue = 0,
// .wIndex = p_interface_desc->bInterfaceNumber
// },
// NULL ),
// error
// );
//------------- TODO skip Get Report Descriptor -------------// //------------- Get Report Descriptor TODO HID parser -------------//
// memclr_(report_descriptor, 256); if ( p_desc_hid->bNumDescriptors )
{
// OSAL_SUBTASK_INVOKED_AND_WAIT( OSAL_SUBTASK_INVOKED_AND_WAIT(
// usbh_control_xfer_subtask( usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_DEV_TO_HOST, TUSB_REQUEST_TYPE_STANDARD, TUSB_REQUEST_RECIPIENT_INTERFACE),
// dev_addr, TUSB_REQUEST_GET_DESCRIPTOR, (p_desc_hid->bReportType << 8), 0,
// &(tusb_control_request_t) p_desc_hid->wReportLength, report_descriptor ),
// { error
// .bmRequestType = { .direction = TUSB_DIR_DEV_TO_HOST, .type = TUSB_REQUEST_TYPE_STANDARD, .recipient = TUSB_REQUEST_RECIPIENT_INTERFACE }, );
// .bRequest = TUSB_REQUEST_GET_DESCRIPTOR, // if error in getting report descriptor --> treating like there is none
// .wValue = HID_DESC_TYPE_REPORT, }
// .wIndex = p_interface_desc->bInterfaceNumber, #endif
// .wLength = p_desc_hid->wReportLength,
// },
// report_descriptor ),
// error
// );
// uint8_t *p_report_desc = NULL; // report descriptor has to be global & in USB RAM
if ( HID_SUBCLASS_BOOT == p_interface_desc->bInterfaceSubClass ) if ( HID_SUBCLASS_BOOT == p_interface_desc->bInterfaceSubClass )
{ {

View File

@ -418,14 +418,14 @@ tusb_error_t enumeration_body_subtask(void)
error error
); );
SUBTASK_ASSERT_STATUS(error); SUBTASK_ASSERT_STATUS(error);
SUBTASK_ASSERT_WITH_HANDLER( TUSB_CFG_HOST_ENUM_BUFFER_SIZE > ((tusb_descriptor_configuration_t*)enum_data_buffer)->wTotalLength, SUBTASK_ASSERT_WITH_HANDLER( TUSB_CFG_HOST_ENUM_BUFFER_SIZE >= ((tusb_descriptor_configuration_t*)enum_data_buffer)->wTotalLength,
tusbh_device_mount_failed_cb(TUSB_ERROR_USBH_MOUNT_CONFIG_DESC_TOO_LONG, NULL) ); tusbh_device_mount_failed_cb(TUSB_ERROR_USBH_MOUNT_CONFIG_DESC_TOO_LONG, NULL) );
//------------- Get full configuration descriptor -------------// //------------- Get full configuration descriptor -------------//
OSAL_SUBTASK_INVOKED_AND_WAIT( OSAL_SUBTASK_INVOKED_AND_WAIT(
usbh_control_xfer_subtask( new_addr, bm_request_type(TUSB_DIR_DEV_TO_HOST, TUSB_REQUEST_TYPE_STANDARD, TUSB_REQUEST_RECIPIENT_DEVICE), usbh_control_xfer_subtask( new_addr, bm_request_type(TUSB_DIR_DEV_TO_HOST, TUSB_REQUEST_TYPE_STANDARD, TUSB_REQUEST_RECIPIENT_DEVICE),
TUSB_REQUEST_GET_DESCRIPTOR, (TUSB_DESC_TYPE_CONFIGURATION << 8) | (configure_selected - 1), 0, TUSB_REQUEST_GET_DESCRIPTOR, (TUSB_DESC_TYPE_CONFIGURATION << 8) | (configure_selected - 1), 0,
((tusb_descriptor_configuration_t*) enum_data_buffer)->wTotalLength, enum_data_buffer ), TUSB_CFG_HOST_ENUM_BUFFER_SIZE, enum_data_buffer ),
error error
); );
SUBTASK_ASSERT_STATUS(error); SUBTASK_ASSERT_STATUS(error);