diff --git a/Cargo.lock b/Cargo.lock index f5934c5..a70bdcd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -354,6 +354,7 @@ dependencies = [ "esp-backtrace", "esp-println", "esp32s3-hal", + "fugit", "static_cell", ] diff --git a/Cargo.toml b/Cargo.toml index 6213fdb..94c3e98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,6 +34,7 @@ esp-backtrace = { version = "0.7.0", features = [ ] } esp-println = { version = "0.5.0", features = ["esp32s3"] } static_cell = "1.0.0" +fugit = "0.3.6" [features] generate-clki = [] diff --git a/src/main.rs b/src/main.rs index f37190d..1764b69 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,7 @@ use esp32s3_hal::{ }; use esp_backtrace as _; use esp_println::println; +use fugit::HertzU32; use static_cell::StaticCell; #[embassy_executor::task] @@ -77,9 +78,14 @@ fn main() -> ! { let mut bm_rst = io.pins.gpio1.into_push_pull_output(); bm_rst.set_low().unwrap(); println!("Reset BM1397 RST with gpio1 LOW"); + + #[cfg(not(feature = "generate-clki"))] + let _bm_clki_freq: HertzU32 = 25u32.MHz(); // will be use to init the bm1397 chain + #[cfg(feature = "generate-clki")] { println!("Generating BM1397 CLKI 20MHz on gpio41"); + let bm_clki_freq: HertzU32 = 20u32.MHz(); let bm_clki = io.pins.gpio41.into_push_pull_output(); let mut ledc = LEDC::new( peripherals.LEDC, @@ -94,7 +100,7 @@ fn main() -> ! { .configure(timer::config::Config { duty: timer::config::Duty::Duty1Bit, clock_source: timer::LSClockSource::APBClk, - frequency: 20u32.MHz(), + frequency: bm_clki_freq, }) .unwrap();