diff options
Diffstat (limited to 'tools/idm-ringbuffer/ringbuffer.c')
-rw-r--r-- | tools/idm-ringbuffer/ringbuffer.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/tools/idm-ringbuffer/ringbuffer.c b/tools/idm-ringbuffer/ringbuffer.c index 0ab35f2..2fc028e 100644 --- a/tools/idm-ringbuffer/ringbuffer.c +++ b/tools/idm-ringbuffer/ringbuffer.c @@ -55,7 +55,7 @@ char* writePtr = 0; char* readPtr = 0; BOOL overrun = FALSE; BOOL underrun = TRUE; -BOOL currentByteLoaded = FALSE; +BOOL cmd_read = FALSE; char spiData = 0; void incrementWriteIdx() @@ -86,12 +86,10 @@ void beginRead() { spiData = underrun ? -1 : *readPtr; printf("SPI Buf: %02x\n", (int)spiData); - currentByteLoaded = TRUE; } void endRead() { - currentByteLoaded = FALSE; incrementReadIdx(); } @@ -106,12 +104,14 @@ void storeSample() void triggerByteTransferred() { - if (spiData == 0) { + if (cmd_read && spiData == 0) { endRead(); beginRead(); } else if (spiData == 'r') { + cmd_read = TRUE; beginRead(); } else { + cmd_read = FALSE; printf("%s\n", "I don't like you!"); } } @@ -120,11 +120,10 @@ void triggerByteTransferred() /* ##### test environment ##### */ void debugPrint(char cmd) { - printf("cmd('%c'): wPtr=%d, rPtr=%d, cbl=%d, ovr=%d, udr=%d\n", + printf("cmd('%c'): wPtr=%d, rPtr=%d, ovr=%d, udr=%d\n", cmd, (int) (writePtr - bufferStart), (int) (readPtr - bufferStart), - (int) currentByteLoaded, (int) overrun, (int) underrun); int i; |