Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drivers: usb_dc_sam: free endpoint memory on End of Reset event #25243

Merged
merged 2 commits into from
May 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions drivers/usb/device/usb_dc_sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,12 @@ static void usb_dc_isr(void)
usb_dc_ep_enable_interrupts(0);
}

/* Free all endpoint memory */
for (int idx = 1; idx < NUM_OF_EP_MAX; idx++) {
usb_dc_ep_disable(idx);
USBHS->USBHS_DEVEPTCFG[idx] &= ~USBHS_DEVEPTCFG_ALLOC;
}

/* Callback function */
dev_data.status_cb(USB_DC_RESET, NULL);
}
Expand Down Expand Up @@ -469,7 +475,7 @@ int usb_dc_ep_configure(const struct usb_dc_ep_cfg_data *const cfg)
return -EBUSY;
}

LOG_DBG("ep %x, mps %d, type %d", cfg->ep_addr, cfg->ep_mps,
LOG_INF("Configure ep %x, mps %d, type %d", cfg->ep_addr, cfg->ep_mps,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On my view we can keep logs as LOG_DBG.

cfg->ep_type);

/* Reset the endpoint */
Expand Down Expand Up @@ -531,6 +537,7 @@ int usb_dc_ep_configure(const struct usb_dc_ep_cfg_data *const cfg)
ep_enabled[i] = usb_dc_ep_is_enabled(i);

if (ep_enabled[i]) {
LOG_INF("Temporary disable ep idx %x", i);
usb_dc_ep_disable(i);
}
if (ep_configured[i]) {
Expand Down Expand Up @@ -640,7 +647,8 @@ int usb_dc_ep_enable(u8_t ep)
/* Enable SETUP, IN or OUT endpoint interrupts */
usb_dc_ep_enable_interrupts(ep_idx);

LOG_DBG("ep 0x%x", ep);
LOG_INF("Enable ep 0x%x", ep);

return 0;
}

Expand All @@ -660,7 +668,8 @@ int usb_dc_ep_disable(u8_t ep)
/* Disable endpoint and SETUP, IN or OUT interrupts */
USBHS->USBHS_DEVEPT &= ~BIT(USBHS_DEVEPT_EPEN0_Pos + ep_idx);

LOG_DBG("ep 0x%x", ep);
LOG_INF("Disable ep 0x%x", ep);

return 0;
}

Expand Down