mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/i2s_apll_clock_fix_v3.2' into 'release/v3.2'
driver/i2s: fix apll_clock_rate for different sample rates (v3.2) See merge request espressif/esp-idf!5449
This commit is contained in:
commit
376377ceca
@ -249,7 +249,7 @@ static esp_err_t i2s_apll_calculate_fi2s(int rate, int bits_per_sample, int *sdm
|
||||
max_rate = i2s_apll_get_fi2s(bits_per_sample, 255, 255, _sdm2, 0);
|
||||
min_rate = i2s_apll_get_fi2s(bits_per_sample, 0, 0, _sdm2, 31);
|
||||
avg = (max_rate + min_rate)/2;
|
||||
if(abs(avg - rate) < min_diff) {
|
||||
if (abs(avg - rate) < min_diff) {
|
||||
min_diff = abs(avg - rate);
|
||||
*sdm2 = _sdm2;
|
||||
}
|
||||
@ -259,11 +259,21 @@ static esp_err_t i2s_apll_calculate_fi2s(int rate, int bits_per_sample, int *sdm
|
||||
max_rate = i2s_apll_get_fi2s(bits_per_sample, 255, 255, *sdm2, _odir);
|
||||
min_rate = i2s_apll_get_fi2s(bits_per_sample, 0, 0, *sdm2, _odir);
|
||||
avg = (max_rate + min_rate)/2;
|
||||
if(abs(avg - rate) < min_diff) {
|
||||
if (abs(avg - rate) < min_diff) {
|
||||
min_diff = abs(avg - rate);
|
||||
*odir = _odir;
|
||||
}
|
||||
}
|
||||
min_diff = APLL_MAX_FREQ;
|
||||
for (_sdm2 = 4; _sdm2 < 9; _sdm2 ++) {
|
||||
max_rate = i2s_apll_get_fi2s(bits_per_sample, 255, 255, _sdm2, *odir);
|
||||
min_rate = i2s_apll_get_fi2s(bits_per_sample, 0, 0, _sdm2, *odir);
|
||||
avg = (max_rate + min_rate)/2;
|
||||
if (abs(avg - rate) < min_diff) {
|
||||
min_diff = abs(avg - rate);
|
||||
*sdm2 = _sdm2;
|
||||
}
|
||||
}
|
||||
|
||||
min_diff = APLL_MAX_FREQ;
|
||||
for (_sdm1 = 0; _sdm1 < 256; _sdm1 ++) {
|
||||
|
Loading…
Reference in New Issue
Block a user