- fix missing mac address in hello message when ethernet is used
- fix noise when adau1961 is used and muted - fix ESP32 not booting because active REFCLK from LAN8720 some code polish
This commit is contained in:
@@ -563,12 +563,27 @@ esp_err_t adau1961_set_mute(bool enable) {
|
||||
esp_err_t ret = ESP_OK;
|
||||
uint8_t data[3];
|
||||
|
||||
// Playback right and left channel enable
|
||||
data[0] = (uint8_t)(R35_PLAYBACK_PWR_MGMT >> 8);
|
||||
data[1] = (uint8_t)R35_PLAYBACK_PWR_MGMT;
|
||||
data[2] = (!enable << 1) | (!enable << 0);
|
||||
// left channel
|
||||
// get mixer 3 control reg
|
||||
data[0] = (uint8_t)(R22_PLAYBACK_MIXER3_LEFT_CTRL0 >> 8);
|
||||
data[1] = (uint8_t)R22_PLAYBACK_MIXER3_LEFT_CTRL0;
|
||||
ret = i2c_bus_read_bytes(i2c_handler, adau1961_addr, data, 2, &data[2], 1);
|
||||
ADAU1961_ASSERT(ret, "Fail to read R22_PLAYBACK_MIXER3_LEFT_CTRL0", ESP_FAIL);
|
||||
|
||||
data[2] = (!enable << 5);
|
||||
ret = i2c_bus_write_data(i2c_handler, adau1961_addr, data, 3);
|
||||
ADAU1961_ASSERT(ret, "Fail to write R35_PLAYBACK_PWR_MGMT", ESP_FAIL);
|
||||
ADAU1961_ASSERT(ret, "Fail to set R22_PLAYBACK_MIXER3_LEFT_CTRL0", ESP_FAIL);
|
||||
|
||||
// right channel
|
||||
// get mixer 4 control reg
|
||||
data[0] = (uint8_t)(R24_PLAYBACK_MIXER4_RIGHT_CTRL0 >> 8);
|
||||
data[1] = (uint8_t)R24_PLAYBACK_MIXER4_RIGHT_CTRL0;
|
||||
ret = i2c_bus_read_bytes(i2c_handler, adau1961_addr, data, 2, &data[2], 1);
|
||||
ADAU1961_ASSERT(ret, "Fail to read R22_PLAYBACK_MIXER3_LEFT_CTRL0", ESP_FAIL);
|
||||
|
||||
data[2] = (!enable << 6);
|
||||
ret = i2c_bus_write_data(i2c_handler, adau1961_addr, data, 3);
|
||||
ADAU1961_ASSERT(ret, "Fail to set R24_PLAYBACK_MIXER4_RIGHT_CTRL0", ESP_FAIL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -397,36 +397,28 @@ int32_t player_send_snapcast_setting(snapcastSetting_t *setting) {
|
||||
(curSet.codec != setting->codec) || (curSet.muted != setting->muted) ||
|
||||
(curSet.sr != setting->sr) || (curSet.volume != setting->volume) ||
|
||||
(curSet.cDacLat_ms != setting->cDacLat_ms)) {
|
||||
ret = player_set_snapcast_settings(setting);
|
||||
if (ret != pdPASS) {
|
||||
ESP_LOGE(TAG,
|
||||
"player_send_snapcast_setting: couldn't change "
|
||||
"snapcast setting");
|
||||
}
|
||||
|
||||
// check if it is only volume / mute related setting, which is handled by
|
||||
// http_get_task()
|
||||
if (((curSet.muted != setting->muted) ||
|
||||
(curSet.volume != setting->volume)) &&
|
||||
((curSet.bits == setting->bits) && (curSet.buf_ms == setting->buf_ms) &&
|
||||
(curSet.ch == setting->ch) &&
|
||||
(curSet.chkInFrames == setting->chkInFrames) &&
|
||||
(curSet.codec == setting->codec) && (curSet.sr == setting->sr) &&
|
||||
(curSet.cDacLat_ms == setting->cDacLat_ms))) {
|
||||
// no notify needed, only set changed parameters
|
||||
ret = player_set_snapcast_settings(setting);
|
||||
if (ret != pdPASS) {
|
||||
ESP_LOGE(TAG,
|
||||
"player_send_snapcast_setting: couldn't change "
|
||||
"snapcast setting");
|
||||
}
|
||||
} else {
|
||||
if ((((curSet.muted != setting->muted) ||
|
||||
(curSet.volume != setting->volume)) &&
|
||||
((curSet.bits == setting->bits) &&
|
||||
(curSet.buf_ms == setting->buf_ms) && (curSet.ch == setting->ch) &&
|
||||
(curSet.chkInFrames == setting->chkInFrames) &&
|
||||
(curSet.codec == setting->codec) && (curSet.sr == setting->sr) &&
|
||||
(curSet.cDacLat_ms == setting->cDacLat_ms))) == false) {
|
||||
// notify needed
|
||||
ret = xQueueOverwrite(snapcastSettingQueueHandle, &settingChanged);
|
||||
if (ret != pdPASS) {
|
||||
ESP_LOGE(TAG,
|
||||
"player_send_snapcast_setting: couldn't notify "
|
||||
"snapcast setting");
|
||||
} else {
|
||||
// notify successful, so change parameters
|
||||
ret = player_set_snapcast_settings(setting);
|
||||
if (ret != pdPASS) {
|
||||
ESP_LOGE(TAG,
|
||||
"player_send_snapcast_setting: couldn't "
|
||||
"change snapcast setting");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1063,6 +1055,8 @@ static void player_task(void *pvParameters) {
|
||||
|
||||
if ((scSet.sr != __scSet.sr) || (scSet.bits != __scSet.bits) ||
|
||||
(scSet.ch != __scSet.ch)) {
|
||||
i2s_custom_start(I2S_NUM_0);
|
||||
audio_set_mute(true);
|
||||
i2s_custom_stop(I2S_NUM_0);
|
||||
|
||||
ret = player_setup_i2s(I2S_NUM_0, ¤tSnapcastSetting);
|
||||
@@ -1079,8 +1073,6 @@ static void player_task(void *pvParameters) {
|
||||
i2s_custom_set_clk(I2S_NUM_0, __scSet.sr, __scSet.bits, __scSet.ch);
|
||||
|
||||
initialSync = 0;
|
||||
|
||||
audio_set_mute(true);
|
||||
}
|
||||
|
||||
if ((__scSet.buf_ms != scSet.buf_ms) ||
|
||||
@@ -1382,12 +1374,12 @@ static void player_task(void *pvParameters) {
|
||||
timer_pause(TIMER_GROUP_1, TIMER_1);
|
||||
timer_set_auto_reload(TIMER_GROUP_1, TIMER_1, TIMER_AUTORELOAD_DIS);
|
||||
|
||||
audio_set_mute(true);
|
||||
|
||||
i2s_custom_stop(I2S_NUM_0);
|
||||
|
||||
initialSync = 0;
|
||||
|
||||
audio_set_mute(true);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ static const char *provSsid = CONFIG_WIFI_PROVISIONING_SSID;
|
||||
|
||||
static const char *TAG = "WIFI";
|
||||
|
||||
char mac_address[18];
|
||||
static char mac_address[18];
|
||||
|
||||
EventGroupHandle_t s_wifi_event_group;
|
||||
|
||||
|
||||
59
main/main.c
59
main/main.c
@@ -118,8 +118,6 @@ static audio_board_handle_t board_handle = NULL;
|
||||
/* Logging tag */
|
||||
static const char *TAG = "SC";
|
||||
|
||||
extern char mac_address[18];
|
||||
|
||||
// static QueueHandle_t playerChunkQueueHandle = NULL;
|
||||
SemaphoreHandle_t timeSyncSemaphoreHandle = NULL;
|
||||
|
||||
@@ -843,6 +841,17 @@ static void http_get_task(void *pvParameters) {
|
||||
|
||||
ESP_LOGI(TAG, "netconn connected");
|
||||
|
||||
char mac_address[18];
|
||||
uint8_t base_mac[6];
|
||||
// Get MAC address for WiFi station
|
||||
#if CONFIG_SNAPCLIENT_ENABLE_ETHERNET
|
||||
esp_read_mac(base_mac, ESP_MAC_ETH);
|
||||
#else
|
||||
esp_read_mac(base_mac, ESP_MAC_WIFI_STA);
|
||||
#endif
|
||||
sprintf(mac_address, "%02X:%02X:%02X:%02X:%02X:%02X", base_mac[0],
|
||||
base_mac[1], base_mac[2], base_mac[3], base_mac[4], base_mac[5]);
|
||||
|
||||
now = esp_timer_get_time();
|
||||
|
||||
// init base message
|
||||
@@ -1118,14 +1127,14 @@ static void http_get_task(void *pvParameters) {
|
||||
|
||||
typedMsgCurrentPos = 0;
|
||||
|
||||
// ESP_LOGI(TAG,"BM type %d ts %d.%d",
|
||||
// base_message_rx.type,
|
||||
// base_message_rx.received.sec,
|
||||
// base_message_rx.received.usec);
|
||||
// ESP_LOGI(TAG,"%d
|
||||
//%d.%d", base_message_rx.type,
|
||||
// base_message_rx.received.sec,
|
||||
// base_message_rx.received.usec);
|
||||
// ESP_LOGI(TAG,"BM type %d ts %d.%d",
|
||||
// base_message_rx.type,
|
||||
// base_message_rx.received.sec,
|
||||
// base_message_rx.received.usec);
|
||||
// ESP_LOGI(TAG,"%d
|
||||
// %d.%d", base_message_rx.type,
|
||||
// base_message_rx.received.sec,
|
||||
// base_message_rx.received.usec);
|
||||
|
||||
state = TYPED_MESSAGE_STATE;
|
||||
break;
|
||||
@@ -2211,9 +2220,9 @@ static void http_get_task(void *pvParameters) {
|
||||
case 3: {
|
||||
typedMsgLen |= (*start & 0xFF) << 24;
|
||||
|
||||
// ESP_LOGI(TAG,
|
||||
// "server settings string is %d long",
|
||||
// typedMsgLen);
|
||||
// ESP_LOGI(TAG,
|
||||
// "server settings string is %d
|
||||
// long", typedMsgLen);
|
||||
|
||||
typedMsgCurrentPos++;
|
||||
start++;
|
||||
@@ -2674,11 +2683,27 @@ void app_main(void) {
|
||||
esp_log_level_set("gpio", ESP_LOG_NONE);
|
||||
|
||||
#if CONFIG_SNAPCLIENT_ENABLE_ETHERNET
|
||||
// ethernet pcb reset pin
|
||||
gpio_config_t cfg = {.pin_bit_mask = BIT64(GPIO_NUM_17),
|
||||
.mode = GPIO_MODE_DEF_OUTPUT,
|
||||
// clang-format off
|
||||
// nINT/REFCLKO Function Select Configuration Strap
|
||||
// • When nINTSEL is floated or pulled to
|
||||
// VDD2A, nINT is selected for operation on the
|
||||
// nINT/REFCLKO pin (default).
|
||||
// • When nINTSEL is pulled low to VSS, REF-
|
||||
// CLKO is selected for operation on the nINT/
|
||||
// REFCLKO pin.
|
||||
//
|
||||
// LAN8720 doesn't stop REFCLK while in reset, so we leave the
|
||||
// strap floated. It is connected to IO0 on ESP32 so we get nINT
|
||||
// function with a HIGH pin value, which is also perfect during boot.
|
||||
// Before initializing LAN8720 (which resets the PHY) we pull the
|
||||
// strap low and this results in REFCLK enabled which is needed
|
||||
// for MAC unit.
|
||||
//
|
||||
// clang-format on
|
||||
gpio_config_t cfg = {.pin_bit_mask = BIT64(GPIO_NUM_5),
|
||||
.mode = GPIO_MODE_DEF_INPUT,
|
||||
.pull_up_en = GPIO_PULLUP_DISABLE,
|
||||
.pull_down_en = GPIO_PULLDOWN_DISABLE,
|
||||
.pull_down_en = GPIO_PULLDOWN_ENABLE,
|
||||
.intr_type = GPIO_INTR_DISABLE};
|
||||
gpio_config(&cfg);
|
||||
#endif
|
||||
|
||||
14
sdkconfig
14
sdkconfig
@@ -190,7 +190,19 @@ CONFIG_USE_BIQUAD_ASM=y
|
||||
#
|
||||
# Snapclient Ethernet Configuration
|
||||
#
|
||||
# CONFIG_SNAPCLIENT_ENABLE_ETHERNET is not set
|
||||
CONFIG_SNAPCLIENT_ENABLE_ETHERNET=y
|
||||
CONFIG_SNAPCLIENT_USE_INTERNAL_ETHERNET=y
|
||||
# CONFIG_SNAPCLIENT_USE_DM9051 is not set
|
||||
# CONFIG_SNAPCLIENT_USE_W5500 is not set
|
||||
# CONFIG_SNAPCLIENT_ETH_PHY_IP101 is not set
|
||||
# CONFIG_SNAPCLIENT_ETH_PHY_RTL8201 is not set
|
||||
CONFIG_SNAPCLIENT_ETH_PHY_LAN8720=y
|
||||
# CONFIG_SNAPCLIENT_ETH_PHY_DP83848 is not set
|
||||
# CONFIG_SNAPCLIENT_ETH_PHY_KSZ8041 is not set
|
||||
CONFIG_SNAPCLIENT_ETH_MDC_GPIO=23
|
||||
CONFIG_SNAPCLIENT_ETH_MDIO_GPIO=18
|
||||
CONFIG_SNAPCLIENT_ETH_PHY_RST_GPIO=17
|
||||
CONFIG_SNAPCLIENT_ETH_PHY_ADDR=0
|
||||
# end of Snapclient Ethernet Configuration
|
||||
|
||||
#
|
||||
|
||||
@@ -203,9 +203,9 @@ CONFIG_SNTP_SERVER="pool.ntp.org"
|
||||
#
|
||||
# Wifi Configuration
|
||||
#
|
||||
# CONFIG_ENABLE_WIFI_PROVISIONING is not set
|
||||
CONFIG_WIFI_SSID="myssid"
|
||||
CONFIG_WIFI_PASSWORD="mypassword"
|
||||
CONFIG_ENABLE_WIFI_PROVISIONING=y
|
||||
CONFIG_WIFI_PROVISIONING_SSID="prov_snapclient"
|
||||
CONFIG_WIFI_PROVISIONING_PASSWORD="12345678"
|
||||
CONFIG_WIFI_MAXIMUM_RETRY=0
|
||||
# end of Wifi Configuration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user