drivers: usb_dc_mcux_ehci: rework endpoint enable/disable
Rework endpoint enable/disable. Fix style. Signed-off-by: Johann Fischer <j.fischer@phytec.de>
This commit is contained in:
parent
031d744b9a
commit
0958667125
1 changed files with 28 additions and 10 deletions
|
@ -305,26 +305,36 @@ int usb_dc_ep_halt(const u8_t ep)
|
||||||
int usb_dc_ep_enable(const u8_t ep)
|
int usb_dc_ep_enable(const u8_t ep)
|
||||||
{
|
{
|
||||||
u8_t ep_abs_idx = EP_ABS_IDX(ep);
|
u8_t ep_abs_idx = EP_ABS_IDX(ep);
|
||||||
|
usb_status_t status;
|
||||||
|
|
||||||
/* endpoint0 OUT is primed by controller driver when configure this
|
/*
|
||||||
* endpoint.
|
* endpoint 0 OUT is primed by controller driver when configure this
|
||||||
|
* endpoint.
|
||||||
*/
|
*/
|
||||||
if (!ep_abs_idx) {
|
if (!ep_abs_idx) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev_data.eps[ep_abs_idx].ep_occupied) {
|
if (dev_data.eps[ep_abs_idx].ep_occupied) {
|
||||||
LOG_WRN("endpoint 0x%x already enabled", ep);
|
LOG_WRN("endpoint 0x%x already enabled", ep);
|
||||||
return -EALREADY;
|
return -EALREADY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((EP_ADDR2IDX(ep) != USB_CONTROL_ENDPOINT) && (EP_ADDR2DIR(ep) == USB_EP_DIR_OUT)) {
|
if ((EP_ADDR2IDX(ep) != USB_CONTROL_ENDPOINT) &&
|
||||||
dev_data.interface->deviceRecv(dev_data.controllerHandle,
|
(EP_ADDR2DIR(ep) == USB_EP_DIR_OUT)) {
|
||||||
ep,
|
status = dev_data.interface->deviceRecv(
|
||||||
(u8_t *)dev_data.eps[ep_abs_idx].block.data,
|
dev_data.controllerHandle, ep,
|
||||||
(uint32_t)dev_data.eps[ep_abs_idx].ep_mps);
|
(u8_t *)dev_data.eps[ep_abs_idx].block.data,
|
||||||
|
(uint32_t)dev_data.eps[ep_abs_idx].ep_mps);
|
||||||
|
if (kStatus_USB_Success != status) {
|
||||||
|
LOG_ERR("Failed to enable reception on 0x%02x", ep);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
dev_data.eps[ep_abs_idx].ep_occupied = true;
|
dev_data.eps[ep_abs_idx].ep_occupied = true;
|
||||||
} else {
|
} else {
|
||||||
/* control enpoint just be enabled before enumeration,
|
/*
|
||||||
|
* control enpoint just be enabled before enumeration,
|
||||||
* when running here, setup has been primed.
|
* when running here, setup has been primed.
|
||||||
*/
|
*/
|
||||||
dev_data.eps[ep_abs_idx].ep_occupied = true;
|
dev_data.eps[ep_abs_idx].ep_occupied = true;
|
||||||
|
@ -336,9 +346,17 @@ int usb_dc_ep_enable(const u8_t ep)
|
||||||
int usb_dc_ep_disable(const u8_t ep)
|
int usb_dc_ep_disable(const u8_t ep)
|
||||||
{
|
{
|
||||||
u8_t ep_abs_idx = EP_ABS_IDX(ep);
|
u8_t ep_abs_idx = EP_ABS_IDX(ep);
|
||||||
|
usb_status_t status;
|
||||||
|
|
||||||
|
status = dev_data.interface->deviceCancel(dev_data.controllerHandle,
|
||||||
|
ep);
|
||||||
|
if (kStatus_USB_Success != status) {
|
||||||
|
LOG_ERR("Failed to disable ep 0x%02x", ep);
|
||||||
|
return -EIO;
|
||||||
|
}
|
||||||
|
|
||||||
dev_data.interface->deviceCancel(dev_data.controllerHandle, ep);
|
|
||||||
dev_data.eps[ep_abs_idx].ep_enabled = false;
|
dev_data.eps[ep_abs_idx].ep_enabled = false;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -351,7 +369,7 @@ int usb_dc_ep_flush(const u8_t ep)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DBG("ep %x, idx %d", ep_idx, ep);
|
LOG_DBG("Not implemented, ep 0x%02x, idx %u", ep_idx, ep);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue