The fucking receive data format/encoding/modulation is just bonkers. But
I think I got it.
This commit is contained in:
Serge Bazanski 2026-01-24 02:24:17 +01:00
parent 06fd42430f
commit 6c38cd59ee
2 changed files with 164 additions and 36 deletions

View file

@ -9,10 +9,10 @@ use alloc::boxed::Box;
use alloc::string::ToString;
use esp_hal::clock::CpuClock;
use esp_hal::delay::Delay;
use esp_hal::main;
use esp_hal::{gpio, main};
use esp_hal::uart::{Config, Uart};
use esp_hal::gpio::Event;
use esp_hal::gpio::{Event, OutputConfig};
use esp_hal::gpio::{Input, InputConfig};
use esp_hal::handler;
use esp_hal::rmt::{Rmt, TxChannelConfig, TxChannelCreator};
@ -69,15 +69,20 @@ fn main() -> ! {
//setup RMT
let freq = Rate::from_mhz(80);
let rmt = Rmt::new(peripherals.RMT, freq).expect("CAN NOT SET FREQUENCY");
let rx_config = RxChannelConfig::default().with_clk_divider(1);
let tx_config = TxChannelConfig::default().with_clk_divider(1);
let rx_config = RxChannelConfig::default().with_clk_divider(1).with_idle_threshold(1000);
let tx_config = TxChannelConfig::default().with_clk_divider(1).with_idle_output(true).with_idle_output_level(esp_hal::gpio::Level::High);
let oc = OutputConfig::default().with_drive_mode(esp_hal::gpio::DriveMode::OpenDrain);
let ic = InputConfig::default();
let rx_pin = gpio::Input::new(unsafe { peripherals.GPIO23.clone_unchecked() }, ic);
let tx_pin = gpio::Output::new(peripherals.GPIO23, esp_hal::gpio::Level::High, oc);
let mut tx_channel = rmt
.channel0
.configure_tx(peripherals.GPIO23, tx_config)
.configure_tx(tx_pin, tx_config)
.expect("creation of TX_CHANNEL FAILED!");
let mut rx_channel = rmt
.channel3
.configure_rx(peripherals.GPIO14, rx_config)
.configure_rx(rx_pin, rx_config)
.unwrap();
let dshot_esc = dshot::DShot::new(
&mut rx_channel,
@ -94,7 +99,7 @@ fn main() -> ! {
dshot_esc.arm();
loop {
dshot_esc.process();
dshot_esc.set_throttle(200);
dshot_esc.set_throttle(150);
}
// rprintln!("RMT SENT!");