mirror of
https://github.com/guilhermewerner/rust-avr
synced 2025-06-15 13:24:18 +00:00
Basic arduino blink
This commit is contained in:
6
.cargo/config.toml
Normal file
6
.cargo/config.toml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[build]
|
||||||
|
target-dir = "Binaries"
|
||||||
|
target = "avr-atmega328p.json"
|
||||||
|
|
||||||
|
[unstable]
|
||||||
|
build-std = ["core"]
|
29
Cargo.toml
Normal file
29
Cargo.toml
Normal 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
19
Source/Main.rs
Normal 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
29
avr-atmega328p.json
Normal 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
1
rust-toolchain
Normal file
@ -0,0 +1 @@
|
|||||||
|
nightly-2021-01-07
|
Reference in New Issue
Block a user