Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compressor #6

Open
wants to merge 1 commit into
base: guitaramp
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions applications/nrf5340_audio/src/drivers/cs47l63_reg_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Expand Down
29 changes: 29 additions & 0 deletions applications/nrf5340_audio/src/modules/hw_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@
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;
Expand Down Expand Up @@ -663,6 +668,27 @@
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) {

Check warning on line 684 in applications/nrf5340_audio/src/modules/hw_codec.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LINE_SPACING

applications/nrf5340_audio/src/modules/hw_codec.c:684 Missing a blank line after declarations
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",
Expand All @@ -674,6 +700,9 @@
" 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 <in> <out> <loslope> <hislope>",
cmd_comp, 5, 0),
SHELL_SUBCMD_SET_END);

SHELL_CMD_REGISTER(hw_codec, &hw_codec_cmd, "Change settings on HW codec", NULL);
Loading