Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: AvailableMemory mbed-rtos mbed
RingBuffer.h
00001 #ifndef _RING_BUFFER_H 00002 #define _RING_BUFFER_H 00003 00004 #include "mbed.h" 00005 00006 class RingBuffer{ 00007 private: 00008 00009 /*buf is the maximum size of the ring buffer; start is the beginning of first valid element, end is the next available position 00010 to write*/ 00011 int bufSize, start, end; 00012 public: 00013 /*buf is the pointer to actual buffer start, bufEnd is the actual end of the buffer, 00014 end is the current available position to insert (no element is at end yet), start is the first full position*/ 00015 int *buf; 00016 /*cur is used in next() method, denoting the current position in a sequential read, count is the number of elements*/ 00017 int cur,count; 00018 00019 RingBuffer(int *data=NULL, int bs=0):buf(data),cur(0),count(0),bufSize(bs),start(0),end(0){} 00020 ~RingBuffer(){buf=NULL;} 00021 void insert(int sample); 00022 int next(); 00023 int getCount()const{return count;} 00024 void dump(FILE *fp)const; 00025 }; 00026 00027 #endif
Generated on Tue Jul 12 2022 18:43:44 by
1.7.2