Skip to content

Commit f57b5bc

Browse files
Add I2S::getOverUnderflow() (#1497)
See #1491. Thanks @LinusHeu
1 parent 35a4d57 commit f57b5bc

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

docs/i2s.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ void flush()
8484
~~~~~~~~~~~~
8585
Waits until all the I2S buffers have been output.
8686

87+
void getOverUnderflow()
88+
~~~~~~~~~~~~~~~~~~~~~~~
89+
Returns a flag indicating if the I2S system ran our of data to send on output,
90+
or had to throw away data on input.
91+
8792
size_t write(uint8_t/int8_t/int16_t/int32_t)
8893
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8994
Writes a single sample of ``bitsPerSample`` to the buffer. It is up to the

libraries/I2S/src/I2S.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@ class I2S : public Stream {
5454
virtual size_t write(const uint8_t *buffer, size_t size) override;
5555
virtual int availableForWrite() override;
5656

57+
// From the AR
58+
bool getOverUnderflow() {
59+
if (!_running) {
60+
return false;
61+
} else {
62+
return _arb->getOverUnderflow();
63+
}
64+
}
65+
5766
// Try and make I2S::write() do what makes sense, namely write
5867
// one sample (L or R) at the I2S configured bit width
5968
virtual size_t write(uint8_t s) override {

0 commit comments

Comments
 (0)