@@ -537,44 +537,44 @@ uint64_t EspClass::getEfuseMac(void) {
537
537
*/
538
538
uint8_t EspClass::getFlashSourceFrequencyMHz (void ) {
539
539
#if CONFIG_IDF_TARGET_ESP32
540
- // ESP32 classic : Use HAL function
540
+ // ESP32: Use HAL function
541
541
return spi_flash_ll_get_source_clock_freq_mhz (0 ); // host_id = 0 for SPI0
542
542
#else
543
- // For newer chips (S2, S3, C2, C3, C6, H2) : Use spimem HAL function
543
+ // All modern MCUs : Use spimem HAL function
544
544
return spimem_flash_ll_get_source_freq_mhz ();
545
545
#endif
546
546
}
547
547
548
548
/* *
549
549
* @brief Read the clock divider from hardware using HAL structures
550
550
* Based on ESP-IDF HAL implementation:
551
- * - ESP32 classic : Uses SPI1.clock (typedef in spi_flash_ll.h line 52 )
552
- * - All modern chips : Use SPIMEM1.clock (typedef in spimem_flash_ll.h)
551
+ * - ESP32: Uses SPI1.clock (typedef in spi_flash_ll.h)
552
+ * - All newer MCUs : Use SPIMEM1.clock (typedef in spimem_flash_ll.h)
553
553
* @return Clock divider value (1 = no division, 2 = divide by 2, etc.)
554
554
*/
555
555
uint8_t EspClass::getFlashClockDivider (void ) {
556
556
#if CONFIG_IDF_TARGET_ESP32
557
- // ESP32 classic : Flash uses SPI1 peripheral (not SPI0)
558
- // See: esp-idf/components/hal/esp32/include/hal/spi_flash_ll.h line 52
557
+ // ESP32: Flash uses SPI1
558
+ // See: line 52: esp-idf/components/hal/esp32/include/hal/spi_flash_ll.h
559
559
if (SPI1.clock .clk_equ_sysclk ) {
560
- return 1 ; // 1:1 clock (no divider)
560
+ return 1 ; // 1:1 clock
561
561
}
562
562
return SPI1.clock .clkcnt_n + 1 ;
563
563
#else
564
- // All modern chips (S2, S3, C2, C3, C5, C6, C61, H2, P4) : Flash uses SPIMEM1
564
+ // All newer MCUs : Flash uses SPIMEM1
565
565
// See: esp-idf/components/hal/esp32*/include/hal/spimem_flash_ll.h
566
566
// Example S3: line 38: typedef typeof(SPIMEM1.clock.val) spimem_flash_ll_clock_reg_t;
567
- // Example C5: esp-idf/components/soc/esp32c5/mp/include/soc/spi_mem_struct.h lines 97-99
567
+ // Example C5: lines 97-99: esp-idf/components/soc/esp32c5/mp/include/soc/spi_mem_struct.h
568
568
if (SPIMEM1.clock .clk_equ_sysclk ) {
569
- return 1 ; // 1:1 clock (no divider)
569
+ return 1 ; // 1:1 clock
570
570
}
571
571
return SPIMEM1.clock .clkcnt_n + 1 ;
572
572
#endif
573
573
}
574
574
575
575
/* *
576
576
* @brief Get the actual flash frequency in MHz
577
- * @return Flash frequency in MHz (e.g., 80, 120, 160, 240)
577
+ * @return Flash frequency in MHz (80, 120, 160, or 240)
578
578
*/
579
579
uint32_t EspClass::getFlashFrequencyMHz (void ) {
580
580
uint8_t source = getFlashSourceFrequencyMHz ();
0 commit comments