test
Dependencies: Nanopb iSerial mbed BaseJpegDecode FatFileSystem SDFileSystem RingBuffer Camera_LS_Y201
iSerial/RingBuffer/RingBuffer.h@0:d69efd0ee139, 2014-09-18 (annotated)
- Committer:
- cgraham
- Date:
- Thu Sep 18 15:21:47 2014 +0000
- Revision:
- 0:d69efd0ee139
test
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cgraham | 0:d69efd0ee139 | 1 | // |
cgraham | 0:d69efd0ee139 | 2 | // RingBuffer.h ... General purpose ring buffer library |
cgraham | 0:d69efd0ee139 | 3 | // |
cgraham | 0:d69efd0ee139 | 4 | // Copyright 2012 Yoji KURODA |
cgraham | 0:d69efd0ee139 | 5 | // |
cgraham | 0:d69efd0ee139 | 6 | // 2009.11.13 ... Originally written in C by Y.Kuroda for Renesas H83664 |
cgraham | 0:d69efd0ee139 | 7 | // 2012.08.31 ... Code convert for mbed in C++ |
cgraham | 0:d69efd0ee139 | 8 | // |
cgraham | 0:d69efd0ee139 | 9 | |
cgraham | 0:d69efd0ee139 | 10 | #ifndef _RINGBUFFER_H |
cgraham | 0:d69efd0ee139 | 11 | #define _RINGBUFFER_H |
cgraham | 0:d69efd0ee139 | 12 | |
cgraham | 0:d69efd0ee139 | 13 | class RingBuffer { |
cgraham | 0:d69efd0ee139 | 14 | |
cgraham | 0:d69efd0ee139 | 15 | protected: |
cgraham | 0:d69efd0ee139 | 16 | unsigned char* buf; |
cgraham | 0:d69efd0ee139 | 17 | unsigned int sp; |
cgraham | 0:d69efd0ee139 | 18 | unsigned int ep; |
cgraham | 0:d69efd0ee139 | 19 | int bufsize; |
cgraham | 0:d69efd0ee139 | 20 | |
cgraham | 0:d69efd0ee139 | 21 | public: |
cgraham | 0:d69efd0ee139 | 22 | RingBuffer(int _bufsize=100); |
cgraham | 0:d69efd0ee139 | 23 | ~RingBuffer(); |
cgraham | 0:d69efd0ee139 | 24 | |
cgraham | 0:d69efd0ee139 | 25 | int save(unsigned char c); |
cgraham | 0:d69efd0ee139 | 26 | unsigned char read(void); |
cgraham | 0:d69efd0ee139 | 27 | int check(void); |
cgraham | 0:d69efd0ee139 | 28 | int buffersize(void){return bufsize;}; |
cgraham | 0:d69efd0ee139 | 29 | int full(void){ return (check()>=bufsize-1 ? 1 : 0); }; |
cgraham | 0:d69efd0ee139 | 30 | }; |
cgraham | 0:d69efd0ee139 | 31 | |
cgraham | 0:d69efd0ee139 | 32 | |
cgraham | 0:d69efd0ee139 | 33 | #endif /* _RINGBUFFER_H */ |
cgraham | 0:d69efd0ee139 | 34 | |
cgraham | 0:d69efd0ee139 | 35 |