rename coreid to port
This commit is contained in:
@@ -60,31 +60,31 @@ typedef enum
|
||||
|
||||
// TODO move Hal
|
||||
typedef struct {
|
||||
uint8_t coreid;
|
||||
uint8_t port;
|
||||
uint8_t index; // must be zero to indicate control
|
||||
} endpoint_handle_t;
|
||||
|
||||
static inline bool edpt_equal(endpoint_handle_t x, endpoint_handle_t y)
|
||||
{
|
||||
return (x.coreid == y.coreid) && (x.index == y.index);
|
||||
return (x.port == y.port) && (x.index == y.index);
|
||||
}
|
||||
|
||||
//------------- Controller API -------------//
|
||||
bool hal_dcd_init (uint8_t coreid);
|
||||
void hal_dcd_connect (uint8_t coreid);
|
||||
void hal_dcd_disconnect (uint8_t coreid);
|
||||
void hal_dcd_set_address (uint8_t coreid, uint8_t dev_addr);
|
||||
void hal_dcd_set_config (uint8_t coreid, uint8_t config_num);
|
||||
bool hal_dcd_init (uint8_t port);
|
||||
void hal_dcd_connect (uint8_t port);
|
||||
void hal_dcd_disconnect (uint8_t port);
|
||||
void hal_dcd_set_address (uint8_t port, uint8_t dev_addr);
|
||||
void hal_dcd_set_config (uint8_t port, uint8_t config_num);
|
||||
|
||||
/*------------- Event function -------------*/
|
||||
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_bus_event(uint8_t port, usbd_bus_event_type_t bus_event);
|
||||
void hal_dcd_setup_received(uint8_t port, uint8_t const* p_request);
|
||||
|
||||
//------------- PIPE API -------------//
|
||||
bool hal_dcd_control_xfer(uint8_t coreid, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete);
|
||||
void hal_dcd_control_stall(uint8_t coreid);
|
||||
bool hal_dcd_control_xfer(uint8_t port, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete);
|
||||
void hal_dcd_control_stall(uint8_t port);
|
||||
|
||||
bool hal_dcd_pipe_open(uint8_t coreid, tusb_descriptor_endpoint_t const * p_endpoint_desc, endpoint_handle_t* eh);
|
||||
bool hal_dcd_pipe_open(uint8_t port, tusb_descriptor_endpoint_t const * p_endpoint_desc, endpoint_handle_t* eh);
|
||||
|
||||
|
||||
tusb_error_t dcd_pipe_queue_xfer(endpoint_handle_t edpt_hdl, uint8_t * buffer, uint16_t total_bytes); // only queue, not transferring yet
|
||||
@@ -92,9 +92,9 @@ tusb_error_t hal_dcd_pipe_xfer(endpoint_handle_t edpt_hdl, uint8_t * buffer, uin
|
||||
|
||||
bool dcd_pipe_is_busy(endpoint_handle_t edpt_hdl);
|
||||
|
||||
// TODO coreid + endpoint address are part of endpoint handle, not endpoint handle, data toggle also need to be reset
|
||||
// TODO port + endpoint address are part of endpoint handle, not endpoint handle, data toggle also need to be reset
|
||||
void hal_dcd_pipe_stall(endpoint_handle_t edpt_hdl);
|
||||
void hal_dcd_pipe_clear_stall(uint8_t coreid, uint8_t edpt_addr);
|
||||
void hal_dcd_pipe_clear_stall(uint8_t port, uint8_t edpt_addr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -122,9 +122,9 @@ static void bus_reset(void)
|
||||
memclr_(&dcd_data, sizeof(dcd_data_t));
|
||||
}
|
||||
|
||||
bool hal_dcd_init(uint8_t coreid)
|
||||
bool hal_dcd_init(uint8_t port)
|
||||
{
|
||||
(void) coreid;
|
||||
(void) port;
|
||||
|
||||
//------------- user manual 11.13 usb device controller initialization -------------// LPC_USB->USBEpInd = 0;
|
||||
// step 6 : set up control endpoint
|
||||
@@ -161,7 +161,7 @@ static void endpoint_non_control_isr(uint32_t eot_int)
|
||||
{
|
||||
endpoint_handle_t edpt_hdl =
|
||||
{
|
||||
.coreid = 0,
|
||||
.port = 0,
|
||||
.index = ep_id,
|
||||
.class_code = dcd_data.class_code[ep_id]
|
||||
};
|
||||
@@ -204,7 +204,7 @@ static void endpoint_control_isr(void)
|
||||
|
||||
if ( BIT_TEST_(dcd_data.control_dma.int_on_complete, ep_id) )
|
||||
{
|
||||
endpoint_handle_t edpt_hdl = { .coreid = 0, .class_code = 0 };
|
||||
endpoint_handle_t edpt_hdl = { .port = 0, .class_code = 0 };
|
||||
dcd_data.control_dma.int_on_complete = 0;
|
||||
|
||||
// FIXME xferred_byte for control xfer is not needed now !!!
|
||||
@@ -216,9 +216,9 @@ static void endpoint_control_isr(void)
|
||||
LPC_USB->USBEpIntClr = endpoint_int_status; // acknowledge interrupt TODO cannot immediately acknowledge setup packet
|
||||
}
|
||||
|
||||
void hal_dcd_isr(uint8_t coreid)
|
||||
void hal_dcd_isr(uint8_t port)
|
||||
{
|
||||
(void) coreid;
|
||||
(void) port;
|
||||
uint32_t const device_int_enable = LPC_USB->USBDevIntEn;
|
||||
uint32_t const device_int_status = LPC_USB->USBDevIntSt & device_int_enable;
|
||||
LPC_USB->USBDevIntClr = device_int_status;// Acknowledge handled interrupt
|
||||
@@ -280,21 +280,21 @@ void hal_dcd_isr(uint8_t coreid)
|
||||
//--------------------------------------------------------------------+
|
||||
// USBD API - CONTROLLER
|
||||
//--------------------------------------------------------------------+
|
||||
void hal_dcd_connect(uint8_t coreid)
|
||||
void hal_dcd_connect(uint8_t port)
|
||||
{
|
||||
(void) coreid;
|
||||
(void) port;
|
||||
sie_write(SIE_CMDCODE_DEVICE_STATUS, 1, 1);
|
||||
}
|
||||
|
||||
void hal_dcd_set_address(uint8_t coreid, uint8_t dev_addr)
|
||||
void hal_dcd_set_address(uint8_t port, uint8_t dev_addr)
|
||||
{
|
||||
(void) coreid;
|
||||
(void) port;
|
||||
sie_write(SIE_CMDCODE_SET_ADDRESS, 1, 0x80 | dev_addr); // 7th bit is : device_enable
|
||||
}
|
||||
|
||||
void hal_dcd_set_config(uint8_t coreid, uint8_t config_num)
|
||||
void hal_dcd_set_config(uint8_t port, uint8_t config_num)
|
||||
{
|
||||
(void) coreid;
|
||||
(void) port;
|
||||
(void) config_num;
|
||||
sie_write(SIE_CMDCODE_CONFIGURE_DEVICE, 1, 1);
|
||||
}
|
||||
@@ -373,14 +373,14 @@ static tusb_error_t pipe_control_read(void * buffer, uint16_t length)
|
||||
//--------------------------------------------------------------------+
|
||||
// CONTROL PIPE API
|
||||
//--------------------------------------------------------------------+
|
||||
void hal_dcd_control_stall(uint8_t coreid)
|
||||
void hal_dcd_control_stall(uint8_t port)
|
||||
{
|
||||
sie_write(SIE_CMDCODE_ENDPOINT_SET_STATUS+0, 1, SIE_SET_ENDPOINT_STALLED_MASK | SIE_SET_ENDPOINT_CONDITION_STALLED_MASK);
|
||||
}
|
||||
|
||||
bool hal_dcd_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 port, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete)
|
||||
{
|
||||
(void) coreid;
|
||||
(void) port;
|
||||
|
||||
VERIFY( !(length != 0 && p_buffer == NULL) );
|
||||
|
||||
@@ -412,9 +412,9 @@ bool hal_dcd_control_xfer(uint8_t coreid, tusb_direction_t dir, uint8_t * p_buff
|
||||
//--------------------------------------------------------------------+
|
||||
// BULK/INTERRUPT/ISO PIPE API
|
||||
//--------------------------------------------------------------------+
|
||||
endpoint_handle_t hal_dcd_pipe_open(uint8_t coreid, tusb_descriptor_endpoint_t const * p_endpoint_desc, uint8_t class_code)
|
||||
endpoint_handle_t hal_dcd_pipe_open(uint8_t port, tusb_descriptor_endpoint_t const * p_endpoint_desc, uint8_t class_code)
|
||||
{
|
||||
(void) coreid;
|
||||
(void) port;
|
||||
|
||||
endpoint_handle_t const null_handle = { 0 };
|
||||
|
||||
@@ -442,7 +442,7 @@ endpoint_handle_t hal_dcd_pipe_open(uint8_t coreid, tusb_descriptor_endpoint_t c
|
||||
|
||||
return (endpoint_handle_t)
|
||||
{
|
||||
.coreid = 0,
|
||||
.port = 0,
|
||||
.index = ep_id,
|
||||
.class_code = class_code
|
||||
};
|
||||
@@ -458,7 +458,7 @@ void hal_dcd_pipe_stall(endpoint_handle_t edpt_hdl)
|
||||
sie_write(SIE_CMDCODE_ENDPOINT_SET_STATUS+edpt_hdl.index, 1, SIE_SET_ENDPOINT_STALLED_MASK);
|
||||
}
|
||||
|
||||
void hal_dcd_pipe_clear_stall(uint8_t coreid, uint8_t edpt_addr)
|
||||
void hal_dcd_pipe_clear_stall(uint8_t port, uint8_t edpt_addr)
|
||||
{
|
||||
uint8_t ep_id = edpt_addr2phy(edpt_addr);
|
||||
|
||||
|
||||
@@ -164,28 +164,28 @@ static void queue_xfer_in_next_td(uint8_t ep_id);
|
||||
//--------------------------------------------------------------------+
|
||||
// CONTROLLER API
|
||||
//--------------------------------------------------------------------+
|
||||
void hal_dcd_connect(uint8_t coreid)
|
||||
void hal_dcd_connect(uint8_t port)
|
||||
{
|
||||
(void) coreid;
|
||||
(void) port;
|
||||
LPC_USB->DEVCMDSTAT |= CMDSTAT_DEVICE_CONNECT_MASK;
|
||||
}
|
||||
|
||||
void hal_dcd_set_config(uint8_t coreid, uint8_t config_num)
|
||||
void hal_dcd_set_config(uint8_t port, uint8_t config_num)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void hal_dcd_set_address(uint8_t coreid, uint8_t dev_addr)
|
||||
void hal_dcd_set_address(uint8_t port, uint8_t dev_addr)
|
||||
{
|
||||
(void) coreid;
|
||||
(void) port;
|
||||
|
||||
LPC_USB->DEVCMDSTAT &= ~CMDSTAT_DEVICE_ADDR_MASK;
|
||||
LPC_USB->DEVCMDSTAT |= dev_addr;
|
||||
}
|
||||
|
||||
bool hal_dcd_init(uint8_t coreid)
|
||||
bool hal_dcd_init(uint8_t port)
|
||||
{
|
||||
(void) coreid;
|
||||
(void) port;
|
||||
|
||||
LPC_USB->EPLISTSTART = (uint32_t) dcd_data.qhd;
|
||||
LPC_USB->DATABUFSTART = 0x20000000; // only SRAM1 & USB RAM can be used for transfer
|
||||
@@ -248,7 +248,7 @@ static void endpoint_non_control_isr(uint32_t int_status)
|
||||
{
|
||||
endpoint_handle_t edpt_hdl =
|
||||
{
|
||||
.coreid = 0,
|
||||
.port = 0,
|
||||
.index = ep_id,
|
||||
.class_code = dcd_data.class_code[ep_id]
|
||||
};
|
||||
@@ -286,7 +286,7 @@ static void endpoint_control_isr(uint32_t int_status)
|
||||
|
||||
if ( BIT_TEST_(dcd_data.current_ioc, ep_id) )
|
||||
{
|
||||
endpoint_handle_t edpt_hdl = { .coreid = 0 };
|
||||
endpoint_handle_t edpt_hdl = { .port = 0 };
|
||||
|
||||
dcd_data.current_ioc = BIT_CLR_(dcd_data.current_ioc, ep_id);
|
||||
|
||||
@@ -296,9 +296,9 @@ static void endpoint_control_isr(uint32_t int_status)
|
||||
}
|
||||
}
|
||||
|
||||
void hal_dcd_isr(uint8_t coreid)
|
||||
void hal_dcd_isr(uint8_t port)
|
||||
{
|
||||
(void) coreid;
|
||||
(void) port;
|
||||
|
||||
uint32_t const int_enable = LPC_USB->INTEN;
|
||||
uint32_t const int_status = LPC_USB->INTSTAT & int_enable;
|
||||
@@ -349,7 +349,7 @@ void hal_dcd_isr(uint8_t coreid)
|
||||
if ( BIT_TEST_(int_status, 0) && (dev_cmd_stat & CMDSTAT_SETUP_RECEIVED_MASK) )
|
||||
{ // received control request from host
|
||||
// copy setup request & acknowledge so that the next setup can be received by hw
|
||||
hal_dcd_setup_received(coreid, (uint8_t*)&dcd_data.setup_request);
|
||||
hal_dcd_setup_received(port, (uint8_t*)&dcd_data.setup_request);
|
||||
|
||||
// NXP control flowchart clear Active & Stall on both Control IN/OUT endpoints
|
||||
dcd_data.qhd[0][0].stall = dcd_data.qhd[1][0].stall = 0;
|
||||
@@ -373,16 +373,16 @@ void hal_dcd_isr(uint8_t coreid)
|
||||
//--------------------------------------------------------------------+
|
||||
// CONTROL PIPE API
|
||||
//--------------------------------------------------------------------+
|
||||
void hal_dcd_control_stall(uint8_t coreid)
|
||||
void hal_dcd_control_stall(uint8_t port)
|
||||
{
|
||||
(void) coreid;
|
||||
(void) port;
|
||||
// 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;
|
||||
}
|
||||
|
||||
bool hal_dcd_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 port, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete)
|
||||
{
|
||||
(void) coreid;
|
||||
(void) port;
|
||||
|
||||
// determine Endpoint where Data & Status phase occurred (IN or OUT)
|
||||
uint8_t const ep_data = (dir == TUSB_DIR_DEV_TO_HOST) ? 1 : 0;
|
||||
@@ -438,7 +438,7 @@ bool dcd_pipe_is_stalled(endpoint_handle_t edpt_hdl)
|
||||
return dcd_data.qhd[edpt_hdl.index][0].stall || dcd_data.qhd[edpt_hdl.index][1].stall;
|
||||
}
|
||||
|
||||
void hal_dcd_pipe_clear_stall(uint8_t coreid, uint8_t edpt_addr)
|
||||
void hal_dcd_pipe_clear_stall(uint8_t port, uint8_t edpt_addr)
|
||||
{
|
||||
uint8_t ep_id = edpt_addr2phy(edpt_addr);
|
||||
// uint8_t active_buffer = BIT_TEST_(LPC_USB->EPINUSE, ep_id) ? 1 : 0;
|
||||
@@ -456,9 +456,9 @@ void hal_dcd_pipe_clear_stall(uint8_t coreid, uint8_t edpt_addr)
|
||||
}
|
||||
}
|
||||
|
||||
endpoint_handle_t hal_dcd_pipe_open(uint8_t coreid, tusb_descriptor_endpoint_t const * p_endpoint_desc, uint8_t class_code)
|
||||
endpoint_handle_t hal_dcd_pipe_open(uint8_t port, tusb_descriptor_endpoint_t const * p_endpoint_desc, uint8_t class_code)
|
||||
{
|
||||
(void) coreid;
|
||||
(void) port;
|
||||
endpoint_handle_t const null_handle = { 0 };
|
||||
|
||||
if (p_endpoint_desc->bmAttributes.xfer == TUSB_XFER_ISOCHRONOUS) return null_handle; // TODO not support ISO yet
|
||||
@@ -483,7 +483,7 @@ endpoint_handle_t hal_dcd_pipe_open(uint8_t coreid, tusb_descriptor_endpoint_t c
|
||||
|
||||
return (endpoint_handle_t)
|
||||
{
|
||||
.coreid = 0,
|
||||
.port = 0,
|
||||
.index = ep_id,
|
||||
.class_code = class_code
|
||||
};
|
||||
|
||||
@@ -102,15 +102,15 @@ enum { USBD_CLASS_DRIVER_COUNT = sizeof(usbd_class_drivers) / sizeof(usbd_class_
|
||||
//--------------------------------------------------------------------+
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
static tusb_error_t usbd_set_configure_received(uint8_t coreid, uint8_t config_number);
|
||||
static tusb_error_t get_descriptor(uint8_t coreid, tusb_control_request_t const * const p_request, uint8_t const ** pp_buffer, uint16_t * p_length);
|
||||
static tusb_error_t usbd_set_configure_received(uint8_t port, uint8_t config_number);
|
||||
static tusb_error_t get_descriptor(uint8_t port, tusb_control_request_t const * const p_request, uint8_t const ** pp_buffer, uint16_t * p_length);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION INTERFACE
|
||||
//--------------------------------------------------------------------+
|
||||
bool tud_mounted(uint8_t coreid)
|
||||
bool tud_mounted(uint8_t port)
|
||||
{
|
||||
return usbd_devices[coreid].state == TUSB_DEVICE_STATE_CONFIGURED;
|
||||
return usbd_devices[port].state == TUSB_DEVICE_STATE_CONFIGURED;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
@@ -129,7 +129,7 @@ typedef enum
|
||||
|
||||
typedef struct ATTR_ALIGNED(4)
|
||||
{
|
||||
uint8_t coreid;
|
||||
uint8_t port;
|
||||
uint8_t event_id;
|
||||
uint8_t sub_event_id;
|
||||
uint8_t reserved;
|
||||
@@ -161,7 +161,7 @@ static osal_queue_t usbd_queue_hdl;
|
||||
//--------------------------------------------------------------------+
|
||||
// IMPLEMENTATION
|
||||
//--------------------------------------------------------------------+
|
||||
tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t const * const p_request);
|
||||
tusb_error_t usbd_control_request_subtask(uint8_t port, tusb_control_request_t const * const p_request);
|
||||
static tusb_error_t usbd_body_subtask(void);
|
||||
|
||||
tusb_error_t usbd_init (void)
|
||||
@@ -244,7 +244,7 @@ static tusb_error_t usbd_body_subtask(void)
|
||||
|
||||
if ( USBD_EVENTID_SETUP_RECEIVED == event.event_id )
|
||||
{
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT( usbd_control_request_subtask(event.coreid, &event.setup_received), error );
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT( usbd_control_request_subtask(event.port, &event.setup_received), error );
|
||||
}else if (USBD_EVENTID_XFER_DONE == event.event_id)
|
||||
{
|
||||
// Call class handling function, Class that endpoint not belong to should check and return
|
||||
@@ -261,7 +261,7 @@ static tusb_error_t usbd_body_subtask(void)
|
||||
{
|
||||
if ( usbd_class_drivers[class_code].sof )
|
||||
{
|
||||
usbd_class_drivers[class_code].sof( event.coreid );
|
||||
usbd_class_drivers[class_code].sof( event.port );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,7 +276,7 @@ static tusb_error_t usbd_body_subtask(void)
|
||||
//--------------------------------------------------------------------+
|
||||
// CONTROL REQUEST
|
||||
//--------------------------------------------------------------------+
|
||||
tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t const * const p_request)
|
||||
tusb_error_t usbd_control_request_subtask(uint8_t port, tusb_control_request_t const * const p_request)
|
||||
{
|
||||
OSAL_SUBTASK_BEGIN
|
||||
|
||||
@@ -292,21 +292,21 @@ tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t
|
||||
uint8_t const * p_buffer = NULL;
|
||||
uint16_t length = 0;
|
||||
|
||||
error = get_descriptor(coreid, p_request, &p_buffer, &length);
|
||||
error = get_descriptor(port, p_request, &p_buffer, &length);
|
||||
|
||||
if ( TUSB_ERROR_NONE == error )
|
||||
{
|
||||
hal_dcd_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction, (uint8_t*) p_buffer, length, false);
|
||||
hal_dcd_control_xfer(port, (tusb_direction_t) p_request->bmRequestType_bit.direction, (uint8_t*) p_buffer, length, false);
|
||||
}
|
||||
}
|
||||
else if ( TUSB_REQUEST_SET_ADDRESS == p_request->bRequest )
|
||||
{
|
||||
hal_dcd_set_address(coreid, (uint8_t) p_request->wValue);
|
||||
usbd_devices[coreid].state = TUSB_DEVICE_STATE_ADDRESSED;
|
||||
hal_dcd_set_address(port, (uint8_t) p_request->wValue);
|
||||
usbd_devices[port].state = TUSB_DEVICE_STATE_ADDRESSED;
|
||||
}
|
||||
else if ( TUSB_REQUEST_SET_CONFIGURATION == p_request->bRequest )
|
||||
{
|
||||
usbd_set_configure_received(coreid, (uint8_t) p_request->wValue);
|
||||
usbd_set_configure_received(port, (uint8_t) p_request->wValue);
|
||||
}else
|
||||
{
|
||||
error = TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT;
|
||||
@@ -317,13 +317,13 @@ tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t
|
||||
{
|
||||
static uint8_t class_code;
|
||||
|
||||
class_code = usbd_devices[coreid].interface2class[ u16_low_u8(p_request->wIndex) ];
|
||||
class_code = usbd_devices[port].interface2class[ u16_low_u8(p_request->wIndex) ];
|
||||
|
||||
// TODO [Custom] TUSB_CLASS_DIAGNOSTIC, vendor etc ...
|
||||
if ( (class_code > 0) && (class_code < USBD_CLASS_DRIVER_COUNT) &&
|
||||
usbd_class_drivers[class_code].control_request_subtask )
|
||||
{
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT( usbd_class_drivers[class_code].control_request_subtask(coreid, p_request), error );
|
||||
OSAL_SUBTASK_INVOKED_AND_WAIT( usbd_class_drivers[class_code].control_request_subtask(port, p_request), error );
|
||||
}else
|
||||
{
|
||||
error = TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT;
|
||||
@@ -335,7 +335,7 @@ tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t
|
||||
TUSB_REQUEST_TYPE_STANDARD == p_request->bmRequestType_bit.type &&
|
||||
TUSB_REQUEST_CLEAR_FEATURE == p_request->bRequest )
|
||||
{
|
||||
hal_dcd_pipe_clear_stall(coreid, u16_low_u8(p_request->wIndex) );
|
||||
hal_dcd_pipe_clear_stall(port, u16_low_u8(p_request->wIndex) );
|
||||
} else
|
||||
{
|
||||
error = TUSB_ERROR_DCD_CONTROL_REQUEST_NOT_SUPPORT;
|
||||
@@ -343,11 +343,11 @@ tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t
|
||||
|
||||
if(TUSB_ERROR_NONE != error)
|
||||
{ // Response with Protocol Stall if request is not supported
|
||||
hal_dcd_control_stall(coreid);
|
||||
hal_dcd_control_stall(port);
|
||||
// ASSERT(error == TUSB_ERROR_NONE, VOID_RETURN);
|
||||
}else if (p_request->wLength == 0)
|
||||
{
|
||||
hal_dcd_control_xfer(coreid, (tusb_direction_t) p_request->bmRequestType_bit.direction, NULL, 0, false); // zero length for non-data
|
||||
hal_dcd_control_xfer(port, (tusb_direction_t) p_request->bmRequestType_bit.direction, NULL, 0, false); // zero length for non-data
|
||||
}
|
||||
|
||||
OSAL_SUBTASK_END
|
||||
@@ -355,10 +355,10 @@ tusb_error_t usbd_control_request_subtask(uint8_t coreid, tusb_control_request_t
|
||||
|
||||
// TODO Host (windows) can get HID report descriptor before set configured
|
||||
// may need to open interface before set configured
|
||||
static tusb_error_t usbd_set_configure_received(uint8_t coreid, uint8_t config_number)
|
||||
static tusb_error_t usbd_set_configure_received(uint8_t port, uint8_t config_number)
|
||||
{
|
||||
hal_dcd_set_config(coreid, config_number);
|
||||
usbd_devices[coreid].state = TUSB_DEVICE_STATE_CONFIGURED;
|
||||
hal_dcd_set_config(port, config_number);
|
||||
usbd_devices[port].state = TUSB_DEVICE_STATE_CONFIGURED;
|
||||
|
||||
//------------- parse configuration & open drivers -------------//
|
||||
uint8_t const * p_desc_config = tusbd_descriptor_pointers.p_configuration;
|
||||
@@ -381,12 +381,12 @@ static tusb_error_t usbd_set_configure_received(uint8_t coreid, uint8_t config_n
|
||||
class_index = p_desc_interface->bInterfaceClass;
|
||||
|
||||
ASSERT( class_index != 0 && class_index < USBD_CLASS_DRIVER_COUNT && usbd_class_drivers[class_index].open != NULL, TUSB_ERROR_NOT_SUPPORTED_YET );
|
||||
ASSERT( 0 == usbd_devices[coreid].interface2class[p_desc_interface->bInterfaceNumber], TUSB_ERROR_FAILED); // duplicate interface number TODO alternate setting
|
||||
ASSERT( 0 == usbd_devices[port].interface2class[p_desc_interface->bInterfaceNumber], TUSB_ERROR_FAILED); // duplicate interface number TODO alternate setting
|
||||
|
||||
usbd_devices[coreid].interface2class[p_desc_interface->bInterfaceNumber] = class_index;
|
||||
usbd_devices[port].interface2class[p_desc_interface->bInterfaceNumber] = class_index;
|
||||
|
||||
uint16_t length=0;
|
||||
ASSERT_STATUS( usbd_class_drivers[class_index].open( coreid, p_desc_interface, &length ) );
|
||||
ASSERT_STATUS( usbd_class_drivers[class_index].open( port, p_desc_interface, &length ) );
|
||||
|
||||
ASSERT( length >= sizeof(tusb_descriptor_interface_t), TUSB_ERROR_FAILED );
|
||||
p_desc += length;
|
||||
@@ -394,12 +394,12 @@ static tusb_error_t usbd_set_configure_received(uint8_t coreid, uint8_t config_n
|
||||
}
|
||||
|
||||
// invoke callback
|
||||
tud_mount_cb(coreid);
|
||||
tud_mount_cb(port);
|
||||
|
||||
return TUSB_ERROR_NONE;
|
||||
}
|
||||
|
||||
static tusb_error_t get_descriptor(uint8_t coreid, tusb_control_request_t const * const p_request, uint8_t const ** pp_buffer, uint16_t * p_length)
|
||||
static tusb_error_t get_descriptor(uint8_t port, tusb_control_request_t const * const p_request, uint8_t const ** pp_buffer, uint16_t * p_length)
|
||||
{
|
||||
tusb_std_descriptor_type_t const desc_type = (tusb_std_descriptor_type_t) u16_high_u8(p_request->wValue);
|
||||
uint8_t const desc_index = u16_low_u8( p_request->wValue );
|
||||
@@ -448,28 +448,28 @@ static tusb_error_t get_descriptor(uint8_t coreid, tusb_control_request_t const
|
||||
//--------------------------------------------------------------------+
|
||||
// USBD-DCD Callback API
|
||||
//--------------------------------------------------------------------+
|
||||
void hal_dcd_bus_event(uint8_t coreid, usbd_bus_event_type_t bus_event)
|
||||
void hal_dcd_bus_event(uint8_t port, usbd_bus_event_type_t bus_event)
|
||||
{
|
||||
switch(bus_event)
|
||||
{
|
||||
case USBD_BUS_EVENT_RESET :
|
||||
memclr_(&usbd_devices[coreid], sizeof(usbd_device_info_t));
|
||||
memclr_(&usbd_devices[port], sizeof(usbd_device_info_t));
|
||||
osal_queue_flush(usbd_queue_hdl);
|
||||
osal_semaphore_reset(usbd_control_xfer_sem_hdl);
|
||||
for (uint8_t class_code = TUSB_CLASS_AUDIO; class_code < USBD_CLASS_DRIVER_COUNT; class_code++)
|
||||
{
|
||||
if ( usbd_class_drivers[class_code].close ) usbd_class_drivers[class_code].close( coreid );
|
||||
if ( usbd_class_drivers[class_code].close ) usbd_class_drivers[class_code].close( port );
|
||||
}
|
||||
|
||||
// invoke callback
|
||||
tud_umount_cb(coreid);
|
||||
tud_umount_cb(port);
|
||||
break;
|
||||
|
||||
case USBD_BUS_EVENT_SOF:
|
||||
{
|
||||
usbd_task_event_t task_event =
|
||||
{
|
||||
.coreid = coreid,
|
||||
.port = port,
|
||||
.event_id = USBD_EVENTID_SOF,
|
||||
};
|
||||
osal_queue_send(usbd_queue_hdl, &task_event);
|
||||
@@ -479,18 +479,18 @@ void hal_dcd_bus_event(uint8_t coreid, usbd_bus_event_type_t bus_event)
|
||||
case USBD_BUS_EVENT_UNPLUGGED : break;
|
||||
|
||||
case USBD_BUS_EVENT_SUSPENDED:
|
||||
usbd_devices[coreid].state = TUSB_DEVICE_STATE_SUSPENDED;
|
||||
usbd_devices[port].state = TUSB_DEVICE_STATE_SUSPENDED;
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
void hal_dcd_setup_received(uint8_t coreid, uint8_t const* p_request)
|
||||
void hal_dcd_setup_received(uint8_t port, uint8_t const* p_request)
|
||||
{
|
||||
usbd_task_event_t task_event =
|
||||
{
|
||||
.coreid = coreid,
|
||||
.port = port,
|
||||
.event_id = USBD_EVENTID_SETUP_RECEIVED,
|
||||
};
|
||||
|
||||
@@ -508,7 +508,7 @@ void usbd_xfer_isr(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32_t xfer
|
||||
{
|
||||
usbd_task_event_t task_event =
|
||||
{
|
||||
.coreid = edpt_hdl.coreid,
|
||||
.port = edpt_hdl.port,
|
||||
.event_id = USBD_EVENTID_XFER_DONE,
|
||||
.sub_event_id = event
|
||||
};
|
||||
|
||||
@@ -79,32 +79,32 @@ extern tusbd_descriptor_pointer_t tusbd_descriptor_pointers;
|
||||
typedef struct {
|
||||
void (* init) (void);
|
||||
tusb_error_t (* open)(uint8_t, tusb_descriptor_interface_t const *, uint16_t*);
|
||||
tusb_error_t (* control_request_subtask) (uint8_t coreid, tusb_control_request_t const *);
|
||||
tusb_error_t (* control_request_subtask) (uint8_t port, tusb_control_request_t const *);
|
||||
tusb_error_t (* xfer_cb) (endpoint_handle_t, tusb_event_t, uint32_t);
|
||||
// void (* routine)(void);
|
||||
void (* sof)(uint8_t coreid);
|
||||
void (* sof)(uint8_t port);
|
||||
void (* close) (uint8_t);
|
||||
} usbd_class_driver_t;
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// APPLICATION API
|
||||
//--------------------------------------------------------------------+
|
||||
bool tud_mounted(uint8_t coreid);
|
||||
bool tud_mounted(uint8_t port);
|
||||
|
||||
/*------------- Callback -------------*/
|
||||
/** \brief Callback function that will be invoked device is mounted (configured) by USB host
|
||||
* \param[in] coreid USB Controller ID of the interface
|
||||
* \param[in] port USB Controller ID of the interface
|
||||
* \note This callback should be used by Application to \b set-up application data
|
||||
*/
|
||||
void tud_mount_cb(uint8_t coreid);
|
||||
void tud_mount_cb(uint8_t port);
|
||||
|
||||
/** \brief Callback function that will be invoked when device is unmounted (bus reset/unplugged)
|
||||
* \param[in] coreid USB Controller ID of the interface
|
||||
* \param[in] port USB Controller ID of the interface
|
||||
* \note This callback should be used by Application to \b tear-down application data
|
||||
*/
|
||||
void tud_umount_cb(uint8_t coreid);
|
||||
void tud_umount_cb(uint8_t port);
|
||||
|
||||
//void tud_device_suspended_cb(uint8_t coreid);
|
||||
//void tud_device_suspended_cb(uint8_t port);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// CLASS-USBD & INTERNAL API
|
||||
|
||||
Reference in New Issue
Block a user