Start raspi picoproject
This commit is contained in:
parent
91b336f2fd
commit
031d28fbd8
12 changed files with 197 additions and 0 deletions
29
rust/pico/.cargo/config.toml
Normal file
29
rust/pico/.cargo/config.toml
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||||
|
# Choose a default "cargo run" tool:
|
||||||
|
# - probe-run provides flashing and defmt via a hardware debugger
|
||||||
|
# - cargo embed offers flashing, rtt, defmt and a gdb server via a hardware debugger
|
||||||
|
# it is configured via the Embed.toml in the root of this project
|
||||||
|
# - elf2uf2-rs loads firmware over USB when the rp2040 is in boot mode
|
||||||
|
# runner = "probe-run --chip RP2040"
|
||||||
|
# runner = "cargo embed"
|
||||||
|
runner = "elf2uf2-rs -d"
|
||||||
|
|
||||||
|
rustflags = [
|
||||||
|
"-C", "linker=flip-link",
|
||||||
|
"-C", "link-arg=--nmagic",
|
||||||
|
"-C", "link-arg=-Tlink.x",
|
||||||
|
"-C", "link-arg=-Tdefmt.x",
|
||||||
|
|
||||||
|
# Code-size optimizations.
|
||||||
|
# trap unreachable can save a lot of space, but requires nightly compiler.
|
||||||
|
# uncomment the next line if you wish to enable it
|
||||||
|
# "-Z", "trap-unreachable=no",
|
||||||
|
"-C", "inline-threshold=5",
|
||||||
|
"-C", "no-vectorize-loops",
|
||||||
|
]
|
||||||
|
|
||||||
|
[build]
|
||||||
|
target = "thumbv6m-none-eabi"
|
||||||
|
|
||||||
|
[env]
|
||||||
|
DEFMT_LOG = "debug"
|
8
rust/pico/.vscode/settings.json
vendored
Normal file
8
rust/pico/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"rust-analyzer.cargo.target": "thumbv6m-none-eabi",
|
||||||
|
"workbench.colorCustomizations": {
|
||||||
|
"activityBar.background": "#43261A",
|
||||||
|
"titleBar.activeBackground": "#5E3524",
|
||||||
|
"titleBar.activeForeground": "#FCF9F8"
|
||||||
|
}
|
||||||
|
}
|
76
rust/pico/Cargo.toml
Normal file
76
rust/pico/Cargo.toml
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
[package]
|
||||||
|
edition = "2021"
|
||||||
|
name = "pico-pedal"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
cortex-m = "0.7"
|
||||||
|
cortex-m-rt = "0.7"
|
||||||
|
embedded-hal = { version = "0.2.5", features = ["unproven"] }
|
||||||
|
embedded-time = "0.12"
|
||||||
|
|
||||||
|
defmt = "0.3"
|
||||||
|
defmt-rtt = "0.3"
|
||||||
|
panic-probe = { version = "0.3", features = ["print-defmt"] }
|
||||||
|
|
||||||
|
# We're using a Pico by default on this template
|
||||||
|
rp-pico = "0.4"
|
||||||
|
|
||||||
|
# but you can use any BSP. Uncomment this to use the pro_micro_rp2040 BSP instead
|
||||||
|
# sparkfun-pro-micro-rp2040 = "0.3"
|
||||||
|
|
||||||
|
# If you're not going to use a Board Support Package you'll need these:
|
||||||
|
# rp2040-hal = { version="0.5", features=["rt"] }
|
||||||
|
# rp2040-boot2 = "0.2"
|
||||||
|
|
||||||
|
# cargo build/run
|
||||||
|
[profile.dev]
|
||||||
|
codegen-units = 1
|
||||||
|
debug = 2
|
||||||
|
debug-assertions = true
|
||||||
|
incremental = false
|
||||||
|
opt-level = 3
|
||||||
|
overflow-checks = true
|
||||||
|
|
||||||
|
# cargo build/run --release
|
||||||
|
[profile.release]
|
||||||
|
codegen-units = 1
|
||||||
|
debug = 2
|
||||||
|
debug-assertions = false
|
||||||
|
incremental = false
|
||||||
|
lto = 'fat'
|
||||||
|
opt-level = 3
|
||||||
|
overflow-checks = false
|
||||||
|
|
||||||
|
# do not optimize proc-macro crates = faster builds from scratch
|
||||||
|
[profile.dev.build-override]
|
||||||
|
codegen-units = 8
|
||||||
|
debug = false
|
||||||
|
debug-assertions = false
|
||||||
|
opt-level = 0
|
||||||
|
overflow-checks = false
|
||||||
|
|
||||||
|
[profile.release.build-override]
|
||||||
|
codegen-units = 8
|
||||||
|
debug = false
|
||||||
|
debug-assertions = false
|
||||||
|
opt-level = 0
|
||||||
|
overflow-checks = false
|
||||||
|
|
||||||
|
# cargo test
|
||||||
|
[profile.test]
|
||||||
|
codegen-units = 1
|
||||||
|
debug = 2
|
||||||
|
debug-assertions = true
|
||||||
|
incremental = false
|
||||||
|
opt-level = 3
|
||||||
|
overflow-checks = true
|
||||||
|
|
||||||
|
# cargo test --release
|
||||||
|
[profile.bench]
|
||||||
|
codegen-units = 1
|
||||||
|
debug = 2
|
||||||
|
debug-assertions = false
|
||||||
|
incremental = false
|
||||||
|
lto = 'fat'
|
||||||
|
opt-level = 3
|
15
rust/pico/memory.x
Normal file
15
rust/pico/memory.x
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
MEMORY {
|
||||||
|
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
|
||||||
|
FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100
|
||||||
|
RAM : ORIGIN = 0x20000000, LENGTH = 256K
|
||||||
|
}
|
||||||
|
|
||||||
|
EXTERN(BOOT2_FIRMWARE)
|
||||||
|
|
||||||
|
SECTIONS {
|
||||||
|
/* ### Boot loader */
|
||||||
|
.boot2 ORIGIN(BOOT2) :
|
||||||
|
{
|
||||||
|
KEEP(*(.boot2));
|
||||||
|
} > BOOT2
|
||||||
|
} INSERT BEFORE .text;
|
69
rust/pico/src/main.rs
Normal file
69
rust/pico/src/main.rs
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
//! Blinks the LED on a Pico board
|
||||||
|
//!
|
||||||
|
//! This will blink an LED attached to GP25, which is the pin the Pico uses for the on-board LED.
|
||||||
|
#![no_std]
|
||||||
|
#![no_main]
|
||||||
|
|
||||||
|
use bsp::entry;
|
||||||
|
use defmt::*;
|
||||||
|
use defmt_rtt as _;
|
||||||
|
use embedded_hal::digital::v2::OutputPin;
|
||||||
|
use embedded_time::fixed_point::FixedPoint;
|
||||||
|
use panic_probe as _;
|
||||||
|
|
||||||
|
// Provide an alias for our BSP so we can switch targets quickly.
|
||||||
|
// Uncomment the BSP you included in Cargo.toml, the rest of the code does not need to change.
|
||||||
|
use rp_pico as bsp;
|
||||||
|
// use sparkfun_pro_micro_rp2040 as bsp;
|
||||||
|
|
||||||
|
use bsp::hal::{
|
||||||
|
clocks::{init_clocks_and_plls, Clock},
|
||||||
|
pac,
|
||||||
|
sio::Sio,
|
||||||
|
watchdog::Watchdog,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[entry]
|
||||||
|
fn main() -> ! {
|
||||||
|
info!("Program start");
|
||||||
|
let mut pac = pac::Peripherals::take().unwrap();
|
||||||
|
let core = pac::CorePeripherals::take().unwrap();
|
||||||
|
let mut watchdog = Watchdog::new(pac.WATCHDOG);
|
||||||
|
let sio = Sio::new(pac.SIO);
|
||||||
|
|
||||||
|
// External high-speed crystal on the pico board is 12Mhz
|
||||||
|
let external_xtal_freq_hz = 12_000_000u32;
|
||||||
|
let clocks = init_clocks_and_plls(
|
||||||
|
external_xtal_freq_hz,
|
||||||
|
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 pins = bsp::Pins::new(
|
||||||
|
pac.IO_BANK0,
|
||||||
|
pac.PADS_BANK0,
|
||||||
|
sio.gpio_bank0,
|
||||||
|
&mut pac.RESETS,
|
||||||
|
);
|
||||||
|
|
||||||
|
let mut led_pin = pins.led.into_push_pull_output();
|
||||||
|
|
||||||
|
loop {
|
||||||
|
info!("on!");
|
||||||
|
led_pin.set_high().unwrap();
|
||||||
|
delay.delay_ms(200);
|
||||||
|
info!("off!");
|
||||||
|
led_pin.set_low().unwrap();
|
||||||
|
delay.delay_ms(200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// End of file
|
Loading…
Reference in a new issue