Inital commit
This commit is contained in:
commit
7a12a39bd3
10 changed files with 148 additions and 0 deletions
16
.cargo/config.toml
Normal file
16
.cargo/config.toml
Normal file
|
@ -0,0 +1,16 @@
|
|||
[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"
|
||||
|
||||
[build]
|
||||
# Cortex-M0 and Cortex-M0+
|
||||
target = "thumbv6m-none-eabi"
|
||||
|
||||
[env]
|
||||
# DEFMT_LOG = "debug"
|
16
.gitea/workflows/pull_request.yaml
Normal file
16
.gitea/workflows/pull_request.yaml
Normal file
|
@ -0,0 +1,16 @@
|
|||
name: Terrarium Controller Merge Build
|
||||
run_name: Test successful terrarium controller build on merge request
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, edited, review_requested, synchronize]
|
||||
|
||||
jobs:
|
||||
Build:
|
||||
steps:
|
||||
- uses: https://github.com/actions/checkout@v3
|
||||
|
||||
- uses: https://github.com/dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Build
|
||||
run: cargo build
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
/target
|
||||
Cargo.lock
|
3
.vscode/settings.json
vendored
Normal file
3
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"rust-analyzer.check.allTargets": false
|
||||
}
|
13
Cargo.toml
Normal file
13
Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "rust-embassy-template"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
embassy-executor = { version = "0.5.0", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "integrated-timers"] }
|
||||
embassy-rp = { version = "0.1.0", features = ["unstable-pac", "time-driver", "critical-section-impl"] }
|
||||
embassy-futures = { version = "0.1.1" }
|
||||
|
||||
cortex-m-rt = "0.7.0"
|
36
build.rs
Normal file
36
build.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
//! 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");
|
||||
|
||||
println!("cargo:rustc-link-arg-bins=--nmagic");
|
||||
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
||||
println!("cargo:rustc-link-arg-bins=-Tlink-rp.x");
|
||||
// println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
|
||||
}
|
17
memory.x
Normal file
17
memory.x
Normal file
|
@ -0,0 +1,17 @@
|
|||
MEMORY {
|
||||
BOOT2 : ORIGIN = 0x10000000, LENGTH = 0x100
|
||||
FLASH : ORIGIN = 0x10000100, LENGTH = 2048K - 0x100
|
||||
|
||||
/* Pick one of the two options for RAM layout */
|
||||
|
||||
/* OPTION A: Use all RAM banks as one big block */
|
||||
/* Reasonable, unless you are doing something */
|
||||
/* really particular with DMA or other concurrent */
|
||||
/* access that would benefit from striping */
|
||||
RAM : ORIGIN = 0x20000000, LENGTH = 264K
|
||||
|
||||
/* OPTION B: Keep the unstriped sections separate */
|
||||
/* RAM: ORIGIN = 0x20000000, LENGTH = 256K */
|
||||
/* SCRATCH_A: ORIGIN = 0x20040000, LENGTH = 4K */
|
||||
/* SCRATCH_B: ORIGIN = 0x20041000, LENGTH = 4K */
|
||||
}
|
15
renovate.json
Normal file
15
renovate.json
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:base"
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"matchUpdateTypes": [
|
||||
"minor",
|
||||
"patch"
|
||||
],
|
||||
"automerge": true
|
||||
}
|
||||
]
|
||||
}
|
3
rust-toolchain.toml
Normal file
3
rust-toolchain.toml
Normal file
|
@ -0,0 +1,3 @@
|
|||
[toolchain]
|
||||
components = [ "rust-src", "rustfmt", "llvm-tools" ]
|
||||
targets = ["thumbv6m-none-eabi"]
|
27
src/main.rs
Normal file
27
src/main.rs
Normal file
|
@ -0,0 +1,27 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use core::panic::PanicInfo;
|
||||
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_rp::gpio::{Level, Output};
|
||||
|
||||
#[panic_handler]
|
||||
fn panic(_info: &PanicInfo) -> ! {
|
||||
loop {}
|
||||
}
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
let p = embassy_rp::init(Default::default());
|
||||
|
||||
let mut pin = Output::new(p.PIN_25, Level::High);
|
||||
|
||||
let toggle_led = async {
|
||||
loop {
|
||||
pin.toggle();
|
||||
}
|
||||
};
|
||||
|
||||
toggle_led.await;
|
||||
}
|
Loading…
Reference in a new issue