Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.
/ arduino-leonardo Public archive

Board Support Crate for Arduino Leonardo in Rust

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

Rahix/arduino-leonardo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deprecation Note:

This crate will soon be deprecated in favor of avr-hal.

avr-hal is a new approach to writing the HAL crate, that was designed with support for many AVR microcontrollers in mind. The macros have been factored out into a common crate named avr-hal-generic, which the board HALs then use to instanciate their respective peripherals. Board support crates like this one are also kept in that repository now.


arduino-leonardo crates.io page docs.rs

Board support crate for Arduino Leonardo. Reexports types to more closely match the leonardo's labeling.

Example

To see the following example in action, take a look at the leonardo-examples repo.

#![no_std]
#![no_main]
extern crate arduino_leonardo;

use arduino_leonardo::prelude::*;

#[no_mangle]
pub extern fn main() {
    let dp = arduino_leonardo::Peripherals::take().unwrap();

    let mut delay = arduino_leonardo::Delay::new();
    let mut pins = arduino_leonardo::Pins::new(dp.PORTB, dp.PORTC, dp.PORTD, dp.PORTE);

    let mut led0 = pins.led_rx.into_output(&mut pins.ddr);
    let mut led1 = pins.led_tx.into_output(&mut pins.ddr);
    let mut led2 = pins.d13.into_output(&mut pins.ddr);

    led0.set_high();
    led1.set_high();
    led2.set_high();

    let mut leds = [
        led0.downgrade(),
        led1.downgrade(),
        led2.downgrade(),
    ];

    loop {
        for i in 0..3 {
            leds[i].toggle();
            leds[(i+2)%3].toggle();
            delay.delay_ms(200);
        }
    }
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Board Support Crate for Arduino Leonardo in Rust

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages