generated from m5stack/M5Template-C-CPP
-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Describe the bug
There are very few examples to show how to pull mic samples with the M5AtomS3U. All my attempts have failed.
To reproduce
Here is some example code that I think should work. It does get samples but all of these are invalid.
do
{
i2s_chan_config_t rx_chan_cfg = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_AUTO, I2S_ROLE_MASTER);
if (i2s_new_channel(&rx_chan_cfg, NULL, &rx_chan) != ESP_OK)
{
Debug::Log.error(LOG_MIC, "i2s_new_channel error");
break;
}
i2s_pdm_rx_config_t pdm_rx_cfg = {
.clk_cfg = I2S_PDM_RX_CLK_DEFAULT_CONFIG(SAMPLE_RATE),
/* The data bit-width of PDM mode is fixed to 16 */
.slot_cfg = I2S_PDM_RX_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_MONO),
.gpio_cfg = {
.clk = (gpio_num_t)I2S_SPM1423_CLK,
.din = (gpio_num_t)I2S_SPM1423_DATA,
.invert_flags = {
.clk_inv = false,
},
},
};
pdm_rx_cfg.slot_cfg.slot_mask = I2S_PDM_SLOT_RIGHT;
if (i2s_channel_init_pdm_rx_mode(rx_chan, &pdm_rx_cfg) != ESP_OK)
{
break;
}
/* Step 3: Enable the rx channels before reading data */
if (i2s_channel_enable(rx_chan) != ESP_OK)
{
break;
}
size_t bytes_read = 0;
if (i2s_channel_read(rx_chan, (microphonedata0 + data_offset), DATA_SIZE, &bytes_read, 1000) == ESP_OK && bytes_read != 0)
{
data_offset += bytes_read;
// write to serial for debug
}
} while (false);
Expected behavior
A working example and some valid samples
Screenshots
No response
Environment
- OS:
- IDE &IDE Version:
- Repository Version:
Additional context
No response
Issue checklist
- I searched for previous reports in the issue tracker
- My report contains all necessary details
Metadata
Metadata
Assignees
Labels
No labels