upgrade to IDF v5.1.1

custom board driver ma120x0 is broken
esp dsp is now IDF managed component
mdns is now IDF managed component

Signed-off-by: Karl Osterseher <karli_o@gmx.at>
This commit is contained in:
Karl Osterseher
2024-01-08 22:49:11 +01:00
Unverified
parent 713cda5816
commit db0f9732b2
454 changed files with 29632 additions and 39819 deletions

View File

@@ -78,6 +78,12 @@ menu "Custom Audio Board"
endmenu
menu "I2S slave interface"
config SLAVE_I2S_MCLK_PIN
int "Slave i2s mclk"
default 0
help
Slave audio interface master clock.
config SLAVE_I2S_BCK_PIN
int "Slave i2s bck"
default 26
@@ -112,13 +118,13 @@ menu "Custom Audio Board"
help
GPIO number to controm mute/unmute.
config MERUS_NERR_PIN
config MA120X0_NERR_PIN
int "NERR monitor pin"
default 21
help
GPIO number to monitor NERROR.
config MERUS_NCLIP_PIN
config MA120X0_NCLIP_PIN
int "Clip indication pin"
default 22
help

View File

@@ -32,6 +32,10 @@
#include "driver/gpio.h"
#include "esp_log.h"
#if SOC_I2S_NUM > 1
#define I2S_NUM_MAX I2S_NUM_1 + 1
#endif
static const char *TAG = "GENERIC_BOARD";
esp_err_t get_i2c_pins(i2c_port_t port, i2c_config_t *i2c_config) {
@@ -48,20 +52,22 @@ esp_err_t get_i2c_pins(i2c_port_t port, i2c_config_t *i2c_config) {
return ESP_OK;
}
esp_err_t get_i2s_pins(i2s_port_t port, i2s_pin_config_t *i2s_config) {
esp_err_t get_i2s_pins(i2s_port_t port, board_i2s_pin_t *i2s_config) {
AUDIO_NULL_CHECK(TAG, i2s_config, return ESP_FAIL);
if (port == I2S_NUM_0) {
i2s_config->mck_io_num = CONFIG_MASTER_I2S_MCLK_PIN;
i2s_config->bck_io_num = CONFIG_MASTER_I2S_BCK_PIN;
i2s_config->ws_io_num = CONFIG_MASTER_I2S_LRCK_PIN;
i2s_config->data_out_num = CONFIG_MASTER_I2S_DATAOUT_PIN;
i2s_config->data_in_num = -1;
} else if (port == I2S_NUM_1) {
i2s_config->mck_io_num = CONFIG_SLAVE_I2S_MCLK_PIN;
i2s_config->bck_io_num = CONFIG_SLAVE_I2S_BCK_PIN;
i2s_config->ws_io_num = CONFIG_SLAVE_I2S_LRCK_PIN;
i2s_config->data_out_num = CONFIG_SLAVE_I2S_DATAOUT_PIN;
i2s_config->data_in_num = -1;
} else {
memset(i2s_config, -1, sizeof(i2s_pin_config_t));
memset(i2s_config, -1, sizeof(board_i2s_pin_t));
ESP_LOGE(TAG, "i2s port %d is not supported", port);
return ESP_FAIL;
}
@@ -69,32 +75,6 @@ esp_err_t get_i2s_pins(i2s_port_t port, i2s_pin_config_t *i2s_config) {
return ESP_OK;
}
esp_err_t i2s_mclk_gpio_select(i2s_port_t i2s_num, gpio_num_t gpio_num) {
if (i2s_num >= I2S_NUM_MAX) {
ESP_LOGE(TAG, "Does not support i2s number(%d)", i2s_num);
return ESP_ERR_INVALID_ARG;
}
if (gpio_num != GPIO_NUM_0 && gpio_num != GPIO_NUM_1 &&
gpio_num != GPIO_NUM_3) {
ESP_LOGE(TAG, "Only support GPIO0/GPIO1/GPIO3, gpio_num:%d", gpio_num);
return ESP_ERR_INVALID_ARG;
}
ESP_LOGI(TAG, "I2S%d, MCLK output by GPIO%d", i2s_num, gpio_num);
if (i2s_num == I2S_NUM_0) {
if (gpio_num == GPIO_NUM_0) {
PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO0_U, FUNC_GPIO0_CLK_OUT1);
WRITE_PERI_REG(PIN_CTRL, 0xFFF0);
} else if (gpio_num == GPIO_NUM_1) {
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD_CLK_OUT3);
WRITE_PERI_REG(PIN_CTRL, 0xF0F0);
} else {
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0RXD_U, FUNC_U0RXD_CLK_OUT2);
WRITE_PERI_REG(PIN_CTRL, 0xFF00);
}
}
return ESP_OK;
}
esp_err_t get_spi_pins(
spi_bus_config_t *spi_config,
spi_device_interface_config_t *spi_device_interface_config) {

View File

@@ -27,6 +27,8 @@
#ifndef _AUDIO_BOARD_DEFINITION_H_
#define _AUDIO_BOARD_DEFINITION_H_
#define BOARD_PA_GAIN (0) /* Power amplifier gain defined by board (dB) */
#define BUTTON_VOLUP_ID 0
#define BUTTON_VOLDOWN_ID 1
#define BUTTON_MUTE_ID 2

View File

@@ -9,15 +9,15 @@
//
//
#include "ma120.h"
#include <stdint.h>
#include <stdio.h>
#include "ma120.h"
#include "board.h"
#include "driver/i2c.h"
#include "esp_log.h"
static const char *TAG = "MA120";
#define MA_ENABLE_IO CONFIG_MA120_ENABLE_PIN
@@ -66,12 +66,12 @@ esp_err_t ma120_deinit(void) {
}
esp_err_t ma120_ctrl(audio_hal_codec_mode_t mode, audio_hal_ctrl_t ctrl_state) {
ESP_LOGI("MA120 Driver", "ctrl w. mode and ctrl_state");
ESP_LOGI("MA120 Driver", "ctrl w. mode and ctrl_state");
return ESP_OK;
}
esp_err_t ma120_config_iface(audio_hal_codec_mode_t mode,
audio_hal_codec_i2s_iface_t *iface) {
audio_hal_codec_i2s_iface_t *iface) {
ESP_LOGI("MA120 Driver", "config_iface w. mode and interface");
return ESP_OK;
}
@@ -111,13 +111,13 @@ esp_err_t ma120_get_mute(bool *enabled) {
esp_err_t ma120_init(audio_hal_codec_config_t *codec_cfg) {
esp_err_t ret = ESP_OK;
setup_ma120();
return ret;
}
return ret;
}
void setup_ma120(void){
void setup_ma120(void) {
gpio_config_t io_conf;
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = (1ULL << MA_ENABLE_IO | 1ULL << MA_NMUTE_IO);
io_conf.pull_down_en = 0;
@@ -126,7 +126,7 @@ void setup_ma120(void){
printf("setup output %d %d \n", MA_ENABLE_IO, MA_NMUTE_IO);
gpio_config(&io_conf);
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pin_bit_mask = (1ULL << MA_NCLIP_IO | 1ULL << MA_NERR_IO);
io_conf.pull_down_en = 0;
@@ -136,8 +136,7 @@ void setup_ma120(void){
gpio_set_level(MA_NMUTE_IO, 0);
gpio_set_level(MA_ENABLE_IO, 0);
i2c_master_init();
gpio_set_level(MA_ENABLE_IO, 1);
@@ -145,7 +144,7 @@ void setup_ma120(void){
uint8_t res = ma_write_byte(MA120_ADDR, 2, 0x060c, 0);
res = ma_read_byte(MA120_ADDR, 2, 0x060c);
printf("Hardware version: 0x%02x\n", res);
printf("Scan I2C bus: ");
for (uint8_t addr = 0x20; addr <= 0x23; addr++) {
res = ma_read_byte(addr, 2, 0);
@@ -153,7 +152,7 @@ void setup_ma120(void){
// printf("Scan i2c address 0x%02x read address 0 : 0x%02x \n", addr ,res);
}
printf("\n");
uint8_t rxbuf[32];
uint8_t otp[1024];
for (uint8_t i = 0; i < 16; i++) {
@@ -234,7 +233,7 @@ void ma120_read_error(uint8_t i2c_addr) { // 0x0118 error now ch0 [clip_stuck
// printf("\n");
}
static i2c_config_t i2c_cfg = {
static i2c_config_t i2c_cfg = {
.mode = I2C_MODE_MASTER,
.sda_pullup_en = GPIO_PULLUP_ENABLE,
.scl_pullup_en = GPIO_PULLUP_ENABLE,

View File

@@ -17,12 +17,12 @@
#include "driver/i2c.h"
#include "esp_log.h"
#include "ma120x0.h"
//#include "ma120_rev1_all.h"
// #include "ma120_rev1_all.h"
#include "audio_hal.h"
static const char *TAG = "MA120X0";
#define MA_NENABLE_IO CONFIG_MA120X0_NENABLE_PIN
#define MA_ENABLE_IO CONFIG_MA120X0_ENABLE_PIN
#define MA_NMUTE_IO CONFIG_MA120X0_NMUTE_PIN
#define MA_NERR_IO CONFIG_MA120X0_NERR_PIN
#define MA_NCLIP_IO CONFIG_MA120X0_NCLIP_PIN
@@ -51,6 +51,16 @@ static const char *I2C_TAG = "i2c";
static i2c_config_t i2c_cfg;
esp_err_t ma120x0_init(audio_hal_codec_config_t *codec_cfg);
esp_err_t ma120x0_deinit(void);
esp_err_t ma120x0_config_iface(audio_hal_codec_mode_t mode,
audio_hal_codec_i2s_iface_t *iface);
esp_err_t ma120x0_set_volume(int vol);
esp_err_t ma120x0_get_volume(int *vol);
esp_err_t ma120x0_set_mute(bool enable);
esp_err_t ma120x0_ctrl(audio_hal_codec_mode_t mode,
audio_hal_ctrl_t ctrl_state);
audio_hal_func_t AUDIO_CODEC_MA120X0_DEFAULT_HANDLE = {
.audio_codec_initialize = ma120x0_init,
.audio_codec_deinitialize = ma120x0_deinit,

View File

@@ -1,6 +1,10 @@
#ifndef _MERUSAUDIO_H_
#define _MERUSAUDIO_H_
#include <stdint.h>
#include "esp_err.h"
void setup_ma120x0(void);
void setup_ma120(void);
void ma120_read_error(uint8_t i2c_addr);

View File

@@ -36,7 +36,7 @@ esp_err_t max98357_init(audio_hal_codec_config_t *codec_cfg) {
gpio_config_t io_conf;
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = (1ULL << CONFIG_MAX98357_MUTE_PIN);
io_conf.pull_down_en = 0;

View File

@@ -1,30 +1,29 @@
/*
* TI PCM5102A audio hal
*
*
* Mostly stubs (no I2C or volume control)
* Configuration of mute/unmute gpio in init (connected to XSMT)
*/
#include "pcm5102a.h"
#include <driver/gpio.h>
#include "board.h"
#include "esp_log.h"
#include <driver/gpio.h>
static const char *TAG = "PCM5102A";
#define PCM5102A_ASSERT(a, format, b, ...) \
if ((a) != 0) { \
ESP_LOGE(TAG, format, ##__VA_ARGS__); \
return b; \
if ((a) != 0) { \
ESP_LOGE(TAG, format, ##__VA_ARGS__); \
return b; \
}
esp_err_t pcm5102a_ctrl(audio_hal_codec_mode_t mode,
audio_hal_ctrl_t ctrl_state);
audio_hal_ctrl_t ctrl_state);
esp_err_t pcm5102a_config_iface(audio_hal_codec_mode_t mode,
audio_hal_codec_i2s_iface_t *iface);
audio_hal_codec_i2s_iface_t *iface);
audio_hal_func_t AUDIO_CODEC_PCM5102A_DEFAULT_HANDLE = {
.audio_codec_initialize = pcm5102a_init,
@@ -43,19 +42,17 @@ esp_err_t pcm5102a_init(audio_hal_codec_config_t *codec_cfg) {
gpio_config_t io_conf;
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = (1ULL << CONFIG_PCM5102A_MUTE_PIN);
io_conf.pull_down_en = 0;
io_conf.pull_up_en = 0;
ret = gpio_config(&io_conf);
if (ret != ESP_OK)
{
ESP_LOGE(TAG, "Mute gpio config failed for pin %d", CONFIG_PCM5102A_MUTE_PIN);
}
else
{
if (ret != ESP_OK) {
ESP_LOGE(TAG, "Mute gpio config failed for pin %d",
CONFIG_PCM5102A_MUTE_PIN);
} else {
gpio_set_level(CONFIG_PCM5102A_MUTE_PIN, 0);
ESP_LOGD(TAG, "Setup mute (XMT) output %d\n", CONFIG_PCM5102A_MUTE_PIN);
}
@@ -63,32 +60,26 @@ esp_err_t pcm5102a_init(audio_hal_codec_config_t *codec_cfg) {
return ret;
}
esp_err_t pcm5102a_set_volume(int vol) {
return ESP_OK;
}
esp_err_t pcm5102a_set_volume(int vol) { return ESP_OK; }
esp_err_t pcm5102a_get_volume(int *value) {
return ESP_OK;
}
esp_err_t pcm5102a_get_volume(int *value) { return ESP_OK; }
esp_err_t pcm5102a_set_mute(bool enable) {
return gpio_set_level(CONFIG_PCM5102A_MUTE_PIN, enable ? 0 : 1);
}
esp_err_t pcm5102a_get_mute(bool *enabled) {
return ESP_OK;
}
esp_err_t pcm5102a_get_mute(bool *enabled) { return ESP_OK; }
esp_err_t pcm5102a_deinit(void) {
return gpio_reset_pin(CONFIG_PCM5102A_MUTE_PIN);
}
esp_err_t pcm5102a_ctrl(audio_hal_codec_mode_t mode,
audio_hal_ctrl_t ctrl_state) {
audio_hal_ctrl_t ctrl_state) {
return ESP_OK;
}
esp_err_t pcm5102a_config_iface(audio_hal_codec_mode_t mode,
audio_hal_codec_i2s_iface_t *iface) {
audio_hal_codec_i2s_iface_t *iface) {
return ESP_OK;
}