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

Clock feature #191

Merged
merged 4 commits into from
Oct 30, 2024
Merged

Clock feature #191

merged 4 commits into from
Oct 30, 2024

Conversation

IFX-Anusha
Copy link

  • machine.freq() implementation for setting clock by the user
  • Remove clock init from I2S and modified tests
  • Documentation

Copy link
Member

@NikhitaR-IFX NikhitaR-IFX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!🚀

Copy link
Member

@jaenrig-ifx jaenrig-ifx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good! 😃 A couple of things that we should refine 📏

@@ -366,21 +323,6 @@ static void mp_machine_i2s_init_helper(machine_i2s_obj_t *self, mp_arg_val_t *ar
mp_raise_ValueError(MP_ERROR_TEXT("invalid format"));
}

// is valid clock freq?
uint32_t audio_clock_freq_hz;
uint32_t rate = args[ARG_rate].u_int;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should keep this part checking that the rate is a valid one or?
Otherwise, the use could pass any integer. But actually only the ones filtered where valid?

Additionally, here I would check if the clock is properly for that rate, and raise exception if that is not the case.

uint32_t reset_cause;
bool clock_set_i2s = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These flags would not be sufficient to properly check the current clock configuration, because there aren´t deinited anywhere or?

Think of the following case:

  • you set the machine.freq(AUDIO_I2S_98_MHZ)
  • the clock_set_i2s = true;
  • then you set machine.freq(AUDIO_PDM_22_579_200_HZ)
  • then clock_set_pdm = true;
  • then you try to use machine.I2S. It will consider that the i2s clock is set, but actually isn´t.

I would say inside the i2s or the pdm we need to check the right configuration (also for the given rates). A function to get freq setup can be called by each module (i2s, pdm, ...) and they can check if that is the right one. Raise an exception otherwise.

Alternatively, you have to keep track of those 2 flags (and any future one), and set them to false, when other functions reconfigure those clocks. I think that is less maintainable because every function needs to keep track of "which setup an I going to break".

Copy link

@ramya-subramanyam ramya-subramanyam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Copy link
Member

@jaenrig-ifx jaenrig-ifx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👯

@IFX-Anusha IFX-Anusha merged commit 658e146 into ports-psoc6-main Oct 30, 2024
33 of 35 checks passed
@IFX-Anusha IFX-Anusha deleted the Clock-feature branch October 30, 2024 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants