-
Notifications
You must be signed in to change notification settings - Fork 208
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
RFC: Investigate the need for a lower-level layer of abstraction #1282
Comments
I'd love that. I think the reason why those things currently look how they look is that they the code is ported straight away from esp-idf and initially it made sense to make it look as closely to what the C code looks like to enable us to compare it to the C code easily ... getting those things to work is amazingly annoying and going multiple steps at once doesn't help. But clearly the next step is to make that code actually look like Rust - not C in Rust syntax 😄 On the other hand, there was a reason to not do it immediately. As long as we are not sure what our code does is 100% correct it's good to have it more or less easily comparable to esp-idf. Especially since many of the things there are not documented well or at all in the TRMs But most probably our code there is proven enough
Totally agree.
I guess this refers to all drivers in general, not just the SOC module? And I guess it's also referring to esp-idf's I think we already have something like that in many drivers (the Having something like a I'm not saying we shouldn't do something like that but I think, it won't be an "makes everything better" thing and we should carefully balance it |
IMO the pac is the low-level layer. The SoC module does have some overlap, but to me it's just a convenient place to put chip-specific stuff. I think most of our need for a ll layer would be solved by:
|
(This is a little all over the place right now, just trying to get my thoughts on this written down; will edit this as my thoughts clarify)
Some low-level implementation details are fundamentally required, as not everything can be abstracted over cleanly. You see most of this taking place in the
soc
module, with per-chip implementations for various functionality. While this is a necessity, in its current state there is a lot of duplication still happening, and I think there's a lot of room for improvement.One big win would be eliminating as much of the raw register accesses as possible, and instead updating our PACs to include the relevant registers/fields. This is currently being tracked in its own issue:
This may or may not be possible/practical for all registers/fields, however I'm sure we can make some great improvements.
Beyond this, some raw register access may still be required. In this case, we should at least make efforts to de-duplicate the helper functions/macros being used. For instance,
reg_set_bit
is defined in each of thesoc::$chip::trng
modules as well as in each of theclock::clocks_ll::$chip
modules. There are likely other such instances lurking as well.Maybe there is a better way to do this than
const
s/macros too, I'm not sure.With all this said, it's not clear to me whether or not we should try to form some low-level HAL API in addition to what we're doing now. This is done in ESP-IDF, for instance, however I suppose it's worth some discussion and reflection how to best handle this all moving forward as complexity continues to grow. There's no immediate need for action, just something to consider for now.
The text was updated successfully, but these errors were encountered: