clean up hid host (temp let test failed)

This commit is contained in:
hathach 2013-09-28 01:01:44 +07:00
parent bfa96ae9da
commit cb600ed988
7 changed files with 78 additions and 80 deletions

View File

@ -69,7 +69,7 @@
</natures>
<filteredResources>
<filter>
<id>0</id>
<id>1380304047311</id>
<name></name>
<type>22</type>
<matcher>
@ -78,7 +78,7 @@
</matcher>
</filter>
<filter>
<id>0</id>
<id>1380304047319</id>
<name></name>
<type>22</type>
<matcher>
@ -87,7 +87,7 @@
</matcher>
</filter>
<filter>
<id>0</id>
<id>1380304047327</id>
<name></name>
<type>10</type>
<matcher>
@ -95,5 +95,14 @@
<arguments>1.0-name-matches-false-false-docs</arguments>
</matcher>
</filter>
<filter>
<id>1380304047336</id>
<name></name>
<type>26</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-build</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>

View File

@ -150,7 +150,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>JL2CM3</Key>
<Name>-U268003250 -O1006 -S8 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(4) -TO23 -TC72000000 -TP21 -TDS800B -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB5 -TFE1 -FO15 -FD10000000 -FC800 -FN2 -FF0LPC18xx43xx_512_BA -FS01A000000 -FL080000 -FF1LPC18xx43xx_512_BB -FS11B000000 -FL180000</Name>
<Name>-U268003250 -O1006 -S8 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(4) -TO19 -TC72000000 -TP21 -TDS800B -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB5 -TFE1 -FO15 -FD10000000 -FC800 -FN2 -FF0LPC18xx43xx_512_BA -FS01A000000 -FL080000 -FF1LPC18xx43xx_512_BB -FS11B000000 -FL180000</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
@ -424,10 +424,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>17</ColumnNumber>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>94</TopLine>
<CurrentLine>111</CurrentLine>
<TopLine>147</TopLine>
<CurrentLine>159</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\src\main.c</PathWithFileName>
<FilenameWithoutPath>main.c</FilenameWithoutPath>
@ -442,8 +442,8 @@
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>92</TopLine>
<CurrentLine>145</CurrentLine>
<TopLine>59</TopLine>
<CurrentLine>75</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\src\cdc_serial_app.c</PathWithFileName>
<FilenameWithoutPath>cdc_serial_app.c</FilenameWithoutPath>
@ -458,8 +458,8 @@
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>111</TopLine>
<CurrentLine>123</CurrentLine>
<TopLine>112</TopLine>
<CurrentLine>135</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\src\keyboard_app.c</PathWithFileName>
<FilenameWithoutPath>keyboard_app.c</FilenameWithoutPath>
@ -488,10 +488,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>12</ColumnNumber>
<ColumnNumber>1</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine>
<CurrentLine>0</CurrentLine>
<TopLine>47</TopLine>
<CurrentLine>65</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\src\rndis_app.c</PathWithFileName>
<FilenameWithoutPath>rndis_app.c</FilenameWithoutPath>
@ -504,10 +504,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>1</ColumnNumber>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>121</TopLine>
<CurrentLine>150</CurrentLine>
<TopLine>1</TopLine>
<CurrentLine>1</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\src\msc_app.c</PathWithFileName>
<FilenameWithoutPath>msc_app.c</FilenameWithoutPath>
@ -576,10 +576,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>6</ColumnNumber>
<ColumnNumber>44</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>93</TopLine>
<CurrentLine>135</CurrentLine>
<TopLine>64</TopLine>
<CurrentLine>106</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\boards\printf_retarget.c</PathWithFileName>
<FilenameWithoutPath>printf_retarget.c</FilenameWithoutPath>
@ -794,7 +794,7 @@
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>1</TopLine>
<TopLine>2</TopLine>
<CurrentLine>5</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\host\ehci\ehci.c</PathWithFileName>
@ -952,10 +952,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>22</ColumnNumber>
<ColumnNumber>79</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>59</TopLine>
<CurrentLine>64</CurrentLine>
<TopLine>1</TopLine>
<CurrentLine>14</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\tinyusb\class\msc_host.c</PathWithFileName>
<FilenameWithoutPath>msc_host.c</FilenameWithoutPath>
@ -1024,10 +1024,10 @@
<FileType>1</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>0</ColumnNumber>
<ColumnNumber>64</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>0</TopLine>
<CurrentLine>0</CurrentLine>
<TopLine>553</TopLine>
<CurrentLine>579</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\lpc43xx\CMSIS_LPC43xx_DriverLib\src\lpc43xx_cgu.c</PathWithFileName>
<FilenameWithoutPath>lpc43xx_cgu.c</FilenameWithoutPath>
@ -1080,10 +1080,10 @@
<FileType>2</FileType>
<tvExp>0</tvExp>
<Focus>0</Focus>
<ColumnNumber>54</ColumnNumber>
<ColumnNumber>0</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>139</TopLine>
<CurrentLine>148</CurrentLine>
<CurrentLine>151</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\bsp\lpc43xx\startup_keil\startup_LPC43xx.s</PathWithFileName>
<FilenameWithoutPath>startup_LPC43xx.s</FilenameWithoutPath>
@ -1106,7 +1106,7 @@
<Focus>0</Focus>
<ColumnNumber>20</ColumnNumber>
<tvExpOptDlg>0</tvExpOptDlg>
<TopLine>49</TopLine>
<TopLine>50</TopLine>
<CurrentLine>62</CurrentLine>
<bDave2>0</bDave2>
<PathWithFileName>..\..\..\vendor\fatfs\diskio.c</PathWithFileName>

View File

@ -204,12 +204,13 @@ void test_keyboard_get_ok()
{
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, tusbh_hid_keyboard_status(dev_addr));
TEST_FAIL();
// TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, tusbh_hid_keyboard_status(dev_addr));
hcd_pipe_xfer_ExpectAndReturn(p_hidh_kbd->pipe_hdl, (uint8_t*) &report, p_hidh_kbd->report_size, true, TUSB_ERROR_NONE);
//------------- Code Under TEST -------------//
TEST_ASSERT_EQUAL(TUSB_ERROR_NONE, tusbh_hid_keyboard_get_report(dev_addr, &report));
TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_BUSY, tusbh_hid_keyboard_status(dev_addr));
// TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_BUSY, tusbh_hid_keyboard_status(dev_addr));
}
void test_keyboard_isr_event_complete(void)
@ -220,7 +221,8 @@ void test_keyboard_isr_event_complete(void)
hidh_isr(p_hidh_kbd->pipe_hdl, TUSB_EVENT_XFER_COMPLETE, 8);
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_COMPLETE, tusbh_hid_keyboard_status(dev_addr));
TEST_FAIL();
// TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_COMPLETE, tusbh_hid_keyboard_status(dev_addr));
}

View File

@ -175,13 +175,15 @@ void test_mouse_get_report_xfer_failed_busy()
void test_mouse_get_ok()
{
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, tusbh_hid_mouse_status(dev_addr));
TEST_FAIL();
// TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_READY, tusbh_hid_mouse_status(dev_addr));
hcd_pipe_xfer_ExpectAndReturn(p_hidh_mouse->pipe_hdl, (uint8_t*) &report, p_hidh_mouse->report_size, true, TUSB_ERROR_NONE);
//------------- Code Under TEST -------------//
TEST_ASSERT_STATUS( tusbh_hid_mouse_get_report(dev_addr, &report));
TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_BUSY, tusbh_hid_mouse_status(dev_addr));
TEST_FAIL();
// TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_BUSY, tusbh_hid_mouse_status(dev_addr));
}
void test_mouse_isr_event_xfer_complete(void)
@ -192,7 +194,8 @@ void test_mouse_isr_event_xfer_complete(void)
hidh_isr(p_hidh_mouse->pipe_hdl, TUSB_EVENT_XFER_COMPLETE, 8);
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_COMPLETE, tusbh_hid_mouse_status(dev_addr));
TEST_FAIL();
// TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_COMPLETE, tusbh_hid_mouse_status(dev_addr));
}
void test_mouse_isr_event_xfer_error(void)
@ -203,7 +206,8 @@ void test_mouse_isr_event_xfer_error(void)
hidh_isr(p_hidh_mouse->pipe_hdl, TUSB_EVENT_XFER_ERROR, 0);
tusbh_device_get_state_IgnoreAndReturn(TUSB_DEVICE_STATE_CONFIGURED);
TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_ERROR, tusbh_hid_mouse_status(dev_addr));
TEST_FAIL();
// TEST_ASSERT_EQUAL(TUSB_INTERFACE_STATUS_ERROR, tusbh_hid_mouse_status(dev_addr));
}

View File

@ -54,20 +54,6 @@
//--------------------------------------------------------------------+
// HID Interface common functions
//--------------------------------------------------------------------+
tusb_interface_status_t hidh_interface_status(uint8_t dev_addr, hidh_interface_info_t *p_hid) ATTR_PURE ATTR_ALWAYS_INLINE;
tusb_interface_status_t hidh_interface_status(uint8_t dev_addr, hidh_interface_info_t *p_hid)
{
switch( tusbh_device_get_state(dev_addr) )
{
case TUSB_DEVICE_STATE_UNPLUG:
case TUSB_DEVICE_STATE_INVALID_PARAMETER:
return TUSB_INTERFACE_STATUS_INVALID_PARA;
default:
return p_hid->status;
}
}
static inline tusb_error_t hidh_interface_open(uint8_t dev_addr, uint8_t interface_number, tusb_descriptor_endpoint_t const *p_endpoint_desc, hidh_interface_info_t *p_hid) ATTR_ALWAYS_INLINE;
static inline tusb_error_t hidh_interface_open(uint8_t dev_addr, uint8_t interface_number, tusb_descriptor_endpoint_t const *p_endpoint_desc, hidh_interface_info_t *p_hid)
{
@ -93,14 +79,12 @@ tusb_error_t hidh_interface_get_report(uint8_t dev_addr, void * report, hidh_int
{
//------------- parameters validation -------------//
// TODO change to use is configured function
ASSERT_INT(TUSB_DEVICE_STATE_CONFIGURED, tusbh_device_get_state(dev_addr), TUSB_ERROR_DEVICE_NOT_READY);
ASSERT_PTR(report, TUSB_ERROR_INVALID_PARA);
ASSERT(TUSB_INTERFACE_STATUS_BUSY != p_hid->status, TUSB_ERROR_INTERFACE_IS_BUSY);
ASSERT_INT (TUSB_DEVICE_STATE_CONFIGURED, tusbh_device_get_state(dev_addr), TUSB_ERROR_DEVICE_NOT_READY);
ASSERT_PTR (report, TUSB_ERROR_INVALID_PARA);
ASSERT_FALSE(hcd_pipe_is_busy(p_hid->pipe_hdl), TUSB_ERROR_INTERFACE_IS_BUSY);
ASSERT_STATUS( hcd_pipe_xfer(p_hid->pipe_hdl, report, p_hid->report_size, true) ) ;
p_hid->status = TUSB_INTERFACE_STATUS_BUSY;
return TUSB_ERROR_NONE;
}
@ -132,9 +116,10 @@ tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, void* report)
return hidh_interface_get_report(dev_addr, report, &keyboardh_data[dev_addr-1]);
}
tusb_interface_status_t tusbh_hid_keyboard_status(uint8_t dev_addr)
bool tusbh_hid_keyboard_is_busy(uint8_t dev_addr)
{
return hidh_interface_status(dev_addr, &keyboardh_data[dev_addr-1]);
return tusbh_hid_keyboard_is_mounted(dev_addr) &&
hcd_pipe_is_busy( keyboardh_data[dev_addr-1].pipe_hdl );
}
#endif
@ -152,16 +137,17 @@ bool tusbh_hid_mouse_is_mounted(uint8_t dev_addr)
return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(mouseh_data[dev_addr-1].pipe_hdl);
}
bool tusbh_hid_mouse_is_busy(uint8_t dev_addr)
{
return tusbh_hid_mouse_is_mounted(dev_addr) &&
hcd_pipe_is_busy( mouseh_data[dev_addr-1].pipe_hdl );
}
tusb_error_t tusbh_hid_mouse_get_report(uint8_t dev_addr, void * report)
{
return hidh_interface_get_report(dev_addr, report, &mouseh_data[dev_addr-1]);
}
tusb_interface_status_t tusbh_hid_mouse_status(uint8_t dev_addr)
{
return hidh_interface_status(dev_addr, &mouseh_data[dev_addr-1]);
}
#endif
//--------------------------------------------------------------------+
@ -214,17 +200,13 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
OSAL_SUBTASK_BEGIN
#if 1
//------------- SET IDLE request -------------//
// TODO this request can be stalled by device (indicate not supported),
// until we have clear stall handler, temporarily disable it.
OSAL_SUBTASK_INVOKED_AND_WAIT(
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_HOST_TO_DEV, TUSB_REQUEST_TYPE_CLASS, TUSB_REQUEST_RECIPIENT_INTERFACE),
HID_REQUEST_CONTROL_SET_IDLE, 0, p_interface_desc->bInterfaceNumber,
0, NULL ),
error
);
#endif
//------------- SET IDLE (0) request -------------//
OSAL_SUBTASK_INVOKED_AND_WAIT(
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_HOST_TO_DEV, TUSB_REQUEST_TYPE_CLASS, TUSB_REQUEST_RECIPIENT_INTERFACE),
HID_REQUEST_CONTROL_SET_IDLE, 0, p_interface_desc->bInterfaceNumber,
0, NULL ),
error
);
#if 0
//------------- Get Report Descriptor TODO HID parser -------------//
@ -276,7 +258,6 @@ void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes
#if TUSB_CFG_HOST_HID_KEYBOARD
if ( pipehandle_is_equal(pipe_hdl, keyboardh_data[pipe_hdl.dev_addr-1].pipe_hdl) )
{
keyboardh_data[pipe_hdl.dev_addr-1].status = (event == TUSB_EVENT_XFER_COMPLETE) ? TUSB_INTERFACE_STATUS_COMPLETE : TUSB_INTERFACE_STATUS_ERROR;
tusbh_hid_keyboard_isr(pipe_hdl.dev_addr, event);
return;
}
@ -285,7 +266,6 @@ void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes
#if TUSB_CFG_HOST_HID_MOUSE
if ( pipehandle_is_equal(pipe_hdl, mouseh_data[pipe_hdl.dev_addr-1].pipe_hdl) )
{
mouseh_data[pipe_hdl.dev_addr-1].status = (event == TUSB_EVENT_XFER_COMPLETE) ? TUSB_INTERFACE_STATUS_COMPLETE : TUSB_INTERFACE_STATUS_ERROR;
tusbh_hid_mouse_isr(pipe_hdl.dev_addr, event);
return;
}

View File

@ -60,8 +60,9 @@
extern uint8_t const hid_keycode_to_ascii_tbl[2][128]; // TODO used weak attr if build failed without KEYBOARD enabled
bool tusbh_hid_keyboard_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
bool tusbh_hid_keyboard_is_busy(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, void * report) /*ATTR_WARN_UNUSED_RESULT*/;
tusb_interface_status_t tusbh_hid_keyboard_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
//------------- Application Callback -------------//
void tusbh_hid_keyboard_isr(uint8_t dev_addr, tusb_event_t event);
void tusbh_hid_keyboard_mounted_cb(uint8_t dev_addr);
@ -71,8 +72,9 @@ void tusbh_hid_keyboard_unmounted_isr(uint8_t dev_addr);
// MOUSE Application API
//--------------------------------------------------------------------+
bool tusbh_hid_mouse_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
bool tusbh_hid_mouse_is_busy(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RESULT;
tusb_error_t tusbh_hid_mouse_get_report(uint8_t dev_addr, void* report) /*ATTR_WARN_UNUSED_RESULT*/;
tusb_interface_status_t tusbh_hid_mouse_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
//------------- Application Callback -------------//
void tusbh_hid_mouse_isr(uint8_t dev_addr, tusb_event_t event);
void tusbh_hid_mouse_mounted_cb(uint8_t dev_addr);
@ -86,6 +88,7 @@ tusb_error_t tusbh_hid_generic_get_report(uint8_t dev_addr, void* report, bool
tusb_error_t tusbh_hid_generic_set_report(uint8_t dev_addr, void* report, bool int_on_complete) ATTR_WARN_UNUSED_RESULT;
tusb_interface_status_t tusbh_hid_generic_get_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
tusb_interface_status_t tusbh_hid_generic_set_status(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
//------------- Application Callback -------------//
void tusbh_hid_generic_isr(uint8_t dev_addr, tusb_event_t event);
@ -98,7 +101,6 @@ typedef struct {
pipe_handle_t pipe_hdl;
uint16_t report_size;
uint8_t interface_number;
volatile tusb_interface_status_t status;
}hidh_interface_info_t;
void hidh_init(void);

View File

@ -100,7 +100,8 @@ tusb_error_t hcd_pipe_xfer(pipe_handle_t pipe_hdl, uint8_t buffer[], uint16_t t
tusb_error_t hcd_pipe_close(pipe_handle_t pipe_hdl) /*ATTR_WARN_UNUSED_RESULT*/;
bool hcd_pipe_is_busy(pipe_handle_t pipe_hdl);
bool hcd_pipe_is_stalled(pipe_handle_t pipe_hdl);
bool hcd_pipe_is_error(pipe_handle_t pipe_hdl);
bool hcd_pipe_is_stalled(pipe_handle_t pipe_hdl); // stalled also counted as error
bool hcd_pipe_is_idle(pipe_handle_t pipe_hdl);
uint8_t hcd_pipe_get_endpoint_addr(pipe_handle_t pipe_hdl);
tusb_error_t hcd_pipe_clear_stall(pipe_handle_t pipe_hdl);