|
@@ -66,7 +66,8 @@ uint8_t fifo8_pop(Fifo8 *fifo)
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
-const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
|
|
|
|
|
|
+static const uint8_t *fifo8_peekpop_buf(Fifo8 *fifo, uint32_t max,
|
|
|
|
+ uint32_t *numptr, bool do_pop)
|
|
{
|
|
{
|
|
uint8_t *ret;
|
|
uint8_t *ret;
|
|
uint32_t num;
|
|
uint32_t num;
|
|
@@ -74,15 +75,28 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
|
|
assert(max > 0 && max <= fifo->num);
|
|
assert(max > 0 && max <= fifo->num);
|
|
num = MIN(fifo->capacity - fifo->head, max);
|
|
num = MIN(fifo->capacity - fifo->head, max);
|
|
ret = &fifo->data[fifo->head];
|
|
ret = &fifo->data[fifo->head];
|
|
- fifo->head += num;
|
|
|
|
- fifo->head %= fifo->capacity;
|
|
|
|
- fifo->num -= num;
|
|
|
|
|
|
+
|
|
|
|
+ if (do_pop) {
|
|
|
|
+ fifo->head += num;
|
|
|
|
+ fifo->head %= fifo->capacity;
|
|
|
|
+ fifo->num -= num;
|
|
|
|
+ }
|
|
if (numptr) {
|
|
if (numptr) {
|
|
*numptr = num;
|
|
*numptr = num;
|
|
}
|
|
}
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const uint8_t *fifo8_peek_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
|
|
|
|
+{
|
|
|
|
+ return fifo8_peekpop_buf(fifo, max, numptr, false);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
|
|
|
|
+{
|
|
|
|
+ return fifo8_peekpop_buf(fifo, max, numptr, true);
|
|
|
|
+}
|
|
|
|
+
|
|
void fifo8_reset(Fifo8 *fifo)
|
|
void fifo8_reset(Fifo8 *fifo)
|
|
{
|
|
{
|
|
fifo->num = 0;
|
|
fifo->num = 0;
|