Simple ring buffer

Committer:
jont
Date:
Mon Jul 13 07:54:11 2015 +0000
Revision:
0:c050eb7b0c10
First pre-release version without documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jont 0:c050eb7b0c10 1 #ifndef NL_RING
jont 0:c050eb7b0c10 2 #define NL_RING
jont 0:c050eb7b0c10 3
jont 0:c050eb7b0c10 4 /**
jont 0:c050eb7b0c10 5
jont 0:c050eb7b0c10 6 Simple Ring Buffer
jont 0:c050eb7b0c10 7 J.J.Trinder, based on original code for midi projects 199X
jont 0:c050eb7b0c10 8 updateded sometime to the MBED
jont 0:c050eb7b0c10 9
jont 0:c050eb7b0c10 10 Yeh its atad klunky, it works and is useful to explain things to people...
jont 0:c050eb7b0c10 11 */
jont 0:c050eb7b0c10 12 #define buff_size 120
jont 0:c050eb7b0c10 13 class NRing {
jont 0:c050eb7b0c10 14 public:
jont 0:c050eb7b0c10 15 NRing();
jont 0:c050eb7b0c10 16
jont 0:c050eb7b0c10 17 void ring_init();
jont 0:c050eb7b0c10 18 int ring_count();
jont 0:c050eb7b0c10 19 long get_next();
jont 0:c050eb7b0c10 20 int RingWriteToBuffer(long); /* put byte in buffer */
jont 0:c050eb7b0c10 21
jont 0:c050eb7b0c10 22 protected:
jont 0:c050eb7b0c10 23 volatile int inIndex; /* where to put next byte */
jont 0:c050eb7b0c10 24 volatile int inCount; /* how full is the buffer */
jont 0:c050eb7b0c10 25 volatile int outIndex; /* for output to sio */
jont 0:c050eb7b0c10 26
jont 0:c050eb7b0c10 27
jont 0:c050eb7b0c10 28 long opBuffer[buff_size]; /* our Ring out buffer */
jont 0:c050eb7b0c10 29 };
jont 0:c050eb7b0c10 30
jont 0:c050eb7b0c10 31 #endif