Merge pull request #93 from heyuanjie87/ForPullRequest

For pull request
This commit is contained in:
qiuyiuestc 2013-05-22 21:49:59 -07:00
commit b0c7d480ee
2 changed files with 36 additions and 14 deletions

View File

@ -42,8 +42,8 @@ struct uendpoint;
struct udcd_ops struct udcd_ops
{ {
rt_err_t (*set_address)(rt_uint8_t value); rt_err_t (*set_address)(rt_uint8_t value);
rt_err_t (*clear_feature)(rt_uint8_t value); rt_err_t (*clear_feature)(rt_uint16_t value, rt_uint16_t index);
rt_err_t (*set_feature)(rt_uint8_t value); 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_alloc)(struct uendpoint* ep);
rt_err_t (*ep_free)(struct uendpoint* ep); rt_err_t (*ep_free)(struct uendpoint* ep);
rt_err_t (*ep_stall)(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); 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); 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); 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) rt_inline rt_err_t dcd_ep_stall(udcd_t dcd, uep_t ep)

View File

@ -256,7 +256,8 @@ static rt_err_t _set_interface(struct udevice* device, ureq_t setup)
dcd_ep_stop(device->dcd, ep); dcd_ep_stop(device->dcd, ep);
dcd_ep_run(device->dcd, ep); dcd_ep_run(device->dcd, ep);
} }
dcd_send_status(device->dcd);
return RT_EOK; 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); dcd_ep_write(device->dcd, 0, &value, 2);
break; break;
case USB_REQ_CLEAR_FEATURE: case USB_REQ_CLEAR_FEATURE:
dcd_clear_feature(dcd, setup->value); dcd_clear_feature(dcd, setup->value, setup->index);
dcd_send_status(dcd);
break; break;
case USB_REQ_SET_FEATURE: case USB_REQ_SET_FEATURE:
dcd_set_feature(dcd, setup->value); dcd_set_feature(dcd, setup->value, setup->index);
break; break;
case USB_REQ_SET_ADDRESS: case USB_REQ_SET_ADDRESS:
_set_address(device, setup); _set_address(device, setup);
@ -504,15 +506,35 @@ static rt_err_t _standard_request(struct udevice* device, ureq_t setup)
switch(setup->request) switch(setup->request)
{ {
case USB_REQ_GET_STATUS: case USB_REQ_GET_STATUS:
{
/* TODO */ /* 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); dcd_ep_write(dcd, 0, &value, 2);
break; }
break;
case USB_REQ_CLEAR_FEATURE: case USB_REQ_CLEAR_FEATURE:
dcd_clear_feature(dcd, setup->value); {
break; 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: case USB_REQ_SET_FEATURE:
dcd_set_feature(dcd, setup->value); {
break; 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: case USB_REQ_SYNCH_FRAME:
break; break;
default: default: