Adafruit feather rp2040 (#91)

* added example for Feather RP2040
This commit is contained in:
Michael Zill 2021-08-21 13:22:18 +02:00 committed by GitHub
parent fae1caaca9
commit 199ad891ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 70 additions and 1 deletions

View file

@ -13,6 +13,12 @@ license = "MIT OR Apache-2.0"
cortex-m = "0.7.2" cortex-m = "0.7.2"
rp2040-hal = { path = "../../rp2040-hal", version = "0.2.0"} rp2040-hal = { path = "../../rp2040-hal", version = "0.2.0"}
cortex-m-rt = { version = "0.6.14", optional = true } cortex-m-rt = { version = "0.6.14", optional = true }
embedded-time = "0.12.0"
[dev-dependencies]
panic-halt= "0.2.0"
embedded-hal ="0.2.5"
rp2040-boot2 = { git = "https://github.com/rp-rs/rp2040-boot2-rs", rev = "d2128ef9875e91e454dd0fb0d747c7439ae0627b" }
[features] [features]
default = ["rt"] default = ["rt"]

View file

@ -0,0 +1 @@
Adafruit Feather RP2040 Board Support Crate

View file

@ -0,0 +1,60 @@
//! Blinks the LED on a Adafruit Feather RP2040 board
//!
//! This will blink on-board LED.
#![no_std]
#![no_main]
use cortex_m_rt::entry;
use embedded_hal::digital::v2::OutputPin;
use embedded_time::rate::*;
use feather_rp2040::{
hal::{
clocks::{init_clocks_and_plls, Clock},
pac,
sio::Sio,
watchdog::Watchdog,
},
Pins, XOSC_CRYSTAL_FREQ,
};
use panic_halt as _;
#[link_section = ".boot2"]
#[used]
pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_GD25Q64CS;
#[entry]
fn main() -> ! {
let mut pac = pac::Peripherals::take().unwrap();
let core = pac::CorePeripherals::take().unwrap();
let mut watchdog = Watchdog::new(pac.WATCHDOG);
let clocks = init_clocks_and_plls(
XOSC_CRYSTAL_FREQ,
pac.XOSC,
pac.CLOCKS,
pac.PLL_SYS,
pac.PLL_USB,
&mut pac.RESETS,
&mut watchdog,
)
.ok()
.unwrap();
let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().integer());
let sio = Sio::new(pac.SIO);
let pins = Pins::new(
pac.IO_BANK0,
pac.PADS_BANK0,
sio.gpio_bank0,
&mut pac.RESETS,
);
let mut led_pin = pins.d13.into_push_pull_output();
loop {
led_pin.set_high().unwrap();
delay.delay_ms(1500);
led_pin.set_low().unwrap();
delay.delay_ms(1500);
}
}

View file

@ -1,6 +1,6 @@
#![no_std] #![no_std]
extern crate rp2040_hal as hal; pub extern crate rp2040_hal as hal;
#[cfg(feature = "rt")] #[cfg(feature = "rt")]
extern crate cortex_m_rt; extern crate cortex_m_rt;
@ -54,3 +54,5 @@ hal::bsp_pins!(
Gpio28 { name: a2 }, Gpio28 { name: a2 },
Gpio29 { name: a3 }, Gpio29 { name: a3 },
); );
pub const XOSC_CRYSTAL_FREQ: u32 = 12_000_000;