esp32c2 support

This commit is contained in:
ivmarkov 2023-10-18 10:32:40 +00:00
parent 846f9dd26c
commit 3cbefd5599

View File

@ -95,10 +95,15 @@ pub mod config {
#[derive(Clone, Copy, Debug, Eq, PartialEq, Default)] #[derive(Clone, Copy, Debug, Eq, PartialEq, Default)]
pub enum ClockSource { pub enum ClockSource {
/// Use PLL_F160M as the source clock /// Use PLL_F160M as the source clock
#[cfg(not(any(esp32h2, esp32c6)))] #[cfg(not(any(esp32h2, esp32c2, esp32c6)))]
#[default] #[default]
Pll160M, Pll160M,
/// Use PLL_F60M as the source clock
#[cfg(esp32c2)]
#[default]
Pll60M,
/// Use PLL_F64M as the source clock /// Use PLL_F64M as the source clock
#[cfg(any(esp32h2, esp32c6))] #[cfg(any(esp32h2, esp32c6))]
#[default] #[default]
@ -114,11 +119,16 @@ pub mod config {
#[allow(clippy::unnecessary_cast)] #[allow(clippy::unnecessary_cast)]
pub(super) fn as_sdk(&self) -> i2s_clock_src_t { pub(super) fn as_sdk(&self) -> i2s_clock_src_t {
match self { match self {
#[cfg(not(any(esp32h2, esp32c6)))] #[cfg(not(any(esp32h2, esp32c2, esp32c6)))]
Self::Pll160M => core::convert::TryInto::try_into( Self::Pll160M => core::convert::TryInto::try_into(
esp_idf_sys::soc_module_clk_t_SOC_MOD_CLK_PLL_F160M, esp_idf_sys::soc_module_clk_t_SOC_MOD_CLK_PLL_F160M,
) )
.unwrap(), .unwrap(),
#[cfg(esp32c2)]
Self::Pll60M => core::convert::TryInto::try_into(
esp_idf_sys::soc_module_clk_t_SOC_MOD_CLK_PLL_F60M,
)
.unwrap(),
#[cfg(any(esp32h2, esp32c6))] #[cfg(any(esp32h2, esp32c6))]
Self::Pll64M => core::convert::TryInto::try_into( Self::Pll64M => core::convert::TryInto::try_into(
esp_idf_sys::soc_module_clk_t_SOC_MOD_CLK_PLL_F64M, esp_idf_sys::soc_module_clk_t_SOC_MOD_CLK_PLL_F64M,