diff options
author | Christian Pointner <equinox@mur.at> | 2012-06-13 22:52:24 +0000 |
---|---|---|
committer | Christian Pointner <equinox@mur.at> | 2012-06-13 22:52:24 +0000 |
commit | c0894504ebce3becfa74c480e09b16c8e8aa4fb5 (patch) | |
tree | 72c0db49a1bee782c4d082d279f8a21b5171a478 /tools/idm-ringbuffer/ringbuffer.c | |
parent | better but not there yet.. (diff) |
cleanup
git-svn-id: https://svn.spreadspace.org/mur.sat@528 7de4ea59-55d0-425e-a1af-a3118ea81d4c
Diffstat (limited to 'tools/idm-ringbuffer/ringbuffer.c')
-rw-r--r-- | tools/idm-ringbuffer/ringbuffer.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/tools/idm-ringbuffer/ringbuffer.c b/tools/idm-ringbuffer/ringbuffer.c index 5fd65b4..2910d6c 100644 --- a/tools/idm-ringbuffer/ringbuffer.c +++ b/tools/idm-ringbuffer/ringbuffer.c @@ -58,7 +58,8 @@ BOOL underrun = TRUE; BOOL currentByteLoaded = FALSE; char spiData = 0; -void incrementWriteIdx() { +void incrementWriteIdx() +{ if (!overrun) { writePtr++; writePtr = writePtr > bufferEnd ? bufferStart : writePtr; @@ -69,7 +70,8 @@ void incrementWriteIdx() { } } -void incrementReadIdx() { +void incrementReadIdx() +{ if(!underrun) { readPtr++; readPtr = readPtr > bufferEnd ? bufferStart : readPtr; @@ -80,20 +82,21 @@ void incrementReadIdx() { } } -void beginRead() { - if (!underrun) { - spiData = *readPtr; - printf("SPI out: %02x\n", (int)spiData); - } +void beginRead() +{ + spiData = underrun ? 0 : *readPtr; + printf("SPI Buf: %02x\n", (int)spiData); currentByteLoaded = TRUE; } -void endRead() { +void endRead() +{ currentByteLoaded = FALSE; incrementReadIdx(); } -void storeSample() { +void storeSample() +{ static char value = 0; if (!overrun) { *writePtr = ++value; @@ -101,7 +104,8 @@ void storeSample() { } } -void triggerByteTransferred() { +void triggerByteTransferred() +{ if (spiData == 0) { endRead(); beginRead(); |