Ring Buffer reconciled with RTOS. If with using RTOS, this lib is enabled Mutex. Default RingBuffer size is 256 Bytes, Max size is 1024 Bytes.
Dependents: RN41 HC05 HC05 mySerial ... more
RingBuffer.h
- Committer:
- AkinoriHashimoto
- Date:
- 2015-10-30
- Revision:
- 0:5373472190f5
- Child:
- 1:8f2a3144902b
File content as of revision 0:5373472190f5:
#pragma once #include "mbed.h" #include <string> //#define BufSize 256 #ifdef RTOS_H extern Mutex mutex; #endif class RingBuffer { public: RingBuffer(unsigned int size= 256); ~RingBuffer(); bool set(char chr); bool set(string &str); // Return Full、参照渡し string get(); private: volatile bool empty; volatile unsigned short idxF, idxR; // front, rear char *buf; unsigned int bufSize; }; // eof