Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ADC crash error #34

Merged
merged 10 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/audio_input/src/ADCSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ void ADCSampler::configureI2S()
i2s_adc_enable(m_i2sPort);
}

void ADCSampler::unConfigureI2S()
{
// make sure ot do this or the ADC is locked
i2s_adc_disable(m_i2sPort);
}

int ADCSampler::read(int16_t *samples, int count)
{
// read from i2s
Expand Down
1 change: 1 addition & 0 deletions lib/audio_input/src/ADCSampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ADCSampler : public I2SSampler

protected:
void configureI2S();
void unConfigureI2S();

public:
ADCSampler(adc_unit_t adc_unit, adc1_channel_t adc_channel, const i2s_config_t &i2s_config);
Expand Down
2 changes: 1 addition & 1 deletion lib/audio_input/src/I2SMEMSSampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class I2SMEMSSampler : public I2SSampler

protected:
void configureI2S();

public:
I2SMEMSSampler(
i2s_port_t i2s_port,
Expand Down
2 changes: 2 additions & 0 deletions lib/audio_input/src/I2SSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ void I2SSampler::start()

void I2SSampler::stop()
{
// clear any I2S configuration
unConfigureI2S();
// stop the i2S driver
i2s_driver_uninstall(m_i2sPort);
}
1 change: 1 addition & 0 deletions lib/audio_input/src/I2SSampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class I2SSampler
i2s_port_t m_i2sPort = I2S_NUM_0;
i2s_config_t m_i2s_config;
virtual void configureI2S() = 0;
virtual void unConfigureI2S(){};
virtual void processI2SData(void *samples, size_t count){
// nothing to do for the default case
};
Expand Down