Skip to content

Commit

Permalink
SiL USB: Disable LEM in Happy with ISOC endpoints
Browse files Browse the repository at this point in the history
Happy Gecko's USB Low Energy Mode does not work properly with
isochronous endpoints.

Note that Happy Gecko errata USB_E112 states:

  Do not use the SUSPEND mode of LEMOSCCTRL in USB_CTRL.

  In rare cases with high data throughput, a transmission can
  fail when this mode is enabled.

  Use the GATED mode of LEMOSCCTRL for the best energy
  efficiency. The NONE mode can be used to disable energy
  savings

However, even using GATE mode causes problems for high-frequency
isochronous transfers. The primary effect for OUT endpoints is that
the first read will succeed, and the following one (targetting the
next frame) will fail with zero bytes incoming data, and PKTDRPSTS
is set in the related interrupt status register.

Disabling LEMOSCCTRL (set to NONE) solves the problem. Since this
will cause increased energy usage, do this only when an ISOC endpoint
is added.
  • Loading branch information
mpolojar committed Jul 28, 2015
1 parent 549d2b9 commit 511b46d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ extern "C" {
USB_PWRSAVE_MODE_ENTEREM2 Enter EM2 when USB peripheral is in low power mode.
On Mbed this allows the sleep() and deepsleep() calls to enter EM2, but
does not automatically enter any sleep states. Entering EM1 is always allowed.
Note for Happy Gecko, errata USB_E111: Entering EM2 when both the system clock
(HFCLK) and the USB core clock (USBCCLK) is running on USHFRCO will result in
a lock-up.
*/
#define USB_PWRSAVE_MODE (USB_PWRSAVE_MODE_ONSUSPEND|USB_PWRSAVE_MODE_ONVBUSOFF|USB_PWRSAVE_MODE_ENTEREM2)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,14 @@ int USBD_AddEndpoint(int epAddr, int transferType,
totalTxFifoSize, totalRxFifoSize);

INT_Disable();
#if defined( CMU_OSCENCMD_USHFRCOEN )
/* Happy Gecko workaround: disable LEM GATE mode if using ISOC endpoints. */
if ( transferType == USB_EPTYPE_ISOC )
{
USB->CTRL = (USB->CTRL & ~_USB_CTRL_LEMOSCCTRL_MASK) | USB_CTRL_LEMOSCCTRL_NONE;
}
#endif

int ret = USBDHAL_ReconfigureFifos(totalRxFifoSize, totalTxFifoSize);
INT_Enable();

Expand Down

0 comments on commit 511b46d

Please sign in to comment.