void USBFrameHandler(U16 wFrame) { // send over USB if( isConnectedFlag ) { if( delay < 4000 ) { //FIXME need to delay a few seconds before doing isoc writes, impliment more elegant solution, status or event driven.... delay++; } else { //Check to see if the DMA descriptor is marked in the normal-completion status and ready for reset int needToResetInputDMADescriptorFlag = (((inputDmaDescriptor[3] >> 1) & 0x0F ) == 2); if (needToResetInputDMADescriptorFlag || !didInputInit) { //normal completion if ( !didInputInit) { didInputInit = 1; } //Always write whatever is in our most recent isoc output data buffer, you may want to pust somthing interesting in there.... incrementingNumberCounter++; memcpy(inputIsocDataBuffer, &incrementingNumberCounter, sizeof(incrementingNumberCounter)); resetDMATransfer(ISOC_IN_EP, inputDmaDescriptor, inputIsocFrameArray, 1, 4, &commonIsocFrameNumber, MAX_PACKET_SIZE, inputIsocDataBuffer); } //Check to see if the DMA descriptor is marked in the normal-completion status and ready for reset int needToResetOutputDMADescriptorFlag = (((outputDmaDescriptor[3] >> 1) & 0x0F ) == 2); if (needToResetOutputDMADescriptorFlag || !didOutputInit) { //normal completion if ( !didOutputInit) { didOutputInit = 1; } else { //The host sample code will send a byte indicating if the sample LED on olimex 2148 dev board should be on of off. if( outputIsocDataBuffer[0] ) {//Note: were only inspecting the first of 4 isoc frames, this is just for the blinky light example IOSET0 = (1<<10);//turn on led on olimex dev board } else { IOCLR0 = (1<<10);//turn off led on olimex dev board } } resetCount++; resetDMATransfer(ISOC_OUT_EP, outputDmaDescriptor, outputIsocFrameArray, NUM_ISOC_FRAMES, BYTES_PER_ISOC_FRAME, &commonIsocFrameNumber, MAX_PACKET_SIZE, outputIsocDataBuffer); } } } }
void USBFrameHandler(U16 wFrame) { if( cc < 4000 ) { cc++; } int inputR = (((inputDmaDescriptor[3] >> 1) & 0x0F ) == 2); if (cc >= 4000 && (inputR || !didInputInit)) { //normal completion if ( !didInputInit) { didInputInit = 1; } /* resetDMATransfer(ISOC_IN_EP, inputDmaDescriptor, inputIsocFrameArray, NUM_ISOC_FRAMES, BYTES_PER_ISOC_FRAME, &commonIsocFrameNumber, MAX_PACKET_SIZE, inputIsocDataBuffer); */ memcpy(inputIsocDataBuffer, ¤tADCReadValue, 4); resetDMATransfer(ISOC_IN_EP, inputDmaDescriptor, inputIsocFrameArray, 1, 4, &commonIsocFrameNumber, MAX_PACKET_SIZE, inputIsocDataBuffer); } }