diff --git a/src/mcpwm/mod.rs b/src/mcpwm/mod.rs index fd59c47eb58..c8b2ee6904d 100644 --- a/src/mcpwm/mod.rs +++ b/src/mcpwm/mod.rs @@ -63,15 +63,6 @@ pub use self::{ timer_connection::TimerConnection, }; -// MCPWM clock source frequency for ESP32 and ESP32-s3 -const MCPWM_CLOCK_SOURCE_FREQUENCY: u32 = 160_000_000; - -// Max PWM timer prescaler -const MAX_PWM_TIMER_PRESCALE: u32 = 0x1_00; - -// Max PWM timer period -const MAX_PWM_TIMER_PERIOD: u32 = 0x1_00_00; - /// The Motor Control Pulse Width Modulator peripheral pub struct MCPWM { pub timer0: TIMER<0, G>, diff --git a/src/mcpwm/timer.rs b/src/mcpwm/timer.rs index e978a7835f5..c22e8d976d4 100644 --- a/src/mcpwm/timer.rs +++ b/src/mcpwm/timer.rs @@ -4,7 +4,7 @@ use std::ptr; use esp_idf_sys::{ esp, mcpwm_del_timer, mcpwm_new_timer, mcpwm_timer_config_t, mcpwm_timer_enable, - mcpwm_timer_handle_t, EspError, + mcpwm_timer_handle_t, }; use crate::mcpwm::Group; @@ -14,7 +14,7 @@ use crate::units::Hertz; use super::operator::NoOperator; use super::timer_connection::TimerConnection; -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct TimerConfig { frequency: Hertz, //resolution: Hertz, @@ -92,7 +92,7 @@ impl Timer { }; let mut handle: mcpwm_timer_handle_t = ptr::null_mut(); unsafe { - esp!(mcpwm_new_timer(&cfg, &mut handle)); + esp!(mcpwm_new_timer(&cfg, &mut handle)).unwrap(); } // TODO: note that this has to be called before mcpwm_timer_enable // mcpwm_timer_register_event_callbacks() @@ -173,7 +173,7 @@ impl Drop for Timer { /// Counter mode for operator's timer for generating PWM signal // TODO: For UpDown, frequency is half of MCPWM frequency set -#[derive(Clone, Copy, Debug, PartialEq)] +#[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum CountMode { /// Timer is frozen or paused //#[cfg(not(esp_idf_version = "4.3"))] diff --git a/src/mcpwm/timer_connection.rs b/src/mcpwm/timer_connection.rs index d1576116c19..465c4699f29 100644 --- a/src/mcpwm/timer_connection.rs +++ b/src/mcpwm/timer_connection.rs @@ -2,7 +2,7 @@ use crate::mcpwm::Group; use super::{ operator::{NoOperator, OperatorConfig, OptionalOperator, OPERATOR}, - timer::{Timer, TIMER}, + timer::Timer, Operator, }; @@ -114,8 +114,10 @@ impl, O1: OptionalOperator<1, } } +// TODO: Should this be moved somewhere else? pub struct NoPin; +// TODO: Should this be moved somewhere else? pub trait OptionalOutputPin {} impl OptionalOutputPin for P {}