Skip to content

Commit

Permalink
set i2s config, 48k 32b 2channels
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishek-samsung committed Apr 12, 2022
1 parent 5d5602f commit 2d164c9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
25 changes: 16 additions & 9 deletions apps/examples/hello/hello_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ int hello_main(int argc, char *argv[])
#if 1
amebad_PA0_set(0);
lldbg("set gpio0 to low");
lldbg("registering i2s driver\n");
struct i2s_dev_s *i2s = amebad_i2s_initialize(0);
sleep(2);
amebad_PA0_set(1);
lldbg("set gpio0 to high");
Expand All @@ -102,7 +104,9 @@ int hello_main(int argc, char *argv[])
config.frequency = 100000;
config.addrlen = 7;
config.address = 0x1A;


// while(true) {

addr[0] = 0x04;
addr[1] = 0x00;

Expand Down Expand Up @@ -200,18 +204,17 @@ int hello_main(int argc, char *argv[])
addr[0] = 0x01;
addr[1] = 0x00;

for (int i = 0; i < 6; i++) {
ret = i2c_write(dev, &config, addr, 2);
ret = i2c_write(dev, &config, addr, 2);

if (ret != 2) {
lldbg("write fail\n");
return;
}
else lldbg("written 0x%02x to regaddr 0x%02x\n", addr[1], addr[0]);
}
if (ret != 2) {
lldbg("write fail\n");
return;
} else lldbg("written 0x%02x to regaddr 0x%02x\n", addr[1], addr[0]);

sleep(2);

while(true) {

ret = i2c_write(dev, &config, addr, 1); // send address 0x01 followed by read command.

if (ret != 1) {
Expand All @@ -228,8 +231,12 @@ int hello_main(int argc, char *argv[])

lldbg("read 0x%02x from regaddr 0x%02x\n", buf[0], addr[0]);

if (buf[0] == 0x02) break; // wait until we read 0x02 from the register.

sleep(2);

}

addr[0] = 0x2A; // write to regaddr 0x01 value 0x00
addr[1] = 0xCC;

Expand Down
2 changes: 1 addition & 1 deletion build/configs/rtl8721csm/hello/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ CONFIG_RTL8721D_UART1=y
CONFIG_RTL8721D_UART2=y
CONFIG_RTL8721D_SERIAL_FIFO=y
CONFIG_AMEBAD_I2S=y
CONFIG_AMEBAD_I2S_RX=y
# CONFIG_AMEBAD_I2S_RX is not set
CONFIG_AMEBAD_I2S_TX=y
# CONFIG_AMEBAD_I2C_DYNTIMEO is not set
CONFIG_AMEBAD_I2CTIMEOSEC=0
Expand Down
8 changes: 4 additions & 4 deletions os/arch/arm/src/amebad/amebad_i2s.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ static int i2s_err_cb_register(struct i2s_dev_s *dev, i2s_err_cb_t cb, void *arg

static const i2s_config_t i2s_default_config = {

.sample_rate = CONFIG_AMEBAD_I2S_SAMPLERATE,
.bits_per_sample = CONFIG_AMEBAD_I2S_DATALEN,
.sample_rate = I2S_SR_48KHZ,
.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT,

.channel_num = CH_MONO,
.channel_num = CH_STEREO,
#if defined(I2S_HAVE_TX) && (0 < I2S_HAVE_TX)
.direction = I2S_DIR_TX,
#endif
Expand Down Expand Up @@ -1055,7 +1055,7 @@ void i2s_transfer_rx_handleirq(void *data, char *pbuf)

int result = OK;

i2s_rxdma_callback(priv, result);
//i2s_rxdma_callback(priv, result);
}

#if defined(I2S_HAVE_RX) && (0 < I2S_HAVE_RX)
Expand Down
1 change: 1 addition & 0 deletions os/arch/arm/src/amebad/amebad_lowerhalf.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ FAR struct gpio_lowerhalf_s *amebad_gpio_lowerhalf(u32 pinname, u32 pinmode, u32
gpio_init(&lower->obj, pinname);
gpio_dir(&lower->obj, pinmode);
gpio_mode(&lower->obj, pinpull);
gpio_write(&lower->obj, 0);
lower->pinmode =pinmode;
lower->pinpull = pinpull;
lower->ops = &amebad_gpio_ops;
Expand Down
10 changes: 0 additions & 10 deletions os/board/rtl8721csm/src/rtl8721csm_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,6 @@ void board_gpio_initialize(void)
} pins[] = {
{
PA_0, PIN_OUTPUT, PullNone
}, {
PA_1, PIN_OUTPUT, PullNone
}, {
PA_2, PIN_OUTPUT, PullNone
}, {
PA_3, PIN_OUTPUT, PullNone
}, {
PB_5, PIN_OUTPUT, PullNone
}, {
PA_12, PIN_INPUT, PullDown
},
/* {PA_6, PIN_OUTPUT, PullNone},
{PA_7, PIN_OUTPUT, PullNone},
Expand Down

0 comments on commit 2d164c9

Please sign in to comment.