Hello,
I have an issue with "cppi41dma.c" code in starterware, "dmaTxCompletion" function.
I am controlling a DSLR camera and In order to keep up with changes in state, I must periodically poll the device to get status while connected.
If I just power off the camera or just pull the usb cable {which are possible operating scenarios} , my code locks up because it get stuck in the following line forever .
if(state == DMA_TX_COMPLETED)
while ((HWREGH(usbInstance->usbBaseAddress + ulRegister) & 0x2) == 0x02);
the 0x2 is TX complete in the hardware register, but this never happens since the device is no longer there , I found that an 0x4 is supposed to be set as error after 3 failed attempts to send , but it never sets either.
I have not been able to detect anything in the code or registers to tell me the device unexpectedly disconnected and this line will only leave on succesfull transmisson which can never happen.
Is there any way to fix this or at least detect device disconnect and exit gracefully so i can shut off the pollling and be able to reconect when the device is turned back on?