Comments (6)
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.
PR #3 now contains the board crate for Arduino Uno.
from avr-hal.
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.
Opened PR #3 that adds a chip crate for atmega328p.
from avr-hal.
Support has landed in 1e1ed1b. 🎉
from avr-hal.
Woop, thanks for the help
from avr-hal.
Related Issues (20)
- No way to switch an analog pin back to digital mode HOT 7
- The crates' avrdude.config not compatible with AVRDUDE 7.1 HOT 1
- "uno-timer" example no longer works HOT 8
- Critical section causes unexpected behaviour in `--release` mode HOT 10
- avrdude 7.3 cannot find programmer HOT 3
- `cargo run` fails - avrdude looking for missing "system wide configuration file" HOT 13
- Arduino Uno readDigital equivalent
- Can't write to serial HOT 7
- Linker error when using a floating point operation HOT 3
- Panic while trying to write to serial using `ufmt::uwriteln` HOT 4
- Add configurable board options to ravedude HOT 3
- Get pin number HOT 6
- Program freezes if compiled in debug mode.
- ravedude should check rust target against selected MCU HOT 3
- Document clock type design in more detail HOT 1
- cargo build - error[E0658] - proc_macro::Literal::byte_character(byte) HOT 9
- can't find crate for `core` HOT 12
- cargo build - error[E0658] - proc_macro::Literal::byte_character(byte) HOT 4
- Very weird error when compiling a very basic program: __addsf3 multiple defenitions HOT 8
- Ravedude freezes on programmer uploading HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from avr-hal.