AnsweredAssumed Answered

Is there a know issue with USB ClearFeature and the DATA0 toggle?

Question asked by Marc Bunyard on Aug 14, 2014
Latest reply on Aug 27, 2014 by Marc Bunyard

I am using the K20 with MQX Lite and Processor Expert, and I'm having a problem with the USB CLEAR FEATURE command.  The command is a CLEAR FEATURE (Endpoint Halt, Endpoint 1 IN).  After this command is handled, the DATA0/1 toggle is uneffected.  When I look at the code, and the documentation, there is a mismatch.  I've tried setting the DATA0/1 bit instead of clearing since the description of the bit is the last setting of this bit.  I have also used the value 0x40 for USB1_BD_LE_DATA1.  Nothing changes the behavior of the DATA0/1 bit when view with the USB analyzer.

 

K20P100M72SF1RM.pdf

 

BufferDescriptorFormat.png

Processor Expert USBX.c

...

 

#define USB1_BD_LE_DATA1                          0x40000000U

#define USB1_BD_LE_STALL                          0x04000000U

 

...

 

void USB1_DeviceUnstallEndpoint(LDD_TDeviceData *DeviceDataPtr, uint8_t EpNum, uint8_t EpDir)
{
  USB1_TDeviceData                *DevDataPtr = (USB1_TDeviceData*)DeviceDataPtr;
  USB1_TEpData                    *EpDataPtr;
  USB1_TBD                        *BDPtr;

  USB1_UsbLock(DevDataPtr);
  EpDataPtr = &DevDataPtr->EpData[((uint32_t)EpNum << 0x01U)]; /* Get address of EPx data structure */
  if (EpDataPtr->TransferType == LDD_USB_CONTROL) {         /* Control EP? */
    (EpDataPtr + 1)->EpState = (USB1_TePState)((uint32_t)((EpDataPtr +1 )->EpState) & ~(uint32)USB1_EP_STALLED);
  } else {
    if (EpDir != LDD_USB_DIR_OUT) {
      EpDataPtr++;
    }
    BDPtr = EpDataPtr->BDPtr;
   
    BDPtr->CtrlReg &= ~(USB1_BD_LE_STALL | USB1_BD_LE_DATA1); /* UNSTALL ODD BD entry, set data toggle to DATA0 */
   (++BDPtr)->CtrlReg &= ~(USB1_BD_LE_STALL | USB1_BD_LE_DATA1); /* UNSTALL EVEN BD entry, set data toggle to DATA0 */

  }
  EpDataPtr->EpState = (USB1_TePState)((uint32_t)(EpDataPtr->EpState) & ~(uint32)USB1_EP_STALLED);
  USB1_UsbUnlock(DevDataPtr);
}

 

 

 

Outcomes