-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Arduino Uno Example #20
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
[package] | ||
name = "arduino-uno" | ||
version = "0.1.0" | ||
authors = ["John Doneth <[email protected]>"] | ||
edition = "2018" | ||
|
||
[dependencies] | ||
avr-hal-generic = { rev = "bfc5dfe", git = "https://github.com/Rahix/avr-hal.git" } | ||
arduino-uno = { rev = "bfc5dfe", git = "https://github.com/Rahix/avr-hal.git" } | ||
panic-halt = "0.2.0" | ||
hd44780-driver = { path = "../.." } | ||
|
||
[dependencies.embedded-hal] | ||
version = "0.2.3" | ||
features = ["unproven"] | ||
|
||
[dev-dependencies] | ||
nb = "0.1.2" | ||
ufmt = "0.1.0" | ||
|
||
[profile.dev] | ||
panic = "abort" | ||
codegen-units = 1 | ||
incremental = false | ||
lto = true | ||
opt-level = "s" | ||
|
||
[profile.release] | ||
panic = "abort" | ||
codegen-units = 1 | ||
debug = false | ||
lto = true | ||
opt-level = "s" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
``` | ||
hd44780 Example for the Arduino Uno | ||
``` | ||
|
||
Building | ||
``` | ||
rustup override set nightly-2020-07-24-x86_64-unknown-linux-gnu | ||
|
||
cargo build -Z build-std=core --target avr-atmega328p.json --release | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"arch": "avr", | ||
"cpu": "atmega328p", | ||
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8", | ||
"env": "", | ||
"executables": true, | ||
"linker": "avr-gcc", | ||
"linker-flavor": "gcc", | ||
"linker-is-gnu": true, | ||
"llvm-target": "avr-unknown-unknown", | ||
"no-compiler-rt": true, | ||
"os": "unknown", | ||
"position-independent-executables": false, | ||
"exe-suffix": ".elf", | ||
"eh-frame-header": false, | ||
"pre-link-args": { | ||
"gcc": [ | ||
"-Os", | ||
"-mmcu=atmega328p" | ||
] | ||
}, | ||
"late-link-args": { | ||
"gcc": [ | ||
"-lc", | ||
"-lgcc" | ||
] | ||
}, | ||
"target-c-int-width": "16", | ||
"target-endian": "little", | ||
"target-pointer-width": "16", | ||
"vendor": "unknown" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#![no_std] | ||
#![no_main] | ||
|
||
extern crate panic_halt; | ||
use arduino_uno::prelude::*; | ||
use hd44780_driver::HD44780; | ||
|
||
use embedded_hal::blocking::delay; | ||
|
||
use arduino_uno::Delay; | ||
|
||
|
||
#[no_mangle] | ||
pub extern "C" fn main() -> ! { | ||
let dp = arduino_uno::Peripherals::take().unwrap(); | ||
|
||
let mut delay = arduino_uno::Delay::new(); | ||
let mut pins = arduino_uno::Pins::new(dp.PORTB, dp.PORTC, dp.PORTD); | ||
|
||
// Digital pin 13 is also connected to an onboard LED marked "L" | ||
//let mut led = pins.d13.into_output(&mut pins.ddr); | ||
|
||
//led.set_high().void_unwrap(); | ||
|
||
//delay.delay_ms(500); | ||
|
||
let mut lcd = HD44780::new_8bit( | ||
|
||
pins.d12.into_output(&mut pins.ddr), // Register Select pin | ||
pins.d13.into_output(&mut pins.ddr), // Enable pin | ||
|
||
|
||
|
||
pins.d11.into_output(&mut pins.ddr), // d0 | ||
pins.d10.into_output(&mut pins.ddr), // d1 | ||
pins.d9.into_output(&mut pins.ddr), // d2 | ||
pins.d8.into_output(&mut pins.ddr), // d3 | ||
|
||
pins.d4.into_output(&mut pins.ddr), // d4 | ||
pins.d5.into_output(&mut pins.ddr), // d5 | ||
pins.d6.into_output(&mut pins.ddr), // d6 | ||
pins.d7.into_output(&mut pins.ddr), // d7 | ||
|
||
&mut delay, | ||
).unwrap(); | ||
|
||
// Unshift display and set cursor to 0 | ||
lcd.reset(&mut delay).unwrap(); | ||
|
||
// Clear existing characters | ||
lcd.clear(&mut delay).unwrap(); | ||
|
||
// Display the following string | ||
lcd.write_str("Hello, world!", &mut delay).unwrap(); | ||
|
||
loop { } | ||
|
||
// loop { | ||
// led.toggle().void_unwrap(); | ||
// delay.delay_ms(200); | ||
// led.toggle().void_unwrap(); | ||
// delay.delay_ms(200); | ||
// led.toggle().void_unwrap(); | ||
// delay.delay_ms(200); | ||
// led.toggle().void_unwrap(); | ||
// delay.delay_ms(2800); | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
#[derive(Debug)] | ||
pub struct Error; | ||
pub type Result<T> = core::result::Result<T, Error>; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is more likely that 4bit interface will be used with Arduino UNO