This repository has been archived on 2024-06-16. You can view files and clone it, but cannot push or open issues or pull requests.
va108xx-hal/examples/blinky.rs
Robin Mueller 63be6ed5fe Refactored GPIO module
- The GPIO module uses type-level programming now
- Implementation heavily based on the ATSAMD GPIO HAL:
  https://docs.rs/atsamd-hal/0.13.0/atsamd_hal/gpio/v2/index.html
- Changes to API, but no passing of peripheral references necessary
  anymore. All examples and tests updated accordingly
2021-11-11 17:39:26 +01:00

40 lines
1.2 KiB
Rust

//! Simple blinky example
//!
//! Additional note on LEDs when using the REB1 development board:
//! Be not afraid: Pulling the GPIOs low makes the LEDs blink. See REB1
//! schematic for more details.
#![no_main]
#![no_std]
use cortex_m_rt::entry;
use embedded_hal::digital::v2::ToggleableOutputPin;
use panic_halt as _;
use va108xx_hal::{gpio::PinsA, pac, prelude::*};
#[entry]
fn main() -> ! {
let mut dp = pac::Peripherals::take().unwrap();
let porta = PinsA::new(&mut dp.SYSCONFIG, Some(dp.IOCONFIG), dp.PORTA);
let mut led1 = porta.pa10.into_push_pull_output();
let mut led2 = porta.pa7.into_push_pull_output();
let mut led3 = porta.pa6.into_push_pull_output();
for _ in 0..10 {
led1.set_low().ok();
led2.set_low().ok();
led3.set_low().ok();
cortex_m::asm::delay(5_000_000);
led1.set_high().ok();
led2.set_high().ok();
led3.set_high().ok();
cortex_m::asm::delay(5_000_000);
}
loop {
led1.toggle().ok();
cortex_m::asm::delay(5_000_000);
led2.toggle().ok();
cortex_m::asm::delay(5_000_000);
led3.toggle().ok();
cortex_m::asm::delay(5_000_000);
}
}