mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
refactor(usb/host): reformat code with astyle_py
This commit is contained in:
parent
1e2c271bd0
commit
3964fb2d04
@ -668,20 +668,20 @@ static bool _internal_pipe_event_notify(pipe_t *pipe, bool from_isr)
|
|||||||
static usb_speed_t get_usb_port_speed(usb_dwc_speed_t priv)
|
static usb_speed_t get_usb_port_speed(usb_dwc_speed_t priv)
|
||||||
{
|
{
|
||||||
switch (priv) {
|
switch (priv) {
|
||||||
case USB_DWC_SPEED_LOW: return USB_SPEED_LOW;
|
case USB_DWC_SPEED_LOW: return USB_SPEED_LOW;
|
||||||
case USB_DWC_SPEED_FULL: return USB_SPEED_FULL;
|
case USB_DWC_SPEED_FULL: return USB_SPEED_FULL;
|
||||||
case USB_DWC_SPEED_HIGH: return USB_SPEED_HIGH;
|
case USB_DWC_SPEED_HIGH: return USB_SPEED_HIGH;
|
||||||
default: abort();
|
default: abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static usb_hal_fifo_bias_t get_hal_fifo_bias(hcd_port_fifo_bias_t public)
|
static usb_hal_fifo_bias_t get_hal_fifo_bias(hcd_port_fifo_bias_t public)
|
||||||
{
|
{
|
||||||
switch (public) {
|
switch (public) {
|
||||||
case HCD_PORT_FIFO_BIAS_BALANCED: return USB_HAL_FIFO_BIAS_DEFAULT;
|
case HCD_PORT_FIFO_BIAS_BALANCED: return USB_HAL_FIFO_BIAS_DEFAULT;
|
||||||
case HCD_PORT_FIFO_BIAS_RX: return USB_HAL_FIFO_BIAS_RX;
|
case HCD_PORT_FIFO_BIAS_RX: return USB_HAL_FIFO_BIAS_RX;
|
||||||
case HCD_PORT_FIFO_BIAS_PTX: return USB_HAL_FIFO_BIAS_PTX;
|
case HCD_PORT_FIFO_BIAS_PTX: return USB_HAL_FIFO_BIAS_PTX;
|
||||||
default: abort();
|
default: abort();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2130,7 +2130,7 @@ static void _buffer_fill(pipe_t *pipe)
|
|||||||
start_idx = (next_interval_idx_no_offset + pipe->ep_char.periodic.phase_offset_frames) & (XFER_LIST_LEN_ISOC - 1);
|
start_idx = (next_interval_idx_no_offset + pipe->ep_char.periodic.phase_offset_frames) & (XFER_LIST_LEN_ISOC - 1);
|
||||||
} else {
|
} else {
|
||||||
// Not enough time until the next schedule, add another interval to it.
|
// Not enough time until the next schedule, add another interval to it.
|
||||||
start_idx = (next_interval_idx_no_offset + pipe->ep_char.periodic.interval + pipe->ep_char.periodic.phase_offset_frames) & (XFER_LIST_LEN_ISOC - 1);
|
start_idx = (next_interval_idx_no_offset + pipe->ep_char.periodic.interval + pipe->ep_char.periodic.phase_offset_frames) & (XFER_LIST_LEN_ISOC - 1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Start index is based on previously filled buffer
|
// Start index is based on previously filled buffer
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -137,21 +137,21 @@ void mock_msc_scsi_init_reference_descriptors(void)
|
|||||||
// String descriptors
|
// String descriptors
|
||||||
const char *str = MOCK_MSC_SCSI_STRING_1;
|
const char *str = MOCK_MSC_SCSI_STRING_1;
|
||||||
uint8_t chr_count = strlen(str);
|
uint8_t chr_count = strlen(str);
|
||||||
mock_msc_scsi_str_desc_manu[0] = (USB_B_DESCRIPTOR_TYPE_STRING << 8 ) | (2 * chr_count + 2); // first byte is length (including header), second byte is string type
|
mock_msc_scsi_str_desc_manu[0] = (USB_B_DESCRIPTOR_TYPE_STRING << 8) | (2 * chr_count + 2); // first byte is length (including header), second byte is string type
|
||||||
for (uint8_t i = 0; i < chr_count; i++) {
|
for (uint8_t i = 0; i < chr_count; i++) {
|
||||||
mock_msc_scsi_str_desc_manu[1 + i] = str[i];
|
mock_msc_scsi_str_desc_manu[1 + i] = str[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
str = MOCK_MSC_SCSI_STRING_2;
|
str = MOCK_MSC_SCSI_STRING_2;
|
||||||
chr_count = strlen(str);
|
chr_count = strlen(str);
|
||||||
mock_msc_scsi_str_desc_prod[0] = (USB_B_DESCRIPTOR_TYPE_STRING << 8 ) | (2 * chr_count + 2); // first byte is length (including header), second byte is string type
|
mock_msc_scsi_str_desc_prod[0] = (USB_B_DESCRIPTOR_TYPE_STRING << 8) | (2 * chr_count + 2); // first byte is length (including header), second byte is string type
|
||||||
for (uint8_t i = 0; i < chr_count; i++) {
|
for (uint8_t i = 0; i < chr_count; i++) {
|
||||||
mock_msc_scsi_str_desc_prod[1 + i] = str[i];
|
mock_msc_scsi_str_desc_prod[1 + i] = str[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
str = MOCK_MSC_SCSI_STRING_3;
|
str = MOCK_MSC_SCSI_STRING_3;
|
||||||
chr_count = strlen(str);
|
chr_count = strlen(str);
|
||||||
mock_msc_scsi_str_desc_ser_num[0] = (USB_B_DESCRIPTOR_TYPE_STRING << 8 ) | (2 * chr_count + 2); // first byte is length (including header), second byte is string type
|
mock_msc_scsi_str_desc_ser_num[0] = (USB_B_DESCRIPTOR_TYPE_STRING << 8) | (2 * chr_count + 2); // first byte is length (including header), second byte is string type
|
||||||
for (uint8_t i = 0; i < chr_count; i++) {
|
for (uint8_t i = 0; i < chr_count; i++) {
|
||||||
mock_msc_scsi_str_desc_ser_num[1 + i] = str[i];
|
mock_msc_scsi_str_desc_ser_num[1 + i] = str[i];
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -112,7 +112,8 @@ extern const usb_ep_desc_t mock_msc_scsi_bulk_in_ep_desc;
|
|||||||
(setup_pkt_ptr)->wLength = 0; \
|
(setup_pkt_ptr)->wLength = 0; \
|
||||||
})
|
})
|
||||||
|
|
||||||
typedef struct __attribute__((packed)) {
|
typedef struct __attribute__((packed))
|
||||||
|
{
|
||||||
uint8_t opcode; //0x28 = read(10), 0x2A=write(10)
|
uint8_t opcode; //0x28 = read(10), 0x2A=write(10)
|
||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
uint8_t lba_3;
|
uint8_t lba_3;
|
||||||
@ -125,7 +126,8 @@ typedef struct __attribute__((packed)) {
|
|||||||
uint8_t control;
|
uint8_t control;
|
||||||
} mock_scsi_cmd10_t;
|
} mock_scsi_cmd10_t;
|
||||||
|
|
||||||
typedef struct __attribute__((packed)) {
|
typedef struct __attribute__((packed))
|
||||||
|
{
|
||||||
uint32_t dCBWSignature;
|
uint32_t dCBWSignature;
|
||||||
uint32_t dCBWTag;
|
uint32_t dCBWTag;
|
||||||
uint32_t dCBWDataTransferLength;
|
uint32_t dCBWDataTransferLength;
|
||||||
@ -137,7 +139,8 @@ typedef struct __attribute__((packed)) {
|
|||||||
} mock_msc_bulk_cbw_t;
|
} mock_msc_bulk_cbw_t;
|
||||||
|
|
||||||
// USB Bulk Transfer Command Status Wrapper data
|
// USB Bulk Transfer Command Status Wrapper data
|
||||||
typedef struct __attribute__((packed)) {
|
typedef struct __attribute__((packed))
|
||||||
|
{
|
||||||
uint32_t dCSWSignature;
|
uint32_t dCSWSignature;
|
||||||
uint32_t dCSWTag;
|
uint32_t dCSWTag;
|
||||||
uint32_t dCSWDataResidue;
|
uint32_t dCSWDataResidue;
|
||||||
@ -180,7 +183,6 @@ ISOC, transferring to a non-existent endpoint should work. The non-existent endp
|
|||||||
#define MOCK_ISOC_EP_NUM 2
|
#define MOCK_ISOC_EP_NUM 2
|
||||||
#define MOCK_ISOC_EP_MPS 512
|
#define MOCK_ISOC_EP_MPS 512
|
||||||
|
|
||||||
|
|
||||||
static const usb_ep_desc_t mock_isoc_out_ep_desc = {
|
static const usb_ep_desc_t mock_isoc_out_ep_desc = {
|
||||||
.bLength = sizeof(usb_ep_desc_t),
|
.bLength = sizeof(usb_ep_desc_t),
|
||||||
.bDescriptorType = USB_B_DESCRIPTOR_TYPE_ENDPOINT,
|
.bDescriptorType = USB_B_DESCRIPTOR_TYPE_ENDPOINT,
|
||||||
@ -190,7 +192,6 @@ static const usb_ep_desc_t mock_isoc_out_ep_desc = {
|
|||||||
.bInterval = 1, //Isoc interval is (2 ^ (bInterval - 1)) which means an interval of 1ms
|
.bInterval = 1, //Isoc interval is (2 ^ (bInterval - 1)) which means an interval of 1ms
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -68,7 +68,7 @@ TEST_CASE("Test HCD control pipe URBs", "[ctrl][low_speed][full_speed]")
|
|||||||
TEST_ASSERT_GREATER_OR_EQUAL(sizeof(usb_setup_packet_t), urb->transfer.actual_num_bytes);
|
TEST_ASSERT_GREATER_OR_EQUAL(sizeof(usb_setup_packet_t), urb->transfer.actual_num_bytes);
|
||||||
TEST_ASSERT_LESS_OR_EQUAL(urb->transfer.num_bytes, urb->transfer.actual_num_bytes);
|
TEST_ASSERT_LESS_OR_EQUAL(urb->transfer.num_bytes, urb->transfer.actual_num_bytes);
|
||||||
usb_config_desc_t *config_desc = (usb_config_desc_t *)(urb->transfer.data_buffer + sizeof(usb_setup_packet_t));
|
usb_config_desc_t *config_desc = (usb_config_desc_t *)(urb->transfer.data_buffer + sizeof(usb_setup_packet_t));
|
||||||
TEST_ASSERT_EQUAL(USB_B_DESCRIPTOR_TYPE_CONFIGURATION , config_desc->bDescriptorType);
|
TEST_ASSERT_EQUAL(USB_B_DESCRIPTOR_TYPE_CONFIGURATION, config_desc->bDescriptorType);
|
||||||
printf("Config Desc wTotalLength %d\n", config_desc->wTotalLength);
|
printf("Config Desc wTotalLength %d\n", config_desc->wTotalLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ TEST_CASE("Test HCD control pipe STALL", "[ctrl][full_speed]")
|
|||||||
TEST_ASSERT_GREATER_OR_EQUAL(sizeof(usb_setup_packet_t), urb->transfer.actual_num_bytes);
|
TEST_ASSERT_GREATER_OR_EQUAL(sizeof(usb_setup_packet_t), urb->transfer.actual_num_bytes);
|
||||||
TEST_ASSERT_LESS_OR_EQUAL(urb->transfer.num_bytes, urb->transfer.actual_num_bytes);
|
TEST_ASSERT_LESS_OR_EQUAL(urb->transfer.num_bytes, urb->transfer.actual_num_bytes);
|
||||||
usb_config_desc_t *config_desc = (usb_config_desc_t *)(urb->transfer.data_buffer + sizeof(usb_setup_packet_t));
|
usb_config_desc_t *config_desc = (usb_config_desc_t *)(urb->transfer.data_buffer + sizeof(usb_setup_packet_t));
|
||||||
TEST_ASSERT_EQUAL(USB_B_DESCRIPTOR_TYPE_CONFIGURATION , config_desc->bDescriptorType);
|
TEST_ASSERT_EQUAL(USB_B_DESCRIPTOR_TYPE_CONFIGURATION, config_desc->bDescriptorType);
|
||||||
printf("Config Desc wTotalLength %d\n", config_desc->wTotalLength);
|
printf("Config Desc wTotalLength %d\n", config_desc->wTotalLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,11 +270,11 @@ TEST_CASE("Test HCD control pipe runtime halt and clear", "[ctrl][low_speed][ful
|
|||||||
TEST_ASSERT_EQUAL_PTR(urb_list[i], urb);
|
TEST_ASSERT_EQUAL_PTR(urb_list[i], urb);
|
||||||
TEST_ASSERT(urb->transfer.status == USB_TRANSFER_STATUS_COMPLETED || urb->transfer.status == USB_TRANSFER_STATUS_CANCELED);
|
TEST_ASSERT(urb->transfer.status == USB_TRANSFER_STATUS_COMPLETED || urb->transfer.status == USB_TRANSFER_STATUS_CANCELED);
|
||||||
if (urb->transfer.status == USB_TRANSFER_STATUS_COMPLETED) {
|
if (urb->transfer.status == USB_TRANSFER_STATUS_COMPLETED) {
|
||||||
//We must have transmitted at least the setup packet, but device may return less than bytes requested
|
//We must have transmitted at least the setup packet, but device may return less than bytes requested
|
||||||
TEST_ASSERT_GREATER_OR_EQUAL(sizeof(usb_setup_packet_t), urb->transfer.actual_num_bytes);
|
TEST_ASSERT_GREATER_OR_EQUAL(sizeof(usb_setup_packet_t), urb->transfer.actual_num_bytes);
|
||||||
TEST_ASSERT_LESS_OR_EQUAL(urb->transfer.num_bytes, urb->transfer.actual_num_bytes);
|
TEST_ASSERT_LESS_OR_EQUAL(urb->transfer.num_bytes, urb->transfer.actual_num_bytes);
|
||||||
usb_config_desc_t *config_desc = (usb_config_desc_t *)(urb->transfer.data_buffer + sizeof(usb_setup_packet_t));
|
usb_config_desc_t *config_desc = (usb_config_desc_t *)(urb->transfer.data_buffer + sizeof(usb_setup_packet_t));
|
||||||
TEST_ASSERT_EQUAL(USB_B_DESCRIPTOR_TYPE_CONFIGURATION , config_desc->bDescriptorType);
|
TEST_ASSERT_EQUAL(USB_B_DESCRIPTOR_TYPE_CONFIGURATION, config_desc->bDescriptorType);
|
||||||
printf("Config Desc wTotalLength %d\n", config_desc->wTotalLength);
|
printf("Config Desc wTotalLength %d\n", config_desc->wTotalLength);
|
||||||
} else {
|
} else {
|
||||||
//A failed transfer should 0 actual number of bytes transmitted
|
//A failed transfer should 0 actual number of bytes transmitted
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -76,14 +76,14 @@ static void ctrl_client_event_cb(const usb_host_client_event_msg_t *event_msg, v
|
|||||||
{
|
{
|
||||||
ctrl_client_obj_t *ctrl_obj = (ctrl_client_obj_t *)arg;
|
ctrl_client_obj_t *ctrl_obj = (ctrl_client_obj_t *)arg;
|
||||||
switch (event_msg->event) {
|
switch (event_msg->event) {
|
||||||
case USB_HOST_CLIENT_EVENT_NEW_DEV:
|
case USB_HOST_CLIENT_EVENT_NEW_DEV:
|
||||||
TEST_ASSERT_EQUAL(TEST_STAGE_WAIT_CONN, ctrl_obj->cur_stage);
|
TEST_ASSERT_EQUAL(TEST_STAGE_WAIT_CONN, ctrl_obj->cur_stage);
|
||||||
ctrl_obj->next_stage = TEST_STAGE_DEV_OPEN;
|
ctrl_obj->next_stage = TEST_STAGE_DEV_OPEN;
|
||||||
ctrl_obj->dev_addr_to_open = event_msg->new_dev.address;
|
ctrl_obj->dev_addr_to_open = event_msg->new_dev.address;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort(); //Should never occur in this test
|
abort(); //Should never occur in this test
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ void ctrl_client_async_seq_task(void *arg)
|
|||||||
.max_num_event_msg = CTRL_CLIENT_MAX_EVENT_MSGS,
|
.max_num_event_msg = CTRL_CLIENT_MAX_EVENT_MSGS,
|
||||||
.async = {
|
.async = {
|
||||||
.client_event_callback = ctrl_client_event_cb,
|
.client_event_callback = ctrl_client_event_cb,
|
||||||
.callback_arg = (void *)&ctrl_obj,
|
.callback_arg = (void *) &ctrl_obj,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_client_register(&client_config, &ctrl_obj.client_hdl));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_client_register(&client_config, &ctrl_obj.client_hdl));
|
||||||
@ -130,52 +130,52 @@ void ctrl_client_async_seq_task(void *arg)
|
|||||||
ctrl_obj.cur_stage = ctrl_obj.next_stage;
|
ctrl_obj.cur_stage = ctrl_obj.next_stage;
|
||||||
|
|
||||||
switch (ctrl_obj.next_stage) {
|
switch (ctrl_obj.next_stage) {
|
||||||
case TEST_STAGE_DEV_OPEN: {
|
case TEST_STAGE_DEV_OPEN: {
|
||||||
ESP_LOGD(CTRL_CLIENT_TAG, "Open");
|
ESP_LOGD(CTRL_CLIENT_TAG, "Open");
|
||||||
//Open the device
|
//Open the device
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(ESP_OK, usb_host_device_open(ctrl_obj.client_hdl, ctrl_obj.dev_addr_to_open, &ctrl_obj.dev_hdl), "Failed to open the device");
|
TEST_ASSERT_EQUAL_MESSAGE(ESP_OK, usb_host_device_open(ctrl_obj.client_hdl, ctrl_obj.dev_addr_to_open, &ctrl_obj.dev_hdl), "Failed to open the device");
|
||||||
//Target our transfers to the device
|
//Target our transfers to the device
|
||||||
for (int i = 0; i < NUM_TRANSFER_OBJ; i++) {
|
for (int i = 0; i < NUM_TRANSFER_OBJ; i++) {
|
||||||
ctrl_xfer[i]->device_handle = ctrl_obj.dev_hdl;
|
ctrl_xfer[i]->device_handle = ctrl_obj.dev_hdl;
|
||||||
}
|
|
||||||
//Check the VID/PID of the opened device
|
|
||||||
const usb_device_desc_t *device_desc;
|
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_get_device_descriptor(ctrl_obj.dev_hdl, &device_desc));
|
|
||||||
TEST_ASSERT_EQUAL(ctrl_obj.test_param.idVendor, device_desc->idVendor);
|
|
||||||
TEST_ASSERT_EQUAL(ctrl_obj.test_param.idProduct, device_desc->idProduct);
|
|
||||||
//Cache the active configuration descriptor for later comparison
|
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_get_active_config_descriptor(ctrl_obj.dev_hdl, &ctrl_obj.config_desc_cached));
|
|
||||||
ctrl_obj.next_stage = TEST_STAGE_CTRL_XFER;
|
|
||||||
skip_event_handling = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case TEST_STAGE_CTRL_XFER: {
|
//Check the VID/PID of the opened device
|
||||||
ESP_LOGD(CTRL_CLIENT_TAG, "Transfer");
|
const usb_device_desc_t *device_desc;
|
||||||
//Send a control transfer to get the device's configuration descriptor
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_get_device_descriptor(ctrl_obj.dev_hdl, &device_desc));
|
||||||
usb_transfer_t *transfer = ctrl_xfer[ctrl_obj.num_xfer_sent % NUM_TRANSFER_OBJ];
|
TEST_ASSERT_EQUAL(ctrl_obj.test_param.idVendor, device_desc->idVendor);
|
||||||
USB_SETUP_PACKET_INIT_GET_CONFIG_DESC((usb_setup_packet_t *)transfer->data_buffer, 0, MAX_TRANSFER_BYTES);
|
TEST_ASSERT_EQUAL(ctrl_obj.test_param.idProduct, device_desc->idProduct);
|
||||||
transfer->num_bytes = sizeof(usb_setup_packet_t) + MAX_TRANSFER_BYTES;
|
//Cache the active configuration descriptor for later comparison
|
||||||
transfer->bEndpointAddress = 0x80;
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_get_active_config_descriptor(ctrl_obj.dev_hdl, &ctrl_obj.config_desc_cached));
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_transfer_submit_control(ctrl_obj.client_hdl, transfer));
|
ctrl_obj.next_stage = TEST_STAGE_CTRL_XFER;
|
||||||
ctrl_obj.num_xfer_sent++;
|
skip_event_handling = true;
|
||||||
ctrl_obj.next_stage = TEST_STAGE_CTRL_XFER_WAIT;
|
break;
|
||||||
skip_event_handling = true;
|
}
|
||||||
break;
|
case TEST_STAGE_CTRL_XFER: {
|
||||||
}
|
ESP_LOGD(CTRL_CLIENT_TAG, "Transfer");
|
||||||
case TEST_STAGE_CTRL_XFER_WAIT: {
|
//Send a control transfer to get the device's configuration descriptor
|
||||||
//Nothing to do but wait
|
usb_transfer_t *transfer = ctrl_xfer[ctrl_obj.num_xfer_sent % NUM_TRANSFER_OBJ];
|
||||||
break;
|
USB_SETUP_PACKET_INIT_GET_CONFIG_DESC((usb_setup_packet_t *)transfer->data_buffer, 0, MAX_TRANSFER_BYTES);
|
||||||
}
|
transfer->num_bytes = sizeof(usb_setup_packet_t) + MAX_TRANSFER_BYTES;
|
||||||
case TEST_STAGE_DEV_CLOSE: {
|
transfer->bEndpointAddress = 0x80;
|
||||||
ESP_LOGD(CTRL_CLIENT_TAG, "Close");
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_transfer_submit_control(ctrl_obj.client_hdl, transfer));
|
||||||
vTaskDelay(10); // Give USB Host Lib some time to process all trnsfers
|
ctrl_obj.num_xfer_sent++;
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_device_close(ctrl_obj.client_hdl, ctrl_obj.dev_hdl));
|
ctrl_obj.next_stage = TEST_STAGE_CTRL_XFER_WAIT;
|
||||||
exit_loop = true;
|
skip_event_handling = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
case TEST_STAGE_CTRL_XFER_WAIT: {
|
||||||
abort();
|
//Nothing to do but wait
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case TEST_STAGE_DEV_CLOSE: {
|
||||||
|
ESP_LOGD(CTRL_CLIENT_TAG, "Close");
|
||||||
|
vTaskDelay(10); // Give USB Host Lib some time to process all trnsfers
|
||||||
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_device_close(ctrl_obj.client_hdl, ctrl_obj.dev_hdl));
|
||||||
|
exit_loop = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Free transfers and deregister client
|
//Free transfers and deregister client
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -64,15 +64,15 @@ static void msc_reset_cbw_transfer_cb(usb_transfer_t *transfer)
|
|||||||
TEST_ASSERT_EQUAL_MESSAGE(USB_TRANSFER_STATUS_COMPLETED, transfer->status, "Transfer NOT completed");
|
TEST_ASSERT_EQUAL_MESSAGE(USB_TRANSFER_STATUS_COMPLETED, transfer->status, "Transfer NOT completed");
|
||||||
TEST_ASSERT_EQUAL(transfer->num_bytes, transfer->actual_num_bytes);
|
TEST_ASSERT_EQUAL(transfer->num_bytes, transfer->actual_num_bytes);
|
||||||
switch (msc_obj->cur_stage) {
|
switch (msc_obj->cur_stage) {
|
||||||
case TEST_STAGE_MSC_RESET:
|
case TEST_STAGE_MSC_RESET:
|
||||||
msc_obj->next_stage = TEST_STAGE_MSC_CBW;
|
msc_obj->next_stage = TEST_STAGE_MSC_CBW;
|
||||||
break;
|
break;
|
||||||
case TEST_STAGE_MSC_CBW:
|
case TEST_STAGE_MSC_CBW:
|
||||||
msc_obj->next_stage = TEST_STAGE_MSC_DATA_DCONN;
|
msc_obj->next_stage = TEST_STAGE_MSC_DATA_DCONN;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,21 +97,21 @@ static void msc_client_event_cb(const usb_host_client_event_msg_t *event_msg, vo
|
|||||||
{
|
{
|
||||||
msc_client_obj_t *msc_obj = (msc_client_obj_t *)arg;
|
msc_client_obj_t *msc_obj = (msc_client_obj_t *)arg;
|
||||||
switch (event_msg->event) {
|
switch (event_msg->event) {
|
||||||
case USB_HOST_CLIENT_EVENT_NEW_DEV:
|
case USB_HOST_CLIENT_EVENT_NEW_DEV:
|
||||||
TEST_ASSERT_EQUAL(TEST_STAGE_WAIT_CONN, msc_obj->cur_stage);
|
TEST_ASSERT_EQUAL(TEST_STAGE_WAIT_CONN, msc_obj->cur_stage);
|
||||||
msc_obj->next_stage = TEST_STAGE_DEV_OPEN;
|
msc_obj->next_stage = TEST_STAGE_DEV_OPEN;
|
||||||
msc_obj->dev_addr_to_open = event_msg->new_dev.address;
|
msc_obj->dev_addr_to_open = event_msg->new_dev.address;
|
||||||
break;
|
break;
|
||||||
case USB_HOST_CLIENT_EVENT_DEV_GONE:
|
case USB_HOST_CLIENT_EVENT_DEV_GONE:
|
||||||
msc_obj->event_count++;
|
msc_obj->event_count++;
|
||||||
//If all transfers dequeued and device gone event occurred. Go to next stage
|
//If all transfers dequeued and device gone event occurred. Go to next stage
|
||||||
if (msc_obj->event_count >= msc_obj->num_data_transfers + 1) {
|
if (msc_obj->event_count >= msc_obj->num_data_transfers + 1) {
|
||||||
msc_obj->next_stage = TEST_STAGE_DEV_CLOSE;
|
msc_obj->next_stage = TEST_STAGE_DEV_CLOSE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort(); //Should never occur in this test
|
abort(); //Should never occur in this test
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ void msc_client_async_dconn_task(void *arg)
|
|||||||
.max_num_event_msg = MSC_ASYNC_CLIENT_MAX_EVENT_MSGS,
|
.max_num_event_msg = MSC_ASYNC_CLIENT_MAX_EVENT_MSGS,
|
||||||
.async = {
|
.async = {
|
||||||
.client_event_callback = msc_client_event_cb,
|
.client_event_callback = msc_client_event_cb,
|
||||||
.callback_arg = (void *)&msc_obj,
|
.callback_arg = (void *) &msc_obj,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_client_register(&client_config, &msc_obj.client_hdl));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_client_register(&client_config, &msc_obj.client_hdl));
|
||||||
@ -168,85 +168,85 @@ void msc_client_async_dconn_task(void *arg)
|
|||||||
msc_obj.cur_stage = msc_obj.next_stage;
|
msc_obj.cur_stage = msc_obj.next_stage;
|
||||||
|
|
||||||
switch (msc_obj.cur_stage) {
|
switch (msc_obj.cur_stage) {
|
||||||
case TEST_STAGE_WAIT_CONN: {
|
case TEST_STAGE_WAIT_CONN: {
|
||||||
//Nothing to do while waiting for connection
|
//Nothing to do while waiting for connection
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case TEST_STAGE_DEV_OPEN: {
|
||||||
|
ESP_LOGD(MSC_CLIENT_TAG, "Open");
|
||||||
|
//Open the device
|
||||||
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_device_open(msc_obj.client_hdl, msc_obj.dev_addr_to_open, &msc_obj.dev_hdl));
|
||||||
|
//Target our transfers to the device
|
||||||
|
xfer_out->device_handle = msc_obj.dev_hdl;
|
||||||
|
xfer_out->callback = msc_reset_cbw_transfer_cb;
|
||||||
|
for (int i = 0; i < msc_obj.num_data_transfers; i++) {
|
||||||
|
xfer_in[i]->device_handle = msc_obj.dev_hdl;
|
||||||
|
xfer_in[i]->callback = msc_data_transfer_cb;
|
||||||
}
|
}
|
||||||
case TEST_STAGE_DEV_OPEN: {
|
//Check the VID/PID of the opened device
|
||||||
ESP_LOGD(MSC_CLIENT_TAG, "Open");
|
const usb_device_desc_t *device_desc;
|
||||||
//Open the device
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_get_device_descriptor(msc_obj.dev_hdl, &device_desc));
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_device_open(msc_obj.client_hdl, msc_obj.dev_addr_to_open, &msc_obj.dev_hdl));
|
TEST_ASSERT_EQUAL(msc_obj.test_param.idVendor, device_desc->idVendor);
|
||||||
//Target our transfers to the device
|
TEST_ASSERT_EQUAL(msc_obj.test_param.idProduct, device_desc->idProduct);
|
||||||
xfer_out->device_handle = msc_obj.dev_hdl;
|
//Claim the MSC interface
|
||||||
xfer_out->callback = msc_reset_cbw_transfer_cb;
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_interface_claim(msc_obj.client_hdl, msc_obj.dev_hdl, MOCK_MSC_SCSI_INTF_NUMBER, MOCK_MSC_SCSI_INTF_ALT_SETTING));
|
||||||
for (int i = 0; i < msc_obj.num_data_transfers; i++) {
|
msc_obj.next_stage = TEST_STAGE_MSC_RESET;
|
||||||
xfer_in[i]->device_handle = msc_obj.dev_hdl;
|
skip_event_handling = true; //Need to execute TEST_STAGE_MSC_RESET
|
||||||
xfer_in[i]->callback = msc_data_transfer_cb;
|
break;
|
||||||
}
|
}
|
||||||
//Check the VID/PID of the opened device
|
case TEST_STAGE_MSC_RESET: {
|
||||||
const usb_device_desc_t *device_desc;
|
ESP_LOGD(MSC_CLIENT_TAG, "MSC Reset");
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_get_device_descriptor(msc_obj.dev_hdl, &device_desc));
|
//Send an MSC SCSI interface reset
|
||||||
TEST_ASSERT_EQUAL(msc_obj.test_param.idVendor, device_desc->idVendor);
|
MOCK_MSC_SCSI_REQ_INIT_RESET((usb_setup_packet_t *)xfer_out->data_buffer, MOCK_MSC_SCSI_INTF_NUMBER);
|
||||||
TEST_ASSERT_EQUAL(msc_obj.test_param.idProduct, device_desc->idProduct);
|
xfer_out->num_bytes = sizeof(usb_setup_packet_t);
|
||||||
//Claim the MSC interface
|
xfer_out->bEndpointAddress = 0;
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_interface_claim(msc_obj.client_hdl, msc_obj.dev_hdl, MOCK_MSC_SCSI_INTF_NUMBER, MOCK_MSC_SCSI_INTF_ALT_SETTING));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_transfer_submit_control(msc_obj.client_hdl, xfer_out));
|
||||||
msc_obj.next_stage = TEST_STAGE_MSC_RESET;
|
//Next stage set from transfer callback
|
||||||
skip_event_handling = true; //Need to execute TEST_STAGE_MSC_RESET
|
break;
|
||||||
break;
|
}
|
||||||
|
case TEST_STAGE_MSC_CBW: {
|
||||||
|
ESP_LOGD(MSC_CLIENT_TAG, "CBW");
|
||||||
|
mock_msc_scsi_init_cbw((mock_msc_bulk_cbw_t *)xfer_out->data_buffer, true, 0, msc_obj.test_param.num_sectors_per_xfer, msc_obj.test_param.msc_scsi_xfer_tag);
|
||||||
|
xfer_out->num_bytes = sizeof(mock_msc_bulk_cbw_t);
|
||||||
|
xfer_out->bEndpointAddress = MOCK_MSC_SCSI_BULK_OUT_EP_ADDR;
|
||||||
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_transfer_submit(xfer_out));
|
||||||
|
//Next stage set from transfer callback
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TEST_STAGE_MSC_DATA_DCONN: {
|
||||||
|
ESP_LOGD(MSC_CLIENT_TAG, "Data and disconnect");
|
||||||
|
//Setup the Data IN transfers
|
||||||
|
for (int i = 0; i < msc_obj.num_data_transfers; i++) {
|
||||||
|
xfer_in[i]->num_bytes = usb_round_up_to_mps(MOCK_MSC_SCSI_SECTOR_SIZE, MOCK_MSC_SCSI_BULK_EP_MPS);
|
||||||
|
xfer_in[i]->bEndpointAddress = MOCK_MSC_SCSI_BULK_IN_EP_ADDR;
|
||||||
}
|
}
|
||||||
case TEST_STAGE_MSC_RESET: {
|
//Submit those transfers
|
||||||
ESP_LOGD(MSC_CLIENT_TAG, "MSC Reset");
|
for (int i = 0; i < msc_obj.num_data_transfers; i++) {
|
||||||
//Send an MSC SCSI interface reset
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_transfer_submit(xfer_in[i]));
|
||||||
MOCK_MSC_SCSI_REQ_INIT_RESET((usb_setup_packet_t *)xfer_out->data_buffer, MOCK_MSC_SCSI_INTF_NUMBER);
|
|
||||||
xfer_out->num_bytes = sizeof(usb_setup_packet_t);
|
|
||||||
xfer_out->bEndpointAddress = 0;
|
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_transfer_submit_control(msc_obj.client_hdl, xfer_out));
|
|
||||||
//Next stage set from transfer callback
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case TEST_STAGE_MSC_CBW: {
|
//Trigger a disconnect
|
||||||
ESP_LOGD(MSC_CLIENT_TAG, "CBW");
|
test_usb_set_phy_state(false, 0);
|
||||||
mock_msc_scsi_init_cbw((mock_msc_bulk_cbw_t *)xfer_out->data_buffer, true, 0, msc_obj.test_param.num_sectors_per_xfer, msc_obj.test_param.msc_scsi_xfer_tag);
|
//Next stage set from transfer callback
|
||||||
xfer_out->num_bytes = sizeof(mock_msc_bulk_cbw_t);
|
break;
|
||||||
xfer_out->bEndpointAddress = MOCK_MSC_SCSI_BULK_OUT_EP_ADDR;
|
}
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_transfer_submit(xfer_out));
|
case TEST_STAGE_DEV_CLOSE: {
|
||||||
//Next stage set from transfer callback
|
ESP_LOGD(MSC_CLIENT_TAG, "Close");
|
||||||
break;
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_interface_release(msc_obj.client_hdl, msc_obj.dev_hdl, MOCK_MSC_SCSI_INTF_NUMBER));
|
||||||
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_device_close(msc_obj.client_hdl, msc_obj.dev_hdl));
|
||||||
|
dconn_iter++;
|
||||||
|
if (dconn_iter < TEST_DCONN_ITERATIONS) {
|
||||||
|
//Start the next test iteration by going back to TEST_STAGE_WAIT_CONN and reenabling connections
|
||||||
|
msc_obj.next_stage = TEST_STAGE_WAIT_CONN;
|
||||||
|
skip_event_handling = true; //Need to execute TEST_STAGE_WAIT_CONN
|
||||||
|
test_usb_set_phy_state(true, 0);
|
||||||
|
} else {
|
||||||
|
exit_loop = true;
|
||||||
}
|
}
|
||||||
case TEST_STAGE_MSC_DATA_DCONN: {
|
break;
|
||||||
ESP_LOGD(MSC_CLIENT_TAG, "Data and disconnect");
|
}
|
||||||
//Setup the Data IN transfers
|
default:
|
||||||
for (int i = 0; i < msc_obj.num_data_transfers; i++) {
|
abort();
|
||||||
xfer_in[i]->num_bytes = usb_round_up_to_mps(MOCK_MSC_SCSI_SECTOR_SIZE, MOCK_MSC_SCSI_BULK_EP_MPS);
|
break;
|
||||||
xfer_in[i]->bEndpointAddress = MOCK_MSC_SCSI_BULK_IN_EP_ADDR;
|
|
||||||
}
|
|
||||||
//Submit those transfers
|
|
||||||
for (int i = 0; i < msc_obj.num_data_transfers; i++) {
|
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_transfer_submit(xfer_in[i]));
|
|
||||||
}
|
|
||||||
//Trigger a disconnect
|
|
||||||
test_usb_set_phy_state(false, 0);
|
|
||||||
//Next stage set from transfer callback
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TEST_STAGE_DEV_CLOSE: {
|
|
||||||
ESP_LOGD(MSC_CLIENT_TAG, "Close");
|
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_interface_release(msc_obj.client_hdl, msc_obj.dev_hdl, MOCK_MSC_SCSI_INTF_NUMBER));
|
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_device_close(msc_obj.client_hdl, msc_obj.dev_hdl));
|
|
||||||
dconn_iter++;
|
|
||||||
if (dconn_iter < TEST_DCONN_ITERATIONS) {
|
|
||||||
//Start the next test iteration by going back to TEST_STAGE_WAIT_CONN and reenabling connections
|
|
||||||
msc_obj.next_stage = TEST_STAGE_WAIT_CONN;
|
|
||||||
skip_event_handling = true; //Need to execute TEST_STAGE_WAIT_CONN
|
|
||||||
test_usb_set_phy_state(true, 0);
|
|
||||||
} else {
|
|
||||||
exit_loop = true;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
abort();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Free transfers
|
//Free transfers
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -54,14 +54,14 @@ static void msc_client_event_cb(const usb_host_client_event_msg_t *event_msg, vo
|
|||||||
{
|
{
|
||||||
msc_client_obj_t *msc_obj = (msc_client_obj_t *)arg;
|
msc_client_obj_t *msc_obj = (msc_client_obj_t *)arg;
|
||||||
switch (event_msg->event) {
|
switch (event_msg->event) {
|
||||||
case USB_HOST_CLIENT_EVENT_NEW_DEV:
|
case USB_HOST_CLIENT_EVENT_NEW_DEV:
|
||||||
TEST_ASSERT_EQUAL(TEST_STAGE_WAIT_CONN, msc_obj->cur_stage);
|
TEST_ASSERT_EQUAL(TEST_STAGE_WAIT_CONN, msc_obj->cur_stage);
|
||||||
msc_obj->next_stage = TEST_STAGE_DEV_OPEN;
|
msc_obj->next_stage = TEST_STAGE_DEV_OPEN;
|
||||||
msc_obj->dev_addr_to_open = event_msg->new_dev.address;
|
msc_obj->dev_addr_to_open = event_msg->new_dev.address;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort(); //Should never occur in this test
|
abort(); //Should never occur in this test
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ void msc_client_async_enum_task(void *arg)
|
|||||||
.max_num_event_msg = MSC_ASYNC_CLIENT_MAX_EVENT_MSGS,
|
.max_num_event_msg = MSC_ASYNC_CLIENT_MAX_EVENT_MSGS,
|
||||||
.async = {
|
.async = {
|
||||||
.client_event_callback = msc_client_event_cb,
|
.client_event_callback = msc_client_event_cb,
|
||||||
.callback_arg = (void *)&msc_obj,
|
.callback_arg = (void *) &msc_obj,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_client_register(&client_config, &msc_obj.client_hdl));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_client_register(&client_config, &msc_obj.client_hdl));
|
||||||
@ -104,78 +104,78 @@ void msc_client_async_enum_task(void *arg)
|
|||||||
msc_obj.cur_stage = msc_obj.next_stage;
|
msc_obj.cur_stage = msc_obj.next_stage;
|
||||||
|
|
||||||
switch (msc_obj.cur_stage) {
|
switch (msc_obj.cur_stage) {
|
||||||
case TEST_STAGE_WAIT_CONN: {
|
case TEST_STAGE_WAIT_CONN: {
|
||||||
//Wait for connection, nothing to do
|
//Wait for connection, nothing to do
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TEST_STAGE_DEV_OPEN: {
|
case TEST_STAGE_DEV_OPEN: {
|
||||||
ESP_LOGD(MSC_CLIENT_TAG, "Open");
|
ESP_LOGD(MSC_CLIENT_TAG, "Open");
|
||||||
//Open the device
|
//Open the device
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_device_open(msc_obj.client_hdl, msc_obj.dev_addr_to_open, &msc_obj.dev_hdl));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_device_open(msc_obj.client_hdl, msc_obj.dev_addr_to_open, &msc_obj.dev_hdl));
|
||||||
msc_obj.next_stage = TEST_STAGE_CHECK_DEV_DESC;
|
msc_obj.next_stage = TEST_STAGE_CHECK_DEV_DESC;
|
||||||
skip_event_handling = true; //Need to execute TEST_STAGE_CHECK_DEV_DESC
|
skip_event_handling = true; //Need to execute TEST_STAGE_CHECK_DEV_DESC
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TEST_STAGE_CHECK_DEV_DESC: {
|
case TEST_STAGE_CHECK_DEV_DESC: {
|
||||||
//Check the device descriptor
|
//Check the device descriptor
|
||||||
const usb_device_desc_t *device_desc;
|
const usb_device_desc_t *device_desc;
|
||||||
const usb_device_desc_t *device_desc_ref = &mock_msc_scsi_dev_desc;
|
const usb_device_desc_t *device_desc_ref = &mock_msc_scsi_dev_desc;
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_get_device_descriptor(msc_obj.dev_hdl, &device_desc));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_get_device_descriptor(msc_obj.dev_hdl, &device_desc));
|
||||||
TEST_ASSERT_EQUAL(device_desc_ref->bLength, device_desc->bLength);
|
TEST_ASSERT_EQUAL(device_desc_ref->bLength, device_desc->bLength);
|
||||||
TEST_ASSERT_EQUAL_MEMORY_MESSAGE(device_desc_ref, device_desc, device_desc_ref->bLength, "Device descriptors do not match.");
|
TEST_ASSERT_EQUAL_MEMORY_MESSAGE(device_desc_ref, device_desc, device_desc_ref->bLength, "Device descriptors do not match.");
|
||||||
msc_obj.next_stage = TEST_STAGE_CHECK_CONFIG_DESC;
|
msc_obj.next_stage = TEST_STAGE_CHECK_CONFIG_DESC;
|
||||||
skip_event_handling = true; //Need to execute TEST_STAGE_CHECK_CONFIG_DESC
|
skip_event_handling = true; //Need to execute TEST_STAGE_CHECK_CONFIG_DESC
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TEST_STAGE_CHECK_CONFIG_DESC: {
|
case TEST_STAGE_CHECK_CONFIG_DESC: {
|
||||||
//Check the configuration descriptor
|
//Check the configuration descriptor
|
||||||
const usb_config_desc_t *config_desc;
|
const usb_config_desc_t *config_desc;
|
||||||
const usb_config_desc_t *config_desc_ref = (const usb_config_desc_t *)mock_msc_scsi_config_desc;
|
const usb_config_desc_t *config_desc_ref = (const usb_config_desc_t *)mock_msc_scsi_config_desc;
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_get_active_config_descriptor(msc_obj.dev_hdl, &config_desc));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_get_active_config_descriptor(msc_obj.dev_hdl, &config_desc));
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(config_desc_ref->wTotalLength, config_desc->wTotalLength, "Incorrent length of CFG descriptor");
|
TEST_ASSERT_EQUAL_MESSAGE(config_desc_ref->wTotalLength, config_desc->wTotalLength, "Incorrent length of CFG descriptor");
|
||||||
TEST_ASSERT_EQUAL_MEMORY_MESSAGE(config_desc_ref, config_desc, config_desc_ref->wTotalLength, "Configuration descriptors do not match");
|
TEST_ASSERT_EQUAL_MEMORY_MESSAGE(config_desc_ref, config_desc, config_desc_ref->wTotalLength, "Configuration descriptors do not match");
|
||||||
msc_obj.next_stage = TEST_STAGE_CHECK_STR_DESC;
|
msc_obj.next_stage = TEST_STAGE_CHECK_STR_DESC;
|
||||||
skip_event_handling = true; //Need to execute TEST_STAGE_CHECK_STR_DESC
|
skip_event_handling = true; //Need to execute TEST_STAGE_CHECK_STR_DESC
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TEST_STAGE_CHECK_STR_DESC: {
|
case TEST_STAGE_CHECK_STR_DESC: {
|
||||||
usb_device_info_t dev_info;
|
usb_device_info_t dev_info;
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_device_info(msc_obj.dev_hdl, &dev_info));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_device_info(msc_obj.dev_hdl, &dev_info));
|
||||||
//Check manufacturer string descriptors
|
//Check manufacturer string descriptors
|
||||||
const usb_str_desc_t *manu_str_desc_ref = (const usb_str_desc_t *)mock_msc_scsi_str_desc_manu;
|
const usb_str_desc_t *manu_str_desc_ref = (const usb_str_desc_t *)mock_msc_scsi_str_desc_manu;
|
||||||
const usb_str_desc_t *product_str_desc_ref = (const usb_str_desc_t *)mock_msc_scsi_str_desc_prod;
|
const usb_str_desc_t *product_str_desc_ref = (const usb_str_desc_t *)mock_msc_scsi_str_desc_prod;
|
||||||
const usb_str_desc_t *ser_num_str_desc_ref = (const usb_str_desc_t *)mock_msc_scsi_str_desc_ser_num;
|
const usb_str_desc_t *ser_num_str_desc_ref = (const usb_str_desc_t *)mock_msc_scsi_str_desc_ser_num;
|
||||||
TEST_ASSERT_EQUAL(manu_str_desc_ref->bLength, dev_info.str_desc_manufacturer->bLength);
|
TEST_ASSERT_EQUAL(manu_str_desc_ref->bLength, dev_info.str_desc_manufacturer->bLength);
|
||||||
TEST_ASSERT_EQUAL(product_str_desc_ref->bLength, dev_info.str_desc_product->bLength);
|
TEST_ASSERT_EQUAL(product_str_desc_ref->bLength, dev_info.str_desc_product->bLength);
|
||||||
TEST_ASSERT_EQUAL(ser_num_str_desc_ref->bLength, dev_info.str_desc_serial_num->bLength);
|
TEST_ASSERT_EQUAL(ser_num_str_desc_ref->bLength, dev_info.str_desc_serial_num->bLength);
|
||||||
TEST_ASSERT_EQUAL_MEMORY_MESSAGE(manu_str_desc_ref, dev_info.str_desc_manufacturer , manu_str_desc_ref->bLength, "Manufacturer string descriptors do not match.");
|
TEST_ASSERT_EQUAL_MEMORY_MESSAGE(manu_str_desc_ref, dev_info.str_desc_manufacturer, manu_str_desc_ref->bLength, "Manufacturer string descriptors do not match.");
|
||||||
TEST_ASSERT_EQUAL_MEMORY_MESSAGE(product_str_desc_ref, dev_info.str_desc_product , manu_str_desc_ref->bLength, "Product string descriptors do not match.");
|
TEST_ASSERT_EQUAL_MEMORY_MESSAGE(product_str_desc_ref, dev_info.str_desc_product, manu_str_desc_ref->bLength, "Product string descriptors do not match.");
|
||||||
//TEST_ASSERT_EQUAL_MEMORY_MESSAGE(ser_num_str_desc_ref, dev_info.str_desc_serial_num , manu_str_desc_ref->bLength, "Serial number string descriptors do not match.");
|
//TEST_ASSERT_EQUAL_MEMORY_MESSAGE(ser_num_str_desc_ref, dev_info.str_desc_serial_num , manu_str_desc_ref->bLength, "Serial number string descriptors do not match.");
|
||||||
//Get dev info and compare
|
//Get dev info and compare
|
||||||
msc_obj.next_stage = TEST_STAGE_DEV_CLOSE;
|
msc_obj.next_stage = TEST_STAGE_DEV_CLOSE;
|
||||||
skip_event_handling = true; //Need to execute TEST_STAGE_DEV_CLOSE
|
skip_event_handling = true; //Need to execute TEST_STAGE_DEV_CLOSE
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case TEST_STAGE_DEV_CLOSE: {
|
case TEST_STAGE_DEV_CLOSE: {
|
||||||
ESP_LOGD(MSC_CLIENT_TAG, "Close");
|
ESP_LOGD(MSC_CLIENT_TAG, "Close");
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_device_close(msc_obj.client_hdl, msc_obj.dev_hdl));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_device_close(msc_obj.client_hdl, msc_obj.dev_hdl));
|
||||||
enum_iter++;
|
enum_iter++;
|
||||||
if (enum_iter < TEST_ENUM_ITERATIONS) {
|
if (enum_iter < TEST_ENUM_ITERATIONS) {
|
||||||
//Start the next test iteration by disconnecting the device, then going back to TEST_STAGE_WAIT_CONN stage
|
//Start the next test iteration by disconnecting the device, then going back to TEST_STAGE_WAIT_CONN stage
|
||||||
test_usb_set_phy_state(false, 0);
|
test_usb_set_phy_state(false, 0);
|
||||||
test_usb_set_phy_state(true, 0);
|
test_usb_set_phy_state(true, 0);
|
||||||
msc_obj.next_stage = TEST_STAGE_WAIT_CONN;
|
msc_obj.next_stage = TEST_STAGE_WAIT_CONN;
|
||||||
skip_event_handling = true; //Need to execute TEST_STAGE_WAIT_CONN
|
skip_event_handling = true; //Need to execute TEST_STAGE_WAIT_CONN
|
||||||
} else {
|
} else {
|
||||||
exit_loop = true;
|
exit_loop = true;
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
default:
|
break;
|
||||||
abort();
|
}
|
||||||
break;
|
default:
|
||||||
|
abort();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Free transfers and deregister the client
|
//Free transfers and deregister the client
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -59,43 +59,43 @@ static void msc_transfer_cb(usb_transfer_t *transfer)
|
|||||||
{
|
{
|
||||||
msc_client_obj_t *msc_obj = (msc_client_obj_t *)transfer->context;
|
msc_client_obj_t *msc_obj = (msc_client_obj_t *)transfer->context;
|
||||||
switch (msc_obj->cur_stage) {
|
switch (msc_obj->cur_stage) {
|
||||||
case TEST_STAGE_MSC_RESET: {
|
case TEST_STAGE_MSC_RESET: {
|
||||||
//Check MSC SCSI interface reset
|
//Check MSC SCSI interface reset
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(USB_TRANSFER_STATUS_COMPLETED, transfer->status, "Transfer NOT completed");
|
TEST_ASSERT_EQUAL_MESSAGE(USB_TRANSFER_STATUS_COMPLETED, transfer->status, "Transfer NOT completed");
|
||||||
TEST_ASSERT_EQUAL(transfer->num_bytes, transfer->actual_num_bytes);
|
TEST_ASSERT_EQUAL(transfer->num_bytes, transfer->actual_num_bytes);
|
||||||
|
msc_obj->next_stage = TEST_STAGE_MSC_CBW;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TEST_STAGE_MSC_CBW: {
|
||||||
|
//Check MSC SCSI CBW transfer
|
||||||
|
TEST_ASSERT_EQUAL_MESSAGE(USB_TRANSFER_STATUS_COMPLETED, transfer->status, "Transfer NOT completed");
|
||||||
|
TEST_ASSERT_EQUAL(sizeof(mock_msc_bulk_cbw_t), transfer->actual_num_bytes);
|
||||||
|
msc_obj->next_stage = TEST_STAGE_MSC_DATA;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TEST_STAGE_MSC_DATA: {
|
||||||
|
//Check MSC SCSI data IN transfer
|
||||||
|
TEST_ASSERT_EQUAL_MESSAGE(USB_TRANSFER_STATUS_COMPLETED, transfer->status, "Transfer NOT completed");
|
||||||
|
TEST_ASSERT_EQUAL(MOCK_MSC_SCSI_SECTOR_SIZE * msc_obj->test_param.num_sectors_per_xfer, transfer->actual_num_bytes);
|
||||||
|
msc_obj->next_stage = TEST_STAGE_MSC_CSW;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TEST_STAGE_MSC_CSW: {
|
||||||
|
//Check MSC SCSI CSW transfer
|
||||||
|
TEST_ASSERT_EQUAL_MESSAGE(USB_TRANSFER_STATUS_COMPLETED, transfer->status, "Transfer NOT completed");
|
||||||
|
TEST_ASSERT_TRUE(mock_msc_scsi_check_csw((mock_msc_bulk_csw_t *)transfer->data_buffer, msc_obj->test_param.msc_scsi_xfer_tag));
|
||||||
|
msc_obj->num_sectors_read += msc_obj->test_param.num_sectors_per_xfer;
|
||||||
|
if (msc_obj->num_sectors_read < msc_obj->test_param.num_sectors_to_read) {
|
||||||
msc_obj->next_stage = TEST_STAGE_MSC_CBW;
|
msc_obj->next_stage = TEST_STAGE_MSC_CBW;
|
||||||
break;
|
} else {
|
||||||
}
|
msc_obj->next_stage = TEST_STAGE_DEV_CLOSE;
|
||||||
case TEST_STAGE_MSC_CBW: {
|
|
||||||
//Check MSC SCSI CBW transfer
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(USB_TRANSFER_STATUS_COMPLETED, transfer->status, "Transfer NOT completed");
|
|
||||||
TEST_ASSERT_EQUAL(sizeof(mock_msc_bulk_cbw_t), transfer->actual_num_bytes);
|
|
||||||
msc_obj->next_stage = TEST_STAGE_MSC_DATA;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TEST_STAGE_MSC_DATA: {
|
|
||||||
//Check MSC SCSI data IN transfer
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(USB_TRANSFER_STATUS_COMPLETED, transfer->status, "Transfer NOT completed");
|
|
||||||
TEST_ASSERT_EQUAL(MOCK_MSC_SCSI_SECTOR_SIZE * msc_obj->test_param.num_sectors_per_xfer, transfer->actual_num_bytes);
|
|
||||||
msc_obj->next_stage = TEST_STAGE_MSC_CSW;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TEST_STAGE_MSC_CSW: {
|
|
||||||
//Check MSC SCSI CSW transfer
|
|
||||||
TEST_ASSERT_EQUAL_MESSAGE(USB_TRANSFER_STATUS_COMPLETED, transfer->status, "Transfer NOT completed");
|
|
||||||
TEST_ASSERT_TRUE(mock_msc_scsi_check_csw((mock_msc_bulk_csw_t *)transfer->data_buffer, msc_obj->test_param.msc_scsi_xfer_tag));
|
|
||||||
msc_obj->num_sectors_read += msc_obj->test_param.num_sectors_per_xfer;
|
|
||||||
if (msc_obj->num_sectors_read < msc_obj->test_param.num_sectors_to_read) {
|
|
||||||
msc_obj->next_stage = TEST_STAGE_MSC_CBW;
|
|
||||||
} else {
|
|
||||||
msc_obj->next_stage = TEST_STAGE_DEV_CLOSE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {
|
|
||||||
abort();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
abort();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,14 +103,14 @@ static void msc_client_event_cb(const usb_host_client_event_msg_t *event_msg, vo
|
|||||||
{
|
{
|
||||||
msc_client_obj_t *msc_obj = (msc_client_obj_t *)arg;
|
msc_client_obj_t *msc_obj = (msc_client_obj_t *)arg;
|
||||||
switch (event_msg->event) {
|
switch (event_msg->event) {
|
||||||
case USB_HOST_CLIENT_EVENT_NEW_DEV:
|
case USB_HOST_CLIENT_EVENT_NEW_DEV:
|
||||||
TEST_ASSERT_EQUAL(TEST_STAGE_WAIT_CONN, msc_obj->cur_stage);
|
TEST_ASSERT_EQUAL(TEST_STAGE_WAIT_CONN, msc_obj->cur_stage);
|
||||||
msc_obj->next_stage = TEST_STAGE_DEV_OPEN;
|
msc_obj->next_stage = TEST_STAGE_DEV_OPEN;
|
||||||
msc_obj->dev_addr_to_open = event_msg->new_dev.address;
|
msc_obj->dev_addr_to_open = event_msg->new_dev.address;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort(); //Should never occur in this test
|
abort(); //Should never occur in this test
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ void msc_client_async_seq_task(void *arg)
|
|||||||
.max_num_event_msg = MSC_ASYNC_CLIENT_MAX_EVENT_MSGS,
|
.max_num_event_msg = MSC_ASYNC_CLIENT_MAX_EVENT_MSGS,
|
||||||
.async = {
|
.async = {
|
||||||
.client_event_callback = msc_client_event_cb,
|
.client_event_callback = msc_client_event_cb,
|
||||||
.callback_arg = (void *)&msc_obj,
|
.callback_arg = (void *) &msc_obj,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_client_register(&client_config, &msc_obj.client_hdl));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_client_register(&client_config, &msc_obj.client_hdl));
|
||||||
@ -166,77 +166,77 @@ void msc_client_async_seq_task(void *arg)
|
|||||||
msc_obj.cur_stage = msc_obj.next_stage;
|
msc_obj.cur_stage = msc_obj.next_stage;
|
||||||
|
|
||||||
switch (msc_obj.cur_stage) {
|
switch (msc_obj.cur_stage) {
|
||||||
case TEST_STAGE_DEV_OPEN: {
|
case TEST_STAGE_DEV_OPEN: {
|
||||||
ESP_LOGD(MSC_CLIENT_TAG, "Open");
|
ESP_LOGD(MSC_CLIENT_TAG, "Open");
|
||||||
//Open the device
|
//Open the device
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_device_open(msc_obj.client_hdl, msc_obj.dev_addr_to_open, &msc_obj.dev_hdl));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_device_open(msc_obj.client_hdl, msc_obj.dev_addr_to_open, &msc_obj.dev_hdl));
|
||||||
//Target our transfers to the device
|
//Target our transfers to the device
|
||||||
xfer_out->device_handle = msc_obj.dev_hdl;
|
xfer_out->device_handle = msc_obj.dev_hdl;
|
||||||
xfer_in->device_handle = msc_obj.dev_hdl;
|
xfer_in->device_handle = msc_obj.dev_hdl;
|
||||||
//Check the VID/PID of the opened device
|
//Check the VID/PID of the opened device
|
||||||
const usb_device_desc_t *device_desc;
|
const usb_device_desc_t *device_desc;
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_get_device_descriptor(msc_obj.dev_hdl, &device_desc));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_get_device_descriptor(msc_obj.dev_hdl, &device_desc));
|
||||||
TEST_ASSERT_EQUAL(msc_obj.test_param.idVendor, device_desc->idVendor);
|
TEST_ASSERT_EQUAL(msc_obj.test_param.idVendor, device_desc->idVendor);
|
||||||
TEST_ASSERT_EQUAL(msc_obj.test_param.idProduct, device_desc->idProduct);
|
TEST_ASSERT_EQUAL(msc_obj.test_param.idProduct, device_desc->idProduct);
|
||||||
//Claim the MSC interface
|
//Claim the MSC interface
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_interface_claim(msc_obj.client_hdl, msc_obj.dev_hdl, MOCK_MSC_SCSI_INTF_NUMBER, MOCK_MSC_SCSI_INTF_ALT_SETTING));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_interface_claim(msc_obj.client_hdl, msc_obj.dev_hdl, MOCK_MSC_SCSI_INTF_NUMBER, MOCK_MSC_SCSI_INTF_ALT_SETTING));
|
||||||
msc_obj.next_stage = TEST_STAGE_MSC_RESET;
|
msc_obj.next_stage = TEST_STAGE_MSC_RESET;
|
||||||
skip_event_handling = true; //Need to execute TEST_STAGE_MSC_RESET
|
skip_event_handling = true; //Need to execute TEST_STAGE_MSC_RESET
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TEST_STAGE_MSC_RESET: {
|
case TEST_STAGE_MSC_RESET: {
|
||||||
ESP_LOGD(MSC_CLIENT_TAG, "MSC Reset");
|
ESP_LOGD(MSC_CLIENT_TAG, "MSC Reset");
|
||||||
//Send an MSC SCSI interface reset
|
//Send an MSC SCSI interface reset
|
||||||
MOCK_MSC_SCSI_REQ_INIT_RESET((usb_setup_packet_t *)xfer_out->data_buffer, MOCK_MSC_SCSI_INTF_NUMBER);
|
MOCK_MSC_SCSI_REQ_INIT_RESET((usb_setup_packet_t *)xfer_out->data_buffer, MOCK_MSC_SCSI_INTF_NUMBER);
|
||||||
xfer_out->num_bytes = sizeof(usb_setup_packet_t);
|
xfer_out->num_bytes = sizeof(usb_setup_packet_t);
|
||||||
xfer_out->bEndpointAddress = 0;
|
xfer_out->bEndpointAddress = 0;
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_transfer_submit_control(msc_obj.client_hdl, xfer_out));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_transfer_submit_control(msc_obj.client_hdl, xfer_out));
|
||||||
//Test that an inflight control transfer cannot be resubmitted
|
//Test that an inflight control transfer cannot be resubmitted
|
||||||
TEST_ASSERT_EQUAL(ESP_ERR_NOT_FINISHED, usb_host_transfer_submit_control(msc_obj.client_hdl, xfer_out));
|
TEST_ASSERT_EQUAL(ESP_ERR_NOT_FINISHED, usb_host_transfer_submit_control(msc_obj.client_hdl, xfer_out));
|
||||||
//Next stage set from transfer callback
|
//Next stage set from transfer callback
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TEST_STAGE_MSC_CBW: {
|
case TEST_STAGE_MSC_CBW: {
|
||||||
ESP_LOGD(MSC_CLIENT_TAG, "CBW");
|
ESP_LOGD(MSC_CLIENT_TAG, "CBW");
|
||||||
mock_msc_scsi_init_cbw((mock_msc_bulk_cbw_t *)xfer_out->data_buffer, true, msc_obj.next_stage, msc_obj.test_param.num_sectors_per_xfer, msc_obj.test_param.msc_scsi_xfer_tag);
|
mock_msc_scsi_init_cbw((mock_msc_bulk_cbw_t *)xfer_out->data_buffer, true, msc_obj.next_stage, msc_obj.test_param.num_sectors_per_xfer, msc_obj.test_param.msc_scsi_xfer_tag);
|
||||||
xfer_out->num_bytes = sizeof(mock_msc_bulk_cbw_t);
|
xfer_out->num_bytes = sizeof(mock_msc_bulk_cbw_t);
|
||||||
xfer_out->bEndpointAddress = MOCK_MSC_SCSI_BULK_OUT_EP_ADDR;
|
xfer_out->bEndpointAddress = MOCK_MSC_SCSI_BULK_OUT_EP_ADDR;
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_transfer_submit(xfer_out));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_transfer_submit(xfer_out));
|
||||||
//Test that an inflight transfer cannot be resubmitted
|
//Test that an inflight transfer cannot be resubmitted
|
||||||
TEST_ASSERT_EQUAL(ESP_ERR_NOT_FINISHED, usb_host_transfer_submit(xfer_out));
|
TEST_ASSERT_EQUAL(ESP_ERR_NOT_FINISHED, usb_host_transfer_submit(xfer_out));
|
||||||
//Next stage set from transfer callback
|
//Next stage set from transfer callback
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TEST_STAGE_MSC_DATA: {
|
case TEST_STAGE_MSC_DATA: {
|
||||||
ESP_LOGD(MSC_CLIENT_TAG, "Data");
|
ESP_LOGD(MSC_CLIENT_TAG, "Data");
|
||||||
xfer_in->num_bytes = usb_round_up_to_mps(MOCK_MSC_SCSI_SECTOR_SIZE * msc_obj.test_param.num_sectors_per_xfer, MOCK_MSC_SCSI_BULK_EP_MPS);
|
xfer_in->num_bytes = usb_round_up_to_mps(MOCK_MSC_SCSI_SECTOR_SIZE * msc_obj.test_param.num_sectors_per_xfer, MOCK_MSC_SCSI_BULK_EP_MPS);
|
||||||
xfer_in->bEndpointAddress = MOCK_MSC_SCSI_BULK_IN_EP_ADDR;
|
xfer_in->bEndpointAddress = MOCK_MSC_SCSI_BULK_IN_EP_ADDR;
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_transfer_submit(xfer_in));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_transfer_submit(xfer_in));
|
||||||
//Test that an inflight transfer cannot be resubmitted
|
//Test that an inflight transfer cannot be resubmitted
|
||||||
TEST_ASSERT_EQUAL(ESP_ERR_NOT_FINISHED, usb_host_transfer_submit(xfer_in));
|
TEST_ASSERT_EQUAL(ESP_ERR_NOT_FINISHED, usb_host_transfer_submit(xfer_in));
|
||||||
//Next stage set from transfer callback
|
//Next stage set from transfer callback
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TEST_STAGE_MSC_CSW: {
|
case TEST_STAGE_MSC_CSW: {
|
||||||
ESP_LOGD(MSC_CLIENT_TAG, "CSW");
|
ESP_LOGD(MSC_CLIENT_TAG, "CSW");
|
||||||
xfer_in->num_bytes = usb_round_up_to_mps(sizeof(mock_msc_bulk_csw_t), MOCK_MSC_SCSI_BULK_EP_MPS);
|
xfer_in->num_bytes = usb_round_up_to_mps(sizeof(mock_msc_bulk_csw_t), MOCK_MSC_SCSI_BULK_EP_MPS);
|
||||||
xfer_in->bEndpointAddress = MOCK_MSC_SCSI_BULK_IN_EP_ADDR;
|
xfer_in->bEndpointAddress = MOCK_MSC_SCSI_BULK_IN_EP_ADDR;
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_transfer_submit(xfer_in));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_transfer_submit(xfer_in));
|
||||||
//Test that an inflight transfer cannot be resubmitted
|
//Test that an inflight transfer cannot be resubmitted
|
||||||
TEST_ASSERT_EQUAL(ESP_ERR_NOT_FINISHED, usb_host_transfer_submit(xfer_in));
|
TEST_ASSERT_EQUAL(ESP_ERR_NOT_FINISHED, usb_host_transfer_submit(xfer_in));
|
||||||
//Next stage set from transfer callback
|
//Next stage set from transfer callback
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TEST_STAGE_DEV_CLOSE: {
|
case TEST_STAGE_DEV_CLOSE: {
|
||||||
ESP_LOGD(MSC_CLIENT_TAG, "Close");
|
ESP_LOGD(MSC_CLIENT_TAG, "Close");
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_interface_release(msc_obj.client_hdl, msc_obj.dev_hdl, MOCK_MSC_SCSI_INTF_NUMBER));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_interface_release(msc_obj.client_hdl, msc_obj.dev_hdl, MOCK_MSC_SCSI_INTF_NUMBER));
|
||||||
TEST_ASSERT_EQUAL(ESP_OK, usb_host_device_close(msc_obj.client_hdl, msc_obj.dev_hdl));
|
TEST_ASSERT_EQUAL(ESP_OK, usb_host_device_close(msc_obj.client_hdl, msc_obj.dev_hdl));
|
||||||
exit_loop = true;
|
exit_loop = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Free transfers and deregister the client
|
//Free transfers and deregister the client
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -169,20 +169,20 @@ static void test_async_client_cb(const usb_host_client_event_msg_t *event_msg, v
|
|||||||
client_test_stage_t *stage = (client_test_stage_t *)arg;
|
client_test_stage_t *stage = (client_test_stage_t *)arg;
|
||||||
|
|
||||||
switch (event_msg->event) {
|
switch (event_msg->event) {
|
||||||
case USB_HOST_CLIENT_EVENT_NEW_DEV:
|
case USB_HOST_CLIENT_EVENT_NEW_DEV:
|
||||||
if (dev_addr == 0) {
|
if (dev_addr == 0) {
|
||||||
dev_addr = event_msg->new_dev.address;
|
dev_addr = event_msg->new_dev.address;
|
||||||
} else {
|
} else {
|
||||||
TEST_ASSERT_EQUAL(dev_addr, event_msg->new_dev.address);
|
TEST_ASSERT_EQUAL(dev_addr, event_msg->new_dev.address);
|
||||||
}
|
}
|
||||||
*stage = CLIENT_TEST_STAGE_CONN;
|
*stage = CLIENT_TEST_STAGE_CONN;
|
||||||
break;
|
break;
|
||||||
case USB_HOST_CLIENT_EVENT_DEV_GONE:
|
case USB_HOST_CLIENT_EVENT_DEV_GONE:
|
||||||
*stage = CLIENT_TEST_STAGE_DCONN;
|
*stage = CLIENT_TEST_STAGE_DCONN;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
abort();
|
abort();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ TEST_CASE("Test USB Host async API", "[usb_host][full_speed][low_speed]")
|
|||||||
.max_num_event_msg = 5,
|
.max_num_event_msg = 5,
|
||||||
.async = {
|
.async = {
|
||||||
.client_event_callback = test_async_client_cb,
|
.client_event_callback = test_async_client_cb,
|
||||||
.callback_arg = (void *)&client0_stage,
|
.callback_arg = (void *) &client0_stage,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
usb_host_client_handle_t client0_hdl;
|
usb_host_client_handle_t client0_hdl;
|
||||||
|
@ -1081,11 +1081,11 @@ esp_err_t usbh_ep_enqueue_urb(usbh_ep_handle_t ep_hdl, urb_t *urb)
|
|||||||
|
|
||||||
endpoint_t *ep_obj = (endpoint_t *)ep_hdl;
|
endpoint_t *ep_obj = (endpoint_t *)ep_hdl;
|
||||||
|
|
||||||
USBH_CHECK( transfer_check_usb_compliance(&(urb->transfer),
|
USBH_CHECK(transfer_check_usb_compliance(&(urb->transfer),
|
||||||
USB_EP_DESC_GET_XFERTYPE(ep_obj->constant.ep_desc),
|
USB_EP_DESC_GET_XFERTYPE(ep_obj->constant.ep_desc),
|
||||||
USB_EP_DESC_GET_MPS(ep_obj->constant.ep_desc),
|
USB_EP_DESC_GET_MPS(ep_obj->constant.ep_desc),
|
||||||
USB_EP_DESC_GET_EP_DIR(ep_obj->constant.ep_desc)),
|
USB_EP_DESC_GET_EP_DIR(ep_obj->constant.ep_desc)),
|
||||||
ESP_ERR_INVALID_ARG);
|
ESP_ERR_INVALID_ARG);
|
||||||
// Check that the EP's underlying pipe is in the active state before submitting the URB
|
// Check that the EP's underlying pipe is in the active state before submitting the URB
|
||||||
if (hcd_pipe_get_state(ep_obj->constant.pipe_hdl) != HCD_PIPE_STATE_ACTIVE) {
|
if (hcd_pipe_get_state(ep_obj->constant.pipe_hdl) != HCD_PIPE_STATE_ACTIVE) {
|
||||||
return ESP_ERR_INVALID_STATE;
|
return ESP_ERR_INVALID_STATE;
|
||||||
|
@ -109,7 +109,6 @@ components_not_formatted_temporary:
|
|||||||
- "/components/touch_element/"
|
- "/components/touch_element/"
|
||||||
- "/components/ulp/"
|
- "/components/ulp/"
|
||||||
- "/components/unity/"
|
- "/components/unity/"
|
||||||
- "/components/usb/"
|
|
||||||
- "/components/vfs/"
|
- "/components/vfs/"
|
||||||
- "/components/wear_levelling/"
|
- "/components/wear_levelling/"
|
||||||
- "/components/wifi_provisioning/"
|
- "/components/wifi_provisioning/"
|
||||||
|
Loading…
Reference in New Issue
Block a user