-
Notifications
You must be signed in to change notification settings - Fork 49
WIP: Support for autogenerated mcu cores #4
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
Conversation
eccbbad
to
1e25d1d
Compare
1e25d1d
to
3324393
Compare
src/spi.rs
Outdated
/// http://maxembedded.com/2013/11/the-spi-of-the-avr/ | ||
pub trait HardwareSpi { | ||
/// Master-in slave-out pin. | ||
type MISO: Pin; |
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.
I don't know if this is a losing battle, but I really was hoping we could avoid having acronym soup. I'm happy that there are comments, but I would rather it be
type MasterInSlaveOut: Pin;
And now the comment is encoded in the code. We can then add comments describing the why and the how, instead of the what.
The reason I think it might be a losing battle is because there's going to be inertia from all sides to "just do what Arduino / C / Atmel does". The reason I don't think that's fully valid is because we want to do things as Rust-like as we can.
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.
I think this is a good idea.
src/spi.rs
Outdated
} | ||
|
||
/// Constants for the control register. | ||
#[allow(dead_code)] |
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.
Why is this needed? Should it be public?
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.
I don't want to expose everything just yet because the design isn't 100%, will be public eventually though
src/pin.rs
Outdated
|
||
/// An IO pin. | ||
pub trait Pin { | ||
/// The associated data direction registerr. |
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.
extra r
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.
Fixed
src/reg.rs
Outdated
@@ -0,0 +1,95 @@ | |||
use core::{cmp, convert, ops}; | |||
|
|||
pub trait RegVal : Copy + Clone + |
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.
Is there are reason RegVal
needs to be abbreviated?
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.
Fixed
build.rs
Outdated
|
||
fn generate_cores(mcus: &[Mcu]) -> Result<(), io::Error> { | ||
for mcu in mcus { | ||
generate_core_module(mcu).expect("failed to generate mcu core"); |
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.
This returns a result; do we just want to propagate?
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.
Or perhaps not until we have an error type to keep the extra information from the expect
text
5c8be93
to
4ff0d90
Compare
There's some great stuff in this PR. Is there any help needed to get it across the finish line? I'd like to use some of the features in https://github.com/pusherofbrooms/rust-arduino-examples without using the extra special branch. |
At the moment, it adds autogenerated core functionality side-by-side with the current arduino master. It's a bit strange having two different implementations of the library, and so I think that if we can get feature parity with current master with the new implementation, that should be good. IIRC, I did most of the work to get it feature complete - I think the SPI stuff is still to be done? |
c1062c0
to
3803ac8
Compare
Alright, this is now feature complete with the current master branch as far as I can tell. Still need to do some cleanups, and the whole |
This is ready for some more eyes again @shepmaster @pusherofbrooms @Restioson |
This reverts commit 99ad3f0.
There isn't as much value as I thought in making the distinction.
A bit less ambiguous.
The "panic_fmt" lang item no longer exists; it has been replaced with the unstable feature #[panic_handler]
This allows 'cargo doc', and notably, docs.rs to work.
The interrupt helper struct does not need to be public. Add some documentation to a bunch of types.
This is much more intuitive.
55c02be
to
3fbe335
Compare
I'm going to merge this now to stop faffing about. It's much easier for people to build utop what is here when it is in master, rather than my private fork. I've looked over it locally, cleaned it up a lot. It should work on https://docs.rs too, automatically assuming atmega328p. |
Docs on docs.rs. |
It should be possible to do something like this
This would allow users to easily mix-and-match supported microcontrollers, provided the microcontroller has enough GPIOs, etc.