🎉
This commit is contained in:
commit
48dce4894f
18
.cargo/config
Normal file
18
.cargo/config
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||||
|
runner = "./probe-run.sh"
|
||||||
|
|
||||||
|
rustflags = [
|
||||||
|
"-C", "link-arg=--nmagic",
|
||||||
|
"-C", "link-arg=-Tlink.x",
|
||||||
|
"-C", "link-arg=-Tdefmt.x",
|
||||||
|
]
|
||||||
|
|
||||||
|
[build]
|
||||||
|
# Pick ONE of these compilation targets
|
||||||
|
target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
|
||||||
|
# target = "thumbv7m-none-eabi" # Cortex-M3
|
||||||
|
# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
|
||||||
|
# target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
|
||||||
|
# target = "thumbv8m.base-none-eabi" # Cortex-M23
|
||||||
|
# target = "thumbv8m.main-none-eabi" # Cortex-M33 (no FPU)
|
||||||
|
# target = "thumbv8m.main-none-eabihf" # Cortex-M33 (with FPU)
|
||||||
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
**/*.rs.bk
|
||||||
|
.#*
|
||||||
|
.gdb_history
|
||||||
|
Cargo.lock
|
||||||
|
target/
|
||||||
|
|
||||||
|
# editor files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/*.md
|
||||||
|
!.vscode/*.svd
|
||||||
|
!.vscode/launch.json
|
||||||
|
!.vscode/tasks.json
|
||||||
|
!.vscode/extensions.json
|
||||||
|
!.vscode/settings.json
|
||||||
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"editor.formatOnSave": true
|
||||||
|
}
|
||||||
66
Cargo.toml
Normal file
66
Cargo.toml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
[package]
|
||||||
|
authors = ["Dario Nieuwenhuis <dirbaio@dirbaio.net>"]
|
||||||
|
edition = "2018"
|
||||||
|
readme = "README.md"
|
||||||
|
name = "rp-test"
|
||||||
|
version = "0.1.0"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
cortex-m = "0.6.0"
|
||||||
|
cortex-m-rt = "0.6.10"
|
||||||
|
cortex-m-semihosting = "0.3.3"
|
||||||
|
|
||||||
|
defmt = "0.1.3"
|
||||||
|
defmt-rtt = "0.1.0"
|
||||||
|
panic-probe = "0.1.0"
|
||||||
|
|
||||||
|
rp2040-pac = { git = "https://github.com/Dirbaio/rp2040-pac", branch="main" }
|
||||||
|
[features]
|
||||||
|
default = [
|
||||||
|
"defmt-default",
|
||||||
|
]
|
||||||
|
defmt-default = []
|
||||||
|
defmt-trace = []
|
||||||
|
defmt-debug = []
|
||||||
|
defmt-info = []
|
||||||
|
defmt-warn = []
|
||||||
|
defmt-error = []
|
||||||
|
|
||||||
|
|
||||||
|
# this lets you use `cargo fix`!
|
||||||
|
[[bin]]
|
||||||
|
name = "rp-test"
|
||||||
|
test = false
|
||||||
|
bench = false
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
codegen-units = 1
|
||||||
|
debug = 2
|
||||||
|
debug-assertions = true
|
||||||
|
incremental = false
|
||||||
|
opt-level = 3
|
||||||
|
overflow-checks = true
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
codegen-units = 1
|
||||||
|
debug = 2
|
||||||
|
debug-assertions = false
|
||||||
|
incremental = false
|
||||||
|
lto = "fat"
|
||||||
|
opt-level = 's'
|
||||||
|
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
|
||||||
26
README.md
Normal file
26
README.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# Raspberry pico RP2040 rust test!
|
||||||
|
|
||||||
|
How to run:
|
||||||
|
|
||||||
|
Fist, clone these repos all in the same directory, next to each other
|
||||||
|
|
||||||
|
- https://github.com/Dirbaio/rp2040-rust-test
|
||||||
|
- https://github.com/Dirbaio/rp2040-pac
|
||||||
|
- https://github.com/Dirbaio/probe-run
|
||||||
|
- https://github.com/Dirbaio/probe-rs
|
||||||
|
|
||||||
|
Then you're done
|
||||||
|
|
||||||
|
cd rp2040-rust-test
|
||||||
|
cargo run
|
||||||
|
|
||||||
|
# License
|
||||||
|
|
||||||
|
This thingy is licensed under either of
|
||||||
|
|
||||||
|
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
|
|
||||||
|
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
|
at your option.
|
||||||
31
build.rs
Normal file
31
build.rs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
//! This build script copies the `memory.x` file from the crate root into
|
||||||
|
//! a directory where the linker can always find it at build time.
|
||||||
|
//! For many projects this is optional, as the linker always searches the
|
||||||
|
//! project root directory -- wherever `Cargo.toml` is. However, if you
|
||||||
|
//! are using a workspace or have a more complicated build setup, this
|
||||||
|
//! build script becomes required. Additionally, by requesting that
|
||||||
|
//! Cargo re-run the build script whenever `memory.x` is changed,
|
||||||
|
//! updating `memory.x` ensures a rebuild of the application with the
|
||||||
|
//! new memory settings.
|
||||||
|
|
||||||
|
use std::env;
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::Write;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
// Put `memory.x` in our output directory and ensure it's
|
||||||
|
// on the linker search path.
|
||||||
|
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||||
|
File::create(out.join("memory.x"))
|
||||||
|
.unwrap()
|
||||||
|
.write_all(include_bytes!("memory.x"))
|
||||||
|
.unwrap();
|
||||||
|
println!("cargo:rustc-link-search={}", out.display());
|
||||||
|
|
||||||
|
// By default, Cargo will re-run a build script whenever
|
||||||
|
// any file in the project changes. By specifying `memory.x`
|
||||||
|
// here, we ensure the build script is only re-run when
|
||||||
|
// `memory.x` is changed.
|
||||||
|
println!("cargo:rerun-if-changed=memory.x");
|
||||||
|
}
|
||||||
6
memory.x
Normal file
6
memory.x
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
/* We set "flash" to half the RAM */
|
||||||
|
FLASH : ORIGIN = 0x20000000, LENGTH = 128K
|
||||||
|
RAM : ORIGIN = 0x20020000, LENGTH = 128K
|
||||||
|
}
|
||||||
7
probe-run.sh
Executable file
7
probe-run.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
bin="$PWD/$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
cd ../probe-run
|
||||||
|
cargo run -- "$bin" "$@" --chip RP2040
|
||||||
45
src/main.rs
Normal file
45
src/main.rs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
#![no_std]
|
||||||
|
#![no_main]
|
||||||
|
|
||||||
|
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
use cortex_m_rt::entry;
|
||||||
|
use defmt::*;
|
||||||
|
use defmt_rtt as _; // global logger
|
||||||
|
use panic_probe as _;
|
||||||
|
use rp2040_pac as pac;
|
||||||
|
|
||||||
|
#[defmt::timestamp]
|
||||||
|
fn timestamp() -> u64 {
|
||||||
|
static COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||||
|
// NOTE(no-CAS) `timestamps` runs with interrupts disabled
|
||||||
|
let n = COUNT.load(Ordering::Relaxed);
|
||||||
|
COUNT.store(n + 1, Ordering::Relaxed);
|
||||||
|
n as u64
|
||||||
|
}
|
||||||
|
|
||||||
|
#[entry]
|
||||||
|
fn main() -> ! {
|
||||||
|
info!("Hello World!");
|
||||||
|
|
||||||
|
let p = pac::Peripherals::take().unwrap();
|
||||||
|
|
||||||
|
loop {
|
||||||
|
info!("on!");
|
||||||
|
p.IO_BANK0.gpio25_ctrl.write(|w| {
|
||||||
|
w.oeover().enable();
|
||||||
|
w.outover().high();
|
||||||
|
w
|
||||||
|
});
|
||||||
|
|
||||||
|
cortex_m::asm::delay(64_000_000);
|
||||||
|
|
||||||
|
info!("off!");
|
||||||
|
p.IO_BANK0.gpio25_ctrl.write(|w| {
|
||||||
|
w.oeover().enable();
|
||||||
|
w.outover().low();
|
||||||
|
w
|
||||||
|
});
|
||||||
|
|
||||||
|
cortex_m::asm::delay(64_000_000);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user