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.
Dependents: RingBuffer_RTOS_test
Fork of RingBuffer by
RingBuffer.h
00001 // 00002 // RingBuffer.h ... General purpose ring buffer library 00003 // 00004 // Copyright 2012 Yoji KURODA 00005 // 00006 // 2009.11.13 ... Originally written in C by Y.Kuroda for Renesas H83664 00007 // 2012.08.31 ... Code convert for mbed in C++ 00008 // 2012.09.26 ... Pointer use 00009 // 2012.09.27 ... RTOS proof 00010 00011 #ifndef _RINGBUFFER_H 00012 #define _RINGBUFFER_H 00013 00014 00015 #include "rtos.h" 00016 00017 00018 class RingBuffer { 00019 00020 protected: 00021 unsigned char* buf; 00022 unsigned char* sp; 00023 unsigned char* ep; 00024 Mutex mutex; 00025 00026 int bufsize; 00027 00028 public: 00029 RingBuffer(int _bufsize=100); 00030 ~RingBuffer(); 00031 00032 int save(unsigned char c); 00033 unsigned char read(void); 00034 int check(void); 00035 int buffersize(void){return bufsize;}; 00036 int full(void){ return (check()>=bufsize-1 ? 1 : 0); }; 00037 }; 00038 00039 00040 #endif /* _RINGBUFFER_H */ 00041 00042
Generated on Sun Jul 17 2022 12:27:47 by
1.7.2
