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

I2S reconfiguration support #334

Open
bbutkovic opened this issue Nov 9, 2023 · 8 comments · May be fixed by #335
Open

I2S reconfiguration support #334

bbutkovic opened this issue Nov 9, 2023 · 8 comments · May be fixed by #335
Labels
enhancement New feature or request

Comments

@bbutkovic
Copy link

I'm working on a project and I'd like to be able to reconfigure the I2S channels on-the-fly.

The IDF already has support for that so it would be great if we could also do it here.

I'm willing to work on this, in fact I started already, going to post a WIP PR.

@bbutkovic bbutkovic linked a pull request Nov 9, 2023 that will close this issue
@ivmarkov
Copy link
Collaborator

Can you describe a bit your specific use case, and in particular - why dropping and re-creating the driver would not work for your case?

@bbutkovic
Copy link
Author

I'm writing a sort-of wrapper around the I2S driver that I may or may not publish later as a crate. I hold the driver within my struct wrapper, meaning when I want to drop and re-create the driver I have to also keep ties to the peripherals or pass them into the function that calls for re-configuration. This is all doable but by using the API above it would make it a little bit cleaner and easier to reason about.

@Vollbrecht Vollbrecht added the enhancement New feature or request label Jun 21, 2024
@skibon02
Copy link

skibon02 commented Jul 24, 2024

Hi! I also need reconfiguration possibility in my scenario.

why dropping and re-creating the driver would not work for your case?

Could you please explain, did you mean using clone_unchecked() for keeping peripherals and reusing them to create a new instance of I2sDriver with a new configuration?

By making use of i2s_channel_reconfig_* functions of esp-idf it would make managing peripherals much easier in code.
Ideally, it'd be great to have uninit(self) method which would return participating peripherals as a tuple. But a variety of i2s modes can make it difficult

@ivmarkov
Copy link
Collaborator

ivmarkov commented Jul 24, 2024

Hi! I also need reconfiguration possibility in my scenario.

why dropping and re-creating the driver would not work for your case?

Could you please explain, did you mean using clone_unchecked() for keeping peripherals and reusing them to create a new instance of I2sDriver with a new configuration?

You can always create the driver with the peripherals passed by &mut instead of by moving them in the driver.
This way, if you drop the driver, you can re-use the peripherals in the new instance of the driver.

@skibon02
Copy link

passed by &mut instead of by moving them in the driver

Oh, thanks, i've missed this feature!
But considering reconfig implementation, I can make a PR with attempt to add reconfigure and uninit methods.

The only thing I want to know is a preferred way to keep I2S mode metadata, are generics ok? (e.g. I2sDriver<StandardMode, I2sRx>, I2sDriver<TdmMode, I2sBiDir>)

@ivmarkov
Copy link
Collaborator

passed by &mut instead of by moving them in the driver

Oh, thanks, i've missed this feature! But considering reconfig implementation, I can make a PR with attempt to add reconfigure and uninit methods.

The only thing I want to know is a preferred way to keep I2S mode metadata, are generics ok? (e.g. I2sDriver<StandardMode, I2sRx>, I2sDriver<TdmMode, I2sBiDir>)

If - as part of the reconfiguration - you plan to change the mode (i.e. to go from StandardMode to TdmMode) this cannot be done without dropping and re-creating the driver, as type-state modeling cannot be done any other way...

@skibon02
Copy link

skibon02 commented Jul 25, 2024

I don't want to change mode during reconfiguration, but everything else. And we need to track which mode was selected upon driver creation to call appropriate reconfigure function.

@ivmarkov
Copy link
Collaborator

ivmarkov commented Jul 25, 2024

I don't want to change mode during reconfiguration, but everything else. And we need to track which mode was selected upon driver creation to call appropriate reconfigure function.

This can be done in many ways. You can also track it with a simple enum. That is, unless the reconfigure functions have different signatures for each mode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

Successfully merging a pull request may close this issue.

4 participants