cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 USB disable endpoint interrupt is not generated

peterdonchev
Associate III
Posted on August 17, 2014 at 23:13

I'm working on usb device project and I need after receiving a command from the host to return the device to predetermined state. To do this, all prepared OUT transfers must be canceled. I set endpoint disable bit(EPDIS) in the endpoint control register. USB core must generate endpoint disable interrupt, but this never happens. The interrupt is not masked. I checked with a debugger inside the interrupt service routine, that bit EPDIS remain set.

What I'm doing wrong?

This is the code of endpoint disable function:

void USB_OTG_DisableEP (USB_OTG_CORE_HANDLE *pdev , USB_OTG_EP *ep)

{

  USB_OTG_DEPCTL_TypeDef  depctl;

  __IO uint32_t *depctl_addr;

  /* Process for IN endpoint */

  if (ep->is_in == 1)

  {

    depctl_addr = &(pdev->regs.INEP_REGS[ep->num]->DIEPCTL);

    depctl.d32 = USB_OTG_READ_REG32(depctl_addr);

  }

  else /* Process for OUT endpoint */

  {

    depctl_addr = &(pdev->regs.OUTEP_REGS[ep->num]->DOEPCTL);

    depctl.d32 = USB_OTG_READ_REG32(depctl_addr);

  }

  if(depctl.b.epena)

  {

      depctl.b.epena = 0;

      depctl.b.epdis = 1;

      depctl.b.snak = 1;

  }

  USB_OTG_WRITE_REG32(depctl_addr, depctl.d32);

}

1 REPLY 1
vincent2399
Associate
Posted on November 18, 2015 at 18:02

Hi,

i see the same issue on the ChibiOS OTGv1 driver.

https://github.com/ChibiOS/ChibiOS/blob/master/os/hal/ports/STM32/LLD/OTGv1/usb_lld.c#L171

Also it seems that NuttX is working around this in their driver as well.

Have you been able to solve this or find the reason for it?

Thanks and cheers

Vincent