Skip to content

Commit

Permalink
Merge branch 'master' of gitee.com:openLuat/LuatOS
Browse files Browse the repository at this point in the history
  • Loading branch information
wendal committed Jun 19, 2024
2 parents 8c7f92a + 0183429 commit 21e3a8d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
7 changes: 5 additions & 2 deletions components/multimedia/luat_audio_es8311.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ static inline void es8311_reset(luat_audio_codec_conf_t* conf){
static int es8311_codec_init(luat_audio_codec_conf_t* conf,uint8_t mode){
luat_audio_power(conf->multimedia_id,1);
luat_rtos_task_sleep(50);
luat_audio_conf_t* audio_conf = luat_audio_get_config(conf->multimedia_id);
uint8_t temp1 = es8311_read_reg(conf,ES8311_CHD1_REGFD);
uint8_t temp2 = es8311_read_reg(conf,ES8311_CHD2_REGFE);
uint8_t temp3 = es8311_read_reg(conf,ES8311_CHVER_REGFF);
Expand All @@ -458,8 +459,10 @@ static int es8311_codec_init(luat_audio_codec_conf_t* conf,uint8_t mode){

es8311_write_reg(conf,ES8311_SYSTEM_REG0B, 0x00);
es8311_write_reg(conf,ES8311_SYSTEM_REG0C, 0x00);

es8311_write_reg(conf,ES8311_SYSTEM_REG10, (0x1C*ES8311_DAC_HP_ON) + (0x60*ES8311_VDDA_VOLTAGE) + 0x03);
if (audio_conf)
es8311_write_reg(conf,ES8311_SYSTEM_REG10, (0x1C*ES8311_DAC_HP_ON) + (0x60 * (audio_conf->voltage ? ES8311_VDDA_1V8 : ES8311_VDDA_3V3)) + 0x03);
else
es8311_write_reg(conf,ES8311_SYSTEM_REG10, (0x1C*ES8311_DAC_HP_ON) + (0x60 * ES8311_VDDA_VOLTAGE) + 0x03);
es8311_write_reg(conf,ES8311_SYSTEM_REG11, 0x7F);

es8311_write_reg(conf,ES8311_CLK_MANAGER_REG01,0x3F + (ES8311_MCLK_SOURCE<<7));
Expand Down
9 changes: 9 additions & 0 deletions components/multimedia/luat_lib_multimedia_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,11 @@ static int l_audio_set_output_bus(lua_State *L) {
audio_conf->codec_conf.i2s_id = luaL_checknumber(L, -1);
}
lua_pop(L, 1);
lua_pushstring(L, "voltage");
if (LUA_TNUMBER == lua_gettable(L, 3)) {
audio_conf->voltage = luaL_checknumber(L, -1);
}
lua_pop(L, 1);
}
ret |= luat_audio_init(id, 0, 0);
lua_pushboolean(L, !ret);
Expand Down Expand Up @@ -795,6 +800,10 @@ static const rotable_Reg_t reg_audio[] =
{ "BUS_I2S", ROREG_INT(LUAT_AUDIO_BUS_I2S)},
//@const BUS_SOFT_DAC number 硬件输出总线,软件模式DAC类型
{ "BUS_SOFT_DAC", ROREG_INT(LUAT_AUDIO_BUS_SOFT_DAC)},
//@const VOLTAGE_1800 number 可配置的codec工作电压,1.8V
{ "VOLTAGE_1800", ROREG_INT(LUAT_AUDIO_VOLTAGE_1800)},
//@const VOLTAGE_3300 number 可配置的codec工作电压,3.3V
{ "VOLTAGE_3300", ROREG_INT(LUAT_AUDIO_VOLTAGE_3300)},
{ NULL, ROREG_INT(0)}
};

Expand Down
5 changes: 5 additions & 0 deletions luat/include/luat_audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ typedef struct luat_audio_conf {
uint8_t power_pin; // 电源控制
uint8_t power_on_level; // 电源使能电平
uint8_t pa_is_control_enable;
uint8_t voltage;
} luat_audio_conf_t;

typedef enum{
Expand All @@ -66,6 +67,10 @@ typedef enum{
LUAT_AUDIO_PM_SHUTDOWN, /* 关断模式 */
LUAT_AUDIO_PM_POWER_OFF, /* 完全断电模式 */
}luat_audio_pm_mode_t;
typedef enum{
LUAT_AUDIO_VOLTAGE_3300 = 0, /* 工作在3.3V */
LUAT_AUDIO_VOLTAGE_1800, /* 工作在1.8V */
}luat_audio_voltage_t;

typedef enum{
LUAT_AUDIO_BUS_DAC=0,
Expand Down
3 changes: 2 additions & 1 deletion script/turnkey/hz201p/ccVolte.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ sys.taskInit(function()
audio.setBus(multimedia_id, audio.BUS_I2S, {
chip = "es8311",
i2cid = i2c_id,
i2sid = i2s_id
i2sid = i2s_id,
voltage = audio.VOLTAGE_1800
}) -- 通道0的硬件输出通道设置为I2S
audio.vol(multimedia_id, voice_vol)
audio.micVol(multimedia_id, mic_vol)
Expand Down

0 comments on commit 21e3a8d

Please sign in to comment.