AnsweredAssumed Answered

VDK threads and Bulk USB

Question asked by G40 on Jun 18, 2012
Latest reply on Aug 6, 2012 by CraigG

This is a problem similar to  http://ez.analog.com/message/27704#27704 but the solution is never made quite clear.

 

I have a VDK application that runs a single USB worker thread. The thread and USB ISR callback communicate using an event set. The basic idea is really simple (see snippets below)

 

The host is a Windows 7 x64 machine with suitable USB Bulk class drivers for the  VID/PID. Once the firmware is running (BF526 EZBRD) it receives the initial configuration event (ADI_USB_EVENT_SET_CONFIG) and Windows installs the drivers. When the EZBRD USB connection is unplugged, the firmware gets the ADI_USB_EVENT_DISCONNECT message which in turn propogates the correct event bits to the VDK thread.

 

*However* when the device is replugged the ADI_USB_EVENT_SET_CONFIG event is never sent. Windows simply claims that the device did not start correctly.

 

Questions:

 

1. Have I missed something important? The USB code works correctly and reliably as a standard single-threaded application

2. I am assuming it is OK to configure the endpoints from within the USB ISR?

3. Is there any way to write to the VDSP debug console from within an ISR? Given USB is time-sensitive it is a problem to break/restart etc.

 

Many thanks.

 

Using VSDP 5.0 Update 10.

 

void USBISR()

{

     if (ADI_USB_EVENT_SET_CONFIG && pArg == 1)

      {

          ConfigureEndpoints()

          C_ISR_SetEventBit(Configured)

     }

     if (ADI_USB_EVENT_DISCONNECT)

     {

          C_ISR_SetEventBit(NotConfigured)

     }

}

 

In Thread::Run()

{

     while (true)

     {

          // wait until something happens in the USB ISR

          VDK::PendEvent(...)

          // configured ...

          if (VDK::GetEventBitValue(Configured))  { do some stuff }

          // not configured

          if (VDK::GetEventBitValue(NotConfigured)) { ensure we do not do any USB stuff }

          // Clear any bits that got set

     }

}

Outcomes