Skip to content

Commit

Permalink
Sleep while waiting for ADC buffer to fill
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiegle committed Sep 3, 2024
1 parent 2e544b8 commit 5c37c0d
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Source/Probes/OneBoxADC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ void OneBoxADC::run()

Neuropixels::PacketInfo packetInfo[MAXPACKETS];

int packetsAvailable;
int headroom;

while (! threadShouldExit())
{
int count = MAXPACKETS;
Expand Down Expand Up @@ -267,5 +270,14 @@ void OneBoxADC::run()
{
LOGD ("readPackets error code: ", errorCode, " for ADCs");
}

Neuropixels::ADC_getPacketFifoStatus (basestation->slot, &packetsAvailable, &headroom);

if (packetsAvailable < MAXPACKETS)
{
int uSecToWait = (MAXPACKETS - packetsAvailable) * 30;

std::this_thread::sleep_for (std::chrono::microseconds (uSecToWait));
}
}
}

0 comments on commit 5c37c0d

Please sign in to comment.