mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-16 05:42:56 +00:00
rename to hal_dcd_control_xfer() and hal_dcd_control_stall()
This commit is contained in:
parent
f9270ac5a4
commit
85511e288d
@ -321,14 +321,14 @@ static inline uint8_t qtd_find_free(uint8_t coreid)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// CONTROL PIPE API
|
// CONTROL PIPE API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void dcd_pipe_control_stall(uint8_t coreid)
|
void hal_dcd_control_stall(uint8_t coreid)
|
||||||
{
|
{
|
||||||
LPC_USB[coreid]->ENDPTCTRL0 |= (ENDPTCTRL_MASK_STALL << 16); // stall Control IN TODO stall control OUT as well
|
LPC_USB[coreid]->ENDPTCTRL0 |= (ENDPTCTRL_MASK_STALL << 16); // stall Control IN TODO stall control OUT as well
|
||||||
}
|
}
|
||||||
|
|
||||||
// control transfer does not need to use qtd find function
|
// control transfer does not need to use qtd find function
|
||||||
// follows UM 24.10.8.1.1 Setup packet handling using setup lockout mechanism
|
// follows UM 24.10.8.1.1 Setup packet handling using setup lockout mechanism
|
||||||
bool dcd_pipe_control_xfer(uint8_t coreid, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete)
|
bool hal_dcd_control_xfer(uint8_t coreid, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete)
|
||||||
{
|
{
|
||||||
LPC_USB0_Type* const lpc_usb = LPC_USB[coreid];
|
LPC_USB0_Type* const lpc_usb = LPC_USB[coreid];
|
||||||
dcd_data_t* const p_dcd = dcd_data_ptr[coreid];
|
dcd_data_t* const p_dcd = dcd_data_ptr[coreid];
|
||||||
|
@ -187,12 +187,12 @@ tusb_error_t cdcd_control_request_subtask(uint8_t coreid, tusb_control_request_t
|
|||||||
switch(p_request->bRequest)
|
switch(p_request->bRequest)
|
||||||
{
|
{
|
||||||
case CDC_REQUEST_GET_LINE_CODING:
|
case CDC_REQUEST_GET_LINE_CODING:
|
||||||
dcd_pipe_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction,
|
hal_dcd_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction,
|
||||||
(uint8_t*) &cdcd_line_coding[coreid], min16_of(sizeof(cdc_line_coding_t), p_request->wLength), false );
|
(uint8_t*) &cdcd_line_coding[coreid], min16_of(sizeof(cdc_line_coding_t), p_request->wLength), false );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CDC_REQUEST_SET_LINE_CODING:
|
case CDC_REQUEST_SET_LINE_CODING:
|
||||||
dcd_pipe_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction,
|
hal_dcd_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction,
|
||||||
(uint8_t*) &cdcd_line_coding[coreid], min16_of(sizeof(cdc_line_coding_t), p_request->wLength), false );
|
(uint8_t*) &cdcd_line_coding[coreid], min16_of(sizeof(cdc_line_coding_t), p_request->wLength), false );
|
||||||
// TODO notify application on xfer completea
|
// TODO notify application on xfer completea
|
||||||
break;
|
break;
|
||||||
|
@ -202,7 +202,7 @@ tusb_error_t hidd_control_request_subtask(uint8_t coreid, tusb_control_request_t
|
|||||||
ASSERT ( p_hid->report_length <= HIDD_BUFFER_SIZE, TUSB_ERROR_NOT_ENOUGH_MEMORY);
|
ASSERT ( p_hid->report_length <= HIDD_BUFFER_SIZE, TUSB_ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
|
||||||
memcpy(m_hid_buffer, p_hid->p_report_desc, p_hid->report_length); // to allow report descriptor not to be in USBRAM
|
memcpy(m_hid_buffer, p_hid->p_report_desc, p_hid->report_length); // to allow report descriptor not to be in USBRAM
|
||||||
dcd_pipe_control_xfer(coreid, TUSB_DIR_DEV_TO_HOST, m_hid_buffer, p_hid->report_length, false);
|
hal_dcd_control_xfer(coreid, TUSB_DIR_DEV_TO_HOST, m_hid_buffer, p_hid->report_length, false);
|
||||||
}
|
}
|
||||||
//------------- Class Specific Request -------------//
|
//------------- Class Specific Request -------------//
|
||||||
else if (p_request->bmRequestType_bit.type == TUSB_REQUEST_TYPE_CLASS)
|
else if (p_request->bmRequestType_bit.type == TUSB_REQUEST_TYPE_CLASS)
|
||||||
@ -218,7 +218,7 @@ tusb_error_t hidd_control_request_subtask(uint8_t coreid, tusb_control_request_t
|
|||||||
&p_buffer, p_request->wLength);
|
&p_buffer, p_request->wLength);
|
||||||
SUBTASK_ASSERT( p_buffer != NULL && actual_length > 0 );
|
SUBTASK_ASSERT( p_buffer != NULL && actual_length > 0 );
|
||||||
|
|
||||||
dcd_pipe_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction, p_buffer, actual_length, false);
|
hal_dcd_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction, p_buffer, actual_length, false);
|
||||||
}
|
}
|
||||||
else if ( (HID_REQUEST_CONTROL_SET_REPORT == p_request->bRequest) && (p_driver->set_report_cb != NULL) )
|
else if ( (HID_REQUEST_CONTROL_SET_REPORT == p_request->bRequest) && (p_driver->set_report_cb != NULL) )
|
||||||
{
|
{
|
||||||
@ -226,7 +226,7 @@ tusb_error_t hidd_control_request_subtask(uint8_t coreid, tusb_control_request_t
|
|||||||
// wValue = Report Type | Report ID
|
// wValue = Report Type | Report ID
|
||||||
tusb_error_t error;
|
tusb_error_t error;
|
||||||
|
|
||||||
dcd_pipe_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction, m_hid_buffer, p_request->wLength, true);
|
hal_dcd_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction, m_hid_buffer, p_request->wLength, true);
|
||||||
|
|
||||||
osal_semaphore_wait(usbd_control_xfer_sem_hdl, OSAL_TIMEOUT_NORMAL, &error); // wait for control xfer complete
|
osal_semaphore_wait(usbd_control_xfer_sem_hdl, OSAL_TIMEOUT_NORMAL, &error); // wait for control xfer complete
|
||||||
SUBTASK_ASSERT_STATUS(error);
|
SUBTASK_ASSERT_STATUS(error);
|
||||||
|
@ -126,12 +126,12 @@ tusb_error_t mscd_control_request_subtask(uint8_t coreid, tusb_control_request_t
|
|||||||
switch(p_request->bRequest)
|
switch(p_request->bRequest)
|
||||||
{
|
{
|
||||||
case MSC_REQUEST_RESET:
|
case MSC_REQUEST_RESET:
|
||||||
dcd_pipe_control_xfer(coreid, TUSB_DIR_HOST_TO_DEV, NULL, 0, false);
|
hal_dcd_control_xfer(coreid, TUSB_DIR_HOST_TO_DEV, NULL, 0, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MSC_REQUEST_GET_MAX_LUN:
|
case MSC_REQUEST_GET_MAX_LUN:
|
||||||
p_msc->scsi_data[0] = p_msc->max_lun; // Note: lpc11/13u need xfer data's address to be aligned 64 -> make use of scsi_data instead of using max_lun directly
|
p_msc->scsi_data[0] = p_msc->max_lun; // Note: lpc11/13u need xfer data's address to be aligned 64 -> make use of scsi_data instead of using max_lun directly
|
||||||
dcd_pipe_control_xfer(coreid, TUSB_DIR_DEV_TO_HOST, p_msc->scsi_data, 1, false);
|
hal_dcd_control_xfer(coreid, TUSB_DIR_DEV_TO_HOST, p_msc->scsi_data, 1, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -57,6 +57,7 @@ typedef enum
|
|||||||
USBD_BUS_EVENT_RESUME
|
USBD_BUS_EVENT_RESUME
|
||||||
}usbd_bus_event_type_t;
|
}usbd_bus_event_type_t;
|
||||||
|
|
||||||
|
// TODO move Hal
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t coreid;
|
uint8_t coreid;
|
||||||
uint8_t reserved; // TODO redundant, cannot be control as control uses separated API
|
uint8_t reserved; // TODO redundant, cannot be control as control uses separated API
|
||||||
@ -91,8 +92,8 @@ void hal_dcd_bus_event(uint8_t coreid, usbd_bus_event_type_t bus_event);
|
|||||||
void hal_dcd_setup_received(uint8_t coreid, uint8_t const* p_request);
|
void hal_dcd_setup_received(uint8_t coreid, uint8_t const* p_request);
|
||||||
|
|
||||||
//------------- PIPE API -------------//
|
//------------- PIPE API -------------//
|
||||||
bool dcd_pipe_control_xfer(uint8_t coreid, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete);
|
bool hal_dcd_control_xfer(uint8_t coreid, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete);
|
||||||
void dcd_pipe_control_stall(uint8_t coreid);
|
void hal_dcd_control_stall(uint8_t coreid);
|
||||||
|
|
||||||
endpoint_handle_t dcd_pipe_open(uint8_t coreid, tusb_descriptor_endpoint_t const * p_endpoint_desc, uint8_t class_code);
|
endpoint_handle_t dcd_pipe_open(uint8_t coreid, tusb_descriptor_endpoint_t const * p_endpoint_desc, uint8_t class_code);
|
||||||
tusb_error_t dcd_pipe_queue_xfer(endpoint_handle_t edpt_hdl, uint8_t * buffer, uint16_t total_bytes); // only queue, not transferring yet
|
tusb_error_t dcd_pipe_queue_xfer(endpoint_handle_t edpt_hdl, uint8_t * buffer, uint16_t total_bytes); // only queue, not transferring yet
|
||||||
|
@ -373,12 +373,12 @@ static tusb_error_t pipe_control_read(void * buffer, uint16_t length)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// CONTROL PIPE API
|
// CONTROL PIPE API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void dcd_pipe_control_stall(uint8_t coreid)
|
void hal_dcd_control_stall(uint8_t coreid)
|
||||||
{
|
{
|
||||||
sie_write(SIE_CMDCODE_ENDPOINT_SET_STATUS+0, 1, SIE_SET_ENDPOINT_STALLED_MASK | SIE_SET_ENDPOINT_CONDITION_STALLED_MASK);
|
sie_write(SIE_CMDCODE_ENDPOINT_SET_STATUS+0, 1, SIE_SET_ENDPOINT_STALLED_MASK | SIE_SET_ENDPOINT_CONDITION_STALLED_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dcd_pipe_control_xfer(uint8_t coreid, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete)
|
bool hal_dcd_control_xfer(uint8_t coreid, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete)
|
||||||
{
|
{
|
||||||
(void) coreid;
|
(void) coreid;
|
||||||
|
|
||||||
|
@ -373,14 +373,14 @@ void dcd_isr(uint8_t coreid)
|
|||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// CONTROL PIPE API
|
// CONTROL PIPE API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void dcd_pipe_control_stall(uint8_t coreid)
|
void hal_dcd_control_stall(uint8_t coreid)
|
||||||
{
|
{
|
||||||
(void) coreid;
|
(void) coreid;
|
||||||
// TODO cannot able to STALL Control OUT endpoint !!!!! FIXME try some walk-around
|
// TODO cannot able to STALL Control OUT endpoint !!!!! FIXME try some walk-around
|
||||||
dcd_data.qhd[0][0].stall = dcd_data.qhd[1][0].stall = 1;
|
dcd_data.qhd[0][0].stall = dcd_data.qhd[1][0].stall = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool dcd_pipe_control_xfer(uint8_t coreid, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete)
|
bool hal_dcd_control_xfer(uint8_t coreid, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete)
|
||||||
{
|
{
|
||||||
(void) coreid;
|
(void) coreid;
|
||||||
|
|
||||||
|
@ -167,7 +167,6 @@ tusb_error_t usbd_init (void)
|
|||||||
hal_dcd_init(1);
|
hal_dcd_init(1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//------------- Task init -------------//
|
//------------- Task init -------------//
|
||||||
usbd_queue_hdl = osal_queue_create(USBD_TASK_QUEUE_DEPTH, sizeof(usbd_task_event_t));
|
usbd_queue_hdl = osal_queue_create(USBD_TASK_QUEUE_DEPTH, sizeof(usbd_task_event_t));
|
||||||
ASSERT_PTR(usbd_queue_hdl, TUSB_ERROR_OSAL_QUEUE_FAILED);
|
ASSERT_PTR(usbd_queue_hdl, TUSB_ERROR_OSAL_QUEUE_FAILED);
|
||||||
@ -177,7 +176,6 @@ tusb_error_t usbd_init (void)
|
|||||||
|
|
||||||
osal_task_create(usbd_task, "usbd", TUC_DEVICE_STACKSIZE, NULL, TUSB_CFG_OS_TASK_PRIO);
|
osal_task_create(usbd_task, "usbd", TUC_DEVICE_STACKSIZE, NULL, TUSB_CFG_OS_TASK_PRIO);
|
||||||
|
|
||||||
|
|
||||||
//------------- Descriptor Check -------------//
|
//------------- Descriptor Check -------------//
|
||||||
ASSERT(tusbd_descriptor_pointers.p_device != NULL && tusbd_descriptor_pointers.p_configuration != NULL, TUSB_ERROR_DESCRIPTOR_CORRUPTED);
|
ASSERT(tusbd_descriptor_pointers.p_device != NULL && tusbd_descriptor_pointers.p_configuration != NULL, TUSB_ERROR_DESCRIPTOR_CORRUPTED);
|
||||||
|
|
||||||
@ -259,7 +257,7 @@ tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t
|
|||||||
|
|
||||||
if ( TUSB_ERROR_NONE == error )
|
if ( TUSB_ERROR_NONE == error )
|
||||||
{
|
{
|
||||||
dcd_pipe_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction, (uint8_t*) p_buffer, length, false);
|
hal_dcd_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction, (uint8_t*) p_buffer, length, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( TUSB_REQUEST_SET_ADDRESS == p_request->bRequest )
|
else if ( TUSB_REQUEST_SET_ADDRESS == p_request->bRequest )
|
||||||
@ -307,11 +305,11 @@ tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t
|
|||||||
|
|
||||||
if(TUSB_ERROR_NONE != error)
|
if(TUSB_ERROR_NONE != error)
|
||||||
{ // Response with Protocol Stall if request is not supported
|
{ // Response with Protocol Stall if request is not supported
|
||||||
dcd_pipe_control_stall(coreid);
|
hal_dcd_control_stall(coreid);
|
||||||
// ASSERT(error == TUSB_ERROR_NONE, VOID_RETURN);
|
// ASSERT(error == TUSB_ERROR_NONE, VOID_RETURN);
|
||||||
}else if (p_request->wLength == 0)
|
}else if (p_request->wLength == 0)
|
||||||
{
|
{
|
||||||
dcd_pipe_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction, NULL, 0, false); // zero length for non-data
|
hal_dcd_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction, NULL, 0, false); // zero length for non-data
|
||||||
}
|
}
|
||||||
|
|
||||||
OSAL_SUBTASK_END
|
OSAL_SUBTASK_END
|
||||||
|
Loading…
x
Reference in New Issue
Block a user