mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
rename sem_hdl in usbh_device_info_t control_sem_hdl
This commit is contained in:
parent
55ce5cc4a2
commit
ea04815bbc
@ -71,7 +71,7 @@ void setUp(void)
|
||||
hcd_pipe_control_xfer_StubWithCallback(control_xfer_stub);
|
||||
|
||||
hcd_port_connect_status_ExpectAndReturn(enum_connect.core_id, true);
|
||||
osal_semaphore_reset_Expect( usbh_device_info_pool[0].sem_hdl );
|
||||
osal_semaphore_reset_Expect( usbh_device_info_pool[0].control_sem_hdl );
|
||||
hcd_pipe_control_open_ExpectAndReturn(0, 8, TUSB_ERROR_NONE);
|
||||
}
|
||||
|
||||
@ -193,7 +193,7 @@ void test_enum_failed_get_full_dev_desc(void)
|
||||
|
||||
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
|
||||
|
||||
osal_semaphore_reset_Expect( usbh_device_info_pool[0].sem_hdl );
|
||||
osal_semaphore_reset_Expect( usbh_device_info_pool[0].control_sem_hdl );
|
||||
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
|
||||
tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
|
||||
|
||||
@ -213,7 +213,7 @@ void test_enum_failed_get_9byte_config_desc(void)
|
||||
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(3));
|
||||
|
||||
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
|
||||
osal_semaphore_reset_Expect( usbh_device_info_pool[0].sem_hdl );
|
||||
osal_semaphore_reset_Expect( usbh_device_info_pool[0].control_sem_hdl );
|
||||
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
|
||||
tusbh_device_attached_cb_ExpectAndReturn((tusb_descriptor_device_t*) enum_data_buffer, 1);
|
||||
tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
|
||||
@ -229,7 +229,7 @@ void test_enum_failed_get_full_config_desc(void)
|
||||
{
|
||||
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(4));
|
||||
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
|
||||
osal_semaphore_reset_Expect( usbh_device_info_pool[0].sem_hdl );
|
||||
osal_semaphore_reset_Expect( usbh_device_info_pool[0].control_sem_hdl );
|
||||
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
|
||||
tusbh_device_attached_cb_ExpectAndReturn((tusb_descriptor_device_t*) enum_data_buffer, 1);
|
||||
tusbh_device_mount_failed_cb_Expect(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL);
|
||||
@ -246,7 +246,7 @@ void test_enum_parse_config_desc(void)
|
||||
{
|
||||
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(5));
|
||||
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
|
||||
osal_semaphore_reset_Expect( usbh_device_info_pool[0].sem_hdl );
|
||||
osal_semaphore_reset_Expect( usbh_device_info_pool[0].control_sem_hdl );
|
||||
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
|
||||
tusbh_device_attached_cb_ExpectAndReturn((tusb_descriptor_device_t*) enum_data_buffer, 1);
|
||||
|
||||
@ -262,7 +262,7 @@ void test_enum_set_configure(void)
|
||||
{
|
||||
osal_semaphore_wait_StubWithCallback(semaphore_wait_timeout_stub(6));
|
||||
hcd_pipe_control_close_ExpectAndReturn(0, TUSB_ERROR_NONE);
|
||||
osal_semaphore_reset_Expect( usbh_device_info_pool[0].sem_hdl );
|
||||
osal_semaphore_reset_Expect( usbh_device_info_pool[0].control_sem_hdl );
|
||||
hcd_pipe_control_open_ExpectAndReturn(1, desc_device.bMaxPacketSize0, TUSB_ERROR_NONE);
|
||||
tusbh_device_attached_cb_ExpectAndReturn((tusb_descriptor_device_t*) enum_data_buffer, 1);
|
||||
class_install_expect();
|
||||
|
@ -143,7 +143,7 @@ void test_usbh_init_ok(void)
|
||||
{
|
||||
osal_semaphore_handle_t sem_hdl_dummy = 0x2233;
|
||||
osal_semaphore_create_IgnoreAndReturn(sem_hdl_dummy);
|
||||
device_info_zero[i].sem_hdl = sem_hdl_dummy;
|
||||
device_info_zero[i].control_sem_hdl = sem_hdl_dummy;
|
||||
}
|
||||
|
||||
osal_task_create_IgnoreAndReturn(TUSB_ERROR_NONE);
|
||||
|
@ -60,7 +60,7 @@ void tusb_tick_tock(void)
|
||||
//--------------------------------------------------------------------+
|
||||
#define ENUM_QUEUE_DEPTH 5
|
||||
|
||||
// TODO fix number of class driver
|
||||
// TODO fix/compress number of class driver
|
||||
static host_class_driver_t const usbh_class_drivers[TUSB_CLASS_MAX_CONSEC_NUMBER] =
|
||||
{
|
||||
[TUSB_CLASS_HID] = {
|
||||
@ -116,8 +116,8 @@ tusb_error_t usbh_init(void)
|
||||
//------------- Semaphore for Control Pipe -------------//
|
||||
for(uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX+1; i++) // including address zero
|
||||
{
|
||||
usbh_device_info_pool[i].sem_hdl = osal_semaphore_create( OSAL_SEM_REF(usbh_device_info_pool[i].semaphore) );
|
||||
ASSERT_PTR(usbh_device_info_pool[i].sem_hdl, TUSB_ERROR_OSAL_SEMAPHORE_FAILED);
|
||||
usbh_device_info_pool[i].control_sem_hdl = osal_semaphore_create( OSAL_SEM_REF(usbh_device_info_pool[i].semaphore) );
|
||||
ASSERT_PTR(usbh_device_info_pool[i].control_sem_hdl, TUSB_ERROR_OSAL_SEMAPHORE_FAILED);
|
||||
}
|
||||
|
||||
//------------- Enumeration & Reporter Task init -------------//
|
||||
@ -147,7 +147,7 @@ tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, tusb_std_request_t cons
|
||||
usbh_device_info_pool[dev_addr].control_request = *p_request;
|
||||
(void) hcd_pipe_control_xfer(dev_addr, &usbh_device_info_pool[dev_addr].control_request, data);
|
||||
|
||||
osal_semaphore_wait(usbh_device_info_pool[dev_addr].sem_hdl, OSAL_TIMEOUT_NORMAL, &error); // careful of local variable without static
|
||||
osal_semaphore_wait(usbh_device_info_pool[dev_addr].control_sem_hdl, OSAL_TIMEOUT_NORMAL, &error); // careful of local variable without static
|
||||
// TODO make handler for this function general purpose
|
||||
SUBTASK_ASSERT_STATUS_WITH_HANDLER(error || usbh_device_info_pool[dev_addr].control_pipe_status == PIPE_STATUS_ERROR,
|
||||
tusbh_device_mount_failed_cb(TUSB_ERROR_USBH_MOUNT_DEVICE_NOT_RESPOND, NULL) );
|
||||
@ -158,7 +158,7 @@ tusb_error_t usbh_control_xfer_subtask(uint8_t dev_addr, tusb_std_request_t cons
|
||||
tusb_error_t usbh_pipe_control_open(uint8_t dev_addr, uint8_t max_packet_size) ATTR_ALWAYS_INLINE;
|
||||
tusb_error_t usbh_pipe_control_open(uint8_t dev_addr, uint8_t max_packet_size)
|
||||
{
|
||||
osal_semaphore_reset( usbh_device_info_pool[dev_addr].sem_hdl );
|
||||
osal_semaphore_reset( usbh_device_info_pool[dev_addr].control_sem_hdl );
|
||||
|
||||
ASSERT_STATUS( hcd_pipe_control_open(dev_addr, max_packet_size) );
|
||||
|
||||
@ -187,7 +187,7 @@ void usbh_isr(pipe_handle_t pipe_hdl, uint8_t class_code, tusb_bus_event_t event
|
||||
if (class_code == 0) // Control transfer
|
||||
{
|
||||
usbh_device_info_pool[ pipe_hdl.dev_addr ].control_pipe_status = (event == BUS_EVENT_XFER_COMPLETE) ? PIPE_STATUS_COMPLETE : PIPE_STATUS_ERROR;
|
||||
osal_semaphore_post( usbh_device_info_pool[ pipe_hdl.dev_addr ].sem_hdl );
|
||||
osal_semaphore_post( usbh_device_info_pool[ pipe_hdl.dev_addr ].control_sem_hdl );
|
||||
}else if (usbh_class_drivers[class_code].isr)
|
||||
{
|
||||
usbh_class_drivers[class_code].isr(pipe_hdl, event);
|
||||
|
@ -96,7 +96,7 @@ typedef struct { // TODO internal structure, re-order members
|
||||
volatile uint8_t control_pipe_status;
|
||||
tusb_std_request_t control_request;
|
||||
OSAL_SEM_DEF(semaphore); // TODO move to semaphore pool
|
||||
osal_semaphore_handle_t sem_hdl;
|
||||
osal_semaphore_handle_t control_sem_hdl;
|
||||
|
||||
} usbh_device_info_t;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user