mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-07 03:57:07 +03:00
Spotify over Ethernet!
This commit is contained in:
@@ -116,7 +116,7 @@ static void set_i2s_pin(char *config, i2s_pin_config_t *pin_config) {
|
|||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
* Get i2s config structure from config string
|
* Get i2s config structure from config string
|
||||||
*/
|
*/
|
||||||
const i2s_platform_config_t * config_get_i2s_from_str(char * dac_config ){
|
const i2s_platform_config_t * config_i2s_get_from_str(char * dac_config ){
|
||||||
static EXT_RAM_ATTR i2s_platform_config_t i2s_dac_pin;
|
static EXT_RAM_ATTR i2s_platform_config_t i2s_dac_pin;
|
||||||
memset(&i2s_dac_pin, 0xff, sizeof(i2s_dac_pin));
|
memset(&i2s_dac_pin, 0xff, sizeof(i2s_dac_pin));
|
||||||
set_i2s_pin(dac_config, &i2s_dac_pin.pin);
|
set_i2s_pin(dac_config, &i2s_dac_pin.pin);
|
||||||
@@ -139,11 +139,8 @@ const i2s_platform_config_t * config_get_i2s_from_str(char * dac_config ){
|
|||||||
/****************************************************************************************
|
/****************************************************************************************
|
||||||
* Get eth config structure from config string
|
* Get eth config structure from config string
|
||||||
*/
|
*/
|
||||||
const eth_config_t * config_get_eth_from_str(char* config ){
|
const eth_config_t * config_eth_get_from_str(char* config ){
|
||||||
static EXT_RAM_ATTR eth_config_t eth_config;
|
static EXT_RAM_ATTR eth_config_t eth_config;
|
||||||
memset(ð_config, 0xff, sizeof(eth_config));
|
|
||||||
memset(ð_config.model, 0x00, sizeof(eth_config.model));
|
|
||||||
eth_config.valid = true;
|
|
||||||
|
|
||||||
PARSE_PARAM_STR(config, "model", '=', eth_config.model, 15);
|
PARSE_PARAM_STR(config, "model", '=', eth_config.model, 15);
|
||||||
PARSE_PARAM(config, "mdc", '=', eth_config.mdc);
|
PARSE_PARAM(config, "mdc", '=', eth_config.mdc);
|
||||||
@@ -158,6 +155,7 @@ const eth_config_t * config_get_eth_from_str(char* config ){
|
|||||||
|
|
||||||
// only system host is available
|
// only system host is available
|
||||||
eth_config.host = spi_system_host;
|
eth_config.host = spi_system_host;
|
||||||
|
eth_config.valid = true;
|
||||||
|
|
||||||
if(!eth_config.model || strlen(eth_config.model)==0){
|
if(!eth_config.model || strlen(eth_config.model)==0){
|
||||||
eth_config.valid = false;
|
eth_config.valid = false;
|
||||||
@@ -197,7 +195,7 @@ const eth_config_t * config_get_eth_from_str(char* config ){
|
|||||||
const i2s_platform_config_t * config_spdif_get( ){
|
const i2s_platform_config_t * config_spdif_get( ){
|
||||||
char * spdif_config = config_spdif_get_string();
|
char * spdif_config = config_spdif_get_string();
|
||||||
static EXT_RAM_ATTR i2s_platform_config_t i2s_dac_config;
|
static EXT_RAM_ATTR i2s_platform_config_t i2s_dac_config;
|
||||||
memcpy(&i2s_dac_config, config_get_i2s_from_str(spdif_config), sizeof(i2s_dac_config));
|
memcpy(&i2s_dac_config, config_i2s_get_from_str(spdif_config), sizeof(i2s_dac_config));
|
||||||
free(spdif_config);
|
free(spdif_config);
|
||||||
return &i2s_dac_config;
|
return &i2s_dac_config;
|
||||||
}
|
}
|
||||||
@@ -208,7 +206,7 @@ const i2s_platform_config_t * config_spdif_get( ){
|
|||||||
const i2s_platform_config_t * config_dac_get(){
|
const i2s_platform_config_t * config_dac_get(){
|
||||||
char * spdif_config = get_dac_config_string();
|
char * spdif_config = get_dac_config_string();
|
||||||
static EXT_RAM_ATTR i2s_platform_config_t i2s_dac_config;
|
static EXT_RAM_ATTR i2s_platform_config_t i2s_dac_config;
|
||||||
memcpy(&i2s_dac_config, config_get_i2s_from_str(spdif_config), sizeof(i2s_dac_config));
|
memcpy(&i2s_dac_config, config_i2s_get_from_str(spdif_config), sizeof(i2s_dac_config));
|
||||||
free(spdif_config);
|
free(spdif_config);
|
||||||
return &i2s_dac_config;
|
return &i2s_dac_config;
|
||||||
}
|
}
|
||||||
@@ -218,6 +216,7 @@ const i2s_platform_config_t * config_dac_get(){
|
|||||||
*/
|
*/
|
||||||
const eth_config_t * config_eth_get( ){
|
const eth_config_t * config_eth_get( ){
|
||||||
char * config = config_alloc_get_str("eth_config", CONFIG_ETH_CONFIG, "rst=" STR(CONFIG_ETH_PHY_RST_IO)
|
char * config = config_alloc_get_str("eth_config", CONFIG_ETH_CONFIG, "rst=" STR(CONFIG_ETH_PHY_RST_IO)
|
||||||
|
|
||||||
#if defined(ETH_LAN8720)
|
#if defined(ETH_LAN8720)
|
||||||
#else
|
#else
|
||||||
#if defined(CONFIG_ETH_USE_SPI_ETHERNET)
|
#if defined(CONFIG_ETH_USE_SPI_ETHERNET)
|
||||||
@@ -240,7 +239,7 @@ const eth_config_t * config_eth_get( ){
|
|||||||
ESP_LOGD(TAG,"Parsing ethernet configuration %s", config);
|
ESP_LOGD(TAG,"Parsing ethernet configuration %s", config);
|
||||||
}
|
}
|
||||||
static EXT_RAM_ATTR eth_config_t eth_config;
|
static EXT_RAM_ATTR eth_config_t eth_config;
|
||||||
memcpy(ð_config, config_get_eth_from_str(config), sizeof(eth_config));
|
memcpy(ð_config, config_eth_get_from_str(config), sizeof(eth_config));
|
||||||
FREE_AND_NULL(config);
|
FREE_AND_NULL(config);
|
||||||
return ð_config;
|
return ð_config;
|
||||||
}
|
}
|
||||||
@@ -642,8 +641,14 @@ const set_GPIO_struct_t * get_gpio_struct(){
|
|||||||
*/
|
*/
|
||||||
const spi_bus_config_t * config_spi_get(spi_host_device_t * spi_host) {
|
const spi_bus_config_t * config_spi_get(spi_host_device_t * spi_host) {
|
||||||
char *nvs_item;
|
char *nvs_item;
|
||||||
static EXT_RAM_ATTR spi_bus_config_t spi;
|
// don't memset all to 0xff as it's more than just GPIO
|
||||||
memset(&spi, 0xff, sizeof(spi));
|
static spi_bus_config_t spi = {
|
||||||
|
.mosi_io_num = -1,
|
||||||
|
.sclk_io_num = -1,
|
||||||
|
.miso_io_num = -1,
|
||||||
|
.quadwp_io_num = -1,
|
||||||
|
.quadhd_io_num = -1
|
||||||
|
};
|
||||||
|
|
||||||
nvs_item = config_alloc_get_str("spi_config", CONFIG_SPI_CONFIG, NULL);
|
nvs_item = config_alloc_get_str("spi_config", CONFIG_SPI_CONFIG, NULL);
|
||||||
if (nvs_item) {
|
if (nvs_item) {
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ const gpio_exp_config_t * config_gpio_exp_get(int index);
|
|||||||
void parse_set_GPIO(void (*cb)(int gpio, char *value));
|
void parse_set_GPIO(void (*cb)(int gpio, char *value));
|
||||||
const i2s_platform_config_t * config_dac_get();
|
const i2s_platform_config_t * config_dac_get();
|
||||||
const i2s_platform_config_t * config_spdif_get( );
|
const i2s_platform_config_t * config_spdif_get( );
|
||||||
const i2s_platform_config_t * config_get_i2s_from_str(char * dac_config );
|
const i2s_platform_config_t * config_i2s_get_from_str(char * dac_config );
|
||||||
esp_err_t config_spdif_set(const i2s_platform_config_t * config);
|
esp_err_t config_spdif_set(const i2s_platform_config_t * config);
|
||||||
bool is_spdif_config_locked();
|
bool is_spdif_config_locked();
|
||||||
esp_err_t free_gpio_entry( gpio_entry_t ** gpio);
|
esp_err_t free_gpio_entry( gpio_entry_t ** gpio);
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ void services_init(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const spi_bus_config_t * spi_config = config_spi_get((spi_host_device_t*) &spi_system_host);
|
const spi_bus_config_t * spi_config = config_spi_get((spi_host_device_t*) &spi_system_host);
|
||||||
ESP_LOGI(TAG,"Configuring SPI data:%d clk:%d host:%u dc:%d", spi_config->mosi_io_num, spi_config->sclk_io_num, spi_system_host, spi_system_dc_gpio);
|
ESP_LOGI(TAG,"Configuring SPI mosi:%d miso:%d clk:%d host:%u dc:%d", spi_config->mosi_io_num, spi_config->miso_io_num, spi_config->sclk_io_num, spi_system_host, spi_system_dc_gpio);
|
||||||
|
|
||||||
if (spi_config->mosi_io_num != -1 && spi_config->sclk_io_num != -1) {
|
if (spi_config->mosi_io_num != -1 && spi_config->sclk_io_num != -1) {
|
||||||
spi_bus_initialize( spi_system_host, spi_config, 1 );
|
spi_bus_initialize( spi_system_host, spi_config, 1 );
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ network_ethernet_driver_t* network_ethernet_driver_autodetect(const char* Driver
|
|||||||
for (int i = 0; drivers[i]; i++) {
|
for (int i = 0; drivers[i]; i++) {
|
||||||
network_ethernet_driver_t* found_driver = drivers[i](Driver);
|
network_ethernet_driver_t* found_driver = drivers[i](Driver);
|
||||||
if (found_driver) {
|
if (found_driver) {
|
||||||
ESP_LOGD(TAG, "Detected driver %s ", Driver);
|
ESP_LOGI(TAG, "Detected driver %s ", Driver);
|
||||||
|
|
||||||
network_driver = found_driver;
|
network_driver = found_driver;
|
||||||
return found_driver;
|
return found_driver;
|
||||||
@@ -90,8 +90,10 @@ void destroy_network_ethernet() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void network_ethernet_print_config(const eth_config_t* eth_config) {
|
static void network_ethernet_print_config(const eth_config_t* eth_config) {
|
||||||
ESP_LOGI(TAG,"Ethernet config: \n model: %s, valid: %s, type: %s, mdc:%d, mdio:%d, rst:%d, mosi:%d, miso:%d, intr:%d, cs:%d, speed:%d, clk:%d, host:%s(%d)",
|
ESP_LOGI(TAG,"Ethernet config => model: %s, valid: %s, type: %s, mdc:%d, mdio:%d, rst:%d, intr:%d, cs:%d, speed:%d, host:%d",
|
||||||
eth_config->model, eth_config->valid?"YES":"NO",eth_config->spi?"SPI":"RMII", eth_config->mdc, eth_config->mdio, eth_config->rst, eth_config->mosi, eth_config->miso, eth_config->intr, eth_config->cs, eth_config->speed, eth_config->clk, eth_config->host==0?"SPI1":eth_config->host==1?"SPI2":eth_config->host==2?"SPI3":"",eth_config->host);
|
eth_config->model, eth_config->valid ? "YES" : "NO", eth_config->spi ? "SPI" : "RMII",
|
||||||
|
eth_config->mdc, eth_config->mdio,
|
||||||
|
eth_config->rst, eth_config->intr, eth_config->cs, eth_config->speed, eth_config->host);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -115,10 +117,7 @@ void init_network_ethernet() {
|
|||||||
xEventGroupClearBits(ethernet_event_group, LINK_UP_BIT);
|
xEventGroupClearBits(ethernet_event_group, LINK_UP_BIT);
|
||||||
spi_device_handle_t spi_handle = NULL;
|
spi_device_handle_t spi_handle = NULL;
|
||||||
if (network_driver->spi) {
|
if (network_driver->spi) {
|
||||||
if (err == ESP_OK) {
|
|
||||||
ESP_LOGI(TAG, "Adding ethernet SPI on host %d (SPI%d) with mosi %d and miso %d", eth.host, eth.host+1, eth.mosi, eth.miso);
|
|
||||||
err = spi_bus_add_device(eth.host, network_driver->devcfg, &spi_handle);
|
err = spi_bus_add_device(eth.host, network_driver->devcfg, &spi_handle);
|
||||||
}
|
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGE(TAG, "SPI host failed : %s", esp_err_to_name(err));
|
ESP_LOGE(TAG, "SPI host failed : %s", esp_err_to_name(err));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user