Browse Source

remove code in main.c

Signed-off-by: zhaijunyuan <1045598574@qq.com>
master
zhaijunyuan 6 years ago
parent
commit
e9c6058bce
  1. 2
      Makefile
  2. 2
      lib/a3k.c
  3. 77
      src/main.c

2
Makefile

@ -22,7 +22,7 @@ usb_dir := $(top_dir)/usb
link_script := $(top_dir)/stm32f4x.lds
specs := --specs=nosys.specs --specs=nano.specs
debug ?= 1
#debug ?= 1
ifeq ($(debug),1)
debug_flags := -O0 -g -ggdb
else

2
lib/a3k.c

@ -280,7 +280,7 @@ static int config_a3k(a3k_t interface, short ratet, short lowpower, short gain
static int config_a3k_codec(a3k_t interface )
{
char packet[50];
char packet[128];
char *p = packet+4;
short plen;
short INPUT_GAIN;

77
src/main.c

@ -6,83 +6,6 @@
#include "gpio.h"
#include "a3k.h"
#define AIC14K_ADDR 0x80
void init_i2c1(void);
int i2c_write(uint8_t addr, uint8_t *data, int len);
int i2c_read(uint8_t addr, uint8_t *data, int len);
int console_read(void *ptr, int len)
{
return serial_recv_buffered(&serial0, ptr, len);
}
int console_write(const void *ptr, int len)
{
return serial_send_buffered(&serial0, ptr, len);
}
static int do_codec_r(struct cmd_tbl_s *cmd, int argc, char *argv[])
{
uint8_t reg, val = 0;
if (argc < 2) {
return -1;
}
reg = strtoul(argv[1], NULL, 0);
i2c_write(AIC14K_ADDR, &reg, 1);
i2c_read(AIC14K_ADDR, &val, 1);
printf("read: reg %02x, val %02x\n", reg, val);
return 0;
}
CON_CMD(ar, 1, "read codec reg", do_codec_r);
static int do_codec_w(struct cmd_tbl_s *cmd, int argc, char *argv[])
{
uint8_t dt[2];
if (argc < 3) {
return -1;
}
dt[0] = strtoul(argv[1], NULL, 0);
dt[1] = strtoul(argv[2], NULL, 0);
i2c_write(AIC14K_ADDR, dt, 2);
printf("write: reg %02x, val %02x\n", dt[0], dt[1]);
return 0;
}
CON_CMD(aw, 1, "write codec reg", do_codec_w);
void init_codec()
{
#define N_REG (7)
int i;
uint8_t regs[N_REG][2] = {
{0x1, 0x41},
{0x2, 0xA0},
{0x4, 0x83},
{0x4, 0x8A},
{0x4, 0x01},
{0x5c, 0xB8},
{0x6, 0x02}
};
uint8_t dt;
for (i = 0; i < N_REG; ++i) {
i2c_write(0x80, regs[i], 2);
}
for (i = 0; i < N_REG; ++i) {
dt = 0xff;
i2c_write(0x80, regs[i], 1);
i2c_read(0x80, &dt, 1);
printf("reg: %02x, val: %02x\r\n", regs[i][0], dt);
}
}
static void loopback()
{
static uint8_t buffer[512] = {0};

Loading…
Cancel
Save