diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2010-05-26 06:59:55 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2010-05-26 06:59:55 +0000 |
commit | 79742c5d24929442175953c796a1834e45a93d0d (patch) | |
tree | 586e05a47ddcd226311d6f965885f3bde6c0fc4a /Projects/XPLAINBridge/Lib/LightweightRingBuff.h | |
parent | 9b29d1dc5045b74516e0ddd3ffcc200ef8ad9bff (diff) | |
download | lufa-79742c5d24929442175953c796a1834e45a93d0d.tar.gz lufa-79742c5d24929442175953c796a1834e45a93d0d.tar.bz2 lufa-79742c5d24929442175953c796a1834e45a93d0d.zip |
Make software USART used in the XPLAINBridge project directly check and store into the ring buffers, rather than polling from the main program loop to avoid added latency.
Diffstat (limited to 'Projects/XPLAINBridge/Lib/LightweightRingBuff.h')
-rw-r--r-- | Projects/XPLAINBridge/Lib/LightweightRingBuff.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Projects/XPLAINBridge/Lib/LightweightRingBuff.h b/Projects/XPLAINBridge/Lib/LightweightRingBuff.h index 16e890c07..31430ddd4 100644 --- a/Projects/XPLAINBridge/Lib/LightweightRingBuff.h +++ b/Projects/XPLAINBridge/Lib/LightweightRingBuff.h @@ -53,13 +53,15 @@ RingBuff_Data_t Buffer[BUFFER_SIZE];
RingBuff_Data_t* In;
RingBuff_Data_t* Out;
+ uint8_t Count;
} RingBuff_t;
/* Inline Functions: */
static inline void RingBuffer_InitBuffer(RingBuff_t* const Buffer)
{
Buffer->In = Buffer->Buffer;
- Buffer->Out = Buffer->Buffer;
+ Buffer->Out = Buffer->Buffer;
+ Buffer->Count = 0;
}
static inline void RingBuffer_Insert(RingBuff_t* const Buffer, RingBuff_Data_t Data)
@@ -68,6 +70,8 @@ if (++Buffer->In == &Buffer->Buffer[BUFFER_SIZE])
Buffer->In = Buffer->Buffer;
+
+ Buffer->Count++;
}
static inline RingBuff_Data_t RingBuffer_Remove(RingBuff_t* const Buffer)
@@ -77,12 +81,9 @@ if (++Buffer->Out == &Buffer->Buffer[BUFFER_SIZE])
Buffer->Out = Buffer->Buffer;
- return Data;
- }
+ Buffer->Count--;
- static inline bool RingBuffer_Empty(RingBuff_t* const Buffer)
- {
- return (Buffer->In == Buffer->Out);
+ return Data;
}
#endif
|