initial commit
This commit is contained in:
commit
05e85fae2b
10 changed files with 1406 additions and 0 deletions
18
.cargo/config.toml
Normal file
18
.cargo/config.toml
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
[env]
|
||||
DEFMT_LOG="info"
|
||||
|
||||
[build]
|
||||
target = "riscv32imc-unknown-none-elf"
|
||||
rustflags = [
|
||||
"-C", "link-arg=-Tdefmt.x",
|
||||
"-C", "link-arg=-Tlinkall.x",
|
||||
# NOTE: This is required to obtain backtraces, however it may negatively
|
||||
# impact the performance of your application.
|
||||
"-C", "force-frame-pointers",
|
||||
]
|
||||
|
||||
[target.riscv32imc-unknown-none-elf]
|
||||
runner = "probe-rs run --chip=esp32c3"
|
||||
|
||||
[unstable]
|
||||
build-std = ["core"]
|
||||
17
.gitignore
vendored
Normal file
17
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
target/
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
# RustRover
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
3
.vscode/extensions.json
vendored
Normal file
3
.vscode/extensions.json
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"recommendations": ["rust-lang.rust-analyzer", "tamasfe.even-better-toml"]
|
||||
}
|
||||
10
.vscode/settings.json
vendored
Normal file
10
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"editor.formatOnSave": true,
|
||||
|
||||
// Even Better TOML:
|
||||
"evenBetterToml.formatter.alignComments": true,
|
||||
"evenBetterToml.formatter.alignEntries": true,
|
||||
"evenBetterToml.formatter.arrayAutoExpand": true,
|
||||
"evenBetterToml.formatter.arrayTrailingComma": true,
|
||||
"evenBetterToml.formatter.reorderArrays": true
|
||||
}
|
||||
1265
Cargo.lock
generated
Normal file
1265
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
25
Cargo.toml
Normal file
25
Cargo.toml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
[package]
|
||||
name = "esp_hal_probe"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.76.0"
|
||||
|
||||
[[bin]]
|
||||
name = "firmware"
|
||||
path = "src/bin/firmware.rs"
|
||||
|
||||
[dependencies]
|
||||
defmt = "0.3.8"
|
||||
defmt-rtt = "0.4.1"
|
||||
embassy-executor = { version = "0.5.0", features = ["defmt"] }
|
||||
embassy-time = { version = "0.3.1", features = ["generic-queue-8"] }
|
||||
esp-backtrace = { version = "0.13.0", features = ["esp32c3", "defmt", "exception-handler", "panic-handler"] }
|
||||
esp-hal = { version = "0.19.0", features = ["esp32c3", "defmt", "async"] }
|
||||
esp-hal-embassy = { version = "0.2.0", features = ["esp32c3", "defmt"] }
|
||||
static_cell = { version = "2.1.0", features = ["nightly"] }
|
||||
|
||||
[profile.release]
|
||||
debug = true # Debug info is useful, and does not affect the size of the final binary
|
||||
codegen-units = 1 # LLVM can perform better optimizations using a single thread
|
||||
lto = "fat" # Attempt to perform optimizations across all crates within the dependency graph
|
||||
opt-level = "s" # Optimize for binary size, but keep loop vectorization enabled
|
||||
4
rust-toolchain.toml
Normal file
4
rust-toolchain.toml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[toolchain]
|
||||
channel = "nightly-2024-06-01"
|
||||
components = ["rust-src"]
|
||||
targets = ["riscv32imc-unknown-none-elf"]
|
||||
16
rustfmt.toml
Normal file
16
rustfmt.toml
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# Edition
|
||||
edition = "2021"
|
||||
|
||||
# Comments
|
||||
format_code_in_doc_comments = true
|
||||
normalize_comments = true
|
||||
wrap_comments = true
|
||||
|
||||
# Imports
|
||||
group_imports = "StdExternalCrate"
|
||||
imports_granularity = "Crate"
|
||||
imports_layout = "HorizontalVertical"
|
||||
|
||||
# Miscellaneous
|
||||
enum_discrim_align_threshold = 25
|
||||
hex_literal_case = "Upper"
|
||||
47
src/bin/firmware.rs
Normal file
47
src/bin/firmware.rs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
use defmt::info;
|
||||
use defmt_rtt as _;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_time::{Duration, Timer};
|
||||
use esp_backtrace as _;
|
||||
use esp_hal::{
|
||||
clock::ClockControl,
|
||||
peripherals::Peripherals,
|
||||
prelude::*,
|
||||
rtc_cntl::Rtc,
|
||||
system::SystemControl,
|
||||
timer::{timg::TimerGroup, OneShotTimer},
|
||||
};
|
||||
use static_cell::make_static;
|
||||
|
||||
#[main]
|
||||
async fn main(spawner: Spawner) {
|
||||
let peripherals = Peripherals::take();
|
||||
let system = SystemControl::new(peripherals.SYSTEM);
|
||||
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
|
||||
|
||||
// Enable the RWDT watchdog timer:
|
||||
let mut rtc = Rtc::new(peripherals.LPWR, None);
|
||||
rtc.rwdt.set_timeout(2.secs());
|
||||
rtc.rwdt.enable();
|
||||
info!("RWDT watchdog enabled!");
|
||||
|
||||
// Initialize the SYSTIMER peripheral, and then Embassy:
|
||||
let timg0 = TimerGroup::new(peripherals.TIMG0, &clocks, None);
|
||||
let timers = [OneShotTimer::new(timg0.timer0.into())];
|
||||
let timers = make_static!(timers);
|
||||
esp_hal_embassy::init(&clocks, timers);
|
||||
info!("Embassy initialized!");
|
||||
|
||||
// TODO: Spawn some tasks
|
||||
let _ = spawner;
|
||||
|
||||
// Periodically feed the RWDT watchdog timer when our tasks are not running:
|
||||
loop {
|
||||
rtc.rwdt.feed();
|
||||
Timer::after(Duration::from_secs(1)).await;
|
||||
}
|
||||
}
|
||||
1
src/lib.rs
Normal file
1
src/lib.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
#![no_std]
|
||||
Loading…
Add table
Reference in a new issue