-
Notifications
You must be signed in to change notification settings - Fork 266
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
Implement the embedded-hal Read trait for the RNG peripheral #26
Conversation
Implementation looks fine, but can we figure out if the RNG has actually been enabled? This document talks about what's required for the RNG to work, and given that we are using the second stage boot loader it will work but in the future that might change. We don't have to implement the clock enable in this PR, but maybe as a bare minimum we can add check to make sure it has? |
Code looks good to me. But Scott's point about the pre-conditions is very good. I'd probably have totally missed that. The scary thing is that apparently when the pre-conditions are not met it will produce pseudo-random numbers so it is not obvious to the user. A PRNG might probably be good enough for many things but for some things it's not Not sure if we should add a runtime-check and panic - as said maybe some users might be totally fine with a PRNG. Also, is this worth to have an example for? The API is simple enough so most people will figure out how to use the RNG |
I'm sort of on the fence with regards to how we should handle this. My gut says that we should avoid runtime checks whenever possible, but I'm happy to hear any refutations to this. Generally speaking, I'm against trying to hold the user's hand too much. If somebody is not using the bootloader from ESP-IDF I assume that they know well enough to properly initialize the device. I'm not sure if this is a reasonable assumption or not, though. Given that we're still in the early stages of the HAL, and that there are already technically incorrect implementations present in the repo (eg. the Xtensa delays) I'm not sure how big of a deal we need to make of this. I think adding a comment stating the pre-conditions is probably adequate for the time being, but please let me know how you both feel about this. |
I personally would be totally fine with a reasonable warning (with a reference to the TRM) in the comments and I agree that a bare-metal HAL is usually not a "batteries-included" thing. Also, since this is not named Maybe it's also a good occasion to think about the general philosophy of the HAL (i.e. should it be as much "batteries-included" as possible or not). While there are a lot of wild assumptions currently (e.g. regarding the various clock speeds) which we need to address there are also other things more similar to this (e.g. is synchronization something that should be taken care of at the call-site (with some hints in the docs where needed) or not) As said, I personally think a bare-metal HAL could assume more care taken by the user than e.g. the ESP-IDF-HAL. Which makes we wonder if the wording |
d5d1045
to
590df9b
Compare
I've added documentation for this driver, should be adequate I believe. @bjoernQ I think you're right and those discussions need to be had. I've created a discussion where we can talk about such things. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Nice we have that peripheral supported now
Simple peripheral, equally simple implementation. Did not include an example but did verify that it works as expected locally.