@@ -1116,52 +1116,23 @@ impl Clocks {
11161116 #[ cfg( systimer) ]
11171117 #[ inline]
11181118 pub ( crate ) fn xtal_freq ( ) -> Rate {
1119- if esp_config:: esp_config_str!( "ESP_HAL_CONFIG_XTAL_FREQUENCY" ) == "auto"
1120- && let Some ( clocks) = Self :: try_get ( )
1121- {
1119+ if let Some ( clocks) = Self :: try_get ( ) {
11221120 return clocks. xtal_clock ;
11231121 }
11241122
11251123 Self :: measure_xtal_frequency ( ) . frequency ( )
11261124 }
11271125
1128- #[ cfg( not( esp32) ) ] // unused
1129- const fn xtal_frequency_from_config ( ) -> Option < XtalClock > {
1130- let frequency_conf = esp_config:: esp_config_str!( "ESP_HAL_CONFIG_XTAL_FREQUENCY" ) ;
1131-
1132- for_each_soc_xtal_options ! (
1133- ( all $( ( $freq: literal) ) , * ) => {
1134- paste:: paste! {
1135- return match frequency_conf. as_bytes( ) {
1136- b"auto" => None ,
1137-
1138- // If the frequency is a pre-set value for the chip, return the associated enum variant.
1139- $( _ if esp_config:: esp_config_int_parse!( u32 , frequency_conf) == $freq => Some ( XtalClock :: [ <_ $freq M >] ) , ) *
1140-
1141- _ => None ,
1142- } ;
1143- }
1144- } ;
1145- ) ;
1146- }
1147-
11481126 #[ cfg( not( esp32) ) ] // unused - the build-time config can be removed in favour of explicit configuration via esp_hal::init
11491127 fn measure_xtal_frequency ( ) -> XtalClock {
1150- if let Some ( clock) = const { Self :: xtal_frequency_from_config ( ) } {
1151- // Use the configured frequency
1152- clock
1153- } else if esp_config:: esp_config_str!( "ESP_HAL_CONFIG_XTAL_FREQUENCY" ) == "auto" {
1154- // TODO: we should be able to read from a retention register, but probe-rs flashes a
1155- // bootloader that assumes a frequency, instead of choosing a matching one.
1156- let mhz = RtcClock :: estimate_xtal_frequency ( ) ;
1157-
1158- debug ! ( "Working with a {}MHz crystal" , mhz) ;
1159-
1160- // Try to guess the closest possible crystal value.
1161- XtalClock :: closest_from_mhz ( mhz)
1162- } else {
1163- unreachable ! ( "Invalid crystal frequency configured, this should not be possible." )
1164- }
1128+ // TODO: we should be able to read from a retention register, but probe-rs flashes a
1129+ // bootloader that assumes a frequency, instead of choosing a matching one.
1130+ let mhz = RtcClock :: estimate_xtal_frequency ( ) ;
1131+
1132+ debug ! ( "Working with a {}MHz crystal" , mhz) ;
1133+
1134+ // Try to guess the closest possible crystal value.
1135+ XtalClock :: closest_from_mhz ( mhz)
11651136 }
11661137}
11671138
0 commit comments