Renjian Hao

Dependencies:   L3G4200D L3GD20 LSM303DLHC LSM303DLM PwmIn Servo mbed

Fork of Fish_2014Fall by Zhan Tu

Committer:
RenjianHao
Date:
Thu Aug 13 18:37:15 2015 +0000
Revision:
5:a5f0395d2fa4
Parent:
0:8f37781c0054
Renjian Hao2015/8/13

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tzxl10000 0:8f37781c0054 1 //
tzxl10000 0:8f37781c0054 2 // RingBuffer.h ... General purpose ring buffer library
tzxl10000 0:8f37781c0054 3 //
tzxl10000 0:8f37781c0054 4 // Copyright 2012 Yoji KURODA
tzxl10000 0:8f37781c0054 5 //
tzxl10000 0:8f37781c0054 6 // 2009.11.13 ... Originally written in C by Y.Kuroda for Renesas H83664
tzxl10000 0:8f37781c0054 7 // 2012.08.31 ... Code convert for mbed in C++
tzxl10000 0:8f37781c0054 8 //
tzxl10000 0:8f37781c0054 9
tzxl10000 0:8f37781c0054 10 #ifndef _RINGBUFFER_H
tzxl10000 0:8f37781c0054 11 #define _RINGBUFFER_H
tzxl10000 0:8f37781c0054 12
tzxl10000 0:8f37781c0054 13 class RingBuffer {
tzxl10000 0:8f37781c0054 14
tzxl10000 0:8f37781c0054 15 protected:
tzxl10000 0:8f37781c0054 16 unsigned char* buf;
tzxl10000 0:8f37781c0054 17 unsigned int sp;
tzxl10000 0:8f37781c0054 18 unsigned int ep;
tzxl10000 0:8f37781c0054 19 int bufsize;
tzxl10000 0:8f37781c0054 20
tzxl10000 0:8f37781c0054 21 public:
tzxl10000 0:8f37781c0054 22 RingBuffer(int _bufsize=100);
tzxl10000 0:8f37781c0054 23 ~RingBuffer();
tzxl10000 0:8f37781c0054 24
tzxl10000 0:8f37781c0054 25 int save(unsigned char c);
tzxl10000 0:8f37781c0054 26 unsigned char read(void);
tzxl10000 0:8f37781c0054 27 int check(void);
tzxl10000 0:8f37781c0054 28 int buffersize(void){return bufsize;};
tzxl10000 0:8f37781c0054 29 int full(void){ return (check()>=bufsize-1 ? 1 : 0); };
tzxl10000 0:8f37781c0054 30 };
tzxl10000 0:8f37781c0054 31
tzxl10000 0:8f37781c0054 32
tzxl10000 0:8f37781c0054 33 #endif /* _RINGBUFFER_H */
tzxl10000 0:8f37781c0054 34
tzxl10000 0:8f37781c0054 35