diff --git a/applications/nrf5340_audio/src/drivers/cs47l63_reg_conf.h b/applications/nrf5340_audio/src/drivers/cs47l63_reg_conf.h index 1dc808010b88..8918e3b7798b 100644 --- a/applications/nrf5340_audio/src/drivers/cs47l63_reg_conf.h +++ b/applications/nrf5340_audio/src/drivers/cs47l63_reg_conf.h @@ -101,11 +101,17 @@ const uint32_t line_in_enable[][2] = { { CS47L63_ASP1TX2_INPUT1, 0x800013 }, }; +/* Wire compressor */ +const uint32_t compressor_enable[][2] = { + {CS47L63_DRC1_CONTROL1, 0b11}, + {CS47L63_DRC1L_INPUT1, 0x800020}, + {CS47L63_DRC1L_INPUT2, 0x800021}, +}; + /* Set up output */ const uint32_t output_enable[][2] = { - { CS47L63_OUTPUT_ENABLE_1, 0x0002 }, - { CS47L63_OUT1L_INPUT1, 0x800020 }, - { CS47L63_OUT1L_INPUT2, 0x800021 }, + {CS47L63_OUTPUT_ENABLE_1, 0x0002}, + {CS47L63_OUT1L_INPUT1, 0x8000C0}, }; const uint32_t output_disable[][2] = { diff --git a/applications/nrf5340_audio/src/modules/hw_codec.c b/applications/nrf5340_audio/src/modules/hw_codec.c index af40fd112582..00ef41d9f33f 100644 --- a/applications/nrf5340_audio/src/modules/hw_codec.c +++ b/applications/nrf5340_audio/src/modules/hw_codec.c @@ -301,6 +301,11 @@ int hw_codec_default_conf_enable(void) return ret; } + ret = cs47l63_comm_reg_conf_write(compressor_enable, ARRAY_SIZE(compressor_enable)); + if (ret) { + return ret; + } + ret = cs47l63_comm_reg_conf_write(output_enable, ARRAY_SIZE(output_enable)); if (ret) { return ret; @@ -663,6 +668,27 @@ static int cmd_filter_off(const struct shell *shell, size_t argc, char **argv) return 0; } +static int cmd_comp(const struct shell *shell, size_t argc, char **argv) +{ + uint32_t inDb = strtoull(argv[1], 0, 10); + uint32_t outDb = strtoull(argv[2], 0, 10); + uint32_t loSlope = strtoull(argv[3], 0, 10); + uint32_t hiSlope = strtoull(argv[4], 0, 10); + + uint32_t compressor_conf[][2] = { + {CS47L63_DRC1_CONTROL3, loSlope | (hiSlope << 3)}, + {CS47L63_DRC1_CONTROL4, outDb | (inDb << 5)}, + }; + + int ret = cs47l63_comm_reg_conf_write(compressor_conf, ARRAY_SIZE(compressor_conf)); + if (ret) { + shell_error(shell, "Error %d\n", ret); + return ret; + } + + return 0; +} + SHELL_STATIC_SUBCMD_SET_CREATE(hw_codec_cmd, SHELL_COND_CMD(CONFIG_SHELL, input, NULL, " Select input\n\t0: LINE_IN\n\t\t1: PDM_MIC", @@ -674,6 +700,9 @@ SHELL_STATIC_SUBCMD_SET_CREATE(hw_codec_cmd, " Select LP filter frequency\n\t", cmd_filter_lp), SHELL_COND_CMD(CONFIG_SHELL, disable_filter, NULL, " Disable filtering\n\t", cmd_filter_off), + SHELL_COND_CMD_ARG(CONFIG_SHELL, comp, NULL, + " Set compressor ", + cmd_comp, 5, 0), SHELL_SUBCMD_SET_END); SHELL_CMD_REGISTER(hw_codec, &hw_codec_cmd, "Change settings on HW codec", NULL);