pschatzmann / arduino-audio-tools

Arduino Audio Tools (a powerful Audio library not only for Arduino)
GNU General Public License v3.0
1.55k stars 237 forks source link

streams-audiokit-audiokit.ino not wokring on v2.2 2762 #1354

Closed SveLil closed 9 months ago

SveLil commented 9 months ago

Problem Description

When using the exmaple from https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-audiokit/streams-audiokit-audiokit/ with AudioBoardStream kit(AudioKitAC101); I only get `Warning: Pin '13' not set up because of conflict Warning: Pin '22' not set up because of conflict Error: ->p_wire->endTransmission: 2 Error: reset failed! Error: init failed

assert failed: audio_driver::error_t i2c_bus_read_bytes(audio_driver::i2c_bus_handle_t, int, uint8_t, int, uint8_t, int) I2C.cpp:40 (datalen == 1)

Backtrace: 0x40083be1:0x3ffb1e00 0x4008a405:0x3ffb1e20 0x4008f52d:0x3ffb1e40 0x400db2b2:0x3ffb1f70 0x400d7db9:0x3ffb1f90 0x400d7f4d:0x3ffb1fc0 0x400d805d:0x3ffb1fe0 0x400d2adb:0x3ffb2000 0x400d4b0d:0x3ffb2020 0x400d4bb7:0x3ffb2070 0x400d4bfd:0x3ffb20f0 0x400d375b:0x3ffb2110 0x400d46c9:0x3ffb2130 0x400d4cab:0x3ffb21b0 0x400ddb86:0x3ffb2290 `

DIP settings I tried: Off, On,On,Off,Off On, On, On, Off, Off (This is working with ESP32-audioI2S)

Device Description

ESP32 Audio Kit V2.2 2762 wtih AC101 (confirmed by using https://github.com/schreibfaul1/ESP32-audioI2S/

Sketch

/**
 * @file streams-audiokit-audiokit.ino
 * @author Phil Schatzmann
 * @brief see https://github.com/pschatzmann/arduino-audio-tools/blob/main/examples/examples-audiokit/streams-audiokit-audiokit/README.md
 * 
 * @author Phil Schatzmann
 * @copyright GPLv3
 */

#include "AudioTools.h"
#include "AudioLibs/AudioBoardStream.h"
#include "FS.h"

  AudioBoardStream kit(AudioKitAC101); // Access I2S as stream
StreamCopy copier(kit, kit); // copy kit to kit

// Arduino Setup
void setup(void) {
    Serial.begin(115200);
    AudioLogger::instance().begin(Serial, AudioLogger::Warning);

    auto cfg = kit.defaultConfig(RXTX_MODE);
    cfg.sd_active = false;
    cfg.input_device = ADC_INPUT_LINE2;
    kit.begin(cfg);
}

// Arduino loop - copy data
void loop() {
    copier.copy();
}

Other Steps to Reproduce

No response

What is your development environment

PlatformIO with ` platform = espressif32 board = esp32dev

lib_deps = https://github.com/pschatzmann/arduino-audio-tools https://github.com/pschatzmann/ESP32-A2DP https://github.com/pschatzmann/arduino-audio-driver https://github.com/pschatzmann/arduino-libhelix https://github.com/pschatzmann/arduino-flite`

I have checked existing issues, discussions and online documentation

SveLil commented 9 months ago

I tried adding my own definition for the board

class PinsAudioKitAC101V2Class : public DriverPins {
  public:
    PinsAudioKitAC101V2Class() {
      // sd pins
    addSPI(ESP32PinsSD);
    // add i2c codec pins: scl, sda, port, frequency
    addI2C(PinFunction::CODEC, 32, 33);
    // add i2s pins: mclk, bck, ws,data_out, data_in ,(port)
    addI2S(PinFunction::CODEC, 0, 27, 26, 25, 35);
    // add other pins
    addPin(PinFunction::KEY, 36, PinLogic::InputActiveLow, 1);
    // addPin(PinFunction::KEY, 13, PinLogic::InputActiveLow, 2);
    addPin(PinFunction::KEY, 19, PinLogic::InputActiveLow, 3);
    addPin(PinFunction::KEY, 23, PinLogic::InputActiveLow, 4);
    addPin(PinFunction::KEY, 18, PinLogic::InputActiveLow, 5);
    addPin(PinFunction::KEY, 5, PinLogic::InputActiveLow, 6);
    // addPin(PinFunction::LED, 22, PinLogic::Output, 0);
    addPin(PinFunction::LED, 19, PinLogic::Output, 1);
    addPin(PinFunction::HEADPHONE_DETECT, 5, PinLogic::InputActiveLow);
    addPin(PinFunction::PA, 21, PinLogic::Output);
  }
};
static PinsAudioKitAC101V2Class PinsAudioKitAC101V2;
static AudioBoard AudioKitAC101V2{AudioDriverAC101, PinsAudioKitAC101V2};

That get rid of the pin warnings, but still leaves the error in Wire

pschatzmann commented 9 months ago

Are you sure that it is a AC101 based board? Usually I2C is failing if you select the wrong board...

pschatzmann commented 9 months ago

I think the I2C address is wrong: it should be 0x1a<<1 (= 0x34) instead of 0x1a ! The code has been converted partly from ADF which uses a different addressing then Arduino

pschatzmann commented 9 months ago

There were some more issues relate to this: I committed a correction!

I did not spend any attention to this, having it already working as part of the legacy AudioKit project, but it seems that I have never ported the I2C functionality to the Arduino Wire API for this driver