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

Allow drivers to be used without clock configuration #707

Open
pustekuchen91 opened this issue Dec 4, 2023 · 5 comments
Open

Allow drivers to be used without clock configuration #707

pustekuchen91 opened this issue Dec 4, 2023 · 5 comments

Comments

@pustekuchen91
Copy link

Hello,

currently i'm using a mix of harmony v3 + C++ Modules and new Modules written with rust / embassy and this crate.
Therefore the clock configuration for many drivers like adc, spi etc. are already done by the harmony code.

It would be nice, if i can use the drivers from the atsamd crate without passing the clock configuration. because it would be done twice and could lead to problems.

Would this be possible? What needed to be changed? Maybe i can do some changes by myself and create a pull request for this.

@ianrrees
Copy link
Contributor

ianrrees commented Dec 4, 2023

@pustekuchen91 I don't fully understand what you are proposing, however my interpretation is that you'd like to effectively mix the parts of Microchip's HAL with parts of this one, is that right? To me, this seems opposed to the design/philosophy of this project, since we leverage features of Rust that C simply does not have; in Rust we can build a library that prevents some types of errors, like if the programmer attempts to use a peripheral that doesn't have a clock configured.

Are there specific features of the Microchip HAL's clock management that this HAL lacks?

@pustekuchen91
Copy link
Author

@ianrrees Yes, you understood correctly. I can understand your point of view. This behavior shouldnt be de default, it could maybe an feature in this crate.

Actually in the case of ADC, its very restrictive with no degree of freedom in the configuration of the clocks. What if i dont want to use DFLL as ClockSource?

The clock configuration in harmony has many more options and this crate lacks some features of clock configuration e. g. clock or is it implemented with v2? I didnt deep dive into it yet.

@sakian
Copy link
Contributor

sakian commented Dec 5, 2023

I haven't found any limitations when configuring the clock using the v2 clocking updates. Harmony does make it easy to configure, with a nice UI, so you'll need to translate it to v2 code yourself, but I think it should be doable.

I do agree with you that there is more work to be done to properly support the v2 clocking changes in the peripheral interfaces. In fact, I already changed the way the ADC init function works in my fork of the HAL (see commit) but haven't had time to submit a PR here yet. I don't think the peripherals should be doing any clock setup, but should take a configured peripheral clock (my changes could probably do this better).

@pustekuchen91
Copy link
Author

@sakian thats looks a lot better. For the case that the clock configuration of harmony and the rust part is identical, it shouldnt matter, if its done twice (just some duplicate code).

@ianrrees
Copy link
Contributor

ianrrees commented Dec 5, 2023

If the other HAL does the same thing, what is the point in using it in addition to this one?

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

No branches or pull requests

3 participants