Fix I2S::write(const uint8_t *buffer, size_t size) (#1461)
According to this: https://github.com/earlephilhower/arduino-pico/discussions/1450
This commit is contained in:
parent
a1ae61b5b1
commit
3b4fb295ea
1 changed files with 4 additions and 3 deletions
|
|
@ -376,13 +376,14 @@ bool I2S::read32(int32_t *l, int32_t *r) {
|
||||||
|
|
||||||
size_t I2S::write(const uint8_t *buffer, size_t size) {
|
size_t I2S::write(const uint8_t *buffer, size_t size) {
|
||||||
// We can only write 32-bit chunks here
|
// We can only write 32-bit chunks here
|
||||||
if (size & 0x3) {
|
if (size & 0x3 || !_running || !_isOutput) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t writtenSize = 0;
|
size_t writtenSize = 0;
|
||||||
int32_t *p = (int32_t *)buffer;
|
uint32_t *p = (uint32_t *)buffer;
|
||||||
while (size) {
|
while (size) {
|
||||||
if (!write((int32_t)*p)) {
|
if (!_arb->write(*p, false)) {
|
||||||
// Blocked, stop write here
|
// Blocked, stop write here
|
||||||
return writtenSize;
|
return writtenSize;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue