Coder Social home page Coder Social logo

ATMega328p Support about avr-hal HOT 6 CLOSED

rahix avatar rahix commented on June 23, 2024
ATMega328p Support

from avr-hal.

Comments (6)

jonahbron avatar jonahbron commented on June 23, 2024 1

Thanks so much for the direction @Rahix. There's clearly a lot here I don't know, but I'm looking forward to figuring it out. If it's okay I'll keep this issue open as I continue working on this.

from avr-hal.

jonahbron avatar jonahbron commented on June 23, 2024 1

PR #3 now contains the board crate for Arduino Uno.

from avr-hal.

Rahix avatar Rahix commented on June 23, 2024

Hey, thanks for your interest!

There are a few things that need to be done. The first aren't actually in this repository, but over in avr-device.

1. Add the MCU to avr-device

You are in luck! This step is already done, because I anticipated this chip to need an implementation soon ;) Just for completeness of this documentation, I'll include it. Detailed instructions are over here.

2. Add svd patches in avr-device

This is probably the first thing you need to start with. Unfortunately, the atdf files that Microchip (former Atmel) supplies are not of great quality. To fix them, we have included the svd patch tool from stm32-rs in our crate. You need to make use of it to rename and change a few registers.

Luckily, the ATmega328P is very similar to the already implemented ATmega32U4. This should mean that you can for the most part copy the patches from that chip. You can find them here. Documentation is in the README.


Now, onto things in this repo:

3. Add a chips/atmega328p-hal/ crate

Just follow what was done for the other chips. Specifically ATmega32U4 because of its similarity.

There are a few important things:

  • The rustc target description file. In your case avr-atmega328p.json. You can just copy the one from 32U4 again and just change the chipname inside it wherever it appears. The rest can stay the same.
  • Inside the sources for the existing chips, you will see a lot of macro calls. These are used to create instances of certain peripherals. The i2c (TWI) and UART ones will probably be almost exactly the same; the port definitions might be slightly different. It should be fairly straightforward to get the necessary information from the datasheet.

4. Adding a board crate for your board

In your case, this is boards/arduino-uno. You can use my Arduino Leonardo crate as a reference. This crate is meant as a wrapper around the hal crate that has an interface which more closely resembles the actual hardware. For example, there is a wrapper around the port peripherals which renames the pins to the names printed on the PCB.


If you have any questions, don't be afraid to ask! Especially don't hesitate to report weird behaviors! There are still some compiler issues and I really wouldn't want you to suffer through them like I had to ...

Anyway, good luck!

from avr-hal.

jonahbron avatar jonahbron commented on June 23, 2024

Opened PR #3 that adds a chip crate for atmega328p.

from avr-hal.

Rahix avatar Rahix commented on June 23, 2024

Support has landed in 1e1ed1b. 🎉

from avr-hal.

jonahbron avatar jonahbron commented on June 23, 2024

Woop, thanks for the help

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.