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.
Fork of SX1276PingPong by
Diff: Buffer.h
- Revision:
- 16:c3c6b13c3c42
- Parent:
- 15:f790f35839db
--- a/Buffer.h Tue May 31 09:52:21 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -#ifndef BUFFER_H_ -#define BUFFER_H_ - -#define DEFAULT_MAX_BUFFER_SZ 64 - -#include "stdint.h" - -template <typename T> -class CircularBuffer -{ -private: - const uint32_t buffer_size; - uint32_t read_ptr; - uint32_t write_ptr; - uint32_t count; - - // mutex lock - bool mux; - - // overflow - bool is_over_flow; - - // container - T *data; - - -public: - CircularBuffer(const uint32_t size=DEFAULT_MAX_BUFFER_SZ); - ~CircularBuffer(); - - // psudo mutex - bool isLocked(); - void lock(); - void unlock(); - - // enqueue and dequeue - void enqueue(T in); - T dequeue(); - - // pointer operation - uint32_t getReadPtr(); - uint32_t getWritePtr(); - uint32_t getCounter(); - - // overflow - bool getOverFlow(); - void clearOverFlow(); - - // operation - T first(); - T last(); - - // random access - T operator[](uint32_t idx); -}; - -#endif \ No newline at end of file