Преглед изворни кода

fix:i2s不支持1个LR周期64clk

alienwalker пре 2 година
родитељ
комит
c57e413280
2 измењених фајлова са 4 додато и 1 уклоњено
  1. 1 0
      luat/include/luat_i2s.h
  2. 3 1
      luat/modules/luat_lib_i2s.c

+ 1 - 0
luat/include/luat_i2s.h

@@ -9,6 +9,7 @@ typedef struct luat_i2s_conf
     uint8_t bits_per_sample;
     uint8_t bits_per_sample;
     uint8_t channel_format;
     uint8_t channel_format;
     uint8_t communication_format;
     uint8_t communication_format;
+    uint8_t channel_bits;
     uint32_t mclk;
     uint32_t mclk;
     //uint8_t intr_alloc_flags;
     //uint8_t intr_alloc_flags;
     // uint8_t dma_buf_count;
     // uint8_t dma_buf_count;

+ 3 - 1
luat/modules/luat_lib_i2s.c

@@ -89,6 +89,7 @@ int32_t luat_i2s_rx_cb(void *pdata, void *param)
 @int 数据位数,默认16, 可以是8的倍数
 @int 数据位数,默认16, 可以是8的倍数
 @int 声道, 0 左声道, 1 右声道, 2 双声道. 可选
 @int 声道, 0 左声道, 1 右声道, 2 双声道. 可选
 @int 格式, 可选MODE_I2S, MODE_LSB, MODE_MSB
 @int 格式, 可选MODE_I2S, MODE_LSB, MODE_MSB
+@int 1个声道的BCLK数量, 可选16和32
 @int mclk频率, 默认 8M. 可选
 @int mclk频率, 默认 8M. 可选
 @return boolean 成功与否
 @return boolean 成功与否
 @return int 底层返回值
 @return int 底层返回值
@@ -106,7 +107,8 @@ static int l_i2s_setup(lua_State *L) {
     conf.bits_per_sample = luaL_optinteger(L, 4, 16); // 通常就是16bit
     conf.bits_per_sample = luaL_optinteger(L, 4, 16); // 通常就是16bit
     conf.channel_format = luaL_optinteger(L, 5, 0); // 1 右声道, 0 左声道
     conf.channel_format = luaL_optinteger(L, 5, 0); // 1 右声道, 0 左声道
     conf.communication_format = luaL_optinteger(L, 6, 0); // 0 - I2S 标准, 当前只支持这种就行
     conf.communication_format = luaL_optinteger(L, 6, 0); // 0 - I2S 标准, 当前只支持这种就行
-    conf.mclk = luaL_optinteger(L, 7, 0);
+    conf.channel_bits = luaL_optinteger(L, 7, 16); //
+    conf.mclk = luaL_optinteger(L, 8, 0);
     // conf.intr_alloc_flags = luaL_optinteger(L, 8, 0);
     // conf.intr_alloc_flags = luaL_optinteger(L, 8, 0);
     int ret = luat_i2s_setup(&conf);
     int ret = luat_i2s_setup(&conf);
     lua_pushboolean(L, ret == 0 ? 1 : 0);
     lua_pushboolean(L, ret == 0 ? 1 : 0);