소스 검색

update:audio相关demo适应内置ES8311的模块

alienwalker 1 년 전
부모
커밋
95aa7e4733
2개의 변경된 파일33개의 추가작업 그리고 28개의 파일을 삭제
  1. 3 1
      demo/cc/main.lua
  2. 30 27
      demo/multimedia/main.lua

+ 3 - 1
demo/cc/main.lua

@@ -71,6 +71,8 @@ sys.taskInit(function()
     local mic_vol = 65
 
     local find_es8311 = false
+    --内置8311的模块(比如air780epa, air780epvh)打开下面的代码
+    --gpio.setup(17,1,nil,nil,4)
 	--自适应开发板,如果明确是I2C几就不用了
     i2c.setup(0, i2c.FAST)
 	i2c.setup(1, i2c.FAST)
@@ -79,7 +81,7 @@ sys.taskInit(function()
     pm.power(pm.LDO_CTL, true)  --开发板上ES8311由LDO_CTL控制上下电
 	sys.wait(10)
     if i2c.send(0, 0x18, 0xfd) == true then
-        log.info("音频小板", "codec on i2c0")
+        log.info("音频小板或内置ES8311", "codec on i2c0")
         i2c_id = 0
         find_es8311 = true
     else

+ 30 - 27
demo/multimedia/main.lua

@@ -82,33 +82,36 @@ function audio_setup()
         local voice_vol = 70
         local mic_vol = 80
     
-		local find_es8311 = false
-		--自适应开发板,如果明确是I2C几就不用了
-		i2c.setup(0, i2c.FAST)
-		i2c.setup(1, i2c.FAST)
-		pm.power(pm.LDO_CTL, false)  --开发板上ES8311由LDO_CTL控制上下电
-		sys.wait(10)
-		pm.power(pm.LDO_CTL, true)  --开发板上ES8311由LDO_CTL控制上下电
-		sys.wait(10)
-		if i2c.send(0, 0x18, 0xfd) == true then
-			log.info("音频小板", "codec on i2c0")
-			i2c_id = 0
-			find_es8311 = true
-		else
-			if i2c.send(1, 0x18, 0xfd) == true then
-				log.info("云喇叭开发板", "codec on i2c1")
-				find_es8311 = true
-				power_pin = nil
-				i2c_id = 1
-			end
-		end
-
-		if not find_es8311 then
-			while true do
-				log.info("not find es8311")
-				sys.wait(1000)
-			end
-		end
+		local find_es8311 = false
+        --内置8311的模块(比如air780epa, air780epvh)打开下面的代码
+        --power_pin = 255
+        --gpio.setup(17,1,nil,nil,4)
+		--自适应开发板,如果明确是I2C几就不用了
+		i2c.setup(0, i2c.FAST)
+		i2c.setup(1, i2c.FAST)
+		pm.power(pm.LDO_CTL, false)  --开发板上ES8311由LDO_CTL控制上下电
+		sys.wait(10)
+		pm.power(pm.LDO_CTL, true)  --开发板上ES8311由LDO_CTL控制上下电
+		sys.wait(10)
+		if i2c.send(0, 0x18, 0xfd) == true then
+			log.info("音频小板或内置ES8311", "codec on i2c0")
+			i2c_id = 0
+			find_es8311 = true
+		else
+			if i2c.send(1, 0x18, 0xfd) == true then
+				log.info("云喇叭开发板", "codec on i2c1")
+				find_es8311 = true
+				power_pin = nil
+				i2c_id = 1
+			end
+		end
+
+		if not find_es8311 then
+			while true do
+				log.info("not find es8311")
+				sys.wait(1000)
+			end
+		end
 		
         i2s.setup(i2s_id, i2s_mode, i2s_sample_rate, i2s_bits_per_sample, i2s_channel_format, i2s_communication_format,i2s_channel_bits)