mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
no big deal, only rename tusb_std_request_t to tusb_control_request_t
This commit is contained in:
parent
8c0bc38713
commit
391e132d6b
@ -58,6 +58,9 @@ void tusbh_cdc_unmounted_isr(uint8_t dev_addr);
|
||||
void tusbh_cdc_isr(uint8_t dev_addr, tusb_event_t event);
|
||||
void tusbh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes);
|
||||
|
||||
void tusbh_cdc_rndis_mounted_cb(uint8_t dev_addr) ATTR_WEAK;
|
||||
void tusbh_cdc_rndis_unmounted_isr(uint8_t dev_addr) ATTR_WEAK;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -77,9 +77,6 @@ void setUp(void)
|
||||
hcd_pipe_open_ExpectAndReturn(dev_addr, p_endpoint_notification, TUSB_CLASS_CDC, pipe_notification);
|
||||
hcd_pipe_open_ExpectAndReturn(dev_addr, p_endpoint_out, TUSB_CLASS_CDC, pipe_out);
|
||||
hcd_pipe_open_ExpectAndReturn(dev_addr, p_endpoint_in, TUSB_CLASS_CDC, pipe_int);
|
||||
tusbh_cdc_mounted_cb_Expect(dev_addr);
|
||||
|
||||
TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, cdch_open_subtask(dev_addr, p_comm_interface, &length) );
|
||||
}
|
||||
|
||||
void tearDown(void)
|
||||
@ -87,7 +84,11 @@ void tearDown(void)
|
||||
|
||||
}
|
||||
|
||||
void test_(void)
|
||||
//tusb_
|
||||
void test_rndis_send_initalize(void)
|
||||
{
|
||||
// usbh_control_xfer_subtask_ExpectAndReturn(dev_addr, )
|
||||
|
||||
//------------- Code Under Test -------------//
|
||||
TEST_ASSERT_EQUAL( TUSB_ERROR_NONE, cdch_open_subtask(dev_addr, p_comm_interface, &length) );
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ void test_addr0_control_close(void)
|
||||
TEST_ASSERT_STATUS( hcd_pipe_control_open(dev_addr, control_max_packet_size) );
|
||||
|
||||
TEST_ASSERT_STATUS( hcd_pipe_control_xfer(dev_addr,
|
||||
&(tusb_std_request_t) {
|
||||
&(tusb_control_request_t) {
|
||||
.bmRequestType = { .direction = TUSB_DIR_HOST_TO_DEV, .type = TUSB_REQUEST_TYPE_STANDARD, .recipient = TUSB_REQUEST_RECIPIENT_DEVICE },
|
||||
.bRequest = TUSB_REQUEST_SET_ADDRESS,
|
||||
.wValue = 3 },
|
||||
@ -124,7 +124,7 @@ void test_isr_disconnect_then_async_advance_control_pipe(void)
|
||||
TEST_ASSERT_STATUS( hcd_pipe_control_open(dev_addr, control_max_packet_size) );
|
||||
|
||||
TEST_ASSERT_STATUS( hcd_pipe_control_xfer(dev_addr,
|
||||
&(tusb_std_request_t) {
|
||||
&(tusb_control_request_t) {
|
||||
.bmRequestType = { .direction = TUSB_DIR_HOST_TO_DEV, .type = TUSB_REQUEST_TYPE_STANDARD, .recipient = TUSB_REQUEST_RECIPIENT_DEVICE },
|
||||
.bRequest = TUSB_REQUEST_SET_ADDRESS,
|
||||
.wValue = 3 },
|
||||
|
@ -103,7 +103,7 @@ void tearDown(void)
|
||||
//--------------------------------------------------------------------+
|
||||
// CONTROL TRANSFER
|
||||
//--------------------------------------------------------------------+
|
||||
tusb_std_request_t request_get_dev_desc =
|
||||
tusb_control_request_t request_get_dev_desc =
|
||||
{
|
||||
.bmRequestType = { .direction = TUSB_DIR_DEV_TO_HOST, .type = TUSB_REQUEST_TYPE_STANDARD, .recipient = TUSB_REQUEST_RECIPIENT_DEVICE },
|
||||
.bRequest = TUSB_REQUEST_GET_DESCRIPTOR,
|
||||
@ -111,7 +111,7 @@ tusb_std_request_t request_get_dev_desc =
|
||||
.wLength = 18
|
||||
};
|
||||
|
||||
tusb_std_request_t request_set_dev_addr =
|
||||
tusb_control_request_t request_set_dev_addr =
|
||||
{
|
||||
.bmRequestType = { .direction = TUSB_DIR_HOST_TO_DEV, .type = TUSB_REQUEST_TYPE_STANDARD, .recipient = TUSB_REQUEST_RECIPIENT_DEVICE },
|
||||
.bRequest = TUSB_REQUEST_SET_ADDRESS,
|
||||
|
@ -118,7 +118,7 @@ void test_keyboard_is_supported_ok(void)
|
||||
TEST_ASSERT_TRUE( tusbh_hid_keyboard_is_mounted(dev_addr) );
|
||||
}
|
||||
|
||||
static tusb_error_t stub_set_idle_request(uint8_t address, tusb_std_request_t const* p_request, uint8_t* data, int num_call)
|
||||
static tusb_error_t stub_set_idle_request(uint8_t address, tusb_control_request_t const* p_request, uint8_t* data, int num_call)
|
||||
{
|
||||
TEST_ASSERT_EQUAL( dev_addr, address);
|
||||
|
||||
|
@ -107,7 +107,7 @@ void test_mouse_is_supported_ok(void)
|
||||
TEST_ASSERT_TRUE( tusbh_hid_mouse_is_mounted(dev_addr) );
|
||||
}
|
||||
|
||||
static tusb_error_t stub_set_idle_request(uint8_t address, tusb_std_request_t const* p_request, uint8_t* data, int num_call)
|
||||
static tusb_error_t stub_set_idle_request(uint8_t address, tusb_control_request_t const* p_request, uint8_t* data, int num_call)
|
||||
{
|
||||
TEST_ASSERT_EQUAL( dev_addr, address);
|
||||
|
||||
|
@ -62,7 +62,7 @@ tusb_speed_t device_speed = TUSB_SPEED_FULL;
|
||||
|
||||
void queue_recv_stub (osal_queue_handle_t const queue_hdl, uint32_t *p_data, uint32_t msec, tusb_error_t *p_error, int num_call);
|
||||
void semaphore_wait_success_stub(osal_semaphore_handle_t const sem_hdl, uint32_t msec, tusb_error_t *p_error, int num_call);
|
||||
tusb_error_t control_xfer_stub(uint8_t dev_addr, const tusb_std_request_t * const p_request, uint8_t data[], int num_call);
|
||||
tusb_error_t control_xfer_stub(uint8_t dev_addr, const tusb_control_request_t * const p_request, uint8_t data[], int num_call);
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
@ -119,7 +119,7 @@ semaphore_wait_timeout(6)
|
||||
semaphore_wait_timeout(7)
|
||||
semaphore_wait_timeout(8)
|
||||
|
||||
tusb_error_t control_xfer_stub(uint8_t dev_addr, const tusb_std_request_t * const p_request, uint8_t data[], int num_call)
|
||||
tusb_error_t control_xfer_stub(uint8_t dev_addr, const tusb_control_request_t * const p_request, uint8_t data[], int num_call)
|
||||
{
|
||||
switch (num_call)
|
||||
{
|
||||
|
@ -181,7 +181,7 @@ static void mutex_wait_failed_stub(osal_mutex_handle_t const sem_hdl, uint32_t m
|
||||
|
||||
void test_usbh_control_xfer_mutex_failed(void)
|
||||
{
|
||||
tusb_std_request_t a_request;
|
||||
tusb_control_request_t a_request;
|
||||
|
||||
osal_mutex_wait_StubWithCallback(mutex_wait_failed_stub);
|
||||
osal_mutex_release_ExpectAndReturn(usbh_devices[dev_addr].control.mutex_hdl, TUSB_ERROR_NONE);
|
||||
@ -192,7 +192,7 @@ void test_usbh_control_xfer_mutex_failed(void)
|
||||
|
||||
void test_usbh_control_xfer_ok(void)
|
||||
{
|
||||
tusb_std_request_t a_request;
|
||||
tusb_control_request_t a_request;
|
||||
|
||||
osal_mutex_wait_StubWithCallback(semaphore_wait_success_stub);
|
||||
|
||||
|
@ -71,7 +71,7 @@ void ehci_controller_control_xfer_proceed(uint8_t dev_addr, uint8_t p_data[])
|
||||
ehci_qtd_t * p_qtd_data = p_qtd_setup + 1;
|
||||
ehci_qtd_t * p_qtd_status = p_qtd_setup + 2;
|
||||
|
||||
tusb_std_request_t const *p_request = (tusb_std_request_t *) p_qtd_setup->buffer[0];
|
||||
tusb_control_request_t const *p_request = (tusb_control_request_t *) p_qtd_setup->buffer[0];
|
||||
|
||||
if (p_request->wLength > 0 && p_request->bmRequestType.direction == TUSB_DIR_DEV_TO_HOST)
|
||||
{
|
||||
|
@ -68,11 +68,21 @@ bool tusbh_cdc_rndis_is_mounted(uint8_t dev_addr) ATTR_PURE ATTR_WARN_UNUSED_RES
|
||||
tusb_error_t tusbh_cdc_send(uint8_t dev_addr, void const * p_data, uint32_t length, bool is_notify);
|
||||
tusb_error_t tusbh_cdc_receive(uint8_t dev_addr, void * p_buffer, uint32_t length, bool is_notify);
|
||||
|
||||
//------------- Application Callback -------------//
|
||||
//------------- CDC Application Callback -------------//
|
||||
void tusbh_cdc_mounted_cb(uint8_t dev_addr) ATTR_WEAK;
|
||||
void tusbh_cdc_unmounted_isr(uint8_t dev_addr) ATTR_WEAK;
|
||||
void tusbh_cdc_isr(uint8_t dev_addr, tusb_event_t event) ATTR_WEAK;
|
||||
void tusbh_cdc_xfer_isr(uint8_t dev_addr, tusb_event_t event, cdc_pipeid_t pipe_id, uint32_t xferred_bytes) ATTR_WEAK;
|
||||
|
||||
//------------- RNDIS Application Callback (overshadow CDC callbacks) -------------//
|
||||
#if TUSB_CFG_HOST_CDC_RNDIS
|
||||
|
||||
void tusbh_cdc_rndis_mounted_cb(uint8_t dev_addr) ATTR_WEAK;
|
||||
void tusbh_cdc_rndis_unmounted_isr(uint8_t dev_addr) ATTR_WEAK;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// USBH-CLASS API
|
||||
//--------------------------------------------------------------------+
|
||||
|
@ -67,7 +67,7 @@ STATIC_ hidd_interface_t keyboard_intf =
|
||||
};
|
||||
#endif
|
||||
|
||||
tusb_error_t hidd_control_request(uint8_t coreid, tusb_std_request_t const * p_request)
|
||||
tusb_error_t hidd_control_request(uint8_t coreid, tusb_control_request_t const * p_request)
|
||||
{
|
||||
#if TUSB_CFG_DEVICE_HID_KEYBOARD
|
||||
if (p_request->bmRequestType.type == TUSB_REQUEST_TYPE_STANDARD) // standard request to hid
|
||||
|
@ -66,7 +66,7 @@ tusb_error_t tusbd_hid_mouse_send_report(tusb_mouse_report_t *p_mouse_report);
|
||||
#ifdef _TINY_USB_SOURCE_FILE_
|
||||
|
||||
tusb_error_t hidd_init(uint8_t coreid, tusb_descriptor_interface_t const * p_interface_desc, uint16_t *p_length);
|
||||
tusb_error_t hidd_control_request(uint8_t coreid, tusb_std_request_t const * p_request);
|
||||
tusb_error_t hidd_control_request(uint8_t coreid, tusb_control_request_t const * p_request);
|
||||
tusb_error_t hidd_configured(void);
|
||||
|
||||
#endif
|
||||
|
@ -221,7 +221,7 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
|
||||
// OSAL_SUBTASK_INVOKED_AND_WAIT(
|
||||
// usbh_control_xfer_subtask(
|
||||
// dev_addr,
|
||||
// &(tusb_std_request_t)
|
||||
// &(tusb_control_request_t)
|
||||
// {
|
||||
// .bmRequestType = { .direction = TUSB_DIR_HOST_TO_DEV, .type = TUSB_REQUEST_TYPE_CLASS, .recipient = TUSB_REQUEST_RECIPIENT_INTERFACE },
|
||||
// .bRequest = HID_REQUEST_CONTROL_SET_IDLE,
|
||||
@ -238,7 +238,7 @@ tusb_error_t hidh_open_subtask(uint8_t dev_addr, tusb_descriptor_interface_t con
|
||||
// OSAL_SUBTASK_INVOKED_AND_WAIT(
|
||||
// usbh_control_xfer_subtask(
|
||||
// dev_addr,
|
||||
// &(tusb_std_request_t)
|
||||
// &(tusb_control_request_t)
|
||||
// {
|
||||
// .bmRequestType = { .direction = TUSB_DIR_DEV_TO_HOST, .type = TUSB_REQUEST_TYPE_STANDARD, .recipient = TUSB_REQUEST_RECIPIENT_INTERFACE },
|
||||
// .bRequest = TUSB_REQUEST_GET_DESCRIPTOR,
|
||||
|
@ -59,7 +59,7 @@
|
||||
typedef ATTR_PACKED_STRUCT(struct){
|
||||
ATTR_PACKED_STRUCT(struct) {
|
||||
uint8_t recipient : 5; /**< Recipient type tusb_std_request_recipient_t. */
|
||||
uint8_t type : 2; /**< Request type tusb_std_request_type_t. */
|
||||
uint8_t type : 2; /**< Request type tusb_control_request_type_t. */
|
||||
uint8_t direction : 1; /**< Direction type. tusb_direction_t */
|
||||
} bmRequestType;
|
||||
|
||||
@ -67,7 +67,7 @@ typedef ATTR_PACKED_STRUCT(struct){
|
||||
uint16_t wValue;
|
||||
uint16_t wIndex;
|
||||
uint16_t wLength;
|
||||
} tusb_std_request_t;
|
||||
} tusb_control_request_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ typedef enum {
|
||||
TUSB_REQUEST_TYPE_STANDARD = 0,
|
||||
TUSB_REQUEST_TYPE_CLASS,
|
||||
TUSB_REQUEST_TYPE_VENDOR
|
||||
} tusb_std_request_type_t;
|
||||
} tusb_control_request_type_t;
|
||||
|
||||
typedef enum {
|
||||
TUSB_REQUEST_RECIPIENT_DEVICE =0,
|
||||
|
@ -66,7 +66,7 @@
|
||||
//--------------------------------------------------------------------+
|
||||
typedef struct {
|
||||
tusb_error_t (* const init)(uint8_t, tusb_descriptor_interface_t const *, uint16_t*);
|
||||
tusb_error_t (* const control_request) (uint8_t, tusb_std_request_t const *);
|
||||
tusb_error_t (* const control_request) (uint8_t, tusb_control_request_t const *);
|
||||
// void (* const isr) (pipe_handle_t, tusb_event_t);
|
||||
// void (* const close) (uint8_t);
|
||||
} device_class_driver_t;
|
||||
|
@ -60,7 +60,7 @@
|
||||
typedef struct {
|
||||
volatile uint8_t state;
|
||||
uint8_t address;
|
||||
tusb_std_request_t setup_packet;
|
||||
tusb_control_request_t setup_packet;
|
||||
uint8_t interface2class[USBD_MAX_INTERFACE]; // determine interface number belongs to which class
|
||||
uint8_t endpoint_idx2class[USBD_MAX_ENDPOINT]; // determine endpoint index belongs to which class
|
||||
}usbd_device_info_t;
|
||||
|
@ -297,7 +297,7 @@ tusb_error_t hcd_pipe_control_open(uint8_t dev_addr, uint8_t max_packet_size)
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_std_request_t const * p_request, uint8_t data[])
|
||||
tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_control_request_t const * p_request, uint8_t data[])
|
||||
{
|
||||
ehci_qhd_t * const p_qhd = get_control_qhd(dev_addr);
|
||||
|
||||
|
@ -91,7 +91,7 @@ void hcd_isr(uint8_t hostid);
|
||||
//--------------------------------------------------------------------+
|
||||
// TODO control xfer should be used via usbh layer
|
||||
tusb_error_t hcd_pipe_control_open(uint8_t dev_addr, uint8_t max_packet_size) ATTR_WARN_UNUSED_RESULT;
|
||||
tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_std_request_t const * p_request, uint8_t data[]) ATTR_WARN_UNUSED_RESULT;
|
||||
tusb_error_t hcd_pipe_control_xfer(uint8_t dev_addr, tusb_control_request_t const * p_request, uint8_t data[]) ATTR_WARN_UNUSED_RESULT;
|
||||
tusb_error_t hcd_pipe_control_close(uint8_t dev_addr) ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
pipe_handle_t hcd_pipe_open(uint8_t dev_addr, tusb_descriptor_endpoint_t const * endpoint_desc, uint8_t class_code) ATTR_WARN_UNUSED_RESULT;
|
||||
|
@ -184,7 +184,7 @@ tusb_error_t usbh_init(void)
|
||||
|
||||
//------------- USBH control transfer -------------//
|
||||
// function called within a task, requesting os blocking services, subtask input parameter must be static/global variables
|
||||
tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, tusb_std_request_t const* p_request, uint8_t* data)
|
||||
tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, tusb_control_request_t const* p_request, uint8_t* data)
|
||||
{
|
||||
tusb_error_t error;
|
||||
|
||||
@ -347,7 +347,7 @@ tusb_error_t enumeration_body_subtask(void)
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT(
|
||||
usbh_control_xfer_subtask(
|
||||
0,
|
||||
&(tusb_std_request_t)
|
||||
&(tusb_control_request_t)
|
||||
{
|
||||
.bmRequestType = { .direction = TUSB_DIR_DEV_TO_HOST, .type = TUSB_REQUEST_TYPE_STANDARD, .recipient = TUSB_REQUEST_RECIPIENT_DEVICE },
|
||||
.bRequest = TUSB_REQUEST_GET_DESCRIPTOR,
|
||||
@ -368,7 +368,7 @@ tusb_error_t enumeration_body_subtask(void)
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT(
|
||||
usbh_control_xfer_subtask(
|
||||
0,
|
||||
&(tusb_std_request_t)
|
||||
&(tusb_control_request_t)
|
||||
{
|
||||
.bmRequestType = { .direction = TUSB_DIR_HOST_TO_DEV, .type = TUSB_REQUEST_TYPE_STANDARD, .recipient = TUSB_REQUEST_RECIPIENT_DEVICE },
|
||||
.bRequest = TUSB_REQUEST_SET_ADDRESS,
|
||||
@ -396,7 +396,7 @@ tusb_error_t enumeration_body_subtask(void)
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT(
|
||||
usbh_control_xfer_subtask(
|
||||
new_addr,
|
||||
&(tusb_std_request_t)
|
||||
&(tusb_control_request_t)
|
||||
{
|
||||
.bmRequestType = { .direction = TUSB_DIR_DEV_TO_HOST, .type = TUSB_REQUEST_TYPE_STANDARD, .recipient = TUSB_REQUEST_RECIPIENT_DEVICE },
|
||||
.bRequest = TUSB_REQUEST_GET_DESCRIPTOR,
|
||||
@ -420,7 +420,7 @@ tusb_error_t enumeration_body_subtask(void)
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT(
|
||||
usbh_control_xfer_subtask(
|
||||
new_addr,
|
||||
&(tusb_std_request_t)
|
||||
&(tusb_control_request_t)
|
||||
{
|
||||
.bmRequestType = { .direction = TUSB_DIR_DEV_TO_HOST, .type = TUSB_REQUEST_TYPE_STANDARD, .recipient = TUSB_REQUEST_RECIPIENT_DEVICE },
|
||||
.bRequest = TUSB_REQUEST_GET_DESCRIPTOR,
|
||||
@ -438,7 +438,7 @@ tusb_error_t enumeration_body_subtask(void)
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT(
|
||||
usbh_control_xfer_subtask(
|
||||
new_addr,
|
||||
&(tusb_std_request_t)
|
||||
&(tusb_control_request_t)
|
||||
{
|
||||
.bmRequestType = { .direction = TUSB_DIR_DEV_TO_HOST, .type = TUSB_REQUEST_TYPE_STANDARD, .recipient = TUSB_REQUEST_RECIPIENT_DEVICE },
|
||||
.bRequest = TUSB_REQUEST_GET_DESCRIPTOR,
|
||||
@ -457,7 +457,7 @@ tusb_error_t enumeration_body_subtask(void)
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT (
|
||||
usbh_control_xfer_subtask(
|
||||
new_addr,
|
||||
&(tusb_std_request_t)
|
||||
&(tusb_control_request_t)
|
||||
{
|
||||
.bmRequestType = { .direction = TUSB_DIR_HOST_TO_DEV, .type = TUSB_REQUEST_TYPE_STANDARD, .recipient = TUSB_REQUEST_RECIPIENT_DEVICE },
|
||||
.bRequest = TUSB_REQUEST_SET_CONFIGURATION,
|
||||
|
@ -111,7 +111,7 @@ void tusbh_device_mount_failed_cb(tusb_error_t error, tusb_descriptor_de
|
||||
OSAL_TASK_FUNCTION (usbh_enumeration_task) (void* p_task_para);
|
||||
tusb_error_t usbh_init(void);
|
||||
|
||||
tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, tusb_std_request_t const* p_request, uint8_t* data);
|
||||
tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, tusb_control_request_t const* p_request, uint8_t* data);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -98,7 +98,7 @@ typedef struct { // TODO internal structure, re-order members
|
||||
//------------- control pipe -------------//
|
||||
struct {
|
||||
volatile uint8_t pipe_status;
|
||||
tusb_std_request_t request;
|
||||
tusb_control_request_t request;
|
||||
|
||||
OSAL_SEM_DEF(semaphore); // TODO move to semaphore pool ?
|
||||
osal_semaphore_handle_t sem_hdl; // used to synchronize with HCD when control xfer complete
|
||||
|
Loading…
x
Reference in New Issue
Block a user