* Initial bi-directional I2S support. * Formatting update on pioasm file. * Added loopback example. * Updated documentation. * Fix `getOverUnderflow` naming. * Revert `getOverUnderflow` naming changes. * Remove python cache file. * Remove `availableForRead`. * Updated naming convention of OverUnderflow methods. * Update constructor to prevent conflicts with existing code. * Avoid ambiguous `setDATA` in bi-directional mode. * Use only input buffer manager in `available`. * Fix input checks in `read` and `peek`. * Fix erroneous comment. * Update pio_i2s.pio to pio v1. * Change pio_i2s.pio back to pio v0.
37 lines
759 B
Arduino
37 lines
759 B
Arduino
/*
|
|
I2S bi-directional input and output loopback example
|
|
Released to the Public Domain by Cooper Dalrymple
|
|
*/
|
|
|
|
#include <I2S.h>
|
|
|
|
I2S i2s(INPUT_PULLUP);
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
|
|
i2s.setDOUT(0);
|
|
i2s.setDIN(1);
|
|
i2s.setBCLK(2); // Note: LRCLK = BCLK + 1
|
|
i2s.setBitsPerSample(16);
|
|
i2s.setFrequency(22050);
|
|
// NOTE: The following values are known to work with the Adafruit microphone:
|
|
// i2s.setBitsPerSample(32);
|
|
// i2s.setFrequency(16000);
|
|
i2s.begin();
|
|
|
|
while (1) {
|
|
int16_t l, r;
|
|
i2s.read16(&l, &r);
|
|
i2s.write16(l, r);
|
|
// NOTE: Adafruit microphone word size needs to match the BPS above.
|
|
// int32_t l, r;
|
|
// i2s.read32(&l, &r);
|
|
// i2s.write32(l, r);
|
|
}
|
|
}
|
|
|
|
void loop() {
|
|
/* Nothing here */
|
|
}
|