Update to latest embedded-hal, include std example - #11
Conversation
|
Addresses #8 |
There was a problem hiding this comment.
The critical section implementation using IsrCriticalSection should be added here
There was a problem hiding this comment.
I think that implementation may lock this crate into the idf use case, where I would like to keep it no-std. Are you referring to this? https://github.com/beeb/coffee-scale-app/blob/main/rs/src/critical_section.rs. We should look into some way to support both.
There was a problem hiding this comment.
Yes exactly, the critical section above is required for the IDF example. It's not required for no-std, as the esp32-rs crates already provide the required critical section implementation. But the provided one for idf is not sufficient to ensure correct reading of the hx711, because it is thread-local only as I understand.
There was a problem hiding this comment.
Perhaps we should upstream the change into esp-idf-hal?
There was a problem hiding this comment.
https://docs.rs/critical-section/latest/critical_section/#usage-in-libraries says not to provide this in libraries, I think we should follow their advice.
There was a problem hiding this comment.
There was a problem hiding this comment.
Of course this only applies to the example, we should not implement it for the library. I'm talking about example code specifically, since consumers of the library will need to implement the critical section when using idf
There was a problem hiding this comment.
@DaneSlattery I commented on your PR over at esp-idf-hal
There was a problem hiding this comment.
I'm starting to think the one provided by default is actually safe across threads and interrupts, see here, they call interrupt::free, which runs the critical section with interrupts disabled. However, whether it is safe across multiple threads or CPUs is another question, and I don't know enough about the details.
https://github.com/esp-rs/esp-idf-hal/blob/e30d7ab708065d48f8a96e32993bde3ff3946370/src/task.rs#L448
There was a problem hiding this comment.
I tried it but had bad readings, the scheduler is free to launch tasks with high priority during the critical section as far as I understood. I discussed this at length on matrix with the team.
Fixes examples
Adds a std example, although this does not build in this environment.
Upgrades to the embedded-hal version 1 release, with new trait defs.