more fifo refinement
This commit is contained in:
1 parent
0cbbe8f291
commit
5b6ee693ac
3 files changed
+18
-6
No files matched your search
@@ -6,6 +6,7 @@
|
||||
|
||||
- Add printf with float format aka %f
|
||||
- Add Servo library port
|
||||
- Enhance Adafruit_FIFO, add overwriteIfFull(), begin(). change constructor's signature
|
||||
|
||||
### Bluefruit
|
||||
|
||||
|
||||
@@ -48,12 +48,14 @@
|
||||
*/
|
||||
/******************************************************************************/
|
||||
Adafruit_FIFO::Adafruit_FIFO(uint8_t item_size, uint16_t depth)
|
||||
: _item_size(item_size), _depth(depth)
|
||||
: _item_size(item_size)
|
||||
{
|
||||
_buffer= NULL;
|
||||
_mutex = NULL;
|
||||
_count = _wr_idx = _rd_idx = 0;
|
||||
_buffer = NULL;
|
||||
_mutex = NULL;
|
||||
_depth = depth;
|
||||
_overwritable = false;
|
||||
|
||||
_count = _wr_idx = _rd_idx = 0;
|
||||
}
|
||||
|
||||
void Adafruit_FIFO::begin(void)
|
||||
@@ -62,6 +64,13 @@ void Adafruit_FIFO::begin(void)
|
||||
_mutex = xSemaphoreCreateMutex();
|
||||
}
|
||||
|
||||
void Adafruit_FIFO::begin(uint16_t depth)
|
||||
{
|
||||
_depth = depth;
|
||||
_buffer = (uint8_t*) malloc(_item_size*_depth);
|
||||
_mutex = xSemaphoreCreateMutex();
|
||||
}
|
||||
|
||||
void Adafruit_FIFO::overwriteIfFull(bool enable)
|
||||
{
|
||||
_overwritable = enable;
|
||||
|
||||
@@ -45,7 +45,7 @@ class Adafruit_FIFO
|
||||
{
|
||||
private:
|
||||
uint8_t* _buffer ; ///< buffer pointer
|
||||
const uint16_t _depth ; ///< max items
|
||||
uint16_t _depth ; ///< max items
|
||||
const uint8_t _item_size ; ///< size of each item
|
||||
bool _overwritable ; ///< Overwrite when full
|
||||
volatile uint16_t _count ; ///< number of items in queue
|
||||
@@ -59,11 +59,13 @@ class Adafruit_FIFO
|
||||
|
||||
public:
|
||||
// Constructor
|
||||
Adafruit_FIFO(uint8_t item_size, uint16_t depth);
|
||||
Adafruit_FIFO(uint8_t item_size, uint16_t depth = 0);
|
||||
|
||||
virtual ~Adafruit_FIFO();
|
||||
|
||||
void begin(void);
|
||||
void begin(uint16_t depth);
|
||||
|
||||
void clear(void);
|
||||
void overwriteIfFull(bool enable);
|
||||
|
||||
|
||||
Reference in new issue
Block a user