mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
house keeping
This commit is contained in:
parent
2db5fcdf0a
commit
d15ba08fdc
@ -48,6 +48,7 @@ void SysTick_Handler (void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
// FIXME refractor
|
||||
void boardGetMACaddr(uint8_t *macaddr)
|
||||
{
|
||||
@ -59,6 +60,8 @@ void boardGetMACaddr(uint8_t *macaddr)
|
||||
macaddr[5] = BOARD_MAC_ADDR5;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void check_failed(uint8_t *file, uint32_t line)
|
||||
{
|
||||
(void) file;
|
||||
|
@ -73,7 +73,7 @@
|
||||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
<IsCurrentTarget>0</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>8</CpuCode>
|
||||
<Books>
|
||||
@ -264,7 +264,7 @@
|
||||
<OPTFL>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<IsCurrentTarget>0</IsCurrentTarget>
|
||||
<IsCurrentTarget>1</IsCurrentTarget>
|
||||
</OPTFL>
|
||||
<CpuCode>8</CpuCode>
|
||||
<Books>
|
||||
@ -403,10 +403,10 @@
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>3</ColumnNumber>
|
||||
<ColumnNumber>71</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>165</TopLine>
|
||||
<CurrentLine>192</CurrentLine>
|
||||
<TopLine>166</TopLine>
|
||||
<CurrentLine>183</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\src\main.c</PathWithFileName>
|
||||
<FilenameWithoutPath>main.c</FilenameWithoutPath>
|
||||
@ -507,10 +507,10 @@
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>13</ColumnNumber>
|
||||
<ColumnNumber>31</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>0</TopLine>
|
||||
<CurrentLine>0</CurrentLine>
|
||||
<TopLine>23</TopLine>
|
||||
<CurrentLine>55</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\bsp\boards\board.c</PathWithFileName>
|
||||
<FilenameWithoutPath>board.c</FilenameWithoutPath>
|
||||
@ -525,7 +525,7 @@
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>2</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>141</TopLine>
|
||||
<TopLine>142</TopLine>
|
||||
<CurrentLine>146</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\bsp\boards\embedded_artists\board_ea4357.c</PathWithFileName>
|
||||
@ -541,7 +541,7 @@
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>1</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>96</TopLine>
|
||||
<TopLine>97</TopLine>
|
||||
<CurrentLine>106</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\bsp\boards\printf_retarget.c</PathWithFileName>
|
||||
@ -677,7 +677,7 @@
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>23</TopLine>
|
||||
<TopLine>33</TopLine>
|
||||
<CurrentLine>69</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\tinyusb\tusb.c</PathWithFileName>
|
||||
@ -757,7 +757,7 @@
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>25</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>142</TopLine>
|
||||
<TopLine>143</TopLine>
|
||||
<CurrentLine>147</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\tinyusb\host\ehci\ehci.c</PathWithFileName>
|
||||
@ -805,7 +805,7 @@
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>7</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>67</TopLine>
|
||||
<TopLine>77</TopLine>
|
||||
<CurrentLine>112</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\tinyusb\hal\hal_lpc43xx.c</PathWithFileName>
|
||||
@ -915,10 +915,10 @@
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<Focus>0</Focus>
|
||||
<ColumnNumber>15</ColumnNumber>
|
||||
<ColumnNumber>0</ColumnNumber>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<TopLine>87</TopLine>
|
||||
<CurrentLine>90</CurrentLine>
|
||||
<TopLine>1</TopLine>
|
||||
<CurrentLine>1</CurrentLine>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\..\tinyusb\class\msc_host.c</PathWithFileName>
|
||||
<FilenameWithoutPath>msc_host.c</FilenameWithoutPath>
|
||||
|
@ -53,7 +53,7 @@
|
||||
uint8_t dev_addr;
|
||||
pipe_handle_t pipe_hdl;
|
||||
|
||||
extern hidh_interface_info_t keyboard_data[TUSB_CFG_HOST_DEVICE_MAX];
|
||||
extern hidh_interface_info_t keyboardh_data[TUSB_CFG_HOST_DEVICE_MAX];
|
||||
|
||||
tusb_descriptor_interface_t const *p_kbd_interface_desc = &desc_configuration.keyboard_interface;
|
||||
tusb_hid_descriptor_hid_t const *p_kbh_hid_desc = &desc_configuration.keyboard_hid;
|
||||
@ -85,8 +85,8 @@ void tearDown(void)
|
||||
|
||||
void test_hidh_close(void)
|
||||
{
|
||||
keyboard_data[dev_addr-1].pipe_hdl = pipe_hdl;
|
||||
keyboard_data[dev_addr-1].report_size = 8;
|
||||
keyboardh_data[dev_addr-1].pipe_hdl = pipe_hdl;
|
||||
keyboardh_data[dev_addr-1].report_size = 8;
|
||||
|
||||
hcd_pipe_close_ExpectAndReturn(pipe_hdl, TUSB_ERROR_NONE);
|
||||
tusbh_hid_keyboard_unmounted_isr_Expect(dev_addr);
|
||||
@ -94,5 +94,5 @@ void test_hidh_close(void)
|
||||
//------------- Code Under TEST -------------//
|
||||
hidh_close(dev_addr);
|
||||
|
||||
TEST_ASSERT_MEM_ZERO(&keyboard_data[dev_addr-1], sizeof(hidh_interface_info_t));
|
||||
TEST_ASSERT_MEM_ZERO(&keyboardh_data[dev_addr-1], sizeof(hidh_interface_info_t));
|
||||
}
|
||||
|
@ -51,7 +51,7 @@
|
||||
#include "host_helper.h"
|
||||
|
||||
|
||||
extern hidh_interface_info_t mouse_data[TUSB_CFG_HOST_DEVICE_MAX];
|
||||
extern hidh_interface_info_t mouseh_data[TUSB_CFG_HOST_DEVICE_MAX];
|
||||
hidh_interface_info_t *p_hidh_mouse;
|
||||
tusb_mouse_report_t report;
|
||||
|
||||
|
@ -48,7 +48,7 @@
|
||||
#include "mock_hidh_callback.h"
|
||||
#include "descriptor_test.h"
|
||||
|
||||
extern hidh_interface_info_t keyboard_data[TUSB_CFG_HOST_DEVICE_MAX];
|
||||
extern hidh_interface_info_t keyboardh_data[TUSB_CFG_HOST_DEVICE_MAX];
|
||||
|
||||
tusb_keyboard_report_t sample_key[2] =
|
||||
{
|
||||
@ -76,7 +76,7 @@ void setUp(void)
|
||||
memclr_(&report, sizeof(tusb_keyboard_report_t));
|
||||
dev_addr = RANDOM(TUSB_CFG_HOST_DEVICE_MAX)+1;
|
||||
|
||||
p_hidh_kbd = &keyboard_data[dev_addr-1];
|
||||
p_hidh_kbd = &keyboardh_data[dev_addr-1];
|
||||
|
||||
p_hidh_kbd->report_size = sizeof(tusb_keyboard_report_t);
|
||||
p_hidh_kbd->pipe_hdl = (pipe_handle_t) {
|
||||
@ -95,7 +95,7 @@ void test_keyboard_init(void)
|
||||
{
|
||||
hidh_init();
|
||||
|
||||
TEST_ASSERT_MEM_ZERO(keyboard_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
|
||||
TEST_ASSERT_MEM_ZERO(keyboardh_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
|
||||
}
|
||||
|
||||
//------------- is supported -------------//
|
||||
|
@ -49,7 +49,7 @@
|
||||
#include "mock_hidh_callback.h"
|
||||
#include "descriptor_test.h"
|
||||
|
||||
extern hidh_interface_info_t mouse_data[TUSB_CFG_HOST_DEVICE_MAX];
|
||||
extern hidh_interface_info_t mouseh_data[TUSB_CFG_HOST_DEVICE_MAX];
|
||||
hidh_interface_info_t *p_hidh_mouse;
|
||||
tusb_mouse_report_t report;
|
||||
|
||||
@ -65,7 +65,7 @@ void setUp(void)
|
||||
memclr_(&report, sizeof(tusb_mouse_report_t));
|
||||
dev_addr = RANDOM(TUSB_CFG_HOST_DEVICE_MAX)+1;
|
||||
|
||||
p_hidh_mouse = &mouse_data[dev_addr-1];
|
||||
p_hidh_mouse = &mouseh_data[dev_addr-1];
|
||||
|
||||
p_hidh_mouse->report_size = sizeof(tusb_mouse_report_t);
|
||||
p_hidh_mouse->pipe_hdl = (pipe_handle_t) {
|
||||
@ -84,7 +84,7 @@ void test_mouse_init(void)
|
||||
{
|
||||
hidh_init();
|
||||
|
||||
TEST_ASSERT_MEM_ZERO(mouse_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
|
||||
TEST_ASSERT_MEM_ZERO(mouseh_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
|
||||
}
|
||||
|
||||
//------------- is supported -------------//
|
||||
|
@ -57,7 +57,7 @@
|
||||
static uint8_t msg_notification[TUSB_CFG_HOST_DEVICE_MAX][8] TUSB_CFG_ATTR_USBRAM;
|
||||
ATTR_ALIGNED(4) static uint8_t msg_payload[RNDIS_MSG_PAYLOAD_MAX] TUSB_CFG_ATTR_USBRAM;
|
||||
|
||||
STATIC_ rndish_data_t rndish_data[TUSB_CFG_HOST_DEVICE_MAX];
|
||||
STATIC_VAR rndish_data_t rndish_data[TUSB_CFG_HOST_DEVICE_MAX];
|
||||
|
||||
// TODO Microsoft requires message length for any get command must be at least 4096 bytes
|
||||
|
||||
|
@ -119,22 +119,22 @@ uint8_t const hid_keycode_to_ascii_tbl[2][128] =
|
||||
HID_KEYCODE_TABLE(EXPAND_KEYCODE_TO_ASCII)
|
||||
};
|
||||
|
||||
STATIC_ hidh_interface_info_t keyboard_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
|
||||
STATIC_VAR hidh_interface_info_t keyboardh_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
|
||||
|
||||
//------------- KEYBOARD PUBLIC API (parameter validation required) -------------//
|
||||
bool tusbh_hid_keyboard_is_mounted(uint8_t dev_addr)
|
||||
{
|
||||
return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(keyboard_data[dev_addr-1].pipe_hdl);
|
||||
return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(keyboardh_data[dev_addr-1].pipe_hdl);
|
||||
}
|
||||
|
||||
tusb_error_t tusbh_hid_keyboard_get_report(uint8_t dev_addr, void* report)
|
||||
{
|
||||
return hidh_interface_get_report(dev_addr, report, &keyboard_data[dev_addr-1]);
|
||||
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)
|
||||
{
|
||||
return hidh_interface_status(dev_addr, &keyboard_data[dev_addr-1]);
|
||||
return hidh_interface_status(dev_addr, &keyboardh_data[dev_addr-1]);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -144,22 +144,22 @@ tusb_interface_status_t tusbh_hid_keyboard_status(uint8_t dev_addr)
|
||||
//--------------------------------------------------------------------+
|
||||
#if TUSB_CFG_HOST_HID_MOUSE
|
||||
|
||||
STATIC_ hidh_interface_info_t mouse_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
|
||||
STATIC_VAR hidh_interface_info_t mouseh_data[TUSB_CFG_HOST_DEVICE_MAX]; // does not have addr0, index = dev_address-1
|
||||
|
||||
//------------- Public API -------------//
|
||||
bool tusbh_hid_mouse_is_mounted(uint8_t dev_addr)
|
||||
{
|
||||
return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(mouse_data[dev_addr-1].pipe_hdl);
|
||||
return tusbh_device_is_configured(dev_addr) && pipehandle_is_valid(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, &mouse_data[dev_addr-1]);
|
||||
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, &mouse_data[dev_addr-1]);
|
||||
return hidh_interface_status(dev_addr, &mouseh_data[dev_addr-1]);
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -181,11 +181,11 @@ tusb_interface_status_t tusbh_hid_mouse_status(uint8_t dev_addr)
|
||||
void hidh_init(void)
|
||||
{
|
||||
#if TUSB_CFG_HOST_HID_KEYBOARD
|
||||
memclr_(&keyboard_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
|
||||
memclr_(&keyboardh_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
|
||||
#endif
|
||||
|
||||
#if TUSB_CFG_HOST_HID_MOUSE
|
||||
memclr_(&mouse_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
|
||||
memclr_(&mouseh_data, sizeof(hidh_interface_info_t)*TUSB_CFG_HOST_DEVICE_MAX);
|
||||
#endif
|
||||
|
||||
#if TUSB_CFG_HOST_HID_GENERIC
|
||||
@ -243,7 +243,7 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
|
||||
#if TUSB_CFG_HOST_HID_KEYBOARD
|
||||
if ( HID_PROTOCOL_KEYBOARD == p_interface_desc->bInterfaceProtocol)
|
||||
{
|
||||
SUBTASK_ASSERT_STATUS ( hidh_interface_open(dev_addr, p_interface_desc->bInterfaceNumber, p_endpoint_desc, &keyboard_data[dev_addr-1]) );
|
||||
SUBTASK_ASSERT_STATUS ( hidh_interface_open(dev_addr, p_interface_desc->bInterfaceNumber, p_endpoint_desc, &keyboardh_data[dev_addr-1]) );
|
||||
if ( tusbh_hid_keyboard_mounted_cb )
|
||||
{
|
||||
tusbh_hid_keyboard_mounted_cb(dev_addr);
|
||||
@ -254,7 +254,7 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
|
||||
#if TUSB_CFG_HOST_HID_MOUSE
|
||||
if ( HID_PROTOCOL_MOUSE == p_interface_desc->bInterfaceProtocol)
|
||||
{
|
||||
SUBTASK_ASSERT_STATUS ( hidh_interface_open(dev_addr, p_interface_desc->bInterfaceNumber, p_endpoint_desc, &mouse_data[dev_addr-1]) );
|
||||
SUBTASK_ASSERT_STATUS ( hidh_interface_open(dev_addr, p_interface_desc->bInterfaceNumber, p_endpoint_desc, &mouseh_data[dev_addr-1]) );
|
||||
if (tusbh_hid_mouse_mounted_cb)
|
||||
{
|
||||
tusbh_hid_mouse_mounted_cb(dev_addr);
|
||||
@ -278,9 +278,9 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
|
||||
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, keyboard_data[pipe_hdl.dev_addr-1].pipe_hdl) )
|
||||
if ( pipehandle_is_equal(pipe_hdl, keyboardh_data[pipe_hdl.dev_addr-1].pipe_hdl) )
|
||||
{
|
||||
keyboard_data[pipe_hdl.dev_addr-1].status = (event == TUSB_EVENT_XFER_COMPLETE) ? TUSB_INTERFACE_STATUS_COMPLETE : TUSB_INTERFACE_STATUS_ERROR;
|
||||
keyboardh_data[pipe_hdl.dev_addr-1].status = (event == TUSB_EVENT_XFER_COMPLETE) ? TUSB_INTERFACE_STATUS_COMPLETE : TUSB_INTERFACE_STATUS_ERROR;
|
||||
if (tusbh_hid_keyboard_isr)
|
||||
{
|
||||
tusbh_hid_keyboard_isr(pipe_hdl.dev_addr, event);
|
||||
@ -290,9 +290,9 @@ void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes
|
||||
#endif
|
||||
|
||||
#if TUSB_CFG_HOST_HID_MOUSE
|
||||
if ( pipehandle_is_equal(pipe_hdl, mouse_data[pipe_hdl.dev_addr-1].pipe_hdl) )
|
||||
if ( pipehandle_is_equal(pipe_hdl, mouseh_data[pipe_hdl.dev_addr-1].pipe_hdl) )
|
||||
{
|
||||
mouse_data[pipe_hdl.dev_addr-1].status = (event == TUSB_EVENT_XFER_COMPLETE) ? TUSB_INTERFACE_STATUS_COMPLETE : TUSB_INTERFACE_STATUS_ERROR;
|
||||
mouseh_data[pipe_hdl.dev_addr-1].status = (event == TUSB_EVENT_XFER_COMPLETE) ? TUSB_INTERFACE_STATUS_COMPLETE : TUSB_INTERFACE_STATUS_ERROR;
|
||||
if (tusbh_hid_mouse_isr)
|
||||
{
|
||||
tusbh_hid_mouse_isr(pipe_hdl.dev_addr, event);
|
||||
@ -310,17 +310,17 @@ void hidh_isr(pipe_handle_t pipe_hdl, tusb_event_t event, uint32_t xferred_bytes
|
||||
void hidh_close(uint8_t dev_addr)
|
||||
{
|
||||
#if TUSB_CFG_HOST_HID_KEYBOARD
|
||||
if ( pipehandle_is_valid( keyboard_data[dev_addr-1].pipe_hdl ) )
|
||||
if ( pipehandle_is_valid( keyboardh_data[dev_addr-1].pipe_hdl ) )
|
||||
{
|
||||
hidh_interface_close(dev_addr, &keyboard_data[dev_addr-1]);
|
||||
hidh_interface_close(dev_addr, &keyboardh_data[dev_addr-1]);
|
||||
tusbh_hid_keyboard_unmounted_isr(dev_addr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TUSB_CFG_HOST_HID_MOUSE
|
||||
if( pipehandle_is_valid( mouse_data[dev_addr-1].pipe_hdl ) )
|
||||
if( pipehandle_is_valid( mouseh_data[dev_addr-1].pipe_hdl ) )
|
||||
{
|
||||
hidh_interface_close(dev_addr, &mouse_data[dev_addr-1]);
|
||||
hidh_interface_close(dev_addr, &mouseh_data[dev_addr-1]);
|
||||
tusbh_hid_mouse_unmounted_isr( dev_addr );
|
||||
}
|
||||
#endif
|
||||
|
@ -76,6 +76,26 @@ enum {
|
||||
MSC_REQUEST_RESET = 255
|
||||
};
|
||||
|
||||
typedef ATTR_PACKED_STRUCT(struct) {
|
||||
uint32_t signature; // const 0x43425355
|
||||
uint32_t tag;
|
||||
uint32_t xfer_bytes;
|
||||
uint8_t flags; // bit7 : direction
|
||||
uint8_t lun;
|
||||
uint8_t cmd_len;
|
||||
uint8_t command[16];
|
||||
}msc_cmd_block_wrapper_t;
|
||||
|
||||
STATIC_ASSERT(sizeof(msc_cmd_block_wrapper_t) == 31, "size is not correct");
|
||||
|
||||
typedef ATTR_PACKED_STRUCT(struct) {
|
||||
uint32_t signature; // const 0x53425355
|
||||
uint32_t tag;
|
||||
uint32_t data_residue;
|
||||
uint8_t status;
|
||||
}msc_cmd_status_wrapper_t;
|
||||
|
||||
STATIC_ASSERT(sizeof(msc_cmd_status_wrapper_t) == 13, "size is not correct");
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// SCSI Primary Command (SPC-4)
|
||||
@ -95,7 +115,7 @@ typedef ATTR_PACKED_STRUCT(struct)
|
||||
uint8_t normal_aca : 1;
|
||||
uint8_t : 2;
|
||||
|
||||
uint8_t additional_length;
|
||||
uint8_t additional_length;
|
||||
|
||||
uint8_t protect : 1;
|
||||
uint8_t : 2;
|
||||
@ -118,11 +138,13 @@ typedef ATTR_PACKED_STRUCT(struct)
|
||||
uint8_t wbus16 : 1;
|
||||
uint8_t : 2;
|
||||
|
||||
uint8_t vendor_id[8];
|
||||
uint8_t product_id[16];
|
||||
uint8_t product_revision[4];
|
||||
uint8_t vendor_id[8];
|
||||
uint8_t product_id[16];
|
||||
uint8_t product_revision[4];
|
||||
} msc_scsi_inquiry_t;
|
||||
|
||||
STATIC_ASSERT(sizeof(msc_scsi_inquiry_t) == 36, "size is not correct");
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// SCSI Block Command (SBC-3)
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -55,12 +55,15 @@ typedef struct {
|
||||
pipe_handle_t bulk_in, bulk_out;
|
||||
uint8_t interface_number;
|
||||
uint8_t max_lun;
|
||||
|
||||
msc_cmd_block_wrapper_t cbw;
|
||||
msc_cmd_status_wrapper_t csw;
|
||||
}msch_interface_t;
|
||||
|
||||
/*STATIC_*/ msch_interface_t msch_data[TUSB_CFG_HOST_DEVICE_MAX]; // TODO to be static
|
||||
STATIC_VAR msch_interface_t msch_data[TUSB_CFG_HOST_DEVICE_MAX] TUSB_CFG_ATTR_USBRAM; // TODO to be static
|
||||
|
||||
// TODO rename this
|
||||
STATIC_ uint8_t msch_buffer[10] TUSB_CFG_ATTR_USBRAM;
|
||||
STATIC_VAR uint8_t msch_buffer[10] TUSB_CFG_ATTR_USBRAM;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
@ -108,6 +111,7 @@ tusb_error_t msch_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
|
||||
msch_data[dev_addr-1].interface_number = p_interface_desc->bInterfaceNumber;
|
||||
(*p_length) += sizeof(tusb_descriptor_interface_t) + 2*sizeof(tusb_descriptor_endpoint_t);
|
||||
|
||||
//------------- Get Max Lun -------------//
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT(
|
||||
usbh_control_xfer_subtask( dev_addr, bm_request_type(TUSB_DIR_DEV_TO_HOST, TUSB_REQUEST_TYPE_CLASS, TUSB_REQUEST_RECIPIENT_INTERFACE),
|
||||
MSC_REQUEST_GET_MAX_LUN, 0, msch_data[dev_addr-1].interface_number,
|
||||
@ -115,12 +119,14 @@ tusb_error_t msch_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
|
||||
error
|
||||
);
|
||||
|
||||
if(TUSB_ERROR_NONE == error /* TODO STALL means zero */)
|
||||
{
|
||||
msch_data[dev_addr-1].max_lun = msch_buffer[0];
|
||||
SUBTASK_ASSERT( TUSB_ERROR_NONE != error /* && TODO STALL means zero */);
|
||||
|
||||
tusbh_msc_mounted_cb(dev_addr);
|
||||
}
|
||||
msch_data[dev_addr-1].max_lun = msch_buffer[0];
|
||||
|
||||
//------------- SCSI Inquiry -------------//
|
||||
|
||||
|
||||
tusbh_msc_mounted_cb(dev_addr);
|
||||
|
||||
OSAL_SUBTASK_END
|
||||
|
||||
|
@ -55,13 +55,17 @@
|
||||
#ifdef _TEST_
|
||||
#define ATTR_ALWAYS_INLINE
|
||||
#define STATIC_
|
||||
#define STATIC_VAR
|
||||
#define INLINE_
|
||||
#else
|
||||
#define STATIC_ static
|
||||
#define INLINE_ inline
|
||||
#define STATIC_ static
|
||||
#define INLINE_ inline
|
||||
|
||||
#if TUSB_CFG_DEBUG == 3
|
||||
#define ATTR_ALWAYS_INLINE // no inline for debug = 3
|
||||
#define STATIC_VAR
|
||||
#else
|
||||
#define STATIC_VAR static
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
@ -57,22 +57,22 @@
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
STATIC_ ehci_data_t ehci_data TUSB_CFG_ATTR_USBRAM;
|
||||
STATIC_VAR ehci_data_t ehci_data TUSB_CFG_ATTR_USBRAM;
|
||||
|
||||
#if EHCI_PERIODIC_LIST
|
||||
|
||||
#if (TUSB_CFG_CONTROLLER0_MODE & TUSB_MODE_HOST)
|
||||
ATTR_ALIGNED(4096) STATIC_ ehci_link_t period_frame_list0[EHCI_FRAMELIST_SIZE] TUSB_CFG_ATTR_USBRAM;
|
||||
ATTR_ALIGNED(4096) STATIC_VAR ehci_link_t period_frame_list0[EHCI_FRAMELIST_SIZE] TUSB_CFG_ATTR_USBRAM;
|
||||
|
||||
#ifndef __ICCARM__ // IAR cannot able to determine the alignment with dataalignment pragma
|
||||
#ifndef __ICCARM__ // IAR cannot able to determine the alignment with datalignment pragma
|
||||
STATIC_ASSERT( ALIGN_OF(period_frame_list0) == 4096, "Period Framelist must be 4k alginment"); // validation
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (TUSB_CFG_CONTROLLER1_MODE & TUSB_MODE_HOST)
|
||||
STATIC_ ehci_link_t period_frame_list1[EHCI_FRAMELIST_SIZE] ATTR_ALIGNED(4096) TUSB_CFG_ATTR_USBRAM;
|
||||
STATIC_VAR ehci_link_t period_frame_list1[EHCI_FRAMELIST_SIZE] ATTR_ALIGNED(4096) TUSB_CFG_ATTR_USBRAM;
|
||||
|
||||
#ifndef __ICCARM__ // IAR cannot able to determine the alignment with dataalignment pragma
|
||||
#ifndef __ICCARM__ // IAR cannot able to determine the alignment with datalignment pragma
|
||||
STATIC_ASSERT( ALIGN_OF(period_frame_list1) == 4096, "Period Framelist must be 4k alginment"); // validation
|
||||
#endif
|
||||
#endif
|
||||
|
@ -110,8 +110,9 @@ usbh_device_info_t usbh_devices[TUSB_CFG_HOST_DEVICE_MAX+1] TUSB_CFG_ATTR_USBRAM
|
||||
//------------- Enumeration Task Data -------------//
|
||||
OSAL_TASK_DEF(usbh_enumeration_task, 150, TUSB_CFG_OS_TASK_PRIO);
|
||||
OSAL_QUEUE_DEF(enum_queue_def, ENUM_QUEUE_DEPTH, uint32_t);
|
||||
osal_queue_handle_t enum_queue_hdl;
|
||||
STATIC_ uint8_t enum_data_buffer[TUSB_CFG_HOST_ENUM_BUFFER_SIZE] TUSB_CFG_ATTR_USBRAM;
|
||||
|
||||
static osal_queue_handle_t enum_queue_hdl;
|
||||
STATIC_VAR uint8_t enum_data_buffer[TUSB_CFG_HOST_ENUM_BUFFER_SIZE] TUSB_CFG_ATTR_USBRAM;
|
||||
|
||||
//------------- Reporter Task Data -------------//
|
||||
|
||||
|
@ -102,11 +102,11 @@
|
||||
// COMMON OPTIONS
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// level 3: ATTR_ALWAYS_INLINE is null, ASSERT has text, Error has its String
|
||||
// level 3: ATTR_ALWAYS_INLINE is null, ASSERT has text, Error has its String, STATIC_VAR is NULL
|
||||
// level 2: ATTR_ALWAYS_INLINE is attribute, ASSERT has no text, Error has no strings
|
||||
/// 0: no debug information 3: most debug information provided
|
||||
#ifndef TUSB_CFG_DEBUG
|
||||
#define TUSB_CFG_DEBUG 3
|
||||
#define TUSB_CFG_DEBUG 2
|
||||
#warning TUSB_CFG_DEBUG is not defined, default value is 3
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user