You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2024/01/04 08:43:05 UTC
(mynewt-core) branch master updated: hw/drivers/i2s: Allow custom mck config
This is an automated email from the ASF dual-hosted git repository.
jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git
The following commit(s) were added to refs/heads/master by this push:
new 9dec05c33 hw/drivers/i2s: Allow custom mck config
9dec05c33 is described below
commit 9dec05c3357e08dfc98c93603db77d7dce66568a
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Mon Dec 11 15:34:11 2023 +0100
hw/drivers/i2s: Allow custom mck config
It was possible to have custom value for MCK setup and ratio,
but if it was set ACLK was no started.
Now custom ration and mck setup can be set and ACLK still be
started if requested
---
hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c b/hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c
index 174cde34e..c08d18b51 100644
--- a/hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c
+++ b/hw/drivers/i2s/i2s_nrfx/src/i2s_nrfx.c
@@ -220,10 +220,6 @@ i2s_nrfx_select_clock_cfg(nrfx_i2s_config_t *cfg, uint32_t sample_rate)
{
int i;
- if (cfg->ratio != 0 || cfg->mck_setup != 0) {
- /* User provided custom clock setup, no need to use stock values */
- return;
- }
#if NRF_I2S_HAS_CLKCONFIG
float src_frq;
uint32_t ratio;
@@ -236,6 +232,11 @@ i2s_nrfx_select_clock_cfg(nrfx_i2s_config_t *cfg, uint32_t sample_rate)
nrfx_clock_hfclkaudio_config_set(39854);
}
NRF_CLOCK->TASKS_HFCLKAUDIOSTART = 1;
+ if (cfg->mck_setup != 0) {
+ /* User provided custom clock setup, no need to compute values */
+ return;
+ }
+
src_frq = (32000000 * (4 + nrfx_clock_hfclkaudio_config_get() * 0.000015259f) / 12);
if (cfg->sample_width == NRF_I2S_SWIDTH_24BIT) {
cfg->ratio = NRF_I2S_RATIO_48X;
@@ -251,6 +252,9 @@ i2s_nrfx_select_clock_cfg(nrfx_i2s_config_t *cfg, uint32_t sample_rate)
mck = sample_rate * ratio;
cfg->mck_setup = 4096 * (mck * 1048576ull / (src_frq + mck / 2));
return;
+ } else if (cfg->mck_setup != 0) {
+ /* User provided custom clock setup, no need to use stock values */
+ return;
}
#endif
for (i = 0; i < ARRAY_SIZE(sample_rates); ++i) {