Compare commits
No commits in common. "07e6e6ec4bd2f6dc4da7614134fccb5a7aaa4e87" and "3ef9bbdcec8a03d110bbd3e5ed3a73ebe01ed63c" have entirely different histories.
07e6e6ec4b
...
3ef9bbdcec
2 changed files with 15 additions and 30 deletions
|
|
@ -16,7 +16,6 @@ const MAX_THROTTLE:u16 = 1421;
|
|||
const GAP:u16 = (MAX_THROTTLE - MIN_THROTTLE)/100;
|
||||
|
||||
impl AfroEsc<'_>{
|
||||
//this is a little hacky tbh
|
||||
pub fn new<'a>(pwm_pin:&'a mut PwmPin<'a, esp_hal::peripherals::MCPWM0<'a>, 0,true>)-> AfroEsc<'a> {
|
||||
AfroEsc{pwm_pin:pwm_pin}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,17 +5,15 @@
|
|||
reason = "mem::forget is generally not safe to do with esp_hal types, especially those \
|
||||
holding buffers for the duration of a data transfer."
|
||||
)]
|
||||
use core::fmt::Write;
|
||||
use esp_hal::uart::{Config, Uart};
|
||||
|
||||
use esp_hal::clock::CpuClock;
|
||||
use esp_hal::delay::Delay;
|
||||
use esp_hal::main;
|
||||
use esp_hal::mcpwm::operator::PwmPinConfig;
|
||||
use esp_hal::mcpwm::timer::PwmWorkingMode;
|
||||
use esp_hal::time::Rate;
|
||||
use esp_hal::time::{Duration, Instant};
|
||||
use esp_hal::timer::timg::TimerGroup;
|
||||
use esp_hal::main;
|
||||
use esp_hal::time::{Duration, Instant};
|
||||
use esp_hal::delay::Delay;
|
||||
use rtt_target::rprintln;
|
||||
mod dc_driver;
|
||||
use dc_driver::afroesc::AfroEsc;
|
||||
|
|
@ -42,15 +40,12 @@ fn main() -> ! {
|
|||
let mut delay = Delay::new();
|
||||
|
||||
esp_alloc::heap_allocator!(#[esp_hal::ram(reclaimed)] size: 65536);
|
||||
let clock_config =
|
||||
esp_hal::mcpwm::PeripheralClockConfig::with_frequency(Rate::from_mhz(32)).unwrap();
|
||||
let clock_config = esp_hal::mcpwm::PeripheralClockConfig::with_frequency(Rate::from_mhz(32)).unwrap();
|
||||
let mut mcpwm = esp_hal::mcpwm::McPwm::new(peripherals.MCPWM0, clock_config);
|
||||
mcpwm.operator0.set_timer(&mcpwm.timer0);
|
||||
let pin = peripherals.GPIO18;
|
||||
|
||||
let mut pwm_pin = mcpwm
|
||||
.operator0
|
||||
.with_pin_a(pin, PwmPinConfig::UP_ACTIVE_HIGH);
|
||||
let mut pwm_pin = mcpwm.operator0.with_pin_a(pin, PwmPinConfig::UP_ACTIVE_HIGH);
|
||||
let timer_clock_cfg = clock_config
|
||||
.timer_clock_with_frequency(19_999, PwmWorkingMode::Increase, Rate::from_hz(50))
|
||||
.unwrap();
|
||||
|
|
@ -64,16 +59,6 @@ fn main() -> ! {
|
|||
esc.set_timestamp(1055);
|
||||
delay.delay_millis(3000);
|
||||
|
||||
let mut uart0 = Uart::new(peripherals.UART0, Config::default().with_baudrate(9600))
|
||||
.unwrap()
|
||||
.with_rx(peripherals.GPIO9)
|
||||
.with_tx(peripherals.GPIO10);
|
||||
uart0.write(b"page page1");
|
||||
uart0.write(b"\xff");
|
||||
uart0.write(b"\xff");
|
||||
uart0.write(b"\xff");
|
||||
uart0.write(b"\xff");
|
||||
rprintln!("WRITE HAPPENED!");
|
||||
// Example: Ramp from 0% to 50% throttle
|
||||
//the afro esc starts turning at roughly setup gets a PWM at
|
||||
//loop{
|
||||
|
|
@ -93,6 +78,7 @@ fn main() -> ! {
|
|||
loop {
|
||||
rprintln!("Hello world!");
|
||||
delay.delay_millis(3000);
|
||||
|
||||
}
|
||||
|
||||
// for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/esp-hal-v1.0.0/examples/src/bin
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue