|
|
@@ -89,6 +89,7 @@ typedef struct {
|
|
|
bool use_apll; /*!< I2S use APLL clock */
|
|
|
bool tx_desc_auto_clear; /*!< I2S auto clear tx descriptor on underflow */
|
|
|
int fixed_mclk; /*!< I2S fixed MLCK clock */
|
|
|
+ double real_rate;
|
|
|
#ifdef CONFIG_PM_ENABLE
|
|
|
esp_pm_lock_handle_t pm_lock;
|
|
|
#endif
|
|
|
@@ -178,6 +179,12 @@ esp_err_t i2s_enable_tx_intr(i2s_port_t i2s_num)
|
|
|
return ESP_OK;
|
|
|
}
|
|
|
|
|
|
+float i2s_get_clk(i2s_port_t i2s_num)
|
|
|
+{
|
|
|
+ I2S_CHECK((i2s_num < I2S_NUM_MAX), "i2s_num error", ESP_ERR_INVALID_ARG);
|
|
|
+ return p_i2s_obj[i2s_num]->real_rate;
|
|
|
+}
|
|
|
+
|
|
|
static esp_err_t i2s_isr_register(i2s_port_t i2s_num, int intr_alloc_flags, void (*fn)(void*), void * arg, i2s_isr_handle_t *handle)
|
|
|
{
|
|
|
return esp_intr_alloc(ETS_I2S0_INTR_SOURCE + i2s_num, intr_alloc_flags, fn, arg, handle);
|
|
|
@@ -465,6 +472,7 @@ esp_err_t i2s_set_clk(i2s_port_t i2s_num, uint32_t rate, i2s_bits_per_sample_t b
|
|
|
I2S[i2s_num]->sample_rate_conf.rx_bck_div_num = m_scale;
|
|
|
I2S[i2s_num]->clkm_conf.clka_en = 1;
|
|
|
double fi2s_rate = i2s_apll_get_fi2s(bits, sdm0, sdm1, sdm2, odir);
|
|
|
+ p_i2s_obj[i2s_num]->real_rate = fi2s_rate/bits/channel/m_scale;
|
|
|
ESP_LOGI(I2S_TAG, "APLL: Req RATE: %d, real rate: %0.3f, BITS: %u, CLKM: %u, BCK_M: %u, MCLK: %0.3f, SCLK: %f, diva: %d, divb: %d",
|
|
|
rate, fi2s_rate/bits/channel/m_scale, bits, 1, m_scale, fi2s_rate, fi2s_rate/8, 1, 0);
|
|
|
} else {
|
|
|
@@ -475,6 +483,7 @@ esp_err_t i2s_set_clk(i2s_port_t i2s_num, uint32_t rate, i2s_bits_per_sample_t b
|
|
|
I2S[i2s_num]->sample_rate_conf.tx_bck_div_num = bck;
|
|
|
I2S[i2s_num]->sample_rate_conf.rx_bck_div_num = bck;
|
|
|
double real_rate = (double) (I2S_BASE_CLK / (bck * bits * clkmInteger) / 2);
|
|
|
+ p_i2s_obj[i2s_num]->real_rate = real_rate;
|
|
|
ESP_LOGI(I2S_TAG, "PLL_D2: Req RATE: %d, real rate: %0.3f, BITS: %u, CLKM: %u, BCK: %u, MCLK: %0.3f, SCLK: %f, diva: %d, divb: %d",
|
|
|
rate, real_rate, bits, clkmInteger, bck, (double)I2S_BASE_CLK / mclk, real_rate*bits*channel, 64, clkmDecimals);
|
|
|
}
|