Merge pull request #93 from heyuanjie87/ForPullRequest
For pull request
This commit is contained in:
commit
b0c7d480ee
|
@ -42,8 +42,8 @@ struct uendpoint;
|
|||
struct udcd_ops
|
||||
{
|
||||
rt_err_t (*set_address)(rt_uint8_t value);
|
||||
rt_err_t (*clear_feature)(rt_uint8_t value);
|
||||
rt_err_t (*set_feature)(rt_uint8_t value);
|
||||
rt_err_t (*clear_feature)(rt_uint16_t value, rt_uint16_t index);
|
||||
rt_err_t (*set_feature)(rt_uint16_t value, rt_uint16_t index);
|
||||
rt_err_t (*ep_alloc)(struct uendpoint* ep);
|
||||
rt_err_t (*ep_free)(struct uendpoint* ep);
|
||||
rt_err_t (*ep_stall)(struct uendpoint* ep);
|
||||
|
@ -212,18 +212,18 @@ rt_inline rt_err_t dcd_set_address(udcd_t dcd, rt_uint8_t value)
|
|||
return dcd->ops->set_address(value);
|
||||
}
|
||||
|
||||
rt_inline rt_err_t dcd_clear_feature(udcd_t dcd, rt_uint8_t value)
|
||||
rt_inline rt_err_t dcd_clear_feature(udcd_t dcd, rt_uint16_t value, rt_uint16_t index)
|
||||
{
|
||||
RT_ASSERT(dcd != RT_NULL);
|
||||
|
||||
return dcd->ops->clear_feature(value);
|
||||
return dcd->ops->clear_feature(value, index);
|
||||
}
|
||||
|
||||
rt_inline rt_err_t dcd_set_feature(udcd_t dcd, rt_uint8_t value)
|
||||
rt_inline rt_err_t dcd_set_feature(udcd_t dcd, rt_uint8_t value, rt_uint16_t index)
|
||||
{
|
||||
RT_ASSERT(dcd != RT_NULL);
|
||||
|
||||
return dcd->ops->set_feature(value);
|
||||
return dcd->ops->set_feature(value, index);
|
||||
}
|
||||
|
||||
rt_inline rt_err_t dcd_ep_stall(udcd_t dcd, uep_t ep)
|
||||
|
|
|
@ -256,6 +256,7 @@ static rt_err_t _set_interface(struct udevice* device, ureq_t setup)
|
|||
dcd_ep_stop(device->dcd, ep);
|
||||
dcd_ep_run(device->dcd, ep);
|
||||
}
|
||||
dcd_send_status(device->dcd);
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
@ -454,10 +455,11 @@ static rt_err_t _standard_request(struct udevice* device, ureq_t setup)
|
|||
dcd_ep_write(device->dcd, 0, &value, 2);
|
||||
break;
|
||||
case USB_REQ_CLEAR_FEATURE:
|
||||
dcd_clear_feature(dcd, setup->value);
|
||||
dcd_clear_feature(dcd, setup->value, setup->index);
|
||||
dcd_send_status(dcd);
|
||||
break;
|
||||
case USB_REQ_SET_FEATURE:
|
||||
dcd_set_feature(dcd, setup->value);
|
||||
dcd_set_feature(dcd, setup->value, setup->index);
|
||||
break;
|
||||
case USB_REQ_SET_ADDRESS:
|
||||
_set_address(device, setup);
|
||||
|
@ -504,14 +506,34 @@ static rt_err_t _standard_request(struct udevice* device, ureq_t setup)
|
|||
switch(setup->request)
|
||||
{
|
||||
case USB_REQ_GET_STATUS:
|
||||
{
|
||||
/* TODO */
|
||||
uep_t ep;
|
||||
|
||||
ep = rt_usbd_find_endpoint(device, RT_NULL, setup->index);
|
||||
value = ep->is_stall;
|
||||
dcd_ep_write(dcd, 0, &value, 2);
|
||||
}
|
||||
break;
|
||||
case USB_REQ_CLEAR_FEATURE:
|
||||
dcd_clear_feature(dcd, setup->value);
|
||||
{
|
||||
uep_t ep;
|
||||
|
||||
ep = rt_usbd_find_endpoint(device, RT_NULL, setup->index);
|
||||
ep->is_stall = 0;
|
||||
dcd_clear_feature(dcd, setup->value, setup->index);
|
||||
dcd_send_status(dcd);
|
||||
}
|
||||
break;
|
||||
case USB_REQ_SET_FEATURE:
|
||||
dcd_set_feature(dcd, setup->value);
|
||||
{
|
||||
uep_t ep;
|
||||
|
||||
ep = rt_usbd_find_endpoint(device, RT_NULL, setup->index);
|
||||
ep->is_stall = 1;
|
||||
dcd_set_feature(dcd, setup->value, setup->index);
|
||||
dcd_send_status(dcd);
|
||||
}
|
||||
break;
|
||||
case USB_REQ_SYNCH_FRAME:
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue