mend
This commit is contained in:
parent
7791c55969
commit
5f9e718f86
6 changed files with 177 additions and 62 deletions
135
spinnyboy_rust/Cargo.lock
generated
135
spinnyboy_rust/Cargo.lock
generated
|
|
@ -40,6 +40,12 @@ dependencies = [
|
|||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.10.0"
|
||||
|
|
@ -155,6 +161,38 @@ dependencies = [
|
|||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "defmt"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "548d977b6da32fa1d1fda2876453da1e7df63ad0304c8b3dae4dbe7b96f39b78"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"defmt-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "defmt-macros"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d4fc12a85bcf441cfe44344c4b72d58493178ce635338a3f3b78943aceb258e"
|
||||
dependencies = [
|
||||
"defmt-parser",
|
||||
"proc-macro-error2",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "defmt-parser"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e"
|
||||
dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "delegate"
|
||||
version = "0.13.5"
|
||||
|
|
@ -227,7 +265,7 @@ dependencies = [
|
|||
"embedded-io-async 0.6.1",
|
||||
"futures-sink",
|
||||
"futures-util",
|
||||
"heapless",
|
||||
"heapless 0.8.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -241,7 +279,7 @@ dependencies = [
|
|||
"embedded-io-async 0.6.1",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"heapless",
|
||||
"heapless 0.8.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -366,6 +404,23 @@ dependencies = [
|
|||
"rlsf",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "esp-backtrace"
|
||||
version = "0.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3318413fb566c7227387f67736cf70cd74d80a11f2bb31c7b95a9eb48d079669"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"defmt",
|
||||
"document-features",
|
||||
"esp-config",
|
||||
"esp-metadata-generated",
|
||||
"esp-println",
|
||||
"heapless 0.9.2",
|
||||
"riscv",
|
||||
"xtensa-lx",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "esp-bootloader-esp-idf"
|
||||
version = "0.4.0"
|
||||
|
|
@ -403,7 +458,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "54786287c0a61ca0f78cb0c338a39427551d1be229103b4444591796c579e093"
|
||||
dependencies = [
|
||||
"bitfield",
|
||||
"bitflags",
|
||||
"bitflags 2.10.0",
|
||||
"bytemuck",
|
||||
"cfg-if",
|
||||
"critical-section",
|
||||
|
|
@ -469,6 +524,18 @@ version = "0.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a93e39c8ad8d390d248dc7b9f4b59a873f313bf535218b8e2351356972399e3"
|
||||
|
||||
[[package]]
|
||||
name = "esp-println"
|
||||
version = "0.16.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5a30e6c9fbcc01c348d46706fef8131c7775ab84c254a3cd65d0cd3f6414d592"
|
||||
dependencies = [
|
||||
"document-features",
|
||||
"esp-metadata-generated",
|
||||
"esp-sync",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "esp-riscv-rt"
|
||||
version = "0.13.0"
|
||||
|
|
@ -662,6 +729,16 @@ dependencies = [
|
|||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heapless"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2af2455f757db2b292a9b1768c4b70186d443bcb3b316252d6b540aec1cd89ed"
|
||||
dependencies = [
|
||||
"hash32",
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
|
|
@ -742,6 +819,12 @@ version = "0.2.178"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37c93d8daa9d8a012fd8ab92f088405fb202ea0b6ab73ee2482ae66af4f42091"
|
||||
|
||||
[[package]]
|
||||
name = "libm"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
|
||||
|
||||
[[package]]
|
||||
name = "linked_list_allocator"
|
||||
version = "0.10.5"
|
||||
|
|
@ -788,6 +871,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"libm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
@ -841,6 +925,28 @@ dependencies = [
|
|||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error-attr2"
|
||||
version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96de42df36bb9bba5542fe9f1a054b8cc87e172759a1868aa05c1f3acc89dfc5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error2"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "11ec05c52be0a07b08061f7dd003e7d7092e0472bc731b4af7bb1ef876109802"
|
||||
dependencies = [
|
||||
"proc-macro-error-attr2",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.103"
|
||||
|
|
@ -1028,9 +1134,12 @@ name = "spinnyboy_rust"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"critical-section",
|
||||
"embedded-hal 1.0.0",
|
||||
"esp-alloc",
|
||||
"esp-backtrace",
|
||||
"esp-bootloader-esp-idf",
|
||||
"esp-hal",
|
||||
"num-traits",
|
||||
"rtt-target",
|
||||
]
|
||||
|
||||
|
|
@ -1111,6 +1220,26 @@ dependencies = [
|
|||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "2.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "2.0.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.111",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.7.5+spec-1.1.0"
|
||||
|
|
|
|||
|
|
@ -14,12 +14,13 @@ esp-hal = { version = "1.0.0", features = ["esp32c6", "unstable"] }
|
|||
|
||||
esp-bootloader-esp-idf = { version = "0.4.0", features = ["esp32c6"] }
|
||||
|
||||
critical-section = "1.2.0"
|
||||
critical-section = {version = "1.2.0"}
|
||||
esp-alloc = "0.9.0"
|
||||
rtt-target = "0.6.2"
|
||||
embedded-hal = "1.0.0"
|
||||
esp-backtrace = {version = "0.18.1",features = ["esp32c6","defmt"]}
|
||||
|
||||
#esp-hal-dshot = {version = "0.3.1",default-features = false ,features = ["esp32c6"]}
|
||||
num-traits = { version = "0.2.19", default-features = false, features = ["libm"] }
|
||||
|
||||
[profile.dev]
|
||||
# Rust debug is too slow.
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
use esp_hal::{
|
||||
delay::Delay,
|
||||
gpio::Level,
|
||||
rmt::{PulseCode, Tx,Rx,TxChannelCreator,Channel},
|
||||
rmt::{Channel, PulseCode, Rx, Tx, TxChannelCreator},
|
||||
};
|
||||
use num_traits::float::FloatCore;
|
||||
|
||||
|
|
@ -112,19 +112,18 @@ impl DShotSpeed {
|
|||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug)]
|
||||
pub struct DShot<'a> {
|
||||
rx_channel:&'a Channel<'a,esp_hal::Blocking,esp_hal::rmt::Rx>,
|
||||
tx_channel:&'a Channel<'a,esp_hal::Blocking,esp_hal::rmt::Tx>,
|
||||
rx_channel: &'a mut Channel<'static, esp_hal::Blocking, esp_hal::rmt::Rx>,
|
||||
tx_channel: &'a mut Channel<'static, esp_hal::Blocking, esp_hal::rmt::Tx>,
|
||||
speed: DShotSpeed,
|
||||
bit_ticks: BitTicks,
|
||||
}
|
||||
|
||||
|
||||
impl<'a> DShot<'a> {
|
||||
pub fn new(
|
||||
rx_channel:&'a Channel<'a,esp_hal::Blocking,esp_hal::rmt::Rx>,
|
||||
tx_channel: &'a Channel<'a,esp_hal::Blocking,esp_hal::rmt::Tx>,
|
||||
rx_channel: &'a mut Channel<'static, esp_hal::Blocking, esp_hal::rmt::Rx>,
|
||||
tx_channel: &'a mut Channel<'static, esp_hal::Blocking, esp_hal::rmt::Tx>,
|
||||
speed: DShotSpeed,
|
||||
clk_speed: Option<u32>,
|
||||
clk_divider: Option<u8>,
|
||||
|
|
@ -134,7 +133,8 @@ impl<'a> DShot<'a> {
|
|||
|
||||
let bit_ticks = BitTicks::from_clk(clk_speed, clk_divider, speed.bit_times());
|
||||
Self {
|
||||
rx_channel: rx_channel,tx_channel: tx_channel,
|
||||
rx_channel: rx_channel,
|
||||
tx_channel: tx_channel,
|
||||
speed,
|
||||
bit_ticks,
|
||||
}
|
||||
|
|
@ -166,14 +166,16 @@ impl<'a> DShot<'a> {
|
|||
self.bit_ticks.t1_h,
|
||||
Level::Low,
|
||||
self.bit_ticks.t1_l,
|
||||
).into()
|
||||
)
|
||||
.into()
|
||||
} else {
|
||||
PulseCode::new(
|
||||
Level::High,
|
||||
self.bit_ticks.t0_h,
|
||||
Level::Low,
|
||||
self.bit_ticks.t0_l,
|
||||
).into()
|
||||
)
|
||||
.into()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -182,15 +184,15 @@ impl<'a> DShot<'a> {
|
|||
pulses
|
||||
}
|
||||
|
||||
pub fn write_throttle(
|
||||
&mut self,
|
||||
throttle: u16,
|
||||
telemetry: bool,
|
||||
) -> Result<(), &'static str> {
|
||||
pub fn write_throttle(&mut self, throttle: u16, telemetry: bool) -> Result<(), &'static str> {
|
||||
let pulses = self.create_pulses(throttle, telemetry);
|
||||
self.channel
|
||||
let tx_chann = self.tx_channel.reborrow();
|
||||
let transaction = tx_chann
|
||||
.transmit(&pulses)
|
||||
.map_err(|_| "Failed to send frame")?;
|
||||
.unwrap_or(return Err("Failed to send frame"))
|
||||
.wait()
|
||||
.unwrap_or(return Err("Waiting failed!"));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
)]
|
||||
use core::fmt::Write;
|
||||
use alloc::string::ToString;
|
||||
use esp_hal::uart::{self, Config, Uart};
|
||||
use esp_hal::uart::{Config, Uart};
|
||||
|
||||
use esp_hal::clock::CpuClock;
|
||||
use esp_hal::delay::Delay;
|
||||
|
|
@ -171,7 +171,6 @@ fn main() -> ! {
|
|||
// pwm_pin.set_timestamp(1000);
|
||||
// Timer::after_millis(1000).await;
|
||||
// }
|
||||
|
||||
loop {
|
||||
rprintln!("Hello world!");
|
||||
delay.delay_millis(3000);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue