35 lines
862 B
C
35 lines
862 B
C
#include "i2s.h"
|
|
#include "pins.h"
|
|
|
|
i2s_chan_handle_t i2s_tx;
|
|
i2s_chan_handle_t i2s_rx;
|
|
void audio_i2s_init(void) {
|
|
i2s_chan_config_t cfg =
|
|
I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_0, I2S_ROLE_MASTER);
|
|
|
|
i2s_new_channel(&cfg, &i2s_tx, &i2s_rx);
|
|
|
|
i2s_std_config_t stdcfg = {
|
|
.clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(44100),
|
|
|
|
.slot_cfg = I2S_STD_MSB_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_16BIT,
|
|
I2S_SLOT_MODE_STEREO),
|
|
|
|
.gpio_cfg =
|
|
{
|
|
.mclk = I2S_GPIO_UNUSED,
|
|
.bclk = AUDIO_SCLK,
|
|
.ws = AUDIO_LRCK,
|
|
.dout = AUDIO_DSDIN,
|
|
.din = AUDIO_ASDOUT,
|
|
},
|
|
};
|
|
|
|
i2s_channel_init_std_mode(i2s_tx, &stdcfg);
|
|
|
|
i2s_channel_init_std_mode(i2s_rx, &stdcfg);
|
|
|
|
i2s_channel_enable(i2s_tx);
|
|
i2s_channel_enable(i2s_rx);
|
|
}
|