private void HandleInterrupt(ref INTs.IRQContext aContext) { ushort sr = pTransferStatus.Word; if ((sr & IRQ_LVBCI) > 0) { // Last Valid Buffer interrupt pTransferStatus.Word = IRQ_LVBCI; } else if ((sr & IRQ_BCIS) > 0) { // Load a buffer ahead int next = lastValidIdx + 1; if (next >= BUFFER_COUNT) { next -= BUFFER_COUNT; } BufferProvider.RequestBuffer(transferBuffer); fixed(byte *mainBufPtr = transferBuffer.RawData) { MemoryOperations.Copy( dest: bufferDescriptorList[next].pointer, src: mainBufPtr, size: bufferSizeBytes ); } // Set the index to the current one lastValidIdx++; if (lastValidIdx == BUFFER_COUNT) { lastValidIdx = 0; } pLastValidEntry.Byte = lastValidIdx; pTransferStatus.Word = IRQ_BCIS; } else if ((sr & IRQ_FIFO_ERROR) > 0) { pTransferStatus.Word = IRQ_FIFO_ERROR; } }