rename usbd_dcd_bus_event_isr to hal_dcd_bus_event

This commit is contained in:
hathach 2018-03-03 16:24:43 +07:00
parent 394302c8cb
commit 185b240f03
6 changed files with 32 additions and 28 deletions

View File

@ -534,7 +534,7 @@ void dcd_isr(uint8_t coreid)
if (int_status & INT_MASK_RESET) if (int_status & INT_MASK_RESET)
{ {
bus_reset(coreid); bus_reset(coreid);
usbd_dcd_bus_event_isr(0, USBD_BUS_EVENT_RESET); hal_dcd_bus_event(coreid, USBD_BUS_EVENT_RESET);
} }
if (int_status & INT_MASK_SUSPEND) if (int_status & INT_MASK_SUSPEND)
@ -543,7 +543,7 @@ void dcd_isr(uint8_t coreid)
{ // Note: Host may delay more than 3 ms before and/or after bus reset before doing enumeration. { // Note: Host may delay more than 3 ms before and/or after bus reset before doing enumeration.
if ((lpc_usb->DEVICEADDR >> 25) & 0x0f) if ((lpc_usb->DEVICEADDR >> 25) & 0x0f)
{ {
usbd_dcd_bus_event_isr(0, USBD_BUS_EVENT_SUSPENDED); hal_dcd_bus_event(0, USBD_BUS_EVENT_SUSPENDED);
} }
} }
} }
@ -553,7 +553,7 @@ void dcd_isr(uint8_t coreid)
// { // {
// if ( !(lpc_usb->PORTSC1_D & PORTSC_CURRENT_CONNECT_STATUS_MASK) ) // if ( !(lpc_usb->PORTSC1_D & PORTSC_CURRENT_CONNECT_STATUS_MASK) )
// { // {
// usbd_dcd_bus_event_isr(0, USBD_BUS_EVENT_UNPLUGGED); // hal_dcd_bus_event(0, USBD_BUS_EVENT_UNPLUGGED);
// } // }
// } // }

View File

@ -49,6 +49,14 @@
extern "C" { extern "C" {
#endif #endif
typedef enum
{
USBD_BUS_EVENT_RESET = 1,
USBD_BUS_EVENT_UNPLUGGED,
USBD_BUS_EVENT_SUSPENDED,
USBD_BUS_EVENT_RESUME
}usbd_bus_event_type_t;
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
@ -68,15 +76,19 @@ static inline bool endpointhandle_is_equal(endpoint_handle_t x, endpoint_handle_
return (x.coreid == y.coreid) && (x.index == y.index) && (x.class_code == y.class_code); return (x.coreid == y.coreid) && (x.index == y.index) && (x.class_code == y.class_code);
} }
bool hal_dcd_init(uint8_t coreid);
void dcd_isr(uint8_t coreid); void dcd_isr(uint8_t coreid);
//------------- Controller API -------------// //------------- Controller API -------------//
void hal_dcd_connect (uint8_t coreid); bool hal_dcd_init (uint8_t coreid);
void hal_dcd_disconnect (uint8_t coreid); void hal_dcd_connect (uint8_t coreid);
void hal_dcd_set_address(uint8_t coreid, uint8_t dev_addr); void hal_dcd_disconnect (uint8_t coreid);
void hal_dcd_set_config (uint8_t coreid, uint8_t config_num); void hal_dcd_set_address (uint8_t coreid, uint8_t dev_addr);
void hal_dcd_set_config (uint8_t coreid, uint8_t config_num);
/*------------- Event function -------------*/
void hal_dcd_setup_received(uint8_t coreid, uint8_t const* p_request);
void hal_dcd_bus_event(uint8_t coreid, usbd_bus_event_type_t bus_event);
//------------- 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 dcd_pipe_control_xfer(uint8_t coreid, tusb_direction_t dir, uint8_t * p_buffer, uint16_t length, bool int_on_complete);

View File

@ -230,23 +230,23 @@ void dcd_isr(uint8_t coreid)
if (dev_status_reg & SIE_DEV_STATUS_RESET_MASK) if (dev_status_reg & SIE_DEV_STATUS_RESET_MASK)
{ {
bus_reset(); bus_reset();
usbd_dcd_bus_event_isr(0, USBD_BUS_EVENT_RESET); hal_dcd_bus_event(0, USBD_BUS_EVENT_RESET);
} }
if (dev_status_reg & SIE_DEV_STATUS_CONNECT_CHANGE_MASK) if (dev_status_reg & SIE_DEV_STATUS_CONNECT_CHANGE_MASK)
{ // device is disconnected, require using VBUS (P1_30) { // device is disconnected, require using VBUS (P1_30)
usbd_dcd_bus_event_isr(0, USBD_BUS_EVENT_UNPLUGGED); hal_dcd_bus_event(0, USBD_BUS_EVENT_UNPLUGGED);
} }
if (dev_status_reg & SIE_DEV_STATUS_SUSPEND_CHANGE_MASK) if (dev_status_reg & SIE_DEV_STATUS_SUSPEND_CHANGE_MASK)
{ {
if (dev_status_reg & SIE_DEV_STATUS_SUSPEND_MASK) if (dev_status_reg & SIE_DEV_STATUS_SUSPEND_MASK)
{ {
usbd_dcd_bus_event_isr(0, USBD_BUS_EVENT_SUSPENDED); hal_dcd_bus_event(0, USBD_BUS_EVENT_SUSPENDED);
} }
// else // else
// { // {
// usbd_dcd_bus_event_isr(0, USBD_BUS_EVENT_RESUME); // hal_dcd_bus_event(0, USBD_BUS_EVENT_RESUME);
// } // }
} }
} }

View File

@ -315,14 +315,14 @@ void dcd_isr(uint8_t coreid)
if ( dev_cmd_stat & CMDSTAT_RESET_CHANGE_MASK) // bus reset if ( dev_cmd_stat & CMDSTAT_RESET_CHANGE_MASK) // bus reset
{ {
bus_reset(); bus_reset();
usbd_dcd_bus_event_isr(0, USBD_BUS_EVENT_RESET); hal_dcd_bus_event(0, USBD_BUS_EVENT_RESET);
} }
if (dev_cmd_stat & CMDSTAT_CONNECT_CHANGE_MASK) if (dev_cmd_stat & CMDSTAT_CONNECT_CHANGE_MASK)
{ // device disconnect { // device disconnect
if (dev_cmd_stat & CMDSTAT_DEVICE_ADDR_MASK) if (dev_cmd_stat & CMDSTAT_DEVICE_ADDR_MASK)
{ // debouncing as this can be set when device is powering { // debouncing as this can be set when device is powering
usbd_dcd_bus_event_isr(0, USBD_BUS_EVENT_UNPLUGGED); hal_dcd_bus_event(0, USBD_BUS_EVENT_UNPLUGGED);
} }
} }
@ -334,13 +334,13 @@ void dcd_isr(uint8_t coreid)
// Note: Host may delay more than 3 ms before and/or after bus reset before doing enumeration. // Note: Host may delay more than 3 ms before and/or after bus reset before doing enumeration.
if (dev_cmd_stat & CMDSTAT_DEVICE_ADDR_MASK) if (dev_cmd_stat & CMDSTAT_DEVICE_ADDR_MASK)
{ {
usbd_dcd_bus_event_isr(0, USBD_BUS_EVENT_SUSPENDED); hal_dcd_bus_event(0, USBD_BUS_EVENT_SUSPENDED);
} }
} }
} }
// else // else
// { // resume signal // { // resume signal
// usbd_dcd_bus_event_isr(0, USBD_BUS_EVENT_RESUME); // hal_dcd_bus_event(0, USBD_BUS_EVENT_RESUME);
// } // }
// } // }
} }

View File

@ -409,12 +409,11 @@ static tusb_error_t get_descriptor(uint8_t coreid, tusb_control_request_t const
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// USBD-DCD Callback API // USBD-DCD Callback API
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void usbd_dcd_bus_event_isr(uint8_t coreid, usbd_bus_event_type_t bus_event) void hal_dcd_bus_event(uint8_t coreid, usbd_bus_event_type_t bus_event)
{ {
switch(bus_event) switch(bus_event)
{ {
case USBD_BUS_EVENT_RESET : case USBD_BUS_EVENT_RESET :
case USBD_BUS_EVENT_UNPLUGGED :
memclr_(&usbd_devices[coreid], sizeof(usbd_device_info_t)); memclr_(&usbd_devices[coreid], sizeof(usbd_device_info_t));
osal_queue_flush(usbd_queue_hdl); osal_queue_flush(usbd_queue_hdl);
osal_semaphore_reset(usbd_control_xfer_sem_hdl); osal_semaphore_reset(usbd_control_xfer_sem_hdl);
@ -424,6 +423,8 @@ void usbd_dcd_bus_event_isr(uint8_t coreid, usbd_bus_event_type_t bus_event)
} }
break; break;
case USBD_BUS_EVENT_UNPLUGGED : break;
case USBD_BUS_EVENT_SUSPENDED: case USBD_BUS_EVENT_SUSPENDED:
usbd_devices[coreid].state = TUSB_DEVICE_STATE_SUSPENDED; usbd_devices[coreid].state = TUSB_DEVICE_STATE_SUSPENDED;
break; break;

View File

@ -55,13 +55,7 @@ enum {
USBD_INTERFACE_NUM_MAX = 16 // USB specs specify up to 16 endpoints per device USBD_INTERFACE_NUM_MAX = 16 // USB specs specify up to 16 endpoints per device
}; };
typedef enum
{
USBD_BUS_EVENT_RESET = 1,
USBD_BUS_EVENT_UNPLUGGED,
USBD_BUS_EVENT_SUSPENDED,
USBD_BUS_EVENT_RESUME
}usbd_bus_event_type_t;
typedef struct { typedef struct {
volatile uint8_t state; volatile uint8_t state;
@ -74,9 +68,6 @@ extern usbd_device_info_t usbd_devices[CONTROLLER_DEVICE_NUMBER];
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// callback from DCD ISR // callback from DCD ISR
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
void usbd_dcd_bus_event_isr(uint8_t coreid, usbd_bus_event_type_t bus_event);
void hal_dcd_setup_received(uint8_t coreid, uint8_t const* p_request);
void usbd_xfer_isr(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32_t xferred_bytes); void usbd_xfer_isr(endpoint_handle_t edpt_hdl, tusb_event_t event, uint32_t xferred_bytes);