Coder Social home page Coder Social logo

Comments (4)

Rahix avatar Rahix commented on June 24, 2024 1

Still not quite sure ... But I think I got something for you:

If you downgrade the pins, you can match them like this (or slightly different, this code is untested):

let pin = pc3.downgrade();

if let atmega328p_hal::port::Pin::C(id, _) = pin {
    // ...
} else {
    panic!("Only pins of port C can be used for analog reads!");
}

from avr-hal.

Rahix avatar Rahix commented on June 24, 2024

I don't quite understand what you are trying to do. Can you please clarify, what your goal is?

from avr-hal.

Altaflux avatar Altaflux commented on June 24, 2024

Similar to what your macro I described above is doing. I want to change a bit on a register.
The bit on the register I want to change is the pin number:
Example from src/atmega328p/port.rs
pc3: (PC3, 3) The 3 here.

As currently analog read is not implemented I am trying to do it myself in the meantime:
dp.ADC.admux.modify(|r, w| { w.bits(r.bits() | mask) }); //Enable ADC for a given pin
But I need to know the mask of the pin.
So, for a given pin, i need the mask to use.

Sorry if I am not making myself clear enough, let me know if more info is needed and thanks for the help and effort!

from avr-hal.

Altaflux avatar Altaflux commented on June 24, 2024

Yeah! This is exactly what I was looking for, that "id". Only correction "i think" is that this is the correct import that worked for me:

let pin = pc3.downgrade();

if let arduino_uno::hal::port::Pin::C(id, _) = pin {
    // ...
} else {
    panic!("Only pins of port C can be used for analog reads!");
}

Thanks a lot for the help and assistance! Great work!

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.