add semphore reset & queue flush API
modify test to check control pipe semaphore created with usbh_init
This commit is contained in:
@@ -340,7 +340,6 @@ static inline ehci_qtd_t* get_control_qtds(uint8_t dev_addr) ATTR_ALWAYS_INLINE
|
||||
//--------------------------------------------------------------------+
|
||||
// CONTROL PIPE API
|
||||
//--------------------------------------------------------------------+
|
||||
// TODO subject to pure function
|
||||
static void init_qtd(ehci_qtd_t* p_qtd, uint32_t data_ptr, uint16_t total_bytes)
|
||||
{
|
||||
memclr_(p_qtd, sizeof(ehci_qtd_t));
|
||||
@@ -537,7 +536,6 @@ static inline ehci_qtd_t* get_control_qtds(uint8_t dev_addr)
|
||||
|
||||
}
|
||||
|
||||
// TODO subject to pure function
|
||||
static void init_qhd(ehci_qhd_t *p_qhd, uint8_t dev_addr, uint16_t max_packet_size, uint8_t endpoint_addr, uint8_t xfer_type)
|
||||
{
|
||||
memclr_(p_qhd, sizeof(ehci_qhd_t));
|
||||
|
||||
@@ -103,6 +103,13 @@ tusb_error_t usbh_init(void)
|
||||
|
||||
ASSERT_STATUS( hcd_init() );
|
||||
|
||||
//------------- Semaphore for Control Pipe -------------//
|
||||
for(uint8_t i=0; i<TUSB_CFG_HOST_DEVICE_MAX; i++)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
//------------- Enumeration & Reporter Task init -------------//
|
||||
ASSERT_STATUS( osal_task_create(&enum_task) );
|
||||
enum_queue_hdl = osal_queue_create(&enum_queue);
|
||||
@@ -118,9 +125,19 @@ tusb_error_t usbh_init(void)
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
// interrupt caused by a TD (with IOC=1) in pipe of class class_code
|
||||
void usbh_isr(pipe_handle_t pipe_hdl, uint8_t class_code)
|
||||
{
|
||||
|
||||
if (class_code == 0) // Control transfer
|
||||
{
|
||||
// TODO some semaphore posting
|
||||
}else if (usbh_class_drivers[class_code].isr)
|
||||
{
|
||||
usbh_class_drivers[class_code].isr(pipe_hdl);
|
||||
}else
|
||||
{
|
||||
ASSERT(false, (void) 0); // something wrong, no one claims the isr's source
|
||||
}
|
||||
}
|
||||
|
||||
// function called within a task, requesting os blocking services, subtask input parameter must be static/global variables
|
||||
|
||||
@@ -90,20 +90,12 @@ typedef struct { // TODO internal structure, re-order members
|
||||
//------------- configuration descriptor info -------------//
|
||||
uint8_t interface_count; // bNumInterfaces alias
|
||||
|
||||
uint8_t status; // value from enum tusbh_device_status_
|
||||
uint8_t status; // value from enum tusbh_device_status_
|
||||
|
||||
// pipe_handle_t pipe_control; NOTE: use device address/handle instead
|
||||
tusb_std_request_t control_request;
|
||||
OSAL_SEM_DEF(semaphore);
|
||||
osal_semaphore_handle_t sem_hdl;
|
||||
|
||||
#if 0 // TODO allow configure for vendor/product
|
||||
struct {
|
||||
uint8_t interface_count;
|
||||
uint8_t attributes;
|
||||
} configuration;
|
||||
#endif
|
||||
|
||||
} usbh_device_info_t;
|
||||
|
||||
extern usbh_device_info_t usbh_device_info_pool[TUSB_CFG_HOST_DEVICE_MAX+1]; // including zero-address
|
||||
|
||||
Reference in New Issue
Block a user