Initial commit
This commit is contained in:
commit
f06907ce13
|
@ -0,0 +1,8 @@
|
|||
[build]
|
||||
target = "thumbv6m-none-eabi"
|
||||
|
||||
[target.thumbv6m-none-eabi]
|
||||
runner = "elf2uf2-rs -d"
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Tlink.x",
|
||||
]
|
|
@ -0,0 +1,2 @@
|
|||
target/
|
||||
Cargo.lock
|
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "pico-test"
|
||||
version = "0.1.0"
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
cortex-m = "0.7.4"
|
||||
embedded-hal = "0.2.7"
|
||||
embedded-time = "0.12.1"
|
||||
panic-halt = "0.2.0"
|
||||
rp-pico = "0.2.0"
|
|
@ -0,0 +1,15 @@
|
|||
use std::env;
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
fs::File::create(out_dir.join("memory.x"))
|
||||
.unwrap()
|
||||
.write_all(include_bytes!("memory.x"))
|
||||
.unwrap();
|
||||
|
||||
println!("cargo:rustc-link-search={}", out_dir.display());
|
||||
println!("cargo:rerun-if-changed=memory.x");
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
MEMORY
|
||||
{
|
||||
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
|
||||
FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100
|
||||
RAM : ORIGIN = 0x20000000, LENGTH = 264K
|
||||
}
|
||||
|
||||
EXTERN(BOOT2_FIRMWARE)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
.boot2 ORIGIN(BOOT2) :
|
||||
{
|
||||
KEEP(*(.boot2));
|
||||
} > BOOT2
|
||||
}
|
||||
INSERT BEFORE .text;
|
|
@ -0,0 +1,48 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use embedded_hal::digital::v2::OutputPin;
|
||||
|
||||
use embedded_time::fixed_point::FixedPoint;
|
||||
|
||||
use panic_halt as _;
|
||||
|
||||
use rp_pico::Pins;
|
||||
use rp_pico::entry;
|
||||
use rp_pico::hal::{Clock, Sio, Watchdog, clocks::init_clocks_and_plls};
|
||||
use rp_pico::pac::{CorePeripherals, Peripherals};
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
let mut p = Peripherals::take().unwrap();
|
||||
let cp = CorePeripherals::take().unwrap();
|
||||
|
||||
let mut watchdog = Watchdog::new(p.WATCHDOG);
|
||||
let clocks = init_clocks_and_plls(
|
||||
rp_pico::XOSC_CRYSTAL_FREQ,
|
||||
p.XOSC,
|
||||
p.CLOCKS,
|
||||
p.PLL_SYS,
|
||||
p.PLL_USB,
|
||||
&mut p.RESETS,
|
||||
&mut watchdog
|
||||
).ok().unwrap();
|
||||
|
||||
let sio = Sio::new(p.SIO);
|
||||
let pins = Pins::new(
|
||||
p.IO_BANK0,
|
||||
p.PADS_BANK0,
|
||||
sio.gpio_bank0,
|
||||
&mut p.RESETS,
|
||||
);
|
||||
|
||||
let mut led = pins.led.into_push_pull_output();
|
||||
let mut delay = cortex_m::delay::Delay::new(cp.SYST, clocks.system_clock.freq().integer());
|
||||
|
||||
loop {
|
||||
led.set_high().unwrap();
|
||||
delay.delay_ms(500);
|
||||
led.set_low().unwrap();
|
||||
delay.delay_ms(500);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue