aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp/src
diff options
context:
space:
mode:
author1-rafael-1 <[email protected]>2025-05-07 21:19:09 +0200
committer1-rafael-1 <[email protected]>2025-05-07 21:19:09 +0200
commita254daf4fffe74c65d1846f620dd674fa4e14aac (patch)
tree988fb8eb150d92bceca97d0f61b16535edd11215 /embassy-rp/src
parent0d03aa0bec01fb0289915861d997bf7f2cf8d232 (diff)
Changes after review
Diffstat (limited to 'embassy-rp/src')
-rw-r--r--embassy-rp/src/clocks.rs51
1 files changed, 35 insertions, 16 deletions
diff --git a/embassy-rp/src/clocks.rs b/embassy-rp/src/clocks.rs
index a4cc129ab..0c3988aac 100644
--- a/embassy-rp/src/clocks.rs
+++ b/embassy-rp/src/clocks.rs
@@ -9,7 +9,7 @@
9//! 9//!
10//! For most users, these functions provide an easy way to configure clocks: 10//! For most users, these functions provide an easy way to configure clocks:
11//! 11//!
12//! - `ClockConfig::at_sys_frequency_mhz(200)` - Set system clock to a specific frequency with automatic voltage scaling 12//! - `ClockConfig::system_freq(125_000_000)` - Set system clock to a specific frequency with automatic voltage scaling
13//! - `ClockConfig::crystal(12_000_000)` - Default configuration with 12MHz crystal giving 125MHz system clock 13//! - `ClockConfig::crystal(12_000_000)` - Default configuration with 12MHz crystal giving 125MHz system clock
14//! 14//!
15//! ## Manual Configuration 15//! ## Manual Configuration
@@ -50,7 +50,7 @@
50//! 50//!
51//! ### Overclock to 200MHz 51//! ### Overclock to 200MHz
52//! ```rust,ignore 52//! ```rust,ignore
53//! let config = ClockConfig::crystal_freq(200_000_000); 53//! let config = ClockConfig::system_freq(200_000_000);
54//! ``` 54//! ```
55//! 55//!
56//! ### Manual configuration for advanced scenarios 56//! ### Manual configuration for advanced scenarios
@@ -90,6 +90,7 @@ struct Clocks {
90 pll_usb: AtomicU32, 90 pll_usb: AtomicU32,
91 usb: AtomicU32, 91 usb: AtomicU32,
92 adc: AtomicU32, 92 adc: AtomicU32,
93 // See above re gpin handling being commented out
93 // gpin0: AtomicU32, 94 // gpin0: AtomicU32,
94 // gpin1: AtomicU32, 95 // gpin1: AtomicU32,
95 rosc: AtomicU32, 96 rosc: AtomicU32,
@@ -106,6 +107,7 @@ static CLOCKS: Clocks = Clocks {
106 pll_usb: AtomicU32::new(0), 107 pll_usb: AtomicU32::new(0),
107 usb: AtomicU32::new(0), 108 usb: AtomicU32::new(0),
108 adc: AtomicU32::new(0), 109 adc: AtomicU32::new(0),
110 // See above re gpin handling being commented out
109 // gpin0: AtomicU32::new(0), 111 // gpin0: AtomicU32::new(0),
110 // gpin1: AtomicU32::new(0), 112 // gpin1: AtomicU32::new(0),
111 rosc: AtomicU32::new(0), 113 rosc: AtomicU32::new(0),
@@ -129,6 +131,7 @@ pub enum PeriClkSrc {
129 Rosc = ClkPeriCtrlAuxsrc::ROSC_CLKSRC_PH as _, 131 Rosc = ClkPeriCtrlAuxsrc::ROSC_CLKSRC_PH as _,
130 /// XOSC. 132 /// XOSC.
131 Xosc = ClkPeriCtrlAuxsrc::XOSC_CLKSRC as _, 133 Xosc = ClkPeriCtrlAuxsrc::XOSC_CLKSRC as _,
134 // See above re gpin handling being commented out
132 // Gpin0 = ClkPeriCtrlAuxsrc::CLKSRC_GPIN0 as _ , 135 // Gpin0 = ClkPeriCtrlAuxsrc::CLKSRC_GPIN0 as _ ,
133 // Gpin1 = ClkPeriCtrlAuxsrc::CLKSRC_GPIN1 as _ , 136 // Gpin1 = ClkPeriCtrlAuxsrc::CLKSRC_GPIN1 as _ ,
134} 137}
@@ -213,6 +216,7 @@ pub struct ClockConfig {
213 /// If not set, defaults will be used based on voltage level. 216 /// If not set, defaults will be used based on voltage level.
214 #[cfg(feature = "rp2040")] 217 #[cfg(feature = "rp2040")]
215 pub voltage_stabilization_delay_us: Option<u32>, 218 pub voltage_stabilization_delay_us: Option<u32>,
219 // See above re gpin handling being commented out
216 // gpin0: Option<(u32, Gpin<'static, AnyPin>)>, 220 // gpin0: Option<(u32, Gpin<'static, AnyPin>)>,
217 // gpin1: Option<(u32, Gpin<'static, AnyPin>)>, 221 // gpin1: Option<(u32, Gpin<'static, AnyPin>)>,
218} 222}
@@ -227,7 +231,7 @@ impl Default for ClockConfig {
227 /// Most users should use one of the more specific configuration functions: 231 /// Most users should use one of the more specific configuration functions:
228 /// - `ClockConfig::crystal()` - Standard configuration with external crystal 232 /// - `ClockConfig::crystal()` - Standard configuration with external crystal
229 /// - `ClockConfig::rosc()` - Configuration using only the internal oscillator 233 /// - `ClockConfig::rosc()` - Configuration using only the internal oscillator
230 /// - `ClockConfig::at_sys_frequency_mhz()` - Configuration for a specific system frequency 234 /// - `ClockConfig::system_freq()` - Configuration for a specific system frequency
231 fn default() -> Self { 235 fn default() -> Self {
232 Self { 236 Self {
233 rosc: None, 237 rosc: None,
@@ -250,6 +254,7 @@ impl Default for ClockConfig {
250 core_voltage: CoreVoltage::V1_10, 254 core_voltage: CoreVoltage::V1_10,
251 #[cfg(feature = "rp2040")] 255 #[cfg(feature = "rp2040")]
252 voltage_stabilization_delay_us: None, 256 voltage_stabilization_delay_us: None,
257 // See above re gpin handling being commented out
253 // gpin0: None, 258 // gpin0: None,
254 // gpin1: None, 259 // gpin1: None,
255 } 260 }
@@ -322,6 +327,7 @@ impl ClockConfig {
322 core_voltage: CoreVoltage::V1_10, // Use hardware default (1.10V) 327 core_voltage: CoreVoltage::V1_10, // Use hardware default (1.10V)
323 #[cfg(feature = "rp2040")] 328 #[cfg(feature = "rp2040")]
324 voltage_stabilization_delay_us: None, 329 voltage_stabilization_delay_us: None,
330 // See above re gpin handling being commented out
325 // gpin0: None, 331 // gpin0: None,
326 // gpin1: None, 332 // gpin1: None,
327 } 333 }
@@ -366,6 +372,7 @@ impl ClockConfig {
366 core_voltage: CoreVoltage::V1_10, // Use hardware default (1.10V) 372 core_voltage: CoreVoltage::V1_10, // Use hardware default (1.10V)
367 #[cfg(feature = "rp2040")] 373 #[cfg(feature = "rp2040")]
368 voltage_stabilization_delay_us: None, 374 voltage_stabilization_delay_us: None,
375 // See above re gpin handling being commented out
369 // gpin0: None, 376 // gpin0: None,
370 // gpin1: None, 377 // gpin1: None,
371 } 378 }
@@ -393,19 +400,19 @@ impl ClockConfig {
393 /// That way all other frequencies below 133MHz or above 200MHz are not explicitly documented and not covered here. 400 /// That way all other frequencies below 133MHz or above 200MHz are not explicitly documented and not covered here.
394 /// In case You want to go below 133MHz or above 200MHz and want a different voltage, You will have to set that manually and with caution. 401 /// In case You want to go below 133MHz or above 200MHz and want a different voltage, You will have to set that manually and with caution.
395 #[cfg(feature = "rp2040")] 402 #[cfg(feature = "rp2040")]
396 pub fn crystal_freq(sys_freq_hz: u32) -> Self { 403 pub fn system_freq(hz: u32) -> Self {
397 // Start with the standard configuration from crystal() 404 // Start with the standard configuration from crystal()
398 const DEFAULT_CRYSTAL_HZ: u32 = 12_000_000; 405 const DEFAULT_CRYSTAL_HZ: u32 = 12_000_000;
399 let mut config = Self::crystal(DEFAULT_CRYSTAL_HZ); 406 let mut config = Self::crystal(DEFAULT_CRYSTAL_HZ);
400 407
401 // No need to modify anything if target frequency is already 125MHz 408 // No need to modify anything if target frequency is already 125MHz
402 // (which is what crystal() configures by default) 409 // (which is what crystal() configures by default)
403 if sys_freq_hz == 125_000_000 { 410 if hz == 125_000_000 {
404 return config; 411 return config;
405 } 412 }
406 413
407 // Find optimal PLL parameters for the requested frequency 414 // Find optimal PLL parameters for the requested frequency
408 let sys_pll_params = find_pll_params(DEFAULT_CRYSTAL_HZ, sys_freq_hz) 415 let sys_pll_params = find_pll_params(DEFAULT_CRYSTAL_HZ, hz)
409 .unwrap_or_else(|| panic!("Could not find valid PLL parameters for system clock")); 416 .unwrap_or_else(|| panic!("Could not find valid PLL parameters for system clock"));
410 417
411 // Replace the sys_pll configuration with our custom parameters 418 // Replace the sys_pll configuration with our custom parameters
@@ -417,7 +424,7 @@ impl ClockConfig {
417 // Higher frequencies require higher voltage 424 // Higher frequencies require higher voltage
418 #[cfg(feature = "rp2040")] 425 #[cfg(feature = "rp2040")]
419 { 426 {
420 config.core_voltage = match sys_freq_hz { 427 config.core_voltage = match hz {
421 freq if freq > 133_000_000 => CoreVoltage::V1_15, 428 freq if freq > 133_000_000 => CoreVoltage::V1_15,
422 _ => CoreVoltage::V1_10, // Use default voltage (V1_10) 429 _ => CoreVoltage::V1_10, // Use default voltage (V1_10)
423 }; 430 };
@@ -631,6 +638,7 @@ pub enum RefClkSrc {
631 Rosc, 638 Rosc,
632 /// PLL USB. 639 /// PLL USB.
633 PllUsb, 640 PllUsb,
641 // See above re gpin handling being commented out
634 // Gpin0, 642 // Gpin0,
635 // Gpin1, 643 // Gpin1,
636} 644}
@@ -649,6 +657,7 @@ pub enum SysClkSrc {
649 Rosc, 657 Rosc,
650 /// XOSC. 658 /// XOSC.
651 Xosc, 659 Xosc,
660 // See above re gpin handling being commented out
652 // Gpin0, 661 // Gpin0,
653 // Gpin1, 662 // Gpin1,
654} 663}
@@ -684,6 +693,7 @@ pub enum UsbClkSrc {
684 Rosc = ClkUsbCtrlAuxsrc::ROSC_CLKSRC_PH as _, 693 Rosc = ClkUsbCtrlAuxsrc::ROSC_CLKSRC_PH as _,
685 /// XOSC. 694 /// XOSC.
686 Xosc = ClkUsbCtrlAuxsrc::XOSC_CLKSRC as _, 695 Xosc = ClkUsbCtrlAuxsrc::XOSC_CLKSRC as _,
696 // See above re gpin handling being commented out
687 // Gpin0 = ClkUsbCtrlAuxsrc::CLKSRC_GPIN0 as _ , 697 // Gpin0 = ClkUsbCtrlAuxsrc::CLKSRC_GPIN0 as _ ,
688 // Gpin1 = ClkUsbCtrlAuxsrc::CLKSRC_GPIN1 as _ , 698 // Gpin1 = ClkUsbCtrlAuxsrc::CLKSRC_GPIN1 as _ ,
689} 699}
@@ -711,6 +721,7 @@ pub enum AdcClkSrc {
711 Rosc = ClkAdcCtrlAuxsrc::ROSC_CLKSRC_PH as _, 721 Rosc = ClkAdcCtrlAuxsrc::ROSC_CLKSRC_PH as _,
712 /// XOSC. 722 /// XOSC.
713 Xosc = ClkAdcCtrlAuxsrc::XOSC_CLKSRC as _, 723 Xosc = ClkAdcCtrlAuxsrc::XOSC_CLKSRC as _,
724 // See above re gpin handling being commented out
714 // Gpin0 = ClkAdcCtrlAuxsrc::CLKSRC_GPIN0 as _ , 725 // Gpin0 = ClkAdcCtrlAuxsrc::CLKSRC_GPIN0 as _ ,
715 // Gpin1 = ClkAdcCtrlAuxsrc::CLKSRC_GPIN1 as _ , 726 // Gpin1 = ClkAdcCtrlAuxsrc::CLKSRC_GPIN1 as _ ,
716} 727}
@@ -739,6 +750,7 @@ pub enum RtcClkSrc {
739 Rosc = ClkRtcCtrlAuxsrc::ROSC_CLKSRC_PH as _, 750 Rosc = ClkRtcCtrlAuxsrc::ROSC_CLKSRC_PH as _,
740 /// XOSC. 751 /// XOSC.
741 Xosc = ClkRtcCtrlAuxsrc::XOSC_CLKSRC as _, 752 Xosc = ClkRtcCtrlAuxsrc::XOSC_CLKSRC as _,
753 // See above re gpin handling being commented out
742 // Gpin0 = ClkRtcCtrlAuxsrc::CLKSRC_GPIN0 as _ , 754 // Gpin0 = ClkRtcCtrlAuxsrc::CLKSRC_GPIN0 as _ ,
743 // Gpin1 = ClkRtcCtrlAuxsrc::CLKSRC_GPIN1 as _ , 755 // Gpin1 = ClkRtcCtrlAuxsrc::CLKSRC_GPIN1 as _ ,
744} 756}
@@ -895,6 +907,7 @@ pub(crate) unsafe fn init(config: ClockConfig) {
895 reset::reset(peris); 907 reset::reset(peris);
896 reset::unreset_wait(peris); 908 reset::unreset_wait(peris);
897 909
910 // See above re gpin handling being commented out
898 // let gpin0_freq = config.gpin0.map_or(0, |p| { 911 // let gpin0_freq = config.gpin0.map_or(0, |p| {
899 // core::mem::forget(p.1); 912 // core::mem::forget(p.1);
900 // p.0 913 // p.0
@@ -941,7 +954,7 @@ pub(crate) unsafe fn init(config: ClockConfig) {
941 cortex_m::asm::delay(delay_cycles); 954 cortex_m::asm::delay(delay_cycles);
942 } 955 }
943 956
944 // Only now set the BOD level. At htis point the voltage is considered stable. 957 // Only now set the BOD level. At this point the voltage is considered stable.
945 vreg.bod().write(|w| { 958 vreg.bod().write(|w| {
946 w.set_vsel(voltage.recommended_bod()); 959 w.set_vsel(voltage.recommended_bod());
947 w.set_en(true); // Enable brownout detection 960 w.set_en(true); // Enable brownout detection
@@ -952,8 +965,6 @@ pub(crate) unsafe fn init(config: ClockConfig) {
952 let (xosc_freq, pll_sys_freq, pll_usb_freq) = match config.xosc { 965 let (xosc_freq, pll_sys_freq, pll_usb_freq) = match config.xosc {
953 Some(config) => { 966 Some(config) => {
954 // start XOSC 967 // start XOSC
955 // datasheet mentions support for clock inputs into XIN, but doesn't go into
956 // how this is achieved. pico-sdk doesn't support this at all.
957 start_xosc(config.hz, config.delay_multiplier); 968 start_xosc(config.hz, config.delay_multiplier);
958 969
959 let pll_sys_freq = match config.sys_pll { 970 let pll_sys_freq = match config.sys_pll {
@@ -988,6 +999,7 @@ pub(crate) unsafe fn init(config: ClockConfig) {
988 RefClkSrc::Xosc => (Src::XOSC_CLKSRC, Aux::CLKSRC_PLL_USB, xosc_freq / div), 999 RefClkSrc::Xosc => (Src::XOSC_CLKSRC, Aux::CLKSRC_PLL_USB, xosc_freq / div),
989 RefClkSrc::Rosc => (Src::ROSC_CLKSRC_PH, Aux::CLKSRC_PLL_USB, rosc_freq / div), 1000 RefClkSrc::Rosc => (Src::ROSC_CLKSRC_PH, Aux::CLKSRC_PLL_USB, rosc_freq / div),
990 RefClkSrc::PllUsb => (Src::CLKSRC_CLK_REF_AUX, Aux::CLKSRC_PLL_USB, pll_usb_freq / div), 1001 RefClkSrc::PllUsb => (Src::CLKSRC_CLK_REF_AUX, Aux::CLKSRC_PLL_USB, pll_usb_freq / div),
1002 // See above re gpin handling being commented out
991 // RefClkSrc::Gpin0 => (Src::CLKSRC_CLK_REF_AUX, Aux::CLKSRC_GPIN0, gpin0_freq / div), 1003 // RefClkSrc::Gpin0 => (Src::CLKSRC_CLK_REF_AUX, Aux::CLKSRC_GPIN0, gpin0_freq / div),
992 // RefClkSrc::Gpin1 => (Src::CLKSRC_CLK_REF_AUX, Aux::CLKSRC_GPIN1, gpin1_freq / div), 1004 // RefClkSrc::Gpin1 => (Src::CLKSRC_CLK_REF_AUX, Aux::CLKSRC_GPIN1, gpin1_freq / div),
993 } 1005 }
@@ -1032,6 +1044,7 @@ pub(crate) unsafe fn init(config: ClockConfig) {
1032 SysClkSrc::PllUsb => (Src::CLKSRC_CLK_SYS_AUX, Aux::CLKSRC_PLL_USB, pll_usb_freq), 1044 SysClkSrc::PllUsb => (Src::CLKSRC_CLK_SYS_AUX, Aux::CLKSRC_PLL_USB, pll_usb_freq),
1033 SysClkSrc::Rosc => (Src::CLKSRC_CLK_SYS_AUX, Aux::ROSC_CLKSRC, rosc_freq), 1045 SysClkSrc::Rosc => (Src::CLKSRC_CLK_SYS_AUX, Aux::ROSC_CLKSRC, rosc_freq),
1034 SysClkSrc::Xosc => (Src::CLKSRC_CLK_SYS_AUX, Aux::XOSC_CLKSRC, xosc_freq), 1046 SysClkSrc::Xosc => (Src::CLKSRC_CLK_SYS_AUX, Aux::XOSC_CLKSRC, xosc_freq),
1047 // See above re gpin handling being commented out
1035 // SysClkSrc::Gpin0 => (Src::CLKSRC_CLK_SYS_AUX, Aux::CLKSRC_GPIN0, gpin0_freq), 1048 // SysClkSrc::Gpin0 => (Src::CLKSRC_CLK_SYS_AUX, Aux::CLKSRC_GPIN0, gpin0_freq),
1036 // SysClkSrc::Gpin1 => (Src::CLKSRC_CLK_SYS_AUX, Aux::CLKSRC_GPIN1, gpin1_freq), 1049 // SysClkSrc::Gpin1 => (Src::CLKSRC_CLK_SYS_AUX, Aux::CLKSRC_GPIN1, gpin1_freq),
1037 }; 1050 };
@@ -1075,6 +1088,7 @@ pub(crate) unsafe fn init(config: ClockConfig) {
1075 PeriClkSrc::PllUsb => pll_usb_freq, 1088 PeriClkSrc::PllUsb => pll_usb_freq,
1076 PeriClkSrc::Rosc => rosc_freq, 1089 PeriClkSrc::Rosc => rosc_freq,
1077 PeriClkSrc::Xosc => xosc_freq, 1090 PeriClkSrc::Xosc => xosc_freq,
1091 // See above re gpin handling being commented out
1078 // PeriClkSrc::Gpin0 => gpin0_freq, 1092 // PeriClkSrc::Gpin0 => gpin0_freq,
1079 // PeriClkSrc::Gpin1 => gpin1_freq, 1093 // PeriClkSrc::Gpin1 => gpin1_freq,
1080 }; 1094 };
@@ -1100,6 +1114,7 @@ pub(crate) unsafe fn init(config: ClockConfig) {
1100 UsbClkSrc::PllSys => pll_sys_freq, 1114 UsbClkSrc::PllSys => pll_sys_freq,
1101 UsbClkSrc::Rosc => rosc_freq, 1115 UsbClkSrc::Rosc => rosc_freq,
1102 UsbClkSrc::Xosc => xosc_freq, 1116 UsbClkSrc::Xosc => xosc_freq,
1117 // See above re gpin handling being commented out
1103 // UsbClkSrc::Gpin0 => gpin0_freq, 1118 // UsbClkSrc::Gpin0 => gpin0_freq,
1104 // UsbClkSrc::Gpin1 => gpin1_freq, 1119 // UsbClkSrc::Gpin1 => gpin1_freq,
1105 }; 1120 };
@@ -1123,6 +1138,7 @@ pub(crate) unsafe fn init(config: ClockConfig) {
1123 AdcClkSrc::PllSys => pll_sys_freq, 1138 AdcClkSrc::PllSys => pll_sys_freq,
1124 AdcClkSrc::Rosc => rosc_freq, 1139 AdcClkSrc::Rosc => rosc_freq,
1125 AdcClkSrc::Xosc => xosc_freq, 1140 AdcClkSrc::Xosc => xosc_freq,
1141 // See above re gpin handling being commented out
1126 // AdcClkSrc::Gpin0 => gpin0_freq, 1142 // AdcClkSrc::Gpin0 => gpin0_freq,
1127 // AdcClkSrc::Gpin1 => gpin1_freq, 1143 // AdcClkSrc::Gpin1 => gpin1_freq,
1128 }; 1144 };
@@ -1151,6 +1167,7 @@ pub(crate) unsafe fn init(config: ClockConfig) {
1151 RtcClkSrc::PllSys => pll_sys_freq, 1167 RtcClkSrc::PllSys => pll_sys_freq,
1152 RtcClkSrc::Rosc => rosc_freq, 1168 RtcClkSrc::Rosc => rosc_freq,
1153 RtcClkSrc::Xosc => xosc_freq, 1169 RtcClkSrc::Xosc => xosc_freq,
1170 // See above re gpin handling being commented out
1154 // RtcClkSrc::Gpin0 => gpin0_freq, 1171 // RtcClkSrc::Gpin0 => gpin0_freq,
1155 // RtcClkSrc::Gpin1 => gpin1_freq, 1172 // RtcClkSrc::Gpin1 => gpin1_freq,
1156 }; 1173 };
@@ -1217,6 +1234,7 @@ pub fn xosc_freq() -> u32 {
1217 CLOCKS.xosc.load(Ordering::Relaxed) 1234 CLOCKS.xosc.load(Ordering::Relaxed)
1218} 1235}
1219 1236
1237// See above re gpin handling being commented out
1220// pub fn gpin0_freq() -> u32 { 1238// pub fn gpin0_freq() -> u32 {
1221// CLOCKS.gpin0.load(Ordering::Relaxed) 1239// CLOCKS.gpin0.load(Ordering::Relaxed)
1222// } 1240// }
@@ -1452,6 +1470,7 @@ impl_gpoutpin!(PIN_25, 3);
1452pub enum GpoutSrc { 1470pub enum GpoutSrc {
1453 /// Sys PLL. 1471 /// Sys PLL.
1454 PllSys = ClkGpoutCtrlAuxsrc::CLKSRC_PLL_SYS as _, 1472 PllSys = ClkGpoutCtrlAuxsrc::CLKSRC_PLL_SYS as _,
1473 // See above re gpin handling being commented out
1455 // Gpin0 = ClkGpoutCtrlAuxsrc::CLKSRC_GPIN0 as _ , 1474 // Gpin0 = ClkGpoutCtrlAuxsrc::CLKSRC_GPIN0 as _ ,
1456 // Gpin1 = ClkGpoutCtrlAuxsrc::CLKSRC_GPIN1 as _ , 1475 // Gpin1 = ClkGpoutCtrlAuxsrc::CLKSRC_GPIN1 as _ ,
1457 /// USB PLL. 1476 /// USB PLL.
@@ -1547,6 +1566,7 @@ impl<'d, T: GpoutPin> Gpout<'d, T> {
1547 1566
1548 let base = match src { 1567 let base = match src {
1549 ClkGpoutCtrlAuxsrc::CLKSRC_PLL_SYS => pll_sys_freq(), 1568 ClkGpoutCtrlAuxsrc::CLKSRC_PLL_SYS => pll_sys_freq(),
1569 // See above re gpin handling being commented out
1550 // ClkGpoutCtrlAuxsrc::CLKSRC_GPIN0 => gpin0_freq(), 1570 // ClkGpoutCtrlAuxsrc::CLKSRC_GPIN0 => gpin0_freq(),
1551 // ClkGpoutCtrlAuxsrc::CLKSRC_GPIN1 => gpin1_freq(), 1571 // ClkGpoutCtrlAuxsrc::CLKSRC_GPIN1 => gpin1_freq(),
1552 ClkGpoutCtrlAuxsrc::CLKSRC_PLL_USB => pll_usb_freq(), 1572 ClkGpoutCtrlAuxsrc::CLKSRC_PLL_USB => pll_usb_freq(),
@@ -1555,7 +1575,6 @@ impl<'d, T: GpoutPin> Gpout<'d, T> {
1555 ClkGpoutCtrlAuxsrc::CLK_SYS => clk_sys_freq(), 1575 ClkGpoutCtrlAuxsrc::CLK_SYS => clk_sys_freq(),
1556 ClkGpoutCtrlAuxsrc::CLK_USB => clk_usb_freq(), 1576 ClkGpoutCtrlAuxsrc::CLK_USB => clk_usb_freq(),
1557 ClkGpoutCtrlAuxsrc::CLK_ADC => clk_adc_freq(), 1577 ClkGpoutCtrlAuxsrc::CLK_ADC => clk_adc_freq(),
1558 //ClkGpoutCtrlAuxsrc::CLK_RTC => clk_rtc_freq() as _,
1559 ClkGpoutCtrlAuxsrc::CLK_REF => clk_ref_freq(), 1578 ClkGpoutCtrlAuxsrc::CLK_REF => clk_ref_freq(),
1560 _ => unreachable!(), 1579 _ => unreachable!(),
1561 }; 1580 };
@@ -1918,21 +1937,21 @@ mod tests {
1918 { 1937 {
1919 // Test automatic voltage scaling based on frequency 1938 // Test automatic voltage scaling based on frequency
1920 // Under 133 MHz should use default voltage (V1_10) 1939 // Under 133 MHz should use default voltage (V1_10)
1921 let config = ClockConfig::crystal_freq(125_000_000); 1940 let config = ClockConfig::system_freq(125_000_000);
1922 assert_eq!(config.core_voltage, CoreVoltage::V1_10); 1941 assert_eq!(config.core_voltage, CoreVoltage::V1_10);
1923 1942
1924 // 133-200 MHz should use V1_15 1943 // 133-200 MHz should use V1_15
1925 let config = ClockConfig::crystal_freq(150_000_000); 1944 let config = ClockConfig::system_freq(150_000_000);
1926 assert_eq!(config.core_voltage, CoreVoltage::V1_15); 1945 assert_eq!(config.core_voltage, CoreVoltage::V1_15);
1927 let config = ClockConfig::crystal_freq(200_000_000); 1946 let config = ClockConfig::system_freq(200_000_000);
1928 assert_eq!(config.core_voltage, CoreVoltage::V1_15); 1947 assert_eq!(config.core_voltage, CoreVoltage::V1_15);
1929 1948
1930 // Above 200 MHz should use V1_25 1949 // Above 200 MHz should use V1_25
1931 let config = ClockConfig::crystal_freq(250_000_000); 1950 let config = ClockConfig::system_freq(250_000_000);
1932 assert_eq!(config.core_voltage, CoreVoltage::V1_15); 1951 assert_eq!(config.core_voltage, CoreVoltage::V1_15);
1933 1952
1934 // Below 125 MHz should use V1_10 1953 // Below 125 MHz should use V1_10
1935 let config = ClockConfig::crystal_freq(100_000_000); 1954 let config = ClockConfig::system_freq(100_000_000);
1936 assert_eq!(config.core_voltage, CoreVoltage::V1_10); 1955 assert_eq!(config.core_voltage, CoreVoltage::V1_10);
1937 } 1956 }
1938 } 1957 }