Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

espressif32 2.0.2 + 2.0.3 support #505

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 26 additions & 5 deletions src/AudioOutputI2S.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
AudioOutputI2S
Base class for I2S interface port
Copyright (C) 2017 Earle F. Philhower, III
This program is free software: you can redistribute it and/or modify
Expand All @@ -21,6 +21,24 @@
#include <Arduino.h>
#ifdef ESP32
#include "driver/i2s.h"

// handle I2S migration across SDK versions
#ifdef ESP_ARDUINO_VERSION_VAL
#if defined ESP_ARDUINO_VERSION && ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(2, 0, 0)
// upstream
#define I2C_COMM_FORMAT I2S_COMM_FORMAT_STAND_I2S
#define I2C_COMM_FORMAT_STAND I2S_COMM_FORMAT_STAND_MSB
#else
// edge case: 1.0.6 built from source ?
#define I2C_COMM_FORMAT I2S_COMM_FORMAT_I2S
#define I2C_COMM_FORMAT_STAND I2S_COMM_FORMAT_I2S_LSB
#endif
#else
// legacy (1.0.6 and previous)
#define I2C_COMM_FORMAT I2S_COMM_FORMAT_I2S
#define I2C_COMM_FORMAT_STAND I2S_COMM_FORMAT_I2S_LSB
#endif

#elif defined(ARDUINO_ARCH_RP2040) || ARDUINO_ESP8266_MAJOR >= 3
#include <I2S.h>
#elif ARDUINO_ESP8266_MAJOR < 3
Expand All @@ -29,6 +47,9 @@
#include "AudioOutputI2S.h"

#if defined(ESP32) || defined(ESP8266)



AudioOutputI2S::AudioOutputI2S(int port, int output_mode, int dma_buf_count, int use_apll)
{
this->portNo = port;
Expand Down Expand Up @@ -178,15 +199,15 @@ bool AudioOutputI2S::begin(bool txDAC)
#if CONFIG_IDF_TARGET_ESP32
mode = (i2s_mode_t)(mode | I2S_MODE_DAC_BUILT_IN);
#else
return false;
return false;
#endif
}
else if (output_mode == INTERNAL_PDM)
{
#if CONFIG_IDF_TARGET_ESP32
mode = (i2s_mode_t)(mode | I2S_MODE_PDM);
#else
return false;
return false;
#endif
}

Expand All @@ -201,14 +222,14 @@ bool AudioOutputI2S::begin(bool txDAC)
}
else if (lsb_justified)
{
comm_fmt = (i2s_comm_format_t) (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_LSB);
comm_fmt = (i2s_comm_format_t) (I2C_COMM_FORMAT | I2C_COMM_FORMAT_STAND);
}
else
{
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 2, 0)
comm_fmt = (i2s_comm_format_t) (I2S_COMM_FORMAT_STAND_I2S);
#else
comm_fmt = (i2s_comm_format_t) (I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB);
comm_fmt = (i2s_comm_format_t) (I2C_COMM_FORMAT | I2S_COMM_FORMAT_I2S_MSB);
#endif
}

Expand Down