Skip to content

Commit bf2f93b

Browse files
committed
add phase adjust command
1 parent 3504b62 commit bf2f93b

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

main.c

+13
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,18 @@ static void cmd_gain(BaseSequentialStream *chp, int argc, char *argv[])
391391
tlv320aic3204_set_gain(gain);
392392
}
393393

394+
static void cmd_phase(BaseSequentialStream *chp, int argc, char *argv[])
395+
{
396+
int value;
397+
if (argc != 1) {
398+
chprintf(chp, "usage: phase {adjust value(-128-127)}\r\n");
399+
return;
400+
}
401+
402+
value = atoi(argv[0]);
403+
tlv320aic3204_set_adc_phase_adjust(value);
404+
}
405+
394406
static void cmd_volume(BaseSequentialStream *chp, int argc, char *argv[])
395407
{
396408
int gain;
@@ -660,6 +672,7 @@ static const ShellCommand commands[] =
660672
{ "channel", cmd_channel },
661673
{ "save", cmd_save },
662674
{ "clearconfig", cmd_clearconfig },
675+
{ "phase", cmd_phase },
663676
{ NULL, NULL }
664677
};
665678

nanosdr.h

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ extern void tlv320aic3204_set_impedance(int imp);
5151
extern int tlv320aic3204_get_sticky_flag_register(void);
5252
extern int8_t tlv320aic3204_get_left_agc_gain(void);
5353
extern int8_t tlv320aic3204_get_right_agc_gain(void);
54+
extern void tlv320aic3204_set_adc_phase_adjust(int8_t adjust);
5455

5556
#define AIC3204_STICKY_ADC_OVERFLOW 0x0c
5657

tlv320aic3204.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static const uint8_t conf_data_clk_192kHz[] = {
117117
2, 0x0c, 0x87, /* Power up the MDAC divider with value 7 */
118118
2, 0x0d, 0x00, /* Program the OSR of DAC to 32 */
119119
2, 0x0e, 0x20,
120-
2, 0x3c, 20, //0x08, /* Set the DAC Mode to PRB_P20 (reduce resource) */
120+
2, 0x3c, 17, //0x08, /* Set the DAC Mode to PRB_P17 (reduce resource) */
121121
2, 0x1b, 0x0c, /* Set the BCLK,WCLK as output */
122122
2, 0x1e, 0x80 + 7, /* Enable the BCLKN divider with value 7 */
123123
2, 0x25, 0xee, /* DAC power up */
@@ -183,7 +183,6 @@ void tlv320aic3204_init(void)
183183
{
184184
tlv320aic3204_config(conf_data_pll);
185185
tlv320aic3204_config(conf_data_clk);
186-
//tlv320aic3204_config(conf_data_clk_192kHz);
187186
tlv320aic3204_config(conf_data_routing);
188187
wait_ms(40);
189188
tlv320aic3204_config(conf_data_unmute);
@@ -201,6 +200,7 @@ void tlv320aic3204_set_fs(int fs)
201200
else if (fs == 192)
202201
tlv320aic3204_config(conf_data_clk_192kHz);
203202

203+
//wait_ms(20);
204204
tlv320aic3204_config(conf_data_unmute);
205205
}
206206

@@ -356,3 +356,8 @@ int8_t tlv320aic3204_get_right_agc_gain(void)
356356
return tlv320aic3204_read(0x65); /* Right Channel AGC Gain Flag */
357357
}
358358

359+
void tlv320aic3204_set_adc_phase_adjust(int8_t adjust)
360+
{
361+
tlv320aic3204_write(0x55, adjust);
362+
}
363+

0 commit comments

Comments
 (0)