Jean Mercier
/
jmSwitch
Read up to 8 debounced switches from serial port
Diff: jmRingBuffer.h
- Revision:
- 0:f3a5f6fe1c03
diff -r 000000000000 -r f3a5f6fe1c03 jmRingBuffer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jmRingBuffer.h Sat Feb 12 16:46:49 2011 +0000 @@ -0,0 +1,36 @@ +/************************************************************************* + * @file jmRingBuffer.h + * @brief Command Line Rx Ring Buffer + * + * @date Feb12, 2011 +*/ + +#ifndef jmRingBufferDef + #define jmRingBufferDef 1 + + #define nl 10 // new line + #define WordMaxSize 21 + #define DimRingBuffer 41 + + + // Ring Buffer data structure + extern struct RingBuffer + { unsigned char Buffer[DimRingBuffer]; + unsigned char head; + unsigned char tail; + unsigned char qty; + }Line, *pLine; +#endif + +// Prototypes +bool Full(struct RingBuffer *p); +void Insert(unsigned char c, struct RingBuffer *p); +bool NotEmpty(struct RingBuffer *p); +unsigned char Extract(struct RingBuffer *p); +void FlushRingBuffer(struct RingBuffer *p); +void DelChar(struct RingBuffer *p); +void InitCommandLineRingBuffer(void); +void NextCommand(unsigned char c, struct RingBuffer *p); +void ViewRingBuffer(struct RingBuffer *p); +bool ExtractWord(struct RingBuffer *p, char *param); +bool ExtractUInteger(struct RingBuffer *p, unsigned int *result, unsigned int min, unsigned int max);