Renjian Hao
Dependencies: L3G4200D L3GD20 LSM303DLHC LSM303DLM PwmIn Servo mbed
Fork of Fish_2014Fall by
iSerial/RingBuffer/RingBuffer.h@0:8f37781c0054, 2015-04-17 (annotated)
- Committer:
- tzxl10000
- Date:
- Fri Apr 17 21:13:44 2015 +0000
- Revision:
- 0:8f37781c0054
Fish_2014 with BBBCamshift
Who changed what in which revision?
User | Revision | Line number | New 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 |