|
|
@ -1,5 +1,6 @@ |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdint.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include <string.h> |
|
|
|
#include <assert.h> |
|
|
|
#include "serial.h" |
|
|
@ -8,9 +9,14 @@ |
|
|
|
#include "a3k.h" |
|
|
|
#include "tick.h" |
|
|
|
|
|
|
|
#include "cmd.h" |
|
|
|
|
|
|
|
#define WAIT_TIMEOUT (100) /* 100ms */ |
|
|
|
#define RATE_PINS (6) |
|
|
|
|
|
|
|
static uint8_t __dac_gain = 0x63; |
|
|
|
static uint8_t __input_gain = 0x2; |
|
|
|
|
|
|
|
struct fifo_tag { |
|
|
|
char *pnew; /* points to newest fifo element */ |
|
|
|
char *pold; /* points to oldest fifo element */ |
|
|
@ -438,7 +444,8 @@ static int config_a3k(a3k_t interface, short ratet, char input_gain, char outpu |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
static int config_a3k_codec(a3k_t interface ) |
|
|
|
|
|
|
|
static int config_a3k_codec(a3k_t interface) |
|
|
|
{ |
|
|
|
char packet[128]; |
|
|
|
char *p = packet+4; |
|
|
@ -446,17 +453,17 @@ static int config_a3k_codec(a3k_t interface ) |
|
|
|
short INPUT_GAIN; |
|
|
|
short INPUT_SEL; |
|
|
|
short ADCGAIN, DACGAIN; |
|
|
|
|
|
|
|
INPUT_GAIN = 0x0; |
|
|
|
|
|
|
|
INPUT_GAIN = __input_gain; |
|
|
|
// INPUT_GAIN = 0x3b; // mute,24db
|
|
|
|
|
|
|
|
INPUT_SEL = 0x2; |
|
|
|
INPUT_SEL = 0x1; |
|
|
|
|
|
|
|
ADCGAIN = 0x3e; //20 dB
|
|
|
|
// ADCGAIN = 0x34; //10 dB
|
|
|
|
|
|
|
|
// DACGAIN = 0x7e; //20db
|
|
|
|
DACGAIN = 0x74; //6db
|
|
|
|
DACGAIN = __dac_gain; //-10db
|
|
|
|
// DACGAIN = 0x74; //0db
|
|
|
|
#if 0 |
|
|
|
/*
|
|
|
@ -957,3 +964,29 @@ void a3k_reset(a3k_t a3k, int baudrate) |
|
|
|
config_a3k_codec(a3k); |
|
|
|
start_a3k_codec(a3k, 0, 0, 0); |
|
|
|
} |
|
|
|
|
|
|
|
#if (TARGET_HAS_A3K_0) && (TARGET_HAS_A3K_1) |
|
|
|
static int do_codec_dac(cmd_tbl_t s, int argc, char *argv[]) |
|
|
|
{ |
|
|
|
__dac_gain = strtoul(argv[1], NULL, 0); |
|
|
|
|
|
|
|
a3k_setup(&a3k0, -1); |
|
|
|
a3k_setup(&a3k1, -1); |
|
|
|
printf("dac_gain = %x\r\n", __dac_gain); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
static int do_codec_ipt(cmd_tbl_t s, int argc, char *argv[]) |
|
|
|
{ |
|
|
|
__input_gain = strtoul(argv[1], NULL, 0); |
|
|
|
|
|
|
|
a3k_setup(&a3k0, -1); |
|
|
|
a3k_setup(&a3k1, -1); |
|
|
|
printf("input_gain = %x\r\n",__input_gain); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CON_CMD(dac, "config the dac_gain of codec", NULL, do_codec_dac); |
|
|
|
CON_CMD(ipt, "config the input_gain of codec", NULL, do_codec_ipt); |
|
|
|
#endif |
|
|
|