Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/master' into httpd

Conflicts:
	Makefile
Sebastien 5 anni fa
parent
commit
fdbb24962a

+ 14 - 2
.cproject

@@ -227,7 +227,7 @@
             			
             <storageModule moduleId="cdtBuildSystem" version="4.0.0">
                 				
-                <configuration artifactName="${ProjName}" buildProperties="" description="Building recovery in windows" id="cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291" name="recovery_windows" optionalBuildProperties="" parent="org.eclipse.cdt.build.core.emptycfg">
+                <configuration artifactName="${ProjName}" buildProperties="" description="Building recovery in windows" id="cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291" name="recovery_windows" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=" parent="org.eclipse.cdt.build.core.emptycfg">
                     					
                     <folderInfo id="cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291." name="/" resourcePath="">
                         						
@@ -239,7 +239,7 @@
                             							
                             <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.1831977109" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
                             							
-                            <builder arguments="&quot;C:/msys32/opt/esp-idf/tools/windows/eclipse_make.py&quot; -j8 EXTRA_CPPFLAGS='-DRECOVERY_APPLICATION=1 -DSQUEEZELITE_ESP32_RELEASE_URL=\&quot;https://github.com/sle118/squeezelite-esp32/releases\&quot; '" command="python" id="cdt.managedbuild.builder.gnu.cross.1069921467" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.builder.gnu.cross"/>
+                            <builder arguments="&quot;c:/msys32/opt/esp-idf/tools/windows/eclipse_make.py&quot;  EXTRA_CPPFLAGS='-DRECOVERY_APPLICATION=${RECOVERY_APPLICATION}'" buildPath="${workspace_loc:/squeezelite-esp32}" command="python" id="cdt.managedbuild.builder.gnu.cross.1069921467" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="cdt.managedbuild.builder.gnu.cross"/>
                             							
                             <tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1302011176" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
                                 								
@@ -495,6 +495,12 @@
             		
         </scannerConfigBuildInfo>
         		
+        <scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.293933348.839256934;cdt.managedbuild.toolchain.gnu.cross.base.293933348.839256934.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.40066190;cdt.managedbuild.tool.gnu.cpp.compiler.input.773825889">
+            			
+            <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+            		
+        </scannerConfigBuildInfo>
+        		
         <scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291.395881736;cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291.395881736.;cdt.managedbuild.tool.gnu.cross.cpp.compiler.1907231332;cdt.managedbuild.tool.gnu.cpp.compiler.input.604467026">
             			
             <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
@@ -560,6 +566,12 @@
             <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
             		
         </scannerConfigBuildInfo>
+        		
+        <scannerConfigBuildInfo instanceId="cdt.managedbuild.toolchain.gnu.cross.base.293933348.839256934;cdt.managedbuild.toolchain.gnu.cross.base.293933348.839256934.;cdt.managedbuild.tool.gnu.cross.c.compiler.1397900624;cdt.managedbuild.tool.gnu.c.compiler.input.24917724">
+            			
+            <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
+            		
+        </scannerConfigBuildInfo>
         	
     </storageModule>
     

+ 1 - 0
.project

@@ -3,6 +3,7 @@
 	<name>squeezelite-esp32</name>
 	<comment></comment>
 	<projects>
+		<project>esp-idf</project>
 	</projects>
 	<buildSpec>
 		<buildCommand>

+ 1 - 0
.settings/.gitignore

@@ -0,0 +1 @@
+/org.eclipse.ltk.core.refactoring.prefs

+ 6 - 6
.settings/language.settings.xml

@@ -33,9 +33,9 @@
             			
             <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
             			
-            <provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
+            <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="true" name="CDT GCC Build Output Parser" parameter="xtensa-esp32-elf-(gcc|g\+\+|c\+\+|cc|cpp|clang)" prefer-non-shared="true"/>
             			
-            <provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="66711578333" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+            <provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="29929057949" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="xtensa-esp32-elf-gcc ${FLAGS} -std=c++11 -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
                 				
                 <language-scope id="org.eclipse.cdt.core.gcc"/>
                 				
@@ -57,9 +57,9 @@
             			
             <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
             			
-            <provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
+            <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="(g?cc)|([gc]\+\+)|(clang)" prefer-non-shared="true"/>
             			
-            <provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1733991311150261732" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+            <provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1502478736382965477" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
                 				
                 <language-scope id="org.eclipse.cdt.core.gcc"/>
                 				
@@ -81,9 +81,9 @@
             			
             <provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
             			
-            <provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
+            <provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="true" name="CDT GCC Build Output Parser" parameter="xtensa-esp32-elf-(gcc|g\+\+|c\+\+|cc|cpp|clang)" prefer-non-shared="true"/>
             			
-            <provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1733991311150261732" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
+            <provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1766868238676867652" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="xtensa-esp32-elf-gcc ${FLAGS} -std=c++11 -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
                 				
                 <language-scope id="org.eclipse.cdt.core.gcc"/>
                 				

+ 2 - 2
.settings/org.eclipse.cdt.core.prefs

@@ -49,10 +49,10 @@ environment/project/cdt.managedbuild.toolchain.gnu.cross.base.293933348.16039962
 environment/project/cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291/IDF_PATH/value=C\:/msys32/opt/esp-idf
 environment/project/cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291/PATH/delimiter=\:
 environment/project/cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291/PATH/operation=replace
-environment/project/cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291/PATH/value=C\:\\msys32\\usr\\bin;C\:\\msys32\\mingw32\\bin;C\:\\msys32\\opt\\xtensa-esp32-elf\\bin\\
+environment/project/cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291/PATH/value=C\:\\msys32\\opt\\openocd-esp32\\bin;c\:\\msys32\\opt\\xtensa-esp32-elf\\bin\\;c\:\\msys32\\mingw32\\bin;C\:\\msys32\\usr\\bin;c\:\\Python27;C\:\\msys32\\usr\\bin\\vendor_perl;C\:\\msys32\\usr\\bin\\core_perl
 environment/project/cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291/PROJECT_NAME/delimiter=\:
 environment/project/cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291/PROJECT_NAME/operation=replace
-environment/project/cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291/PROJECT_NAME/value=recovery.custom
+environment/project/cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291/PROJECT_NAME/value=recovery
 environment/project/cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291/PROJECT_VER/delimiter=\:
 environment/project/cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291/PROJECT_VER/operation=append
 environment/project/cdt.managedbuild.toolchain.gnu.cross.base.293933348.1603996291/PROJECT_VER/value=custom

+ 3 - 1
Makefile

@@ -14,4 +14,6 @@
 
 PROJECT_NAME?=squeezelite
 include $(IDF_PATH)/make/project.mk 
-CFLAGS += -Wno-error=format-overflow -Wno-error=stringop-truncation
+
+CFLAGS += -Wno-error=format-overflow -Wno-error=stringop-truncation
+CPPFLAGS+= -Wno-error=maybe-uninitialized

+ 4 - 3
README.md

@@ -81,18 +81,19 @@ Syntax is:
 ```
 <gpio_1>=Vcc|GND|amp|jack[,<gpio_n>=Vcc|GND|amp|jack]
 ```
-
 ### Rotary Encoder
 One rotary encoder is supported, quadrature shift with press. Such encoders usually have 2 pins for encoders (A and B), and common C that must be set to ground and an optional SW pin for press. A, B and SW must be pulled up, so automatic pull-up is provided by ESP32, but you can add your own resistors. A bit of filtering on A and B (~470nF) helps for debouncing which is not made by software. 
 
-Encoder is hard-coded to respectively knob left, right and push on LMS and to volume down/up/play toggle on BT and AirPlay. There is no complex configuration like buttons (see below). Long press is not supported
+Encoder is normally hard-coded to respectively knob left, right and push on LMS and to volume down/up/play toggle on BT and AirPlay. Using the option 'volume' makes it hard-coded to volume down/up/play toggle all the time (even in LMS). The option 'longpress' allows an alternate mode when SW is long-pressed. In that mode, left is previous, right is next and press is toggle. Every long press on SW alternates between modes.
 
 Use parameter rotary_config with the following syntax:
 
 ```
-A=<gpio>,B=<gpio>[,SW=gpio>]
+A=<gpio>,B=<gpio>[,SW=gpio>[,volume][,longpress]]
 ```
 
+HW note: all gpio used for rotary have internal pull-up so normally there is no need to provide Vcc to the encoder. Nevertheless if the encoder board you're using also has its own pull-up that are stronger than ESP32's ones (which is likely the case), then there will be crosstalk between gpio, so you must bring Vcc. Look at your board schematic and you'll understand that these board pull-up create a "winning" pull-down when any other pin is grounded. 
+
 ### Buttons
 Buttons are described using a JSON string with the following syntax
 ```

+ 1 - 1
components/services/audio_controls.c

@@ -148,7 +148,7 @@ static void control_rotary_handler(void *client, rotary_event_e event, bool long
 	case ROTARY_PRESSED:
 		if (long_press)	rotary.long_state = !rotary.long_state;
 		else if (rotary.volume_lock) action = ACTRLS_TOGGLE;
-		else action = KNOB_RIGHT;
+		else action = KNOB_PUSH;
 		break;
 	default:
 		break;

+ 2 - 1
components/services/buttons.c

@@ -81,7 +81,8 @@ static void IRAM_ATTR gpio_isr_handler(void* arg)
 
 	if (xTimerGetPeriod(button->timer) > button->debounce / portTICK_RATE_MS) xTimerChangePeriodFromISR(button->timer, button->debounce / portTICK_RATE_MS, &woken); // does that restart the timer? 
 	else xTimerResetFromISR(button->timer, &woken);
-	// ESP_EARLY_LOGI(TAG, "INT gpio %u level %u", button->gpio, button->level);
+	if (woken) portYIELD_FROM_ISR();
+	ESP_EARLY_LOGD(TAG, "INT gpio %u level %u", button->gpio, button->level);
 }
 
 /****************************************************************************************

+ 1 - 1
components/services/services.c

@@ -70,7 +70,7 @@ void services_init(void) {
 		i2c_param_config(i2c_system_port, i2c_config);
 		i2c_driver_install(i2c_system_port, i2c_config->mode, 0, 0, 0 );
 	} else {
-		ESP_LOGE(TAG, "can't initialize I2C");
+		ESP_LOGW(TAG, "no I2C configured");
 	}	
 
 	ESP_LOGD(TAG,"Configuring LEDs");

+ 36 - 34
components/squeezelite/a1s/ac101.c

@@ -37,6 +37,7 @@ const static char TAG[] = "AC101";
 
 #define SPKOUT_EN ((1 << 11) | (1 << 7))
 #define EAROUT_EN ((1 << 11) | (1 << 12) | (1 << 13))
+#define BIN(a,b,c,d)	0b##a##b##c##d
 
 #define min(a,b) (((a) < (b)) ? (a) : (b))
 #define max(a,b) (((a) > (b)) ? (a) : (b))
@@ -90,51 +91,52 @@ static bool init(int i2c_port_num, int i2s_num, i2s_config_t *i2s_config) {
 	ESP_LOGI(TAG, "DAC using I2C sda:%u, scl:%u", i2c_config.sda_io_num, i2c_config.scl_io_num);
 	
 	res = i2c_write_reg(CHIP_AUDIO_RS, 0x123);
-	//huh?
-	//vTaskDelay(1000 / portTICK_PERIOD_MS); 
+	// huh?
+	 vTaskDelay(100 / portTICK_PERIOD_MS); 
 	
 	if (ESP_OK != res) {
 		ESP_LOGE(TAG, "AC101 reset failed! %d", res);
 		return false;
 	} 
 			
-	// Enable the PLL from 256*44.1KHz MCLK source
-	i2c_write_reg(PLL_CTRL1, 0x014f);
-	//res |= i2c_write_reg(PLL_CTRL2, 0x83c0);
-	i2c_write_reg(PLL_CTRL2, 0x8600);
+	// enable the PLL from BCLK source
+	i2c_write_reg(PLL_CTRL1, BIN(0000,0001,0100,1111));			// F=1,M=1,PLL,INT=31 (medium)				
+	i2c_write_reg(PLL_CTRL2, BIN(1000,0110,0000,0000));			// PLL, F=96,N_i=1024-96,F=0,N_f=0*0.2;
+	// i2c_write_reg(PLL_CTRL2, BIN(1000,0011,1100,0000));										
 
-	//Clocking system
-	i2c_write_reg(SYSCLK_CTRL, 0x8b08);
-	i2c_write_reg(MOD_CLK_ENA, 0x800c);
-	i2c_write_reg(MOD_RST_CTRL, 0x800c);
-	i2c_write_reg(I2S_SR_CTRL, 0x7000);			//sample rate
+	// clocking system
+	i2c_write_reg(SYSCLK_CTRL,  BIN(1010,1010,0000,1000));		// PLLCLK, BCLK1, IS1CLK, PLL, SYSCLK 
+	i2c_write_reg(MOD_CLK_ENA,  BIN(1000,0000,0000,1100));		// IS21, ADC, DAC
+	i2c_write_reg(MOD_RST_CTRL, BIN(1000,0000,0000,1100));		// IS21, ADC, DAC
+	i2c_write_reg(I2S_SR_CTRL,  BIN(0111,0000,0000,0000));		// 44.1kHz
 	 
-	//AIF config
-	i2c_write_reg(I2S1LCK_CTRL, 0x8850);		//BCLK/LRCK
-	i2c_write_reg(I2S1_SDOUT_CTRL, 0xc000);		
-	i2c_write_reg(I2S1_SDIN_CTRL, 0xc000);
-	i2c_write_reg(I2S1_MXR_SRC, 0x2200);		
-
-	i2c_write_reg(ADC_SRCBST_CTRL, 0xccc4);
-	i2c_write_reg(ADC_SRC, 0x2020);
-	i2c_write_reg(ADC_DIG_CTRL, 0x8000);
-	i2c_write_reg(ADC_APC_CTRL, 0xbbc3);
+	// analogue config
+	i2c_write_reg(I2S1LCK_CTRL, 	BIN(1000,1000,0101,0000));	// Slave, BCLK=I2S/8,LRCK=32,16bits,I2Smode, Stereo
+	i2c_write_reg(I2S1_SDOUT_CTRL, 	BIN(1100,0000,0000,0000));	// I2S1ADC (R&L) 	
+	i2c_write_reg(I2S1_SDIN_CTRL, 	BIN(1100,0000,0000,0000));	// IS21DAC (R&L)
+	i2c_write_reg(I2S1_MXR_SRC, 	BIN(0010,0010,0000,0000));	// ADCL, ADCR
+	i2c_write_reg(ADC_SRCBST_CTRL, BIN(0100,0100,0100,0000));	// disable all boost (default)
+#if ENABLE_ADC
+	i2c_write_reg(ADC_SRC, 		   BIN(0000,0100,0000,1000));	// source=linein(R/L)
+	i2c_write_reg(ADC_DIG_CTRL,    BIN(1000,0000,0000,0000));	// enable digital ADC
+	i2c_write_reg(ADC_ANA_CTRL,    BIN(1011, 1011,0000,0000));	// enable analogue R/L, 0dB
+#else
+	i2c_write_reg(ADC_SRC, 		   BIN(0000,0000,0000,0000));	// source=none
+	i2c_write_reg(ADC_DIG_CTRL,    BIN(0000,0000,0000,0000));	// disable digital ADC
+	i2c_write_reg(ADC_ANA_CTRL,    BIN(0011, 0011,0000,0000));	// disable analogue R/L, 0dB
+#endif	
 
 	//Path Configuration
-	i2c_write_reg(DAC_MXR_SRC, 0xcc00);
-	i2c_write_reg(DAC_DIG_CTRL, 0x8000);
-	i2c_write_reg(OMIXER_SR, 0x0081);
-	i2c_write_reg(OMIXER_DACA_CTRL, 0xf080);
+	i2c_write_reg(DAC_MXR_SRC, 		BIN(1000,1000,0000,0000));	// DAC from I2S
+	i2c_write_reg(DAC_DIG_CTRL, 	BIN(1000,0000,0000,0000));	// enable DAC
+	i2c_write_reg(OMIXER_DACA_CTRL, BIN(1111,0000,0000,000));	// enable DAC/Analogue (see note on offset removal and PA)
+	i2c_write_reg(OMIXER_DACA_CTRL, BIN(1100,0000,0000,000));	// enable DAC/Analogue (see note on offset removal and PA)
+#if ENABLE_ADC	
+	i2c_write_reg(OMIXER_SR, 		BIN(0000,0001,0000,0010));	// source=DAC(R/L) (are DACR and DACL really inverted in bitmap?)
+#else
+	i2c_write_reg(OMIXER_SR, 		BIN(0000,0101,0000,1010));	// source=DAC(R/L) and LINEIN(R/L)
+#endif	
 	
-	// configure I2S		
-	uint16_t regval = i2c_read_reg(I2S1LCK_CTRL);
-	regval &= 0xffc3;
-	regval |= (AC_MODE_SLAVE << 15);
-	regval |= (BIT_LENGTH_16_BITS << 4);
-	regval |= (AC_MODE_SLAVE << 2);
-	res |= i2c_write_reg(I2S1LCK_CTRL, regval);
-	res |= i2c_write_reg(I2S_SR_CTRL, SAMPLE_RATE_44100);
-			
 	// configure I2S pins & install driver	
 	i2s_pin_config_t i2s_pin_config = (i2s_pin_config_t) { 	.bck_io_num = 27, .ws_io_num = 26, 
 															.data_out_num = 25, .data_in_num = 35 //Not used 

+ 1 - 1
components/squeezelite/a1s/ac101.h

@@ -61,7 +61,7 @@
 #define DAC_VOL_CTRL		0x49
 #define DAC_MXR_SRC			0x4c
 #define DAC_MXR_GAIN		0x4d
-#define ADC_APC_CTRL		0x50
+#define ADC_ANA_CTRL		0x50
 #define ADC_SRC				0x51
 #define ADC_SRCBST_CTRL		0x52
 #define OMIXER_DACA_CTRL	0x53