mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
2e31cce390
Previous APIs used to set CPU frequency used CPU frequencies listed in rtc_cpu_freq_t enumeration. This was problematic for two reasons. First, supporting many possible frequency values obtained by dividing XTAL frequency was hard, as every value would have to be listed in the enumeration. Since different base XTAL frequencies are supported, this further complicated things, since not all of these divided frequencies would be valid for any given XTAL frequency. Second, having to deal with enumeration values often involved switch statements to convert between enumeration and MHz values, handle PLL/XTAL frequencies separately, etc. This change introduces rtc_cpu_freq_config_t structure, which contains CPU frequency (in MHz) and information on how this frequency has to be generated: clock source (XTAL/PLL), source frequency, clock divider value. More fields can be added to this structure in the future. This structure simplifies many parts of the code, since both frequency value and frequency generation settings can be accessed in any place in code without the need for conversions. Additionally, this change adds setting of REF_TICK dividers to support frequencies lower then XTAL with DFS.