Coder Social home page Coder Social logo

Comments (6)

Rahix avatar Rahix commented on June 30, 2024 1

whilst also preventing usage of the USART for USART purposes.

This part is actually very simple. The UsartSpi driver constructor consumes the USART peripheral, just like the current UART driver consumes it. Due to Rust's ownership rules, this means only one of the two can ever exist:

    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

from avr-hal.

Rahix avatar Rahix commented on June 30, 2024 1

I'd create a completely new module for USART as SPI. usart_spi I guess.

from avr-hal.

Rahix avatar Rahix commented on June 30, 2024

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!

from avr-hal.

CoolSlimbo avatar CoolSlimbo commented on June 30, 2024

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.

from avr-hal.

Rahix avatar Rahix commented on June 30, 2024

if you could aid a hand in the direction it needs to go in!

Generally, you'll need to add a usart_spi module in avr-hal-generic, similar in structure to the existing spi or usart modules. This defines the generic UsartSpi driver and a macro for the MCU-specific HALs. This macro is then instanciated in atmega-hal to implement USART as SPI for the available USART peripherals.

from avr-hal.

CoolSlimbo avatar CoolSlimbo commented on June 30, 2024

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 USART or SPI module?

from avr-hal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.