![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Renjian Hao
Dependencies: L3G4200D L3GD20 LSM303DLHC LSM303DLM PwmIn Servo mbed
Fork of Fish_2014Fall by
Diff: iSerial/RingBuffer/RingBuffer.h
- Revision:
- 0:8f37781c0054
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/iSerial/RingBuffer/RingBuffer.h Fri Apr 17 21:13:44 2015 +0000 @@ -0,0 +1,35 @@ +// +// RingBuffer.h ... General purpose ring buffer library +// +// Copyright 2012 Yoji KURODA +// +// 2009.11.13 ... Originally written in C by Y.Kuroda for Renesas H83664 +// 2012.08.31 ... Code convert for mbed in C++ +// + +#ifndef _RINGBUFFER_H +#define _RINGBUFFER_H + +class RingBuffer { + + protected: + unsigned char* buf; + unsigned int sp; + unsigned int ep; + int bufsize; + + public: + RingBuffer(int _bufsize=100); + ~RingBuffer(); + + int save(unsigned char c); + unsigned char read(void); + int check(void); + int buffersize(void){return bufsize;}; + int full(void){ return (check()>=bufsize-1 ? 1 : 0); }; +}; + + +#endif /* _RINGBUFFER_H */ + +