Remark from projectkk2glider taken into account

Serial2 connection and USB CDC output now waits there is some free space
before adding anything to the buffer
This commit is contained in:
Bertrand Songis
2015-08-27 14:38:47 +02:00
parent 330a91441a
commit 5d7f55fa97
6 changed files with 26 additions and 14 deletions
+9 -4
View File
@@ -56,7 +56,7 @@ class Fifo
}
bool pop(uint8_t & byte) {
if (empty()) {
if (isEmpty()) {
return false;
}
else {
@@ -66,12 +66,17 @@ class Fifo
}
}
bool empty() {
bool isEmpty() {
return (ridx == widx);
}
bool isFull() {
uint32_t next = (widx+1) & (N-1);
return (next == ridx);
}
void flush() {
while (!empty()) {};
while (!isEmpty()) {};
}
protected:
@@ -80,4 +85,4 @@ class Fifo
volatile uint32_t ridx;
};
#endif
#endif // _FIFO_H_