This fork re-enables FRDM boards and adds WebUSB CDC functionality
Fork of USBDevice_STM32F103 by
Diff: USBSerial/CircBuffer.h
- Revision:
- 65:48fe9050cb4a
- Parent:
- 56:151ba33713ff
diff -r c3d0530b6d82 -r 48fe9050cb4a USBSerial/CircBuffer.h --- a/USBSerial/CircBuffer.h Thu Jun 25 09:33:51 2015 +0900 +++ b/USBSerial/CircBuffer.h Fri Jul 08 21:16:25 2016 +0000 @@ -19,10 +19,16 @@ #ifndef CIRCBUFFER_H #define CIRCBUFFER_H -template <class T, int Size> +template <class T> class CircBuffer { public: - CircBuffer():write(0), read(0){} + CircBuffer(int length) { + write = 0; + read = 0; + size = length + 1; + buf = (T *)malloc(size * sizeof(T)); + }; + bool isFull() { return ((write + 1) % size == read); }; @@ -56,8 +62,8 @@ private: volatile uint16_t write; volatile uint16_t read; - static const int size = Size+1; //a modern optimizer should be able to remove this so it uses no ram. - T buf[Size+1]; + uint16_t size; + T * buf; }; #endif