@@ -521,24 +521,7 @@ uint64_t EspClass::getEfuseMac(void) {
521521// Flash Frequency Runtime Detection
522522// ============================================================================
523523
524- // Define SPI0 base addresses for different chips
525- #if CONFIG_IDF_TARGET_ESP32S3
526- #define FLASH_SPI0_BASE 0x60003000
527- #elif CONFIG_IDF_TARGET_ESP32S2
528- #define FLASH_SPI0_BASE 0x3f402000
529- #elif CONFIG_IDF_TARGET_ESP32C3
530- #define FLASH_SPI0_BASE 0x60002000
531- #elif CONFIG_IDF_TARGET_ESP32C2
532- #define FLASH_SPI0_BASE 0x60002000
533- #elif CONFIG_IDF_TARGET_ESP32C6
534- #define FLASH_SPI0_BASE 0x60003000
535- #elif CONFIG_IDF_TARGET_ESP32H2
536- #define FLASH_SPI0_BASE 0x60003000
537- #elif CONFIG_IDF_TARGET_ESP32
538- #define FLASH_SPI0_BASE 0x3ff42000
539- #else
540- #define FLASH_SPI0_BASE 0x60003000 // Default for new chips
541- #endif
524+ // Note: DR_REG_SPI0_BASE is defined in soc/soc.h or soc/reg_base.h for each chip
542525
543526// Register offsets
544527#define FLASH_CORE_CLK_SEL_OFFSET 0x80
@@ -554,7 +537,7 @@ uint8_t EspClass::getFlashSourceFrequencyMHz(void) {
554537 // Note: ESP32 uses the PLL clock (80 MHz) as source and divides it
555538 return 80 ; // Always 80 MHz source, divider determines 40/80 MHz
556539#else
557- volatile uint32_t * core_clk_reg = (volatile uint32_t *)(FLASH_SPI0_BASE + FLASH_CORE_CLK_SEL_OFFSET);
540+ volatile uint32_t * core_clk_reg = (volatile uint32_t *)(DR_REG_SPI0_BASE + FLASH_CORE_CLK_SEL_OFFSET);
558541 uint32_t core_clk_sel = (*core_clk_reg) & 0x3 ; // Bits 0-1
559542
560543 uint8_t source_freq = 80 ; // Default
@@ -595,7 +578,7 @@ uint8_t EspClass::getFlashSourceFrequencyMHz(void) {
595578 * @return Clock divider value (1 = no division, 2 = divide by 2, etc.)
596579 */
597580uint8_t EspClass::getFlashClockDivider (void ) {
598- volatile uint32_t * clock_reg = (volatile uint32_t *)(FLASH_SPI0_BASE + FLASH_CLOCK_OFFSET);
581+ volatile uint32_t * clock_reg = (volatile uint32_t *)(DR_REG_SPI0_BASE + FLASH_CLOCK_OFFSET);
599582 uint32_t clock_val = *clock_reg;
600583
601584 // Bit 31: if set, clock is 1:1 (no divider)
0 commit comments