Basic arduino blink

This commit is contained in:
Werner
2021-12-25 08:13:42 -03:00
parent 7386595421
commit 536616d424
5 changed files with 84 additions and 0 deletions

6
.cargo/config.toml Normal file
View File

@ -0,0 +1,6 @@
[build]
target-dir = "Binaries"
target = "avr-atmega328p.json"
[unstable]
build-std = ["core"]

29
Cargo.toml Normal file
View File

@ -0,0 +1,29 @@
[package]
name = "rust-avr"
version = "0.1.0"
edition = "2018"
[[bin]]
name = "RustAVR"
path = "Source/Main.rs"
bench = false
test = false
[dependencies]
arduino-hal = { git = "https://github.com/Rahix/avr-hal", rev = "f84c0dff774c2292bc932b670955165161ecc7d1", features = ["arduino-uno"] }
embedded-hal = "0.2.3"
nb = "0.1.2"
panic-halt = "0.2.0"
ufmt = "0.1.0"
[profile.dev]
panic = "abort"
lto = true
opt-level = "s"
[profile.release]
panic = "abort"
codegen-units = 1
debug = true
lto = true
opt-level = "s"

19
Source/Main.rs Normal file
View File

@ -0,0 +1,19 @@
#![no_std]
#![no_main]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use panic_halt as _;
#[arduino_hal::entry]
fn main() -> ! {
let peripherals = arduino_hal::Peripherals::take().unwrap();
let pins = arduino_hal::pins!(peripherals);
let mut led = pins.d13.into_output();
loop {
led.toggle();
arduino_hal::delay_ms(1000);
}
}

29
avr-atmega328p.json Normal file
View File

@ -0,0 +1,29 @@
{
"llvm-target": "avr-unknown-unknown",
"cpu": "atmega328p",
"target-endian": "little",
"target-pointer-width": "16",
"target-c-int-width": "16",
"os": "unknown",
"arch": "avr",
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
"executables": true,
"linker": "avr-gcc",
"linker-flavor": "gcc",
"pre-link-args": {
"gcc": [
"-Os",
"-mmcu=atmega328p"
]
},
"exe-suffix": ".elf",
"post-link-args": {
"gcc": [
"-Wl,--gc-sections"
]
},
"singlethread": false,
"no-builtins": false,
"no-default-libraries": false,
"eh-frame-header": false
}

1
rust-toolchain Normal file
View File

@ -0,0 +1 @@
nightly-2021-01-07