From 19341672a9f1ca715509fa681bae54a4ce5c1a2b Mon Sep 17 00:00:00 2001 From: linuswck Date: Mon, 26 Feb 2024 16:49:00 +0800 Subject: [PATCH] Correct SPI Clock Freq and Set them to Max - Set the SPI frequency to maximum to reduce data transaction time - SPI1 SCLK is divided from PCLK2 - SPI2, SPI2 SCLK are divided from PCLK1 --- src/laser_diode/max5719.rs | 3 ++- src/thermostat/ad5680.rs | 3 ++- src/thermostat/ad7172/mod.rs | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/laser_diode/max5719.rs b/src/laser_diode/max5719.rs index dd50684..c43e419 100644 --- a/src/laser_diode/max5719.rs +++ b/src/laser_diode/max5719.rs @@ -9,7 +9,8 @@ pub const SPI_MODE: spi::Mode = spi::Mode { polarity: spi::Polarity::IdleLow, phase: spi::Phase::CaptureOnFirstTransition, }; -pub const SPI_CLOCK_MHZ: MegahertzU32 = MegahertzU32::from_raw(10); +// MAX5719 Max Frequency: 50MHz | SPI2 Max Frequency: 21MHz +pub const SPI_CLOCK_MHZ: MegahertzU32 = MegahertzU32::from_raw(21); pub const MAX_VALUE: u32 = 0xFFFFF; diff --git a/src/thermostat/ad5680.rs b/src/thermostat/ad5680.rs index bc09518..cf8862c 100644 --- a/src/thermostat/ad5680.rs +++ b/src/thermostat/ad5680.rs @@ -10,7 +10,8 @@ pub const SPI_MODE: spi::Mode = spi::Mode { polarity: spi::Polarity::IdleLow, phase: spi::Phase::CaptureOnSecondTransition, }; -pub const SPI_CLOCK_MHZ: MegahertzU32 = MegahertzU32::from_raw(30); +// MAX Clock Frequency: 30MHz | SPI1 Max Frequency 42MHz +pub const SPI_CLOCK_MHZ: MegahertzU32 = MegahertzU32::from_raw(21); pub const MAX_VALUE: u32 = 0x3FFFF; diff --git a/src/thermostat/ad7172/mod.rs b/src/thermostat/ad7172/mod.rs index 1578e20..f12e608 100644 --- a/src/thermostat/ad7172/mod.rs +++ b/src/thermostat/ad7172/mod.rs @@ -15,8 +15,8 @@ pub const SPI_MODE: spi::Mode = spi::Mode { polarity: spi::Polarity::IdleHigh, phase: spi::Phase::CaptureOnSecondTransition, }; -/// 2 MHz -pub const SPI_CLOCK_MHZ: MegahertzU32 = MegahertzU32::from_raw(2); +/// AD7172 Max Frequency: 40MHz | SPI3 Max Frequency: 21MHz +pub const SPI_CLOCK_MHZ: MegahertzU32 = MegahertzU32::from_raw(21); pub const MAX_VALUE: u32 = 0xFF_FFFF;