-
Notifications
You must be signed in to change notification settings - Fork 226
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
Utilising the atmega2560
's "USART in SPI Mode"
#561
Comments
Yes, this isn't supported yet. If anyone is interested in working on a "USART as SPI" driver and needs guidance on how to do this, feel free to ping me! |
I'll gladly give this a shot in implementation, if you could aid a hand in the direction it needs to go in! Currently, my confusion is just on how one would implement it, whilst also preventing usage of the USART for USART purposes. |
This part is actually very simple. The let dp = atmega_hal::Peripherals::take().unwrap();
let pins = atmega_hal::pins!(dp);
let mut serial = Usart::new(
dp.USART0, // <- USART0 is moved into `serial` here
pins.pe0,
pins.pe1.into_output(),
Baudrate::<crate::CoreClock>::new(57600),
);
let mut spi = UsartSpi::new(dp.USART0, ...); // <- compiler error because USART0 was moved previously and is no longer available |
Generally, you'll need to add a |
Roger on that. I do see that now, I was over-engineering that way to much... I'll get to work on implementing the driver, however, would this preferred to be in the |
I'd create a completely new module for USART as SPI. |
@CoolSlimbo Thanks for taking this one! I was missing this feature and pondered working on it, but my Rust skill is still lacking for it... I'll be happy to give it a test! |
@armandas If you could, that would be splendid. I had completely forgot about this due to school, and my lack of multi USART devices, so testing it out and closing this up for me (us?) would be great. |
@CoolSlimbo I just posted my results on the PR. There is a small compilation issue, so I think if you resolve it, the PR may be good ready for review. |
Thank you. As long as it runs the CI (which it should now), it'll be able to finally be merged! |
According the the
atmega2560
datasheet, itsUSART
modules can be used in "SPI Mode," which essentially gives an extra bus (or four) to add SPI devices to it.However, within the current implementation of
avr_hal
/atmega_hal
, it's not plausible to use the USART modules in SPI mode.Given this is hardware supported on the
atmega
's (versions of it), it would make sense to have a hardware implementation of it it in the HAL's.Free to give this an attempt if given a suggestion in the right way for how to get started.
Related Issue:
Linked PR: #562
The text was updated successfully, but these errors were encountered: