#[doc = concat!("assert_eq!(chip_name, ", chip!(), ")")]
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! chip {
() => {
"esp32"
};
}
#[doc = concat!("assert_eq!(chip_name, ", chip_pretty!(), ")")]
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! chip_pretty {
() => {
"ESP32"
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! property {
("chip") => {
"esp32"
};
("arch") => {
"xtensa"
};
("cores") => {
2
};
("cores", str) => {
stringify!(2)
};
("trm") => {
"https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf"
};
("aes.dma") => {
false
};
("aes.has_split_text_registers") => {
false
};
("aes.endianness_configurable") => {
true
};
("bt.controller") => {
"btdm"
};
("dma.kind") => {
"pdma"
};
("dma.supports_mem2mem") => {
false
};
("dma.can_access_psram") => {
false
};
("dma.ext_mem_configurable_block_size") => {
false
};
("dma.separate_in_out_interrupts") => {
false
};
("gpio.has_bank_1") => {
true
};
("gpio.gpio_function") => {
2
};
("gpio.gpio_function", str) => {
stringify!(2)
};
("gpio.constant_0_input") => {
48
};
("gpio.constant_0_input", str) => {
stringify!(48)
};
("gpio.constant_1_input") => {
56
};
("gpio.constant_1_input", str) => {
stringify!(56)
};
("gpio.remap_iomux_pin_registers") => {
true
};
("gpio.func_in_sel_offset") => {
0
};
("gpio.func_in_sel_offset", str) => {
stringify!(0)
};
("gpio.input_signal_max") => {
206
};
("gpio.input_signal_max", str) => {
stringify!(206)
};
("gpio.output_signal_max") => {
256
};
("gpio.output_signal_max", str) => {
stringify!(256)
};
("i2c_master.has_fsm_timeouts") => {
false
};
("i2c_master.has_hw_bus_clear") => {
false
};
("i2c_master.has_bus_timeout_enable") => {
false
};
("i2c_master.separate_filter_config_registers") => {
true
};
("i2c_master.can_estimate_nack_reason") => {
false
};
("i2c_master.has_conf_update") => {
false
};
("i2c_master.has_reliable_fsm_reset") => {
false
};
("i2c_master.has_arbitration_en") => {
false
};
("i2c_master.has_tx_fifo_watermark") => {
false
};
("i2c_master.bus_timeout_is_exponential") => {
false
};
("i2c_master.i2c0_data_register_ahb_address") => {
1610690588
};
("i2c_master.i2c0_data_register_ahb_address", str) => {
stringify!(1610690588)
};
("i2c_master.max_bus_timeout") => {
1048575
};
("i2c_master.max_bus_timeout", str) => {
stringify!(1048575)
};
("i2c_master.ll_intr_mask") => {
262143
};
("i2c_master.ll_intr_mask", str) => {
stringify!(262143)
};
("i2c_master.fifo_size") => {
32
};
("i2c_master.fifo_size", str) => {
stringify!(32)
};
("interrupts.status_registers") => {
3
};
("interrupts.status_registers", str) => {
stringify!(3)
};
("phy.combo_module") => {
true
};
("psram.octal_spi") => {
false
};
("psram.extmem_origin") => {
1065353216
};
("psram.extmem_origin", str) => {
stringify!(1065353216)
};
("rmt.ram_start") => {
1073047552
};
("rmt.ram_start", str) => {
stringify!(1073047552)
};
("rmt.channel_ram_size") => {
64
};
("rmt.channel_ram_size", str) => {
stringify!(64)
};
("rmt.has_tx_immediate_stop") => {
false
};
("rmt.has_tx_loop_count") => {
false
};
("rmt.has_tx_loop_auto_stop") => {
false
};
("rmt.has_tx_carrier_data_only") => {
false
};
("rmt.has_tx_sync") => {
false
};
("rmt.has_rx_wrap") => {
false
};
("rmt.has_rx_demodulation") => {
false
};
("rmt.has_dma") => {
false
};
("rmt.has_per_channel_clock") => {
true
};
("rng.apb_cycle_wait_num") => {
16
};
("rng.apb_cycle_wait_num", str) => {
stringify!(16)
};
("rng.trng_supported") => {
true
};
("rsa.size_increment") => {
512
};
("rsa.size_increment", str) => {
stringify!(512)
};
("rsa.memory_size_bytes") => {
512
};
("rsa.memory_size_bytes", str) => {
stringify!(512)
};
("sha.dma") => {
false
};
("sleep.light_sleep") => {
true
};
("sleep.deep_sleep") => {
true
};
("soc.cpu_has_branch_predictor") => {
false
};
("soc.cpu_has_csr_pc") => {
false
};
("soc.multi_core_enabled") => {
true
};
("soc.rc_fast_clk_default") => {
8500000
};
("soc.rc_fast_clk_default", str) => {
stringify!(8500000)
};
("clock_tree.syscon_pre_div.divisor") => {
(0, 1023)
};
("clock_tree.ref_tick_pll.divisor") => {
(0, 255)
};
("clock_tree.ref_tick_apll.divisor") => {
(0, 255)
};
("clock_tree.ref_tick_xtal.divisor") => {
(0, 255)
};
("clock_tree.ref_tick_fosc.divisor") => {
(0, 255)
};
("clock_tree.uart.baud_rate_generator.fractional") => {
(0, 15)
};
("clock_tree.uart.baud_rate_generator.integral") => {
(0, 1048575)
};
("spi_master.supports_dma") => {
true
};
("spi_master.has_octal") => {
false
};
("spi_master.has_app_interrupts") => {
false
};
("spi_master.has_dma_segmented_transfer") => {
false
};
("spi_master.has_clk_pre_div") => {
false
};
("spi_slave.supports_dma") => {
true
};
("timergroup.timg_has_timer1") => {
true
};
("timergroup.timg_has_divcnt_rst") => {
false
};
("uart.ram_size") => {
128
};
("uart.ram_size", str) => {
stringify!(128)
};
("uart.peripheral_controls_mem_clk") => {
false
};
("uart.has_sclk_divider") => {
false
};
("uhci.combined_uart_selector_field") => {
false
};
("wifi.has_wifi6") => {
false
};
("wifi.mac_version") => {
1
};
("wifi.mac_version", str) => {
stringify!(1)
};
("wifi.has_5g") => {
false
};
("wifi.csi_supported") => {
true
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_aes_key_length {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner_aes_key_length { $(($pattern) => $code;)* ($other :
tt) => {} } _for_each_inner_aes_key_length!((128));
_for_each_inner_aes_key_length!((192)); _for_each_inner_aes_key_length!((256));
_for_each_inner_aes_key_length!((128, 0, 4));
_for_each_inner_aes_key_length!((192, 1, 5));
_for_each_inner_aes_key_length!((256, 2, 6));
_for_each_inner_aes_key_length!((bits(128), (192), (256)));
_for_each_inner_aes_key_length!((modes(128, 0, 4), (192, 1, 5), (256, 2, 6)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_sw_interrupt {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner_sw_interrupt { $(($pattern) => $code;)* ($other :
tt) => {} } _for_each_inner_sw_interrupt!((0, FROM_CPU_INTR0,
software_interrupt0)); _for_each_inner_sw_interrupt!((1, FROM_CPU_INTR1,
software_interrupt1)); _for_each_inner_sw_interrupt!((2, FROM_CPU_INTR2,
software_interrupt2)); _for_each_inner_sw_interrupt!((3, FROM_CPU_INTR3,
software_interrupt3)); _for_each_inner_sw_interrupt!((all(0, FROM_CPU_INTR0,
software_interrupt0), (1, FROM_CPU_INTR1, software_interrupt1), (2,
FROM_CPU_INTR2, software_interrupt2), (3, FROM_CPU_INTR3, software_interrupt3)));
};
}
#[macro_export]
macro_rules! sw_interrupt_delay {
() => {
unsafe {}
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_rmt_channel {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner_rmt_channel { $(($pattern) => $code;)* ($other : tt)
=> {} } _for_each_inner_rmt_channel!((0)); _for_each_inner_rmt_channel!((1));
_for_each_inner_rmt_channel!((2)); _for_each_inner_rmt_channel!((3));
_for_each_inner_rmt_channel!((4)); _for_each_inner_rmt_channel!((5));
_for_each_inner_rmt_channel!((6)); _for_each_inner_rmt_channel!((7));
_for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
_for_each_inner_rmt_channel!((2, 2)); _for_each_inner_rmt_channel!((3, 3));
_for_each_inner_rmt_channel!((4, 4)); _for_each_inner_rmt_channel!((5, 5));
_for_each_inner_rmt_channel!((6, 6)); _for_each_inner_rmt_channel!((7, 7));
_for_each_inner_rmt_channel!((0, 0)); _for_each_inner_rmt_channel!((1, 1));
_for_each_inner_rmt_channel!((2, 2)); _for_each_inner_rmt_channel!((3, 3));
_for_each_inner_rmt_channel!((4, 4)); _for_each_inner_rmt_channel!((5, 5));
_for_each_inner_rmt_channel!((6, 6)); _for_each_inner_rmt_channel!((7, 7));
_for_each_inner_rmt_channel!((all(0), (1), (2), (3), (4), (5), (6), (7)));
_for_each_inner_rmt_channel!((tx(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5),
(6, 6), (7, 7))); _for_each_inner_rmt_channel!((rx(0, 0), (1, 1), (2, 2), (3, 3),
(4, 4), (5, 5), (6, 6), (7, 7)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_rmt_clock_source {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner_rmt_clock_source { $(($pattern) => $code;)* ($other
: tt) => {} } _for_each_inner_rmt_clock_source!((RefTick, 0));
_for_each_inner_rmt_clock_source!((Apb, 1));
_for_each_inner_rmt_clock_source!((Apb));
_for_each_inner_rmt_clock_source!((all(RefTick, 0), (Apb, 1)));
_for_each_inner_rmt_clock_source!((default(Apb)));
_for_each_inner_rmt_clock_source!((is_boolean));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_rsa_exponentiation {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner_rsa_exponentiation { $(($pattern) => $code;)*
($other : tt) => {} } _for_each_inner_rsa_exponentiation!((512));
_for_each_inner_rsa_exponentiation!((1024));
_for_each_inner_rsa_exponentiation!((1536));
_for_each_inner_rsa_exponentiation!((2048));
_for_each_inner_rsa_exponentiation!((2560));
_for_each_inner_rsa_exponentiation!((3072));
_for_each_inner_rsa_exponentiation!((3584));
_for_each_inner_rsa_exponentiation!((4096));
_for_each_inner_rsa_exponentiation!((all(512), (1024), (1536), (2048), (2560),
(3072), (3584), (4096)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_rsa_multiplication {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner_rsa_multiplication { $(($pattern) => $code;)*
($other : tt) => {} } _for_each_inner_rsa_multiplication!((512));
_for_each_inner_rsa_multiplication!((1024));
_for_each_inner_rsa_multiplication!((1536));
_for_each_inner_rsa_multiplication!((2048));
_for_each_inner_rsa_multiplication!((all(512), (1024), (1536), (2048)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_sha_algorithm {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner_sha_algorithm { $(($pattern) => $code;)* ($other :
tt) => {} } _for_each_inner_sha_algorithm!((Sha1, "SHA-1"(sizes : 64, 20, 8)
(insecure_against : "collision", "length extension"), 0));
_for_each_inner_sha_algorithm!((Sha256, "SHA-256"(sizes : 64, 32, 8)
(insecure_against : "length extension"), 0));
_for_each_inner_sha_algorithm!((Sha384, "SHA-384"(sizes : 128, 48, 16)
(insecure_against :), 0)); _for_each_inner_sha_algorithm!((Sha512,
"SHA-512"(sizes : 128, 64, 16) (insecure_against : "length extension"), 0));
_for_each_inner_sha_algorithm!((algos(Sha1, "SHA-1"(sizes : 64, 20, 8)
(insecure_against : "collision", "length extension"), 0), (Sha256,
"SHA-256"(sizes : 64, 32, 8) (insecure_against : "length extension"), 0),
(Sha384, "SHA-384"(sizes : 128, 48, 16) (insecure_against :), 0), (Sha512,
"SHA-512"(sizes : 128, 64, 16) (insecure_against : "length extension"), 0)));
};
}
#[macro_export]
macro_rules! define_clock_tree_types {
() => {
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum McpwmInstance {
Mcpwm0 = 0,
Mcpwm1 = 1,
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum UartInstance {
Uart0 = 0,
Uart1 = 1,
Uart2 = 2,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum XtalClkConfig {
_26,
_40,
}
impl XtalClkConfig {
pub fn value(&self) -> u32 {
match self {
XtalClkConfig::_26 => 26000000,
XtalClkConfig::_40 => 40000000,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum PllClkConfig {
_320,
_480,
}
impl PllClkConfig {
pub fn value(&self) -> u32 {
match self {
PllClkConfig::_320 => 320000000,
PllClkConfig::_480 => 480000000,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct ApllClkConfig(u32);
impl ApllClkConfig {
pub const fn new(frequency: u32) -> Self {
::core::assert!(
frequency >= 16000000u32 && frequency <= 128000000u32,
"`APLL_CLK` output frequency value must be between 16000000 and 128000000 \
(inclusive)."
);
Self(frequency)
}
}
impl ApllClkConfig {
pub fn value(&self) -> u32 {
self.0
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum CpuPllDivInConfig {
Pll,
Apll,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum CpuPllDivDivisor {
_2 = 2,
_4 = 4,
}
impl CpuPllDivDivisor {
pub const fn new(raw: u32) -> Self {
match raw {
2 => Self::_2,
4 => Self::_4,
_ => ::core::panic!("Invalid CPU_PLL_DIV divisor value"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct CpuPllDivConfig {
divisor: CpuPllDivDivisor,
}
impl CpuPllDivConfig {
pub const fn new(divisor: CpuPllDivDivisor) -> Self {
Self { divisor }
}
fn divisor(self) -> u32 {
self.divisor as u32
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum SysconPreDivInConfig {
Xtal,
RcFast,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct SysconPreDivConfig {
divisor: u32,
}
impl SysconPreDivConfig {
pub const fn new(divisor: u32) -> Self {
::core::assert!(
divisor <= 1023,
"`SYSCON_PRE_DIV` divisor must be between 0 and 1023 (inclusive)."
);
Self { divisor }
}
fn divisor(self) -> u32 {
self.divisor as u32
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ApbClkConfig {
Pll80m,
CpuDiv2,
Cpu,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum RefTickConfig {
Pll,
Apll,
Xtal,
Fosc,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct RefTickXtalConfig {
divisor: u32,
}
impl RefTickXtalConfig {
pub const fn new(divisor: u32) -> Self {
::core::assert!(
divisor <= 255,
"`REF_TICK_XTAL` divisor must be between 0 and 255 (inclusive)."
);
Self { divisor }
}
fn divisor(self) -> u32 {
self.divisor as u32
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct RefTickFoscConfig {
divisor: u32,
}
impl RefTickFoscConfig {
pub const fn new(divisor: u32) -> Self {
::core::assert!(
divisor <= 255,
"`REF_TICK_FOSC` divisor must be between 0 and 255 (inclusive)."
);
Self { divisor }
}
fn divisor(self) -> u32 {
self.divisor as u32
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct RefTickApllConfig {
divisor: u32,
}
impl RefTickApllConfig {
pub const fn new(divisor: u32) -> Self {
::core::assert!(
divisor <= 255,
"`REF_TICK_APLL` divisor must be between 0 and 255 (inclusive)."
);
Self { divisor }
}
fn divisor(self) -> u32 {
self.divisor as u32
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct RefTickPllConfig {
divisor: u32,
}
impl RefTickPllConfig {
pub const fn new(divisor: u32) -> Self {
::core::assert!(
divisor <= 255,
"`REF_TICK_PLL` divisor must be between 0 and 255 (inclusive)."
);
Self { divisor }
}
fn divisor(self) -> u32 {
self.divisor as u32
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum CpuClkConfig {
Xtal,
RcFast,
Apll,
Pll,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum RtcSlowClkConfig {
Xtal32k,
RcSlow,
RcFast,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum RtcFastClkConfig {
Xtal,
Rc,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum TimgCalibrationClockConfig {
RcSlowClk,
RcFastDivClk,
Xtal32kClk,
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum McpwmFunctionClockConfig {
#[default]
PllF160m,
}
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum UartFunctionClockSclk {
#[default]
Apb,
RefTick,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct UartFunctionClockConfig {
sclk: UartFunctionClockSclk,
}
impl UartFunctionClockConfig {
pub const fn new(sclk: UartFunctionClockSclk) -> Self {
Self { sclk }
}
fn sclk(self) -> UartFunctionClockSclk {
self.sclk
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct UartMemClockConfig {}
impl UartMemClockConfig {
pub const fn new() -> Self {
Self {}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub struct UartBaudRateGeneratorConfig {
fractional: u32,
integral: u32,
}
impl UartBaudRateGeneratorConfig {
pub const fn new(fractional: u32, integral: u32) -> Self {
::core::assert!(
fractional <= 15,
"`UART0_BAUD_RATE_GENERATOR` fractional must be between 0 and 15 (inclusive)."
);
::core::assert!(
integral <= 1048575,
"`UART0_BAUD_RATE_GENERATOR` integral must be between 0 and 1048575 \
(inclusive)."
);
Self {
fractional,
integral,
}
}
fn fractional(self) -> u32 {
self.fractional as u32
}
fn integral(self) -> u32 {
self.integral as u32
}
}
pub struct ClockTree {
xtal_clk: Option<XtalClkConfig>,
pll_clk: Option<PllClkConfig>,
apll_clk: Option<ApllClkConfig>,
cpu_pll_div_in: Option<CpuPllDivInConfig>,
cpu_pll_div: Option<CpuPllDivConfig>,
syscon_pre_div_in: Option<SysconPreDivInConfig>,
syscon_pre_div: Option<SysconPreDivConfig>,
apb_clk: Option<ApbClkConfig>,
ref_tick: Option<RefTickConfig>,
ref_tick_xtal: Option<RefTickXtalConfig>,
ref_tick_fosc: Option<RefTickFoscConfig>,
ref_tick_apll: Option<RefTickApllConfig>,
ref_tick_pll: Option<RefTickPllConfig>,
cpu_clk: Option<CpuClkConfig>,
rtc_slow_clk: Option<RtcSlowClkConfig>,
rtc_fast_clk: Option<RtcFastClkConfig>,
timg_calibration_clock: Option<TimgCalibrationClockConfig>,
mcpwm_function_clock: [Option<McpwmFunctionClockConfig>; 2],
uart_function_clock: [Option<UartFunctionClockConfig>; 3],
uart_mem_clock: [Option<UartMemClockConfig>; 3],
uart_baud_rate_generator: [Option<UartBaudRateGeneratorConfig>; 3],
pll_clk_refcount: u32,
rc_fast_clk_refcount: u32,
pll_f160m_clk_refcount: u32,
apb_clk_refcount: u32,
ref_tick_refcount: u32,
xtal32k_clk_refcount: u32,
rc_slow_clk_refcount: u32,
rc_fast_div_clk_refcount: u32,
rtc_slow_clk_refcount: u32,
rtc_fast_clk_refcount: u32,
uart_mem_clk_refcount: u32,
timg_calibration_clock_refcount: u32,
mcpwm_function_clock_refcount: [u32; 2],
uart_function_clock_refcount: [u32; 3],
uart_mem_clock_refcount: [u32; 3],
uart_baud_rate_generator_refcount: [u32; 3],
}
impl ClockTree {
pub fn with<R>(f: impl FnOnce(&mut ClockTree) -> R) -> R {
CLOCK_TREE.with(f)
}
pub fn xtal_clk(&self) -> Option<XtalClkConfig> {
self.xtal_clk
}
pub fn pll_clk(&self) -> Option<PllClkConfig> {
self.pll_clk
}
pub fn apll_clk(&self) -> Option<ApllClkConfig> {
self.apll_clk
}
pub fn cpu_pll_div_in(&self) -> Option<CpuPllDivInConfig> {
self.cpu_pll_div_in
}
pub fn cpu_pll_div(&self) -> Option<CpuPllDivConfig> {
self.cpu_pll_div
}
pub fn syscon_pre_div_in(&self) -> Option<SysconPreDivInConfig> {
self.syscon_pre_div_in
}
pub fn syscon_pre_div(&self) -> Option<SysconPreDivConfig> {
self.syscon_pre_div
}
pub fn apb_clk(&self) -> Option<ApbClkConfig> {
self.apb_clk
}
pub fn ref_tick(&self) -> Option<RefTickConfig> {
self.ref_tick
}
pub fn ref_tick_xtal(&self) -> Option<RefTickXtalConfig> {
self.ref_tick_xtal
}
pub fn ref_tick_fosc(&self) -> Option<RefTickFoscConfig> {
self.ref_tick_fosc
}
pub fn ref_tick_apll(&self) -> Option<RefTickApllConfig> {
self.ref_tick_apll
}
pub fn ref_tick_pll(&self) -> Option<RefTickPllConfig> {
self.ref_tick_pll
}
pub fn cpu_clk(&self) -> Option<CpuClkConfig> {
self.cpu_clk
}
pub fn rtc_slow_clk(&self) -> Option<RtcSlowClkConfig> {
self.rtc_slow_clk
}
pub fn rtc_fast_clk(&self) -> Option<RtcFastClkConfig> {
self.rtc_fast_clk
}
pub fn timg_calibration_clock(&self) -> Option<TimgCalibrationClockConfig> {
self.timg_calibration_clock
}
pub fn mcpwm0_function_clock(&self) -> Option<McpwmFunctionClockConfig> {
self.mcpwm_function_clock[McpwmInstance::Mcpwm0 as usize]
}
pub fn mcpwm1_function_clock(&self) -> Option<McpwmFunctionClockConfig> {
self.mcpwm_function_clock[McpwmInstance::Mcpwm1 as usize]
}
pub fn uart0_function_clock(&self) -> Option<UartFunctionClockConfig> {
self.uart_function_clock[UartInstance::Uart0 as usize]
}
pub fn uart0_mem_clock(&self) -> Option<UartMemClockConfig> {
self.uart_mem_clock[UartInstance::Uart0 as usize]
}
pub fn uart0_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
self.uart_baud_rate_generator[UartInstance::Uart0 as usize]
}
pub fn uart1_function_clock(&self) -> Option<UartFunctionClockConfig> {
self.uart_function_clock[UartInstance::Uart1 as usize]
}
pub fn uart1_mem_clock(&self) -> Option<UartMemClockConfig> {
self.uart_mem_clock[UartInstance::Uart1 as usize]
}
pub fn uart1_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
self.uart_baud_rate_generator[UartInstance::Uart1 as usize]
}
pub fn uart2_function_clock(&self) -> Option<UartFunctionClockConfig> {
self.uart_function_clock[UartInstance::Uart2 as usize]
}
pub fn uart2_mem_clock(&self) -> Option<UartMemClockConfig> {
self.uart_mem_clock[UartInstance::Uart2 as usize]
}
pub fn uart2_baud_rate_generator(&self) -> Option<UartBaudRateGeneratorConfig> {
self.uart_baud_rate_generator[UartInstance::Uart2 as usize]
}
}
static CLOCK_TREE: ::esp_sync::NonReentrantMutex<ClockTree> =
::esp_sync::NonReentrantMutex::new(ClockTree {
xtal_clk: None,
pll_clk: None,
apll_clk: None,
cpu_pll_div_in: None,
cpu_pll_div: None,
syscon_pre_div_in: None,
syscon_pre_div: None,
apb_clk: None,
ref_tick: None,
ref_tick_xtal: None,
ref_tick_fosc: None,
ref_tick_apll: None,
ref_tick_pll: None,
cpu_clk: None,
rtc_slow_clk: None,
rtc_fast_clk: None,
timg_calibration_clock: None,
mcpwm_function_clock: [None; 2],
uart_function_clock: [None; 3],
uart_mem_clock: [None; 3],
uart_baud_rate_generator: [None; 3],
pll_clk_refcount: 0,
rc_fast_clk_refcount: 0,
pll_f160m_clk_refcount: 0,
apb_clk_refcount: 0,
ref_tick_refcount: 0,
xtal32k_clk_refcount: 0,
rc_slow_clk_refcount: 0,
rc_fast_div_clk_refcount: 0,
rtc_slow_clk_refcount: 0,
rtc_fast_clk_refcount: 0,
uart_mem_clk_refcount: 0,
timg_calibration_clock_refcount: 0,
mcpwm_function_clock_refcount: [0; 2],
uart_function_clock_refcount: [0; 3],
uart_mem_clock_refcount: [0; 3],
uart_baud_rate_generator_refcount: [0; 3],
});
pub fn configure_xtal_clk(clocks: &mut ClockTree, config: XtalClkConfig) {
let old_config = clocks.xtal_clk.replace(config);
configure_xtal_clk_impl(clocks, old_config, config);
}
pub fn xtal_clk_config(clocks: &mut ClockTree) -> Option<XtalClkConfig> {
clocks.xtal_clk
}
fn request_xtal_clk(_clocks: &mut ClockTree) {}
fn release_xtal_clk(_clocks: &mut ClockTree) {}
#[allow(unused_variables)]
pub fn xtal_clk_config_frequency(clocks: &mut ClockTree, config: XtalClkConfig) -> u32 {
config.value()
}
pub fn xtal_clk_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.xtal_clk {
xtal_clk_config_frequency(clocks, config)
} else {
0
}
}
pub fn configure_pll_clk(clocks: &mut ClockTree, config: PllClkConfig) {
if clocks.cpu_pll_div.is_some() {
assert!(
!((config.value() == 480000000)
&& (unwrap!(clocks.cpu_pll_div).divisor() == 4))
);
}
let old_config = clocks.pll_clk.replace(config);
configure_pll_clk_impl(clocks, old_config, config);
}
pub fn pll_clk_config(clocks: &mut ClockTree) -> Option<PllClkConfig> {
clocks.pll_clk
}
pub fn request_pll_clk(clocks: &mut ClockTree) {
trace!("Requesting PLL_CLK");
if increment_reference_count(&mut clocks.pll_clk_refcount) {
trace!("Enabling PLL_CLK");
request_xtal_clk(clocks);
enable_pll_clk_impl(clocks, true);
}
}
pub fn release_pll_clk(clocks: &mut ClockTree) {
trace!("Releasing PLL_CLK");
if decrement_reference_count(&mut clocks.pll_clk_refcount) {
trace!("Disabling PLL_CLK");
enable_pll_clk_impl(clocks, false);
release_xtal_clk(clocks);
}
}
#[allow(unused_variables)]
pub fn pll_clk_config_frequency(clocks: &mut ClockTree, config: PllClkConfig) -> u32 {
config.value()
}
pub fn pll_clk_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.pll_clk {
pll_clk_config_frequency(clocks, config)
} else {
0
}
}
pub fn configure_apll_clk(clocks: &mut ClockTree, config: ApllClkConfig) {
let old_config = clocks.apll_clk.replace(config);
configure_apll_clk_impl(clocks, old_config, config);
}
pub fn apll_clk_config(clocks: &mut ClockTree) -> Option<ApllClkConfig> {
clocks.apll_clk
}
pub fn request_apll_clk(clocks: &mut ClockTree) {
trace!("Requesting APLL_CLK");
trace!("Enabling APLL_CLK");
request_pll_clk(clocks);
enable_apll_clk_impl(clocks, true);
}
pub fn release_apll_clk(clocks: &mut ClockTree) {
trace!("Releasing APLL_CLK");
trace!("Disabling APLL_CLK");
enable_apll_clk_impl(clocks, false);
release_pll_clk(clocks);
}
#[allow(unused_variables)]
pub fn apll_clk_config_frequency(clocks: &mut ClockTree, config: ApllClkConfig) -> u32 {
config.value()
}
pub fn apll_clk_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.apll_clk {
apll_clk_config_frequency(clocks, config)
} else {
0
}
}
pub fn request_rc_fast_clk(clocks: &mut ClockTree) {
trace!("Requesting RC_FAST_CLK");
if increment_reference_count(&mut clocks.rc_fast_clk_refcount) {
trace!("Enabling RC_FAST_CLK");
enable_rc_fast_clk_impl(clocks, true);
}
}
pub fn release_rc_fast_clk(clocks: &mut ClockTree) {
trace!("Releasing RC_FAST_CLK");
if decrement_reference_count(&mut clocks.rc_fast_clk_refcount) {
trace!("Disabling RC_FAST_CLK");
enable_rc_fast_clk_impl(clocks, false);
}
}
pub fn rc_fast_clk_frequency(clocks: &mut ClockTree) -> u32 {
8000000
}
pub fn request_pll_f160m_clk(clocks: &mut ClockTree) {
trace!("Requesting PLL_F160M_CLK");
if increment_reference_count(&mut clocks.pll_f160m_clk_refcount) {
trace!("Enabling PLL_F160M_CLK");
request_pll_clk(clocks);
enable_pll_f160m_clk_impl(clocks, true);
}
}
pub fn release_pll_f160m_clk(clocks: &mut ClockTree) {
trace!("Releasing PLL_F160M_CLK");
if decrement_reference_count(&mut clocks.pll_f160m_clk_refcount) {
trace!("Disabling PLL_F160M_CLK");
enable_pll_f160m_clk_impl(clocks, false);
release_pll_clk(clocks);
}
}
pub fn pll_f160m_clk_frequency(clocks: &mut ClockTree) -> u32 {
160000000
}
pub fn configure_cpu_pll_div_in(clocks: &mut ClockTree, new_selector: CpuPllDivInConfig) {
let old_selector = clocks.cpu_pll_div_in.replace(new_selector);
match new_selector {
CpuPllDivInConfig::Pll => request_pll_clk(clocks),
CpuPllDivInConfig::Apll => request_apll_clk(clocks),
}
configure_cpu_pll_div_in_impl(clocks, old_selector, new_selector);
if let Some(old_selector) = old_selector {
match old_selector {
CpuPllDivInConfig::Pll => release_pll_clk(clocks),
CpuPllDivInConfig::Apll => release_apll_clk(clocks),
}
}
}
pub fn cpu_pll_div_in_config(clocks: &mut ClockTree) -> Option<CpuPllDivInConfig> {
clocks.cpu_pll_div_in
}
pub fn request_cpu_pll_div_in(clocks: &mut ClockTree) {
trace!("Requesting CPU_PLL_DIV_IN");
trace!("Enabling CPU_PLL_DIV_IN");
match unwrap!(clocks.cpu_pll_div_in) {
CpuPllDivInConfig::Pll => request_pll_clk(clocks),
CpuPllDivInConfig::Apll => request_apll_clk(clocks),
}
enable_cpu_pll_div_in_impl(clocks, true);
}
pub fn release_cpu_pll_div_in(clocks: &mut ClockTree) {
trace!("Releasing CPU_PLL_DIV_IN");
trace!("Disabling CPU_PLL_DIV_IN");
enable_cpu_pll_div_in_impl(clocks, false);
match unwrap!(clocks.cpu_pll_div_in) {
CpuPllDivInConfig::Pll => release_pll_clk(clocks),
CpuPllDivInConfig::Apll => release_apll_clk(clocks),
}
}
#[allow(unused_variables)]
pub fn cpu_pll_div_in_config_frequency(
clocks: &mut ClockTree,
config: CpuPllDivInConfig,
) -> u32 {
match config {
CpuPllDivInConfig::Pll => pll_clk_frequency(clocks),
CpuPllDivInConfig::Apll => apll_clk_frequency(clocks),
}
}
pub fn cpu_pll_div_in_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.cpu_pll_div_in {
cpu_pll_div_in_config_frequency(clocks, config)
} else {
0
}
}
pub fn configure_cpu_pll_div(clocks: &mut ClockTree, config: CpuPllDivConfig) {
if clocks.pll_clk.is_some() {
assert!(!((pll_clk_frequency(clocks) == 480000000) && (config.divisor() == 4)));
}
let old_config = clocks.cpu_pll_div.replace(config);
configure_cpu_pll_div_impl(clocks, old_config, config);
}
pub fn cpu_pll_div_config(clocks: &mut ClockTree) -> Option<CpuPllDivConfig> {
clocks.cpu_pll_div
}
pub fn request_cpu_pll_div(clocks: &mut ClockTree) {
trace!("Requesting CPU_PLL_DIV");
trace!("Enabling CPU_PLL_DIV");
request_cpu_pll_div_in(clocks);
enable_cpu_pll_div_impl(clocks, true);
}
pub fn release_cpu_pll_div(clocks: &mut ClockTree) {
trace!("Releasing CPU_PLL_DIV");
trace!("Disabling CPU_PLL_DIV");
enable_cpu_pll_div_impl(clocks, false);
release_cpu_pll_div_in(clocks);
}
#[allow(unused_variables)]
pub fn cpu_pll_div_config_frequency(
clocks: &mut ClockTree,
config: CpuPllDivConfig,
) -> u32 {
(cpu_pll_div_in_frequency(clocks) / config.divisor())
}
pub fn cpu_pll_div_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.cpu_pll_div {
cpu_pll_div_config_frequency(clocks, config)
} else {
0
}
}
pub fn configure_syscon_pre_div_in(
clocks: &mut ClockTree,
new_selector: SysconPreDivInConfig,
) {
let old_selector = clocks.syscon_pre_div_in.replace(new_selector);
match new_selector {
SysconPreDivInConfig::Xtal => request_xtal_clk(clocks),
SysconPreDivInConfig::RcFast => request_rc_fast_clk(clocks),
}
configure_syscon_pre_div_in_impl(clocks, old_selector, new_selector);
if let Some(old_selector) = old_selector {
match old_selector {
SysconPreDivInConfig::Xtal => release_xtal_clk(clocks),
SysconPreDivInConfig::RcFast => release_rc_fast_clk(clocks),
}
}
}
pub fn syscon_pre_div_in_config(clocks: &mut ClockTree) -> Option<SysconPreDivInConfig> {
clocks.syscon_pre_div_in
}
pub fn request_syscon_pre_div_in(clocks: &mut ClockTree) {
trace!("Requesting SYSCON_PRE_DIV_IN");
trace!("Enabling SYSCON_PRE_DIV_IN");
match unwrap!(clocks.syscon_pre_div_in) {
SysconPreDivInConfig::Xtal => request_xtal_clk(clocks),
SysconPreDivInConfig::RcFast => request_rc_fast_clk(clocks),
}
enable_syscon_pre_div_in_impl(clocks, true);
}
pub fn release_syscon_pre_div_in(clocks: &mut ClockTree) {
trace!("Releasing SYSCON_PRE_DIV_IN");
trace!("Disabling SYSCON_PRE_DIV_IN");
enable_syscon_pre_div_in_impl(clocks, false);
match unwrap!(clocks.syscon_pre_div_in) {
SysconPreDivInConfig::Xtal => release_xtal_clk(clocks),
SysconPreDivInConfig::RcFast => release_rc_fast_clk(clocks),
}
}
#[allow(unused_variables)]
pub fn syscon_pre_div_in_config_frequency(
clocks: &mut ClockTree,
config: SysconPreDivInConfig,
) -> u32 {
match config {
SysconPreDivInConfig::Xtal => xtal_clk_frequency(clocks),
SysconPreDivInConfig::RcFast => rc_fast_clk_frequency(clocks),
}
}
pub fn syscon_pre_div_in_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.syscon_pre_div_in {
syscon_pre_div_in_config_frequency(clocks, config)
} else {
0
}
}
pub fn configure_syscon_pre_div(clocks: &mut ClockTree, config: SysconPreDivConfig) {
let old_config = clocks.syscon_pre_div.replace(config);
configure_syscon_pre_div_impl(clocks, old_config, config);
}
pub fn syscon_pre_div_config(clocks: &mut ClockTree) -> Option<SysconPreDivConfig> {
clocks.syscon_pre_div
}
pub fn request_syscon_pre_div(clocks: &mut ClockTree) {
trace!("Requesting SYSCON_PRE_DIV");
trace!("Enabling SYSCON_PRE_DIV");
request_syscon_pre_div_in(clocks);
enable_syscon_pre_div_impl(clocks, true);
}
pub fn release_syscon_pre_div(clocks: &mut ClockTree) {
trace!("Releasing SYSCON_PRE_DIV");
trace!("Disabling SYSCON_PRE_DIV");
enable_syscon_pre_div_impl(clocks, false);
release_syscon_pre_div_in(clocks);
}
#[allow(unused_variables)]
pub fn syscon_pre_div_config_frequency(
clocks: &mut ClockTree,
config: SysconPreDivConfig,
) -> u32 {
(syscon_pre_div_in_frequency(clocks) / (config.divisor() + 1))
}
pub fn syscon_pre_div_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.syscon_pre_div {
syscon_pre_div_config_frequency(clocks, config)
} else {
0
}
}
pub fn configure_apb_clk(clocks: &mut ClockTree, new_selector: ApbClkConfig) {
let old_selector = clocks.apb_clk.replace(new_selector);
if clocks.apb_clk_refcount > 0 {
match new_selector {
ApbClkConfig::Pll80m => request_apb_clk_80m(clocks),
ApbClkConfig::CpuDiv2 => request_apb_clk_cpu_div2(clocks),
ApbClkConfig::Cpu => request_cpu_clk(clocks),
}
configure_apb_clk_impl(clocks, old_selector, new_selector);
if let Some(old_selector) = old_selector {
match old_selector {
ApbClkConfig::Pll80m => release_apb_clk_80m(clocks),
ApbClkConfig::CpuDiv2 => release_apb_clk_cpu_div2(clocks),
ApbClkConfig::Cpu => release_cpu_clk(clocks),
}
}
} else {
configure_apb_clk_impl(clocks, old_selector, new_selector);
}
}
pub fn apb_clk_config(clocks: &mut ClockTree) -> Option<ApbClkConfig> {
clocks.apb_clk
}
pub fn request_apb_clk(clocks: &mut ClockTree) {
trace!("Requesting APB_CLK");
if increment_reference_count(&mut clocks.apb_clk_refcount) {
trace!("Enabling APB_CLK");
match unwrap!(clocks.apb_clk) {
ApbClkConfig::Pll80m => request_apb_clk_80m(clocks),
ApbClkConfig::CpuDiv2 => request_apb_clk_cpu_div2(clocks),
ApbClkConfig::Cpu => request_cpu_clk(clocks),
}
enable_apb_clk_impl(clocks, true);
}
}
pub fn release_apb_clk(clocks: &mut ClockTree) {
trace!("Releasing APB_CLK");
if decrement_reference_count(&mut clocks.apb_clk_refcount) {
trace!("Disabling APB_CLK");
enable_apb_clk_impl(clocks, false);
match unwrap!(clocks.apb_clk) {
ApbClkConfig::Pll80m => release_apb_clk_80m(clocks),
ApbClkConfig::CpuDiv2 => release_apb_clk_cpu_div2(clocks),
ApbClkConfig::Cpu => release_cpu_clk(clocks),
}
}
}
#[allow(unused_variables)]
pub fn apb_clk_config_frequency(clocks: &mut ClockTree, config: ApbClkConfig) -> u32 {
match config {
ApbClkConfig::Pll80m => apb_clk_80m_frequency(clocks),
ApbClkConfig::CpuDiv2 => apb_clk_cpu_div2_frequency(clocks),
ApbClkConfig::Cpu => cpu_clk_frequency(clocks),
}
}
pub fn apb_clk_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.apb_clk {
apb_clk_config_frequency(clocks, config)
} else {
0
}
}
pub fn configure_ref_tick(clocks: &mut ClockTree, new_selector: RefTickConfig) {
let old_selector = clocks.ref_tick.replace(new_selector);
if clocks.ref_tick_refcount > 0 {
match new_selector {
RefTickConfig::Pll => request_ref_tick_pll(clocks),
RefTickConfig::Apll => request_ref_tick_apll(clocks),
RefTickConfig::Xtal => request_ref_tick_xtal(clocks),
RefTickConfig::Fosc => request_ref_tick_fosc(clocks),
}
configure_ref_tick_impl(clocks, old_selector, new_selector);
if let Some(old_selector) = old_selector {
match old_selector {
RefTickConfig::Pll => release_ref_tick_pll(clocks),
RefTickConfig::Apll => release_ref_tick_apll(clocks),
RefTickConfig::Xtal => release_ref_tick_xtal(clocks),
RefTickConfig::Fosc => release_ref_tick_fosc(clocks),
}
}
} else {
configure_ref_tick_impl(clocks, old_selector, new_selector);
}
}
pub fn ref_tick_config(clocks: &mut ClockTree) -> Option<RefTickConfig> {
clocks.ref_tick
}
pub fn request_ref_tick(clocks: &mut ClockTree) {
trace!("Requesting REF_TICK");
if increment_reference_count(&mut clocks.ref_tick_refcount) {
trace!("Enabling REF_TICK");
match unwrap!(clocks.ref_tick) {
RefTickConfig::Pll => request_ref_tick_pll(clocks),
RefTickConfig::Apll => request_ref_tick_apll(clocks),
RefTickConfig::Xtal => request_ref_tick_xtal(clocks),
RefTickConfig::Fosc => request_ref_tick_fosc(clocks),
}
enable_ref_tick_impl(clocks, true);
}
}
pub fn release_ref_tick(clocks: &mut ClockTree) {
trace!("Releasing REF_TICK");
if decrement_reference_count(&mut clocks.ref_tick_refcount) {
trace!("Disabling REF_TICK");
enable_ref_tick_impl(clocks, false);
match unwrap!(clocks.ref_tick) {
RefTickConfig::Pll => release_ref_tick_pll(clocks),
RefTickConfig::Apll => release_ref_tick_apll(clocks),
RefTickConfig::Xtal => release_ref_tick_xtal(clocks),
RefTickConfig::Fosc => release_ref_tick_fosc(clocks),
}
}
}
#[allow(unused_variables)]
pub fn ref_tick_config_frequency(clocks: &mut ClockTree, config: RefTickConfig) -> u32 {
match config {
RefTickConfig::Pll => ref_tick_pll_frequency(clocks),
RefTickConfig::Apll => ref_tick_apll_frequency(clocks),
RefTickConfig::Xtal => ref_tick_xtal_frequency(clocks),
RefTickConfig::Fosc => ref_tick_fosc_frequency(clocks),
}
}
pub fn ref_tick_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.ref_tick {
ref_tick_config_frequency(clocks, config)
} else {
0
}
}
pub fn configure_ref_tick_xtal(clocks: &mut ClockTree, config: RefTickXtalConfig) {
let old_config = clocks.ref_tick_xtal.replace(config);
configure_ref_tick_xtal_impl(clocks, old_config, config);
}
pub fn ref_tick_xtal_config(clocks: &mut ClockTree) -> Option<RefTickXtalConfig> {
clocks.ref_tick_xtal
}
pub fn request_ref_tick_xtal(clocks: &mut ClockTree) {
trace!("Requesting REF_TICK_XTAL");
trace!("Enabling REF_TICK_XTAL");
request_apb_clk(clocks);
enable_ref_tick_xtal_impl(clocks, true);
}
pub fn release_ref_tick_xtal(clocks: &mut ClockTree) {
trace!("Releasing REF_TICK_XTAL");
trace!("Disabling REF_TICK_XTAL");
enable_ref_tick_xtal_impl(clocks, false);
release_apb_clk(clocks);
}
#[allow(unused_variables)]
pub fn ref_tick_xtal_config_frequency(
clocks: &mut ClockTree,
config: RefTickXtalConfig,
) -> u32 {
(apb_clk_frequency(clocks) / (config.divisor() + 1))
}
pub fn ref_tick_xtal_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.ref_tick_xtal {
ref_tick_xtal_config_frequency(clocks, config)
} else {
0
}
}
pub fn configure_ref_tick_fosc(clocks: &mut ClockTree, config: RefTickFoscConfig) {
let old_config = clocks.ref_tick_fosc.replace(config);
configure_ref_tick_fosc_impl(clocks, old_config, config);
}
pub fn ref_tick_fosc_config(clocks: &mut ClockTree) -> Option<RefTickFoscConfig> {
clocks.ref_tick_fosc
}
pub fn request_ref_tick_fosc(clocks: &mut ClockTree) {
trace!("Requesting REF_TICK_FOSC");
trace!("Enabling REF_TICK_FOSC");
request_apb_clk(clocks);
enable_ref_tick_fosc_impl(clocks, true);
}
pub fn release_ref_tick_fosc(clocks: &mut ClockTree) {
trace!("Releasing REF_TICK_FOSC");
trace!("Disabling REF_TICK_FOSC");
enable_ref_tick_fosc_impl(clocks, false);
release_apb_clk(clocks);
}
#[allow(unused_variables)]
pub fn ref_tick_fosc_config_frequency(
clocks: &mut ClockTree,
config: RefTickFoscConfig,
) -> u32 {
(apb_clk_frequency(clocks) / (config.divisor() + 1))
}
pub fn ref_tick_fosc_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.ref_tick_fosc {
ref_tick_fosc_config_frequency(clocks, config)
} else {
0
}
}
pub fn configure_ref_tick_apll(clocks: &mut ClockTree, config: RefTickApllConfig) {
let old_config = clocks.ref_tick_apll.replace(config);
configure_ref_tick_apll_impl(clocks, old_config, config);
}
pub fn ref_tick_apll_config(clocks: &mut ClockTree) -> Option<RefTickApllConfig> {
clocks.ref_tick_apll
}
pub fn request_ref_tick_apll(clocks: &mut ClockTree) {
trace!("Requesting REF_TICK_APLL");
trace!("Enabling REF_TICK_APLL");
request_apb_clk(clocks);
enable_ref_tick_apll_impl(clocks, true);
}
pub fn release_ref_tick_apll(clocks: &mut ClockTree) {
trace!("Releasing REF_TICK_APLL");
trace!("Disabling REF_TICK_APLL");
enable_ref_tick_apll_impl(clocks, false);
release_apb_clk(clocks);
}
#[allow(unused_variables)]
pub fn ref_tick_apll_config_frequency(
clocks: &mut ClockTree,
config: RefTickApllConfig,
) -> u32 {
(apb_clk_frequency(clocks) / (config.divisor() + 1))
}
pub fn ref_tick_apll_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.ref_tick_apll {
ref_tick_apll_config_frequency(clocks, config)
} else {
0
}
}
pub fn configure_ref_tick_pll(clocks: &mut ClockTree, config: RefTickPllConfig) {
let old_config = clocks.ref_tick_pll.replace(config);
configure_ref_tick_pll_impl(clocks, old_config, config);
}
pub fn ref_tick_pll_config(clocks: &mut ClockTree) -> Option<RefTickPllConfig> {
clocks.ref_tick_pll
}
pub fn request_ref_tick_pll(clocks: &mut ClockTree) {
trace!("Requesting REF_TICK_PLL");
trace!("Enabling REF_TICK_PLL");
request_apb_clk(clocks);
enable_ref_tick_pll_impl(clocks, true);
}
pub fn release_ref_tick_pll(clocks: &mut ClockTree) {
trace!("Releasing REF_TICK_PLL");
trace!("Disabling REF_TICK_PLL");
enable_ref_tick_pll_impl(clocks, false);
release_apb_clk(clocks);
}
#[allow(unused_variables)]
pub fn ref_tick_pll_config_frequency(
clocks: &mut ClockTree,
config: RefTickPllConfig,
) -> u32 {
(apb_clk_frequency(clocks) / (config.divisor() + 1))
}
pub fn ref_tick_pll_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.ref_tick_pll {
ref_tick_pll_config_frequency(clocks, config)
} else {
0
}
}
pub fn configure_cpu_clk(clocks: &mut ClockTree, new_selector: CpuClkConfig) {
let old_selector = clocks.cpu_clk.replace(new_selector);
match new_selector {
CpuClkConfig::Xtal => {
configure_apb_clk(clocks, ApbClkConfig::Cpu);
configure_syscon_pre_div_in(clocks, SysconPreDivInConfig::Xtal);
configure_ref_tick(clocks, RefTickConfig::Xtal);
let config_value =
RefTickXtalConfig::new(((apb_clk_frequency(clocks) / 1000000) - 1));
configure_ref_tick_xtal(clocks, config_value);
}
CpuClkConfig::RcFast => {
configure_apb_clk(clocks, ApbClkConfig::Cpu);
configure_syscon_pre_div_in(clocks, SysconPreDivInConfig::RcFast);
configure_ref_tick(clocks, RefTickConfig::Fosc);
let config_value =
RefTickFoscConfig::new(((apb_clk_frequency(clocks) / 1000000) - 1));
configure_ref_tick_fosc(clocks, config_value);
}
CpuClkConfig::Apll => {
configure_apb_clk(clocks, ApbClkConfig::CpuDiv2);
configure_cpu_pll_div_in(clocks, CpuPllDivInConfig::Apll);
configure_ref_tick(clocks, RefTickConfig::Apll);
let config_value =
RefTickApllConfig::new(((apb_clk_frequency(clocks) / 1000000) - 1));
configure_ref_tick_apll(clocks, config_value);
}
CpuClkConfig::Pll => {
configure_apb_clk(clocks, ApbClkConfig::Pll80m);
configure_cpu_pll_div_in(clocks, CpuPllDivInConfig::Pll);
configure_ref_tick(clocks, RefTickConfig::Pll);
let config_value =
RefTickPllConfig::new(((apb_clk_frequency(clocks) / 1000000) - 1));
configure_ref_tick_pll(clocks, config_value);
}
}
match new_selector {
CpuClkConfig::Xtal => request_syscon_pre_div(clocks),
CpuClkConfig::RcFast => request_syscon_pre_div(clocks),
CpuClkConfig::Apll => request_cpu_pll_div(clocks),
CpuClkConfig::Pll => request_cpu_pll_div(clocks),
}
configure_cpu_clk_impl(clocks, old_selector, new_selector);
if let Some(old_selector) = old_selector {
match old_selector {
CpuClkConfig::Xtal => release_syscon_pre_div(clocks),
CpuClkConfig::RcFast => release_syscon_pre_div(clocks),
CpuClkConfig::Apll => release_cpu_pll_div(clocks),
CpuClkConfig::Pll => release_cpu_pll_div(clocks),
}
}
}
pub fn cpu_clk_config(clocks: &mut ClockTree) -> Option<CpuClkConfig> {
clocks.cpu_clk
}
fn request_cpu_clk(_clocks: &mut ClockTree) {}
fn release_cpu_clk(_clocks: &mut ClockTree) {}
#[allow(unused_variables)]
pub fn cpu_clk_config_frequency(clocks: &mut ClockTree, config: CpuClkConfig) -> u32 {
match config {
CpuClkConfig::Xtal => syscon_pre_div_frequency(clocks),
CpuClkConfig::RcFast => syscon_pre_div_frequency(clocks),
CpuClkConfig::Apll => cpu_pll_div_frequency(clocks),
CpuClkConfig::Pll => cpu_pll_div_frequency(clocks),
}
}
pub fn cpu_clk_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.cpu_clk {
cpu_clk_config_frequency(clocks, config)
} else {
0
}
}
pub fn request_apb_clk_cpu_div2(clocks: &mut ClockTree) {
trace!("Requesting APB_CLK_CPU_DIV2");
trace!("Enabling APB_CLK_CPU_DIV2");
request_cpu_clk(clocks);
enable_apb_clk_cpu_div2_impl(clocks, true);
}
pub fn release_apb_clk_cpu_div2(clocks: &mut ClockTree) {
trace!("Releasing APB_CLK_CPU_DIV2");
trace!("Disabling APB_CLK_CPU_DIV2");
enable_apb_clk_cpu_div2_impl(clocks, false);
release_cpu_clk(clocks);
}
pub fn apb_clk_cpu_div2_frequency(clocks: &mut ClockTree) -> u32 {
(cpu_clk_frequency(clocks) / 2)
}
pub fn request_apb_clk_80m(clocks: &mut ClockTree) {
trace!("Requesting APB_CLK_80M");
trace!("Enabling APB_CLK_80M");
request_cpu_clk(clocks);
enable_apb_clk_80m_impl(clocks, true);
}
pub fn release_apb_clk_80m(clocks: &mut ClockTree) {
trace!("Releasing APB_CLK_80M");
trace!("Disabling APB_CLK_80M");
enable_apb_clk_80m_impl(clocks, false);
release_cpu_clk(clocks);
}
pub fn apb_clk_80m_frequency(clocks: &mut ClockTree) -> u32 {
80000000
}
pub fn request_xtal32k_clk(clocks: &mut ClockTree) {
trace!("Requesting XTAL32K_CLK");
if increment_reference_count(&mut clocks.xtal32k_clk_refcount) {
trace!("Enabling XTAL32K_CLK");
enable_xtal32k_clk_impl(clocks, true);
}
}
pub fn release_xtal32k_clk(clocks: &mut ClockTree) {
trace!("Releasing XTAL32K_CLK");
if decrement_reference_count(&mut clocks.xtal32k_clk_refcount) {
trace!("Disabling XTAL32K_CLK");
enable_xtal32k_clk_impl(clocks, false);
}
}
pub fn xtal32k_clk_frequency(clocks: &mut ClockTree) -> u32 {
32768
}
pub fn request_rc_slow_clk(clocks: &mut ClockTree) {
trace!("Requesting RC_SLOW_CLK");
if increment_reference_count(&mut clocks.rc_slow_clk_refcount) {
trace!("Enabling RC_SLOW_CLK");
enable_rc_slow_clk_impl(clocks, true);
}
}
pub fn release_rc_slow_clk(clocks: &mut ClockTree) {
trace!("Releasing RC_SLOW_CLK");
if decrement_reference_count(&mut clocks.rc_slow_clk_refcount) {
trace!("Disabling RC_SLOW_CLK");
enable_rc_slow_clk_impl(clocks, false);
}
}
pub fn rc_slow_clk_frequency(clocks: &mut ClockTree) -> u32 {
150000
}
pub fn request_rc_fast_div_clk(clocks: &mut ClockTree) {
trace!("Requesting RC_FAST_DIV_CLK");
if increment_reference_count(&mut clocks.rc_fast_div_clk_refcount) {
trace!("Enabling RC_FAST_DIV_CLK");
request_rc_fast_clk(clocks);
enable_rc_fast_div_clk_impl(clocks, true);
}
}
pub fn release_rc_fast_div_clk(clocks: &mut ClockTree) {
trace!("Releasing RC_FAST_DIV_CLK");
if decrement_reference_count(&mut clocks.rc_fast_div_clk_refcount) {
trace!("Disabling RC_FAST_DIV_CLK");
enable_rc_fast_div_clk_impl(clocks, false);
release_rc_fast_clk(clocks);
}
}
pub fn rc_fast_div_clk_frequency(clocks: &mut ClockTree) -> u32 {
(rc_fast_clk_frequency(clocks) / 256)
}
pub fn request_xtal_div_clk(clocks: &mut ClockTree) {
trace!("Requesting XTAL_DIV_CLK");
trace!("Enabling XTAL_DIV_CLK");
request_xtal_clk(clocks);
enable_xtal_div_clk_impl(clocks, true);
}
pub fn release_xtal_div_clk(clocks: &mut ClockTree) {
trace!("Releasing XTAL_DIV_CLK");
trace!("Disabling XTAL_DIV_CLK");
enable_xtal_div_clk_impl(clocks, false);
release_xtal_clk(clocks);
}
pub fn xtal_div_clk_frequency(clocks: &mut ClockTree) -> u32 {
(xtal_clk_frequency(clocks) / 4)
}
pub fn configure_rtc_slow_clk(clocks: &mut ClockTree, new_selector: RtcSlowClkConfig) {
let old_selector = clocks.rtc_slow_clk.replace(new_selector);
if clocks.rtc_slow_clk_refcount > 0 {
match new_selector {
RtcSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
RtcSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
RtcSlowClkConfig::RcFast => request_rc_fast_div_clk(clocks),
}
configure_rtc_slow_clk_impl(clocks, old_selector, new_selector);
if let Some(old_selector) = old_selector {
match old_selector {
RtcSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
RtcSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
RtcSlowClkConfig::RcFast => release_rc_fast_div_clk(clocks),
}
}
} else {
configure_rtc_slow_clk_impl(clocks, old_selector, new_selector);
}
}
pub fn rtc_slow_clk_config(clocks: &mut ClockTree) -> Option<RtcSlowClkConfig> {
clocks.rtc_slow_clk
}
pub fn request_rtc_slow_clk(clocks: &mut ClockTree) {
trace!("Requesting RTC_SLOW_CLK");
if increment_reference_count(&mut clocks.rtc_slow_clk_refcount) {
trace!("Enabling RTC_SLOW_CLK");
match unwrap!(clocks.rtc_slow_clk) {
RtcSlowClkConfig::Xtal32k => request_xtal32k_clk(clocks),
RtcSlowClkConfig::RcSlow => request_rc_slow_clk(clocks),
RtcSlowClkConfig::RcFast => request_rc_fast_div_clk(clocks),
}
enable_rtc_slow_clk_impl(clocks, true);
}
}
pub fn release_rtc_slow_clk(clocks: &mut ClockTree) {
trace!("Releasing RTC_SLOW_CLK");
if decrement_reference_count(&mut clocks.rtc_slow_clk_refcount) {
trace!("Disabling RTC_SLOW_CLK");
enable_rtc_slow_clk_impl(clocks, false);
match unwrap!(clocks.rtc_slow_clk) {
RtcSlowClkConfig::Xtal32k => release_xtal32k_clk(clocks),
RtcSlowClkConfig::RcSlow => release_rc_slow_clk(clocks),
RtcSlowClkConfig::RcFast => release_rc_fast_div_clk(clocks),
}
}
}
#[allow(unused_variables)]
pub fn rtc_slow_clk_config_frequency(
clocks: &mut ClockTree,
config: RtcSlowClkConfig,
) -> u32 {
match config {
RtcSlowClkConfig::Xtal32k => xtal32k_clk_frequency(clocks),
RtcSlowClkConfig::RcSlow => rc_slow_clk_frequency(clocks),
RtcSlowClkConfig::RcFast => rc_fast_div_clk_frequency(clocks),
}
}
pub fn rtc_slow_clk_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.rtc_slow_clk {
rtc_slow_clk_config_frequency(clocks, config)
} else {
0
}
}
pub fn configure_rtc_fast_clk(clocks: &mut ClockTree, new_selector: RtcFastClkConfig) {
let old_selector = clocks.rtc_fast_clk.replace(new_selector);
if clocks.rtc_fast_clk_refcount > 0 {
match new_selector {
RtcFastClkConfig::Xtal => request_xtal_div_clk(clocks),
RtcFastClkConfig::Rc => request_rc_fast_clk(clocks),
}
configure_rtc_fast_clk_impl(clocks, old_selector, new_selector);
if let Some(old_selector) = old_selector {
match old_selector {
RtcFastClkConfig::Xtal => release_xtal_div_clk(clocks),
RtcFastClkConfig::Rc => release_rc_fast_clk(clocks),
}
}
} else {
configure_rtc_fast_clk_impl(clocks, old_selector, new_selector);
}
}
pub fn rtc_fast_clk_config(clocks: &mut ClockTree) -> Option<RtcFastClkConfig> {
clocks.rtc_fast_clk
}
pub fn request_rtc_fast_clk(clocks: &mut ClockTree) {
trace!("Requesting RTC_FAST_CLK");
if increment_reference_count(&mut clocks.rtc_fast_clk_refcount) {
trace!("Enabling RTC_FAST_CLK");
match unwrap!(clocks.rtc_fast_clk) {
RtcFastClkConfig::Xtal => request_xtal_div_clk(clocks),
RtcFastClkConfig::Rc => request_rc_fast_clk(clocks),
}
enable_rtc_fast_clk_impl(clocks, true);
}
}
pub fn release_rtc_fast_clk(clocks: &mut ClockTree) {
trace!("Releasing RTC_FAST_CLK");
if decrement_reference_count(&mut clocks.rtc_fast_clk_refcount) {
trace!("Disabling RTC_FAST_CLK");
enable_rtc_fast_clk_impl(clocks, false);
match unwrap!(clocks.rtc_fast_clk) {
RtcFastClkConfig::Xtal => release_xtal_div_clk(clocks),
RtcFastClkConfig::Rc => release_rc_fast_clk(clocks),
}
}
}
#[allow(unused_variables)]
pub fn rtc_fast_clk_config_frequency(
clocks: &mut ClockTree,
config: RtcFastClkConfig,
) -> u32 {
match config {
RtcFastClkConfig::Xtal => xtal_div_clk_frequency(clocks),
RtcFastClkConfig::Rc => rc_fast_clk_frequency(clocks),
}
}
pub fn rtc_fast_clk_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.rtc_fast_clk {
rtc_fast_clk_config_frequency(clocks, config)
} else {
0
}
}
pub fn request_uart_mem_clk(clocks: &mut ClockTree) {
trace!("Requesting UART_MEM_CLK");
if increment_reference_count(&mut clocks.uart_mem_clk_refcount) {
trace!("Enabling UART_MEM_CLK");
request_xtal_clk(clocks);
enable_uart_mem_clk_impl(clocks, true);
}
}
pub fn release_uart_mem_clk(clocks: &mut ClockTree) {
trace!("Releasing UART_MEM_CLK");
if decrement_reference_count(&mut clocks.uart_mem_clk_refcount) {
trace!("Disabling UART_MEM_CLK");
enable_uart_mem_clk_impl(clocks, false);
release_xtal_clk(clocks);
}
}
pub fn uart_mem_clk_frequency(clocks: &mut ClockTree) -> u32 {
xtal_clk_frequency(clocks)
}
pub fn configure_timg_calibration_clock(
clocks: &mut ClockTree,
new_selector: TimgCalibrationClockConfig,
) {
let old_selector = clocks.timg_calibration_clock.replace(new_selector);
if clocks.timg_calibration_clock_refcount > 0 {
match new_selector {
TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_div_clk(clocks),
TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
}
configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
if let Some(old_selector) = old_selector {
match old_selector {
TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_div_clk(clocks),
TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
}
}
} else {
configure_timg_calibration_clock_impl(clocks, old_selector, new_selector);
}
}
pub fn timg_calibration_clock_config(
clocks: &mut ClockTree,
) -> Option<TimgCalibrationClockConfig> {
clocks.timg_calibration_clock
}
pub fn request_timg_calibration_clock(clocks: &mut ClockTree) {
trace!("Requesting TIMG_CALIBRATION_CLOCK");
if increment_reference_count(&mut clocks.timg_calibration_clock_refcount) {
trace!("Enabling TIMG_CALIBRATION_CLOCK");
match unwrap!(clocks.timg_calibration_clock) {
TimgCalibrationClockConfig::RcSlowClk => request_rc_slow_clk(clocks),
TimgCalibrationClockConfig::RcFastDivClk => request_rc_fast_div_clk(clocks),
TimgCalibrationClockConfig::Xtal32kClk => request_xtal32k_clk(clocks),
}
enable_timg_calibration_clock_impl(clocks, true);
}
}
pub fn release_timg_calibration_clock(clocks: &mut ClockTree) {
trace!("Releasing TIMG_CALIBRATION_CLOCK");
if decrement_reference_count(&mut clocks.timg_calibration_clock_refcount) {
trace!("Disabling TIMG_CALIBRATION_CLOCK");
enable_timg_calibration_clock_impl(clocks, false);
match unwrap!(clocks.timg_calibration_clock) {
TimgCalibrationClockConfig::RcSlowClk => release_rc_slow_clk(clocks),
TimgCalibrationClockConfig::RcFastDivClk => release_rc_fast_div_clk(clocks),
TimgCalibrationClockConfig::Xtal32kClk => release_xtal32k_clk(clocks),
}
}
}
#[allow(unused_variables)]
pub fn timg_calibration_clock_config_frequency(
clocks: &mut ClockTree,
config: TimgCalibrationClockConfig,
) -> u32 {
match config {
TimgCalibrationClockConfig::RcSlowClk => rc_slow_clk_frequency(clocks),
TimgCalibrationClockConfig::RcFastDivClk => rc_fast_div_clk_frequency(clocks),
TimgCalibrationClockConfig::Xtal32kClk => xtal32k_clk_frequency(clocks),
}
}
pub fn timg_calibration_clock_frequency(clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.timg_calibration_clock {
timg_calibration_clock_config_frequency(clocks, config)
} else {
0
}
}
impl McpwmInstance {
pub fn configure_function_clock(
self,
clocks: &mut ClockTree,
new_selector: McpwmFunctionClockConfig,
) {
let old_selector = clocks.mcpwm_function_clock[self as usize].replace(new_selector);
if clocks.mcpwm_function_clock_refcount[self as usize] > 0 {
request_pll_f160m_clk(clocks);
self.configure_function_clock_impl(clocks, old_selector, new_selector);
if let Some(old_selector) = old_selector {
release_pll_f160m_clk(clocks);
}
} else {
self.configure_function_clock_impl(clocks, old_selector, new_selector);
}
}
pub fn function_clock_config(
self,
clocks: &mut ClockTree,
) -> Option<McpwmFunctionClockConfig> {
clocks.mcpwm_function_clock[self as usize]
}
pub fn request_function_clock(self, clocks: &mut ClockTree) {
trace!("Requesting {:?}::FUNCTION_CLOCK", self);
if increment_reference_count(
&mut clocks.mcpwm_function_clock_refcount[self as usize],
) {
trace!("Enabling {:?}::FUNCTION_CLOCK", self);
request_pll_f160m_clk(clocks);
self.enable_function_clock_impl(clocks, true);
}
}
pub fn release_function_clock(self, clocks: &mut ClockTree) {
trace!("Releasing {:?}::FUNCTION_CLOCK", self);
if decrement_reference_count(
&mut clocks.mcpwm_function_clock_refcount[self as usize],
) {
trace!("Disabling {:?}::FUNCTION_CLOCK", self);
self.enable_function_clock_impl(clocks, false);
release_pll_f160m_clk(clocks);
}
}
#[allow(unused_variables)]
pub fn function_clock_config_frequency(
self,
clocks: &mut ClockTree,
config: McpwmFunctionClockConfig,
) -> u32 {
pll_f160m_clk_frequency(clocks)
}
pub fn function_clock_frequency(self, clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.mcpwm_function_clock[self as usize] {
self.function_clock_config_frequency(clocks, config)
} else {
0
}
}
}
impl UartInstance {
pub fn configure_function_clock(
self,
clocks: &mut ClockTree,
config: UartFunctionClockConfig,
) {
let old_config = clocks.uart_function_clock[self as usize].replace(config);
if clocks.uart_function_clock_refcount[self as usize] > 0 {
match config.sclk {
UartFunctionClockSclk::Apb => request_apb_clk(clocks),
UartFunctionClockSclk::RefTick => request_ref_tick(clocks),
}
self.configure_function_clock_impl(clocks, old_config, config);
if let Some(old_config) = old_config {
match old_config.sclk {
UartFunctionClockSclk::Apb => release_apb_clk(clocks),
UartFunctionClockSclk::RefTick => release_ref_tick(clocks),
}
}
} else {
self.configure_function_clock_impl(clocks, old_config, config);
}
}
pub fn function_clock_config(
self,
clocks: &mut ClockTree,
) -> Option<UartFunctionClockConfig> {
clocks.uart_function_clock[self as usize]
}
pub fn request_function_clock(self, clocks: &mut ClockTree) {
trace!("Requesting {:?}::FUNCTION_CLOCK", self);
if increment_reference_count(
&mut clocks.uart_function_clock_refcount[self as usize],
) {
trace!("Enabling {:?}::FUNCTION_CLOCK", self);
match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
UartFunctionClockSclk::Apb => request_apb_clk(clocks),
UartFunctionClockSclk::RefTick => request_ref_tick(clocks),
}
self.enable_function_clock_impl(clocks, true);
}
}
pub fn release_function_clock(self, clocks: &mut ClockTree) {
trace!("Releasing {:?}::FUNCTION_CLOCK", self);
if decrement_reference_count(
&mut clocks.uart_function_clock_refcount[self as usize],
) {
trace!("Disabling {:?}::FUNCTION_CLOCK", self);
self.enable_function_clock_impl(clocks, false);
match unwrap!(clocks.uart_function_clock[self as usize]).sclk {
UartFunctionClockSclk::Apb => release_apb_clk(clocks),
UartFunctionClockSclk::RefTick => release_ref_tick(clocks),
}
}
}
#[allow(unused_variables)]
pub fn function_clock_config_frequency(
self,
clocks: &mut ClockTree,
config: UartFunctionClockConfig,
) -> u32 {
match config.sclk {
UartFunctionClockSclk::Apb => apb_clk_frequency(clocks),
UartFunctionClockSclk::RefTick => ref_tick_frequency(clocks),
}
}
pub fn function_clock_frequency(self, clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.uart_function_clock[self as usize] {
self.function_clock_config_frequency(clocks, config)
} else {
0
}
}
pub fn configure_mem_clock(self, clocks: &mut ClockTree, config: UartMemClockConfig) {
let old_config = clocks.uart_mem_clock[self as usize].replace(config);
self.configure_mem_clock_impl(clocks, old_config, config);
}
pub fn mem_clock_config(self, clocks: &mut ClockTree) -> Option<UartMemClockConfig> {
clocks.uart_mem_clock[self as usize]
}
pub fn request_mem_clock(self, clocks: &mut ClockTree) {
trace!("Requesting {:?}::MEM_CLOCK", self);
if increment_reference_count(&mut clocks.uart_mem_clock_refcount[self as usize]) {
trace!("Enabling {:?}::MEM_CLOCK", self);
request_uart_mem_clk(clocks);
self.enable_mem_clock_impl(clocks, true);
}
}
pub fn release_mem_clock(self, clocks: &mut ClockTree) {
trace!("Releasing {:?}::MEM_CLOCK", self);
if decrement_reference_count(&mut clocks.uart_mem_clock_refcount[self as usize]) {
trace!("Disabling {:?}::MEM_CLOCK", self);
self.enable_mem_clock_impl(clocks, false);
release_uart_mem_clk(clocks);
}
}
#[allow(unused_variables)]
pub fn mem_clock_config_frequency(
self,
clocks: &mut ClockTree,
config: UartMemClockConfig,
) -> u32 {
uart_mem_clk_frequency(clocks)
}
pub fn mem_clock_frequency(self, clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.uart_mem_clock[self as usize] {
self.mem_clock_config_frequency(clocks, config)
} else {
0
}
}
pub fn configure_baud_rate_generator(
self,
clocks: &mut ClockTree,
config: UartBaudRateGeneratorConfig,
) {
let old_config = clocks.uart_baud_rate_generator[self as usize].replace(config);
self.configure_baud_rate_generator_impl(clocks, old_config, config);
}
pub fn baud_rate_generator_config(
self,
clocks: &mut ClockTree,
) -> Option<UartBaudRateGeneratorConfig> {
clocks.uart_baud_rate_generator[self as usize]
}
pub fn request_baud_rate_generator(self, clocks: &mut ClockTree) {
trace!("Requesting {:?}::BAUD_RATE_GENERATOR", self);
if increment_reference_count(
&mut clocks.uart_baud_rate_generator_refcount[self as usize],
) {
trace!("Enabling {:?}::BAUD_RATE_GENERATOR", self);
self.request_function_clock(clocks);
self.enable_baud_rate_generator_impl(clocks, true);
}
}
pub fn release_baud_rate_generator(self, clocks: &mut ClockTree) {
trace!("Releasing {:?}::BAUD_RATE_GENERATOR", self);
if decrement_reference_count(
&mut clocks.uart_baud_rate_generator_refcount[self as usize],
) {
trace!("Disabling {:?}::BAUD_RATE_GENERATOR", self);
self.enable_baud_rate_generator_impl(clocks, false);
self.release_function_clock(clocks);
}
}
#[allow(unused_variables)]
pub fn baud_rate_generator_config_frequency(
self,
clocks: &mut ClockTree,
config: UartBaudRateGeneratorConfig,
) -> u32 {
((self.function_clock_frequency(clocks) * 16)
/ ((config.integral() * 16) + config.fractional()))
}
pub fn baud_rate_generator_frequency(self, clocks: &mut ClockTree) -> u32 {
if let Some(config) = clocks.uart_baud_rate_generator[self as usize] {
self.baud_rate_generator_config_frequency(clocks, config)
} else {
0
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[instability::unstable]
pub struct ClockConfig {
pub xtal_clk: Option<XtalClkConfig>,
pub pll_clk: Option<PllClkConfig>,
pub apll_clk: Option<ApllClkConfig>,
pub cpu_pll_div: Option<CpuPllDivConfig>,
pub syscon_pre_div: Option<SysconPreDivConfig>,
pub cpu_clk: Option<CpuClkConfig>,
pub rtc_slow_clk: Option<RtcSlowClkConfig>,
pub rtc_fast_clk: Option<RtcFastClkConfig>,
pub timg_calibration_clock: Option<TimgCalibrationClockConfig>,
}
impl ClockConfig {
fn apply(&self) {
ClockTree::with(|clocks| {
if let Some(config) = self.xtal_clk {
configure_xtal_clk(clocks, config);
}
if let Some(config) = self.pll_clk {
configure_pll_clk(clocks, config);
}
if let Some(config) = self.apll_clk {
configure_apll_clk(clocks, config);
}
if let Some(config) = self.cpu_pll_div {
configure_cpu_pll_div(clocks, config);
}
if let Some(config) = self.syscon_pre_div {
configure_syscon_pre_div(clocks, config);
}
if let Some(config) = self.cpu_clk {
configure_cpu_clk(clocks, config);
}
if let Some(config) = self.rtc_slow_clk {
configure_rtc_slow_clk(clocks, config);
}
if let Some(config) = self.rtc_fast_clk {
configure_rtc_fast_clk(clocks, config);
}
if let Some(config) = self.timg_calibration_clock {
configure_timg_calibration_clock(clocks, config);
}
});
}
}
fn increment_reference_count(refcount: &mut u32) -> bool {
let first = *refcount == 0;
*refcount = unwrap!(refcount.checked_add(1), "Reference count overflow");
first
}
fn decrement_reference_count(refcount: &mut u32) -> bool {
*refcount = refcount.saturating_sub(1);
let last = *refcount == 0;
last
}
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! implement_peripheral_clocks {
() => {
#[doc(hidden)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u8)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Peripheral {
Aes,
I2cExt0,
I2cExt1,
I2s0,
I2s1,
Ledc,
Mcpwm0,
Mcpwm1,
Pcnt,
Rmt,
Rsa,
Sha,
Spi2,
Spi3,
SpiDma,
Timg0,
Timg1,
Twai0,
Uart0,
Uart1,
Uart2,
UartMem,
Uhci0,
Uhci1,
}
impl Peripheral {
const KEEP_ENABLED: &[Peripheral] = &[Self::Timg0, Self::Uart0, Self::UartMem];
const COUNT: usize = Self::ALL.len();
const ALL: &[Self] = &[
Self::Aes,
Self::I2cExt0,
Self::I2cExt1,
Self::I2s0,
Self::I2s1,
Self::Ledc,
Self::Mcpwm0,
Self::Mcpwm1,
Self::Pcnt,
Self::Rmt,
Self::Rsa,
Self::Sha,
Self::Spi2,
Self::Spi3,
Self::SpiDma,
Self::Timg0,
Self::Timg1,
Self::Twai0,
Self::Uart0,
Self::Uart1,
Self::Uart2,
Self::UartMem,
Self::Uhci0,
Self::Uhci1,
];
}
unsafe fn enable_internal_racey(peripheral: Peripheral, enable: bool) {
match peripheral {
Peripheral::Aes => {
crate::peripherals::SYSTEM::regs()
.peri_clk_en()
.modify(|_, w| w.crypto_aes_clk_en().bit(enable));
}
Peripheral::I2cExt0 => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.i2c_ext0_clk_en().bit(enable));
}
Peripheral::I2cExt1 => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.i2c_ext1_clk_en().bit(enable));
}
Peripheral::I2s0 => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.i2s0_clk_en().bit(enable));
}
Peripheral::I2s1 => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.i2s1_clk_en().bit(enable));
}
Peripheral::Ledc => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.ledc_clk_en().bit(enable));
}
Peripheral::Mcpwm0 => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.pwm0_clk_en().bit(enable));
}
Peripheral::Mcpwm1 => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.pwm1_clk_en().bit(enable));
}
Peripheral::Pcnt => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.pcnt_clk_en().bit(enable));
}
Peripheral::Rmt => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.rmt_clk_en().bit(enable));
}
Peripheral::Rsa => {
crate::peripherals::SYSTEM::regs()
.peri_clk_en()
.modify(|_, w| w.crypto_rsa_clk_en().bit(enable));
}
Peripheral::Sha => {
crate::peripherals::SYSTEM::regs()
.peri_clk_en()
.modify(|_, w| w.crypto_sha_clk_en().bit(enable));
}
Peripheral::Spi2 => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.spi2_clk_en().bit(enable));
}
Peripheral::Spi3 => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.spi3_clk_en().bit(enable));
}
Peripheral::SpiDma => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.spi_dma_clk_en().bit(enable));
}
Peripheral::Timg0 => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.timergroup_clk_en().bit(enable));
}
Peripheral::Timg1 => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.timergroup1_clk_en().bit(enable));
}
Peripheral::Twai0 => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.twai_clk_en().bit(enable));
}
Peripheral::Uart0 => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.uart_clk_en().bit(enable));
}
Peripheral::Uart1 => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.uart1_clk_en().bit(enable));
}
Peripheral::Uart2 => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.uart2_clk_en().bit(enable));
}
Peripheral::UartMem => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.uart_mem_clk_en().bit(enable));
}
Peripheral::Uhci0 => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.uhci0_clk_en().bit(enable));
}
Peripheral::Uhci1 => {
crate::peripherals::SYSTEM::regs()
.perip_clk_en()
.modify(|_, w| w.uhci1_clk_en().bit(enable));
}
}
}
unsafe fn assert_peri_reset_racey(peripheral: Peripheral, reset: bool) {
match peripheral {
Peripheral::Aes => {
crate::peripherals::SYSTEM::regs()
.peri_rst_en()
.modify(|_, w| w.crypto_aes_rst().bit(reset));
}
Peripheral::I2cExt0 => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.i2c_ext0_rst().bit(reset));
}
Peripheral::I2cExt1 => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.i2c_ext1_rst().bit(reset));
}
Peripheral::I2s0 => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.i2s0_rst().bit(reset));
}
Peripheral::I2s1 => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.i2s1_rst().bit(reset));
}
Peripheral::Ledc => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.ledc_rst().bit(reset));
}
Peripheral::Mcpwm0 => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.pwm0_rst().bit(reset));
}
Peripheral::Mcpwm1 => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.pwm1_rst().bit(reset));
}
Peripheral::Pcnt => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.pcnt_rst().bit(reset));
}
Peripheral::Rmt => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.rmt_rst().bit(reset));
}
Peripheral::Rsa => {
crate::peripherals::SYSTEM::regs()
.peri_rst_en()
.modify(|_, w| w.crypto_rsa_rst().bit(reset));
}
Peripheral::Sha => {
crate::peripherals::SYSTEM::regs()
.peri_rst_en()
.modify(|_, w| w.crypto_sha_rst().bit(reset));
}
Peripheral::Spi2 => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.spi2_rst().bit(reset));
}
Peripheral::Spi3 => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.spi3_rst().bit(reset));
}
Peripheral::SpiDma => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.spi_dma_rst().bit(reset));
}
Peripheral::Timg0 => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.timergroup_rst().bit(reset));
}
Peripheral::Timg1 => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.timergroup1_rst().bit(reset));
}
Peripheral::Twai0 => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.twai_rst().bit(reset));
}
Peripheral::Uart0 => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.uart_rst().bit(reset));
}
Peripheral::Uart1 => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.uart1_rst().bit(reset));
}
Peripheral::Uart2 => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.uart2_rst().bit(reset));
}
Peripheral::UartMem => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.uart_mem_rst().bit(reset));
}
Peripheral::Uhci0 => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.uhci0_rst().bit(reset));
}
Peripheral::Uhci1 => {
crate::peripherals::SYSTEM::regs()
.perip_rst_en()
.modify(|_, w| w.uhci1_rst().bit(reset));
}
}
}
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! memory_range {
("DRAM") => {
0x3FFAE000..0x40000000
};
(size as str, "DRAM") => {
"335872"
};
("DRAM2_UNINIT") => {
0x3FFE7E30..0x40000000
};
(size as str, "DRAM2_UNINIT") => {
"98768"
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_i2c_master {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner_i2c_master { $(($pattern) => $code;)* ($other : tt)
=> {} } _for_each_inner_i2c_master!((0, I2C0, I2cExt0, I2CEXT0_SCL,
I2CEXT0_SDA)); _for_each_inner_i2c_master!((1, I2C1, I2cExt1, I2CEXT1_SCL,
I2CEXT1_SDA)); _for_each_inner_i2c_master!((all(0, I2C0, I2cExt0, I2CEXT0_SCL,
I2CEXT0_SDA), (1, I2C1, I2cExt1, I2CEXT1_SCL, I2CEXT1_SDA)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_uart {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner_uart { $(($pattern) => $code;)* ($other : tt) => {}
} _for_each_inner_uart!((0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS));
_for_each_inner_uart!((1, UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS));
_for_each_inner_uart!((2, UART2, Uart2, U2RXD, U2TXD, U2CTS, U2RTS));
_for_each_inner_uart!((all(0, UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS), (1,
UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS), (2, UART2, Uart2, U2RXD, U2TXD, U2CTS,
U2RTS)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_spi_master {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner_spi_master { $(($pattern) => $code;)* ($other : tt)
=> {} } _for_each_inner_spi_master!((SPI2, Spi2, HSPICLK[HSPICS0, HSPICS1,
HSPICS2] [HSPID, HSPIQ, HSPIWP, HSPIHD], true));
_for_each_inner_spi_master!((SPI3, Spi3, VSPICLK[VSPICS0, VSPICS1, VSPICS2]
[VSPID, VSPIQ, VSPIWP, VSPIHD], true)); _for_each_inner_spi_master!((all(SPI2,
Spi2, HSPICLK[HSPICS0, HSPICS1, HSPICS2] [HSPID, HSPIQ, HSPIWP, HSPIHD], true),
(SPI3, Spi3, VSPICLK[VSPICS0, VSPICS1, VSPICS2] [VSPID, VSPIQ, VSPIWP, VSPIHD],
true)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_spi_slave {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner_spi_slave { $(($pattern) => $code;)* ($other : tt)
=> {} } _for_each_inner_spi_slave!((SPI2, Spi2, HSPICLK, HSPID, HSPIQ, HSPICS0));
_for_each_inner_spi_slave!((SPI3, Spi3, VSPICLK, VSPID, VSPIQ, VSPICS0));
_for_each_inner_spi_slave!((all(SPI2, Spi2, HSPICLK, HSPID, HSPIQ, HSPICS0),
(SPI3, Spi3, VSPICLK, VSPID, VSPIQ, VSPICS0)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_peripheral {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner_peripheral { $(($pattern) => $code;)* ($other : tt)
=> {} } _for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO0 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO0 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO1 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO1 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc = "GPIO4 peripheral singleton"]
GPIO4 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
"</ul>"] #[doc = "</section>"] GPIO6 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
"</ul>"] #[doc = "</section>"] GPIO7 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
"</ul>"] #[doc = "</section>"] GPIO8 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
"</ul>"] #[doc = "</section>"] GPIO9 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO10 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
"</ul>"] #[doc = "</section>"] GPIO10 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
"</ul>"] #[doc = "</section>"] GPIO11 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
=
"<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
#[doc = "</ul>"] #[doc = "</section>"] GPIO12 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
#[doc = "</ul>"] #[doc = "</section>"] GPIO13 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
#[doc = "</ul>"] #[doc = "</section>"] GPIO14 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
=
"<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
#[doc = "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
"</ul>"] #[doc = "</section>"] GPIO16 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
"</ul>"] #[doc = "</section>"] GPIO17 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc = "GPIO18 peripheral singleton"]
GPIO18 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO19 peripheral singleton"] GPIO19 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc = "<li>This pin is only available on ESP32-PICO-V3.</li>"]
#[doc = "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc = "GPIO21 peripheral singleton"]
GPIO21 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO22 peripheral singleton"] GPIO22 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc = "GPIO23 peripheral singleton"]
GPIO23 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO25 peripheral singleton"] GPIO25 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc = "GPIO26 peripheral singleton"]
GPIO26 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO27 peripheral singleton"] GPIO27 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc = "GPIO32 peripheral singleton"]
GPIO32 <= virtual())); _for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO33 peripheral singleton"] GPIO33 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO34 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO34 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO35 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO35 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO36 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO36 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO37 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO37 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO38 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO38 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO39 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO39 <= virtual()));
_for_each_inner_peripheral!((@ peri_type #[doc = "AES peripheral singleton"] AES
<= AES() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"APB_CTRL peripheral singleton"] APB_CTRL <= APB_CTRL() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "BB peripheral singleton"] BB <=
BB() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"DPORT peripheral singleton"] DPORT <= DPORT() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "SYSTEM peripheral singleton"]
SYSTEM <= DPORT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "EMAC_DMA peripheral singleton"]
EMAC_DMA <= EMAC_DMA() (unstable))); _for_each_inner_peripheral!((@ peri_type
#[doc = "EMAC_EXT peripheral singleton"] EMAC_EXT <= EMAC_EXT() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "EMAC_MAC peripheral singleton"]
EMAC_MAC <= EMAC_MAC() (unstable))); _for_each_inner_peripheral!((@ peri_type
#[doc = "FLASH_ENCRYPTION peripheral singleton"] FLASH_ENCRYPTION <=
FLASH_ENCRYPTION() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"FRC_TIMER peripheral singleton"] FRC_TIMER <= FRC_TIMER() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "GPIO peripheral singleton"]
GPIO <= GPIO() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"GPIO_SD peripheral singleton"] GPIO_SD <= GPIO_SD() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "HINF peripheral singleton"]
HINF <= HINF() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"I2C0 peripheral singleton"] I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt,
enable_peri_interrupt, disable_peri_interrupt })));
_for_each_inner_peripheral!((@ peri_type #[doc = "I2C1 peripheral singleton"]
I2C1 <= I2C1(I2C_EXT1 : { bind_peri_interrupt, enable_peri_interrupt,
disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
"I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "I2S1 peripheral singleton"]
I2S1 <= I2S1(I2S1 : { bind_peri_interrupt, enable_peri_interrupt,
disable_peri_interrupt }) (unstable))); _for_each_inner_peripheral!((@ peri_type
#[doc = "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "LEDC peripheral singleton"]
LEDC <= LEDC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "MCPWM1 peripheral singleton"]
MCPWM1 <= MCPWM1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"NRX peripheral singleton"] NRX <= NRX() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "PCNT peripheral singleton"]
PCNT <= PCNT() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"RMT peripheral singleton"] RMT <= RMT() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "RNG peripheral singleton"] RNG
<= RNG() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"RSA peripheral singleton"] RSA <= RSA(RSA : { bind_peri_interrupt,
enable_peri_interrupt, disable_peri_interrupt }) (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "LPWR peripheral singleton"]
LPWR <= RTC_CNTL() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"RTC_I2C peripheral singleton"] RTC_I2C <= RTC_I2C() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "RTC_IO peripheral singleton"]
RTC_IO <= RTC_IO() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"SDHOST peripheral singleton"] SDHOST <= SDHOST() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "SENS peripheral singleton"]
SENS <= SENS() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"SHA peripheral singleton"] SHA <= SHA() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "SLC peripheral singleton"] SLC
<= SLC() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"SLCHOST peripheral singleton"] SLCHOST <= SLCHOST() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "SPI0 peripheral singleton"]
SPI0 <= SPI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"SPI1 peripheral singleton"] SPI1 <= SPI1() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "SPI2 peripheral singleton"]
SPI2 <= SPI2(SPI2_DMA : { bind_dma_interrupt, enable_dma_interrupt,
disable_dma_interrupt }, SPI2 : { bind_peri_interrupt, enable_peri_interrupt,
disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
"SPI3 peripheral singleton"] SPI3 <= SPI3(SPI3_DMA : { bind_dma_interrupt,
enable_dma_interrupt, disable_dma_interrupt }, SPI3 : { bind_peri_interrupt,
enable_peri_interrupt, disable_peri_interrupt })));
_for_each_inner_peripheral!((@ peri_type #[doc = "TIMG0 peripheral singleton"]
TIMG0 <= TIMG0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "TWAI0 peripheral singleton"]
TWAI0 <= TWAI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"UART0 peripheral singleton"] UART0 <= UART0(UART0 : { bind_peri_interrupt,
enable_peri_interrupt, disable_peri_interrupt })));
_for_each_inner_peripheral!((@ peri_type #[doc = "UART1 peripheral singleton"]
UART1 <= UART1(UART1 : { bind_peri_interrupt, enable_peri_interrupt,
disable_peri_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
"UART2 peripheral singleton"] UART2 <= UART2(UART2 : { bind_peri_interrupt,
enable_peri_interrupt, disable_peri_interrupt })));
_for_each_inner_peripheral!((@ peri_type #[doc = "UHCI0 peripheral singleton"]
UHCI0 <= UHCI0() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"UHCI1 peripheral singleton"] UHCI1 <= UHCI1() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "WIFI peripheral singleton"]
WIFI <= WIFI(WIFI_MAC : { bind_mac_interrupt, enable_mac_interrupt,
disable_mac_interrupt }))); _for_each_inner_peripheral!((@ peri_type #[doc =
"DMA_SPI2 peripheral singleton"] DMA_SPI2 <= SPI2() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "DMA_SPI3 peripheral singleton"]
DMA_SPI3 <= SPI3() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"DMA_I2S0 peripheral singleton"] DMA_I2S0 <= I2S0() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "DMA_I2S1 peripheral singleton"]
DMA_I2S1 <= I2S1() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"ADC1 peripheral singleton"] ADC1 <= virtual() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "ADC2 peripheral singleton"]
ADC2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"BT peripheral singleton"] BT <= virtual(BT_BB : { bind_bb_interrupt,
enable_bb_interrupt, disable_bb_interrupt }, RWBLE : { bind_rwble_interrupt,
enable_rwble_interrupt, disable_rwble_interrupt }, RWBT : { bind_rwbt_interrupt,
enable_rwbt_interrupt, disable_rwbt_interrupt }) (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "CPU_CTRL peripheral singleton"]
CPU_CTRL <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type
#[doc = "DAC1 peripheral singleton"] DAC1 <= virtual() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "DAC2 peripheral singleton"]
DAC2 <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"FLASH peripheral singleton"] FLASH <= virtual() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "PSRAM peripheral singleton"]
PSRAM <= virtual() (unstable))); _for_each_inner_peripheral!((@ peri_type #[doc =
"SW_INTERRUPT peripheral singleton"] SW_INTERRUPT <= virtual() (unstable)));
_for_each_inner_peripheral!((@ peri_type #[doc = "TOUCH peripheral singleton"]
TOUCH <= virtual() (unstable))); _for_each_inner_peripheral!((GPIO0));
_for_each_inner_peripheral!((GPIO1)); _for_each_inner_peripheral!((GPIO2));
_for_each_inner_peripheral!((GPIO3)); _for_each_inner_peripheral!((GPIO4));
_for_each_inner_peripheral!((GPIO5)); _for_each_inner_peripheral!((GPIO6));
_for_each_inner_peripheral!((GPIO7)); _for_each_inner_peripheral!((GPIO8));
_for_each_inner_peripheral!((GPIO9)); _for_each_inner_peripheral!((GPIO10));
_for_each_inner_peripheral!((GPIO11)); _for_each_inner_peripheral!((GPIO12));
_for_each_inner_peripheral!((GPIO13)); _for_each_inner_peripheral!((GPIO14));
_for_each_inner_peripheral!((GPIO15)); _for_each_inner_peripheral!((GPIO16));
_for_each_inner_peripheral!((GPIO17)); _for_each_inner_peripheral!((GPIO18));
_for_each_inner_peripheral!((GPIO19)); _for_each_inner_peripheral!((GPIO20));
_for_each_inner_peripheral!((GPIO21)); _for_each_inner_peripheral!((GPIO22));
_for_each_inner_peripheral!((GPIO23)); _for_each_inner_peripheral!((GPIO25));
_for_each_inner_peripheral!((GPIO26)); _for_each_inner_peripheral!((GPIO27));
_for_each_inner_peripheral!((GPIO32)); _for_each_inner_peripheral!((GPIO33));
_for_each_inner_peripheral!((GPIO34)); _for_each_inner_peripheral!((GPIO35));
_for_each_inner_peripheral!((GPIO36)); _for_each_inner_peripheral!((GPIO37));
_for_each_inner_peripheral!((GPIO38)); _for_each_inner_peripheral!((GPIO39));
_for_each_inner_peripheral!((AES(unstable)));
_for_each_inner_peripheral!((APB_CTRL(unstable)));
_for_each_inner_peripheral!((BB(unstable)));
_for_each_inner_peripheral!((DPORT(unstable)));
_for_each_inner_peripheral!((SYSTEM(unstable)));
_for_each_inner_peripheral!((EMAC_DMA(unstable)));
_for_each_inner_peripheral!((EMAC_EXT(unstable)));
_for_each_inner_peripheral!((EMAC_MAC(unstable)));
_for_each_inner_peripheral!((FLASH_ENCRYPTION(unstable)));
_for_each_inner_peripheral!((FRC_TIMER(unstable)));
_for_each_inner_peripheral!((GPIO(unstable)));
_for_each_inner_peripheral!((GPIO_SD(unstable)));
_for_each_inner_peripheral!((HINF(unstable)));
_for_each_inner_peripheral!((I2C0)); _for_each_inner_peripheral!((I2C1));
_for_each_inner_peripheral!((I2S0(unstable)));
_for_each_inner_peripheral!((I2S1(unstable)));
_for_each_inner_peripheral!((IO_MUX(unstable)));
_for_each_inner_peripheral!((LEDC(unstable)));
_for_each_inner_peripheral!((MCPWM0(unstable)));
_for_each_inner_peripheral!((MCPWM1(unstable)));
_for_each_inner_peripheral!((NRX(unstable)));
_for_each_inner_peripheral!((PCNT(unstable)));
_for_each_inner_peripheral!((RMT(unstable)));
_for_each_inner_peripheral!((RNG(unstable)));
_for_each_inner_peripheral!((RSA(unstable)));
_for_each_inner_peripheral!((LPWR(unstable)));
_for_each_inner_peripheral!((RTC_I2C(unstable)));
_for_each_inner_peripheral!((RTC_IO(unstable)));
_for_each_inner_peripheral!((SDHOST(unstable)));
_for_each_inner_peripheral!((SENS(unstable)));
_for_each_inner_peripheral!((SHA(unstable)));
_for_each_inner_peripheral!((SLC(unstable)));
_for_each_inner_peripheral!((SLCHOST(unstable)));
_for_each_inner_peripheral!((SPI0(unstable)));
_for_each_inner_peripheral!((SPI1(unstable)));
_for_each_inner_peripheral!((SPI2)); _for_each_inner_peripheral!((SPI3));
_for_each_inner_peripheral!((TIMG0(unstable)));
_for_each_inner_peripheral!((TIMG1(unstable)));
_for_each_inner_peripheral!((TWAI0(unstable)));
_for_each_inner_peripheral!((UART0)); _for_each_inner_peripheral!((UART1));
_for_each_inner_peripheral!((UART2));
_for_each_inner_peripheral!((UHCI0(unstable)));
_for_each_inner_peripheral!((UHCI1(unstable)));
_for_each_inner_peripheral!((WIFI));
_for_each_inner_peripheral!((DMA_SPI2(unstable)));
_for_each_inner_peripheral!((DMA_SPI3(unstable)));
_for_each_inner_peripheral!((DMA_I2S0(unstable)));
_for_each_inner_peripheral!((DMA_I2S1(unstable)));
_for_each_inner_peripheral!((ADC1(unstable)));
_for_each_inner_peripheral!((ADC2(unstable)));
_for_each_inner_peripheral!((BT(unstable)));
_for_each_inner_peripheral!((CPU_CTRL(unstable)));
_for_each_inner_peripheral!((DAC1(unstable)));
_for_each_inner_peripheral!((DAC2(unstable)));
_for_each_inner_peripheral!((FLASH(unstable)));
_for_each_inner_peripheral!((PSRAM(unstable)));
_for_each_inner_peripheral!((SW_INTERRUPT(unstable)));
_for_each_inner_peripheral!((TOUCH(unstable)));
_for_each_inner_peripheral!((I2S0, I2s0, 0)); _for_each_inner_peripheral!((I2S1,
I2s1, 1)); _for_each_inner_peripheral!((SPI2, Spi2, 2));
_for_each_inner_peripheral!((SPI3, Spi3, 3)); _for_each_inner_peripheral!((UHCI0,
Uhci0, 4)); _for_each_inner_peripheral!((UHCI1, Uhci1, 5));
_for_each_inner_peripheral!((all(@ peri_type #[doc =
"GPIO0 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO0 <= virtual()), (@ peri_type #[doc =
"GPIO1 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO1 <= virtual()), (@ peri_type #[doc =
"GPIO2 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO2 <= virtual()), (@ peri_type #[doc =
"GPIO3 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>By default, this pin is used by the UART programming interface.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO3 <= virtual()), (@ peri_type #[doc =
"GPIO4 peripheral singleton"] GPIO4 <= virtual()), (@ peri_type #[doc =
"GPIO5 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO5 <= virtual()), (@ peri_type #[doc =
"GPIO6 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
"</ul>"] #[doc = "</section>"] GPIO6 <= virtual()), (@ peri_type #[doc =
"GPIO7 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
"</ul>"] #[doc = "</section>"] GPIO7 <= virtual()), (@ peri_type #[doc =
"GPIO8 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
"</ul>"] #[doc = "</section>"] GPIO8 <= virtual()), (@ peri_type #[doc =
"GPIO9 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
"</ul>"] #[doc = "</section>"] GPIO9 <= virtual()), (@ peri_type #[doc =
"GPIO10 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
"</ul>"] #[doc = "</section>"] GPIO10 <= virtual()), (@ peri_type #[doc =
"GPIO11 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
"</ul>"] #[doc = "</section>"] GPIO11 <= virtual()), (@ peri_type #[doc =
"GPIO12 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
=
"<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
#[doc = "</ul>"] #[doc = "</section>"] GPIO12 <= virtual()), (@ peri_type #[doc =
"GPIO13 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
#[doc = "</ul>"] #[doc = "</section>"] GPIO13 <= virtual()), (@ peri_type #[doc =
"GPIO14 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
#[doc = "</ul>"] #[doc = "</section>"] GPIO14 <= virtual()), (@ peri_type #[doc =
"GPIO15 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin is a strapping pin, it determines how the chip boots.</li>"] #[doc
=
"<li>These pins may be used to debug the chip using an external JTAG debugger.</li>"]
#[doc = "</ul>"] #[doc = "</section>"] GPIO15 <= virtual()), (@ peri_type #[doc =
"GPIO16 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI flash.</li>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
"</ul>"] #[doc = "</section>"] GPIO16 <= virtual()), (@ peri_type #[doc =
"GPIO17 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc =
"<li>This pin may be reserved for interfacing with SPI PSRAM.</li>"] #[doc =
"</ul>"] #[doc = "</section>"] GPIO17 <= virtual()), (@ peri_type #[doc =
"GPIO18 peripheral singleton"] GPIO18 <= virtual()), (@ peri_type #[doc =
"GPIO19 peripheral singleton"] GPIO19 <= virtual()), (@ peri_type #[doc =
"GPIO20 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc = "<li>This pin is only available on ESP32-PICO-V3.</li>"]
#[doc = "</ul>"] #[doc = "</section>"] GPIO20 <= virtual()), (@ peri_type #[doc =
"GPIO21 peripheral singleton"] GPIO21 <= virtual()), (@ peri_type #[doc =
"GPIO22 peripheral singleton"] GPIO22 <= virtual()), (@ peri_type #[doc =
"GPIO23 peripheral singleton"] GPIO23 <= virtual()), (@ peri_type #[doc =
"GPIO25 peripheral singleton"] GPIO25 <= virtual()), (@ peri_type #[doc =
"GPIO26 peripheral singleton"] GPIO26 <= virtual()), (@ peri_type #[doc =
"GPIO27 peripheral singleton"] GPIO27 <= virtual()), (@ peri_type #[doc =
"GPIO32 peripheral singleton"] GPIO32 <= virtual()), (@ peri_type #[doc =
"GPIO33 peripheral singleton"] GPIO33 <= virtual()), (@ peri_type #[doc =
"GPIO34 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO34 <= virtual()), (@ peri_type #[doc =
"GPIO35 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO35 <= virtual()), (@ peri_type #[doc =
"GPIO36 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO36 <= virtual()), (@ peri_type #[doc =
"GPIO37 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO37 <= virtual()), (@ peri_type #[doc =
"GPIO38 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO38 <= virtual()), (@ peri_type #[doc =
"GPIO39 peripheral singleton (Limitations exist)"] #[doc = ""] #[doc =
"<section class=\"warning\">"] #[doc =
"This pin may be available with certain limitations. Check your hardware to make sure whether you can use it."]
#[doc = "<ul>"] #[doc = "<li>This pin can only be used as an input.</li>"] #[doc
= "</ul>"] #[doc = "</section>"] GPIO39 <= virtual()), (@ peri_type #[doc =
"AES peripheral singleton"] AES <= AES() (unstable)), (@ peri_type #[doc =
"APB_CTRL peripheral singleton"] APB_CTRL <= APB_CTRL() (unstable)), (@ peri_type
#[doc = "BB peripheral singleton"] BB <= BB() (unstable)), (@ peri_type #[doc =
"DPORT peripheral singleton"] DPORT <= DPORT() (unstable)), (@ peri_type #[doc =
"SYSTEM peripheral singleton"] SYSTEM <= DPORT() (unstable)), (@ peri_type #[doc
= "EFUSE peripheral singleton"] EFUSE <= EFUSE() (unstable)), (@ peri_type #[doc
= "EMAC_DMA peripheral singleton"] EMAC_DMA <= EMAC_DMA() (unstable)), (@
peri_type #[doc = "EMAC_EXT peripheral singleton"] EMAC_EXT <= EMAC_EXT()
(unstable)), (@ peri_type #[doc = "EMAC_MAC peripheral singleton"] EMAC_MAC <=
EMAC_MAC() (unstable)), (@ peri_type #[doc =
"FLASH_ENCRYPTION peripheral singleton"] FLASH_ENCRYPTION <= FLASH_ENCRYPTION()
(unstable)), (@ peri_type #[doc = "FRC_TIMER peripheral singleton"] FRC_TIMER <=
FRC_TIMER() (unstable)), (@ peri_type #[doc = "GPIO peripheral singleton"] GPIO
<= GPIO() (unstable)), (@ peri_type #[doc = "GPIO_SD peripheral singleton"]
GPIO_SD <= GPIO_SD() (unstable)), (@ peri_type #[doc =
"HINF peripheral singleton"] HINF <= HINF() (unstable)), (@ peri_type #[doc =
"I2C0 peripheral singleton"] I2C0 <= I2C0(I2C_EXT0 : { bind_peri_interrupt,
enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
"I2C1 peripheral singleton"] I2C1 <= I2C1(I2C_EXT1 : { bind_peri_interrupt,
enable_peri_interrupt, disable_peri_interrupt })), (@ peri_type #[doc =
"I2S0 peripheral singleton"] I2S0 <= I2S0(I2S0 : { bind_peri_interrupt,
enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
= "I2S1 peripheral singleton"] I2S1 <= I2S1(I2S1 : { bind_peri_interrupt,
enable_peri_interrupt, disable_peri_interrupt }) (unstable)), (@ peri_type #[doc
= "IO_MUX peripheral singleton"] IO_MUX <= IO_MUX() (unstable)), (@ peri_type
#[doc = "LEDC peripheral singleton"] LEDC <= LEDC() (unstable)), (@ peri_type
#[doc = "MCPWM0 peripheral singleton"] MCPWM0 <= MCPWM0() (unstable)), (@
peri_type #[doc = "MCPWM1 peripheral singleton"] MCPWM1 <= MCPWM1() (unstable)),
(@ peri_type #[doc = "NRX peripheral singleton"] NRX <= NRX() (unstable)), (@
peri_type #[doc = "PCNT peripheral singleton"] PCNT <= PCNT() (unstable)), (@
peri_type #[doc = "RMT peripheral singleton"] RMT <= RMT() (unstable)), (@
peri_type #[doc = "RNG peripheral singleton"] RNG <= RNG() (unstable)), (@
peri_type #[doc = "RSA peripheral singleton"] RSA <= RSA(RSA : {
bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })
(unstable)), (@ peri_type #[doc = "LPWR peripheral singleton"] LPWR <= RTC_CNTL()
(unstable)), (@ peri_type #[doc = "RTC_I2C peripheral singleton"] RTC_I2C <=
RTC_I2C() (unstable)), (@ peri_type #[doc = "RTC_IO peripheral singleton"] RTC_IO
<= RTC_IO() (unstable)), (@ peri_type #[doc = "SDHOST peripheral singleton"]
SDHOST <= SDHOST() (unstable)), (@ peri_type #[doc = "SENS peripheral singleton"]
SENS <= SENS() (unstable)), (@ peri_type #[doc = "SHA peripheral singleton"] SHA
<= SHA() (unstable)), (@ peri_type #[doc = "SLC peripheral singleton"] SLC <=
SLC() (unstable)), (@ peri_type #[doc = "SLCHOST peripheral singleton"] SLCHOST
<= SLCHOST() (unstable)), (@ peri_type #[doc = "SPI0 peripheral singleton"] SPI0
<= SPI0() (unstable)), (@ peri_type #[doc = "SPI1 peripheral singleton"] SPI1 <=
SPI1() (unstable)), (@ peri_type #[doc = "SPI2 peripheral singleton"] SPI2 <=
SPI2(SPI2_DMA : { bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt
}, SPI2 : { bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt
})), (@ peri_type #[doc = "SPI3 peripheral singleton"] SPI3 <= SPI3(SPI3_DMA : {
bind_dma_interrupt, enable_dma_interrupt, disable_dma_interrupt }, SPI3 : {
bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
peri_type #[doc = "TIMG0 peripheral singleton"] TIMG0 <= TIMG0() (unstable)), (@
peri_type #[doc = "TIMG1 peripheral singleton"] TIMG1 <= TIMG1() (unstable)), (@
peri_type #[doc = "TWAI0 peripheral singleton"] TWAI0 <= TWAI0() (unstable)), (@
peri_type #[doc = "UART0 peripheral singleton"] UART0 <= UART0(UART0 : {
bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
peri_type #[doc = "UART1 peripheral singleton"] UART1 <= UART1(UART1 : {
bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
peri_type #[doc = "UART2 peripheral singleton"] UART2 <= UART2(UART2 : {
bind_peri_interrupt, enable_peri_interrupt, disable_peri_interrupt })), (@
peri_type #[doc = "UHCI0 peripheral singleton"] UHCI0 <= UHCI0() (unstable)), (@
peri_type #[doc = "UHCI1 peripheral singleton"] UHCI1 <= UHCI1() (unstable)), (@
peri_type #[doc = "WIFI peripheral singleton"] WIFI <= WIFI(WIFI_MAC : {
bind_mac_interrupt, enable_mac_interrupt, disable_mac_interrupt })), (@ peri_type
#[doc = "DMA_SPI2 peripheral singleton"] DMA_SPI2 <= SPI2() (unstable)), (@
peri_type #[doc = "DMA_SPI3 peripheral singleton"] DMA_SPI3 <= SPI3()
(unstable)), (@ peri_type #[doc = "DMA_I2S0 peripheral singleton"] DMA_I2S0 <=
I2S0() (unstable)), (@ peri_type #[doc = "DMA_I2S1 peripheral singleton"]
DMA_I2S1 <= I2S1() (unstable)), (@ peri_type #[doc = "ADC1 peripheral singleton"]
ADC1 <= virtual() (unstable)), (@ peri_type #[doc = "ADC2 peripheral singleton"]
ADC2 <= virtual() (unstable)), (@ peri_type #[doc = "BT peripheral singleton"] BT
<= virtual(BT_BB : { bind_bb_interrupt, enable_bb_interrupt, disable_bb_interrupt
}, RWBLE : { bind_rwble_interrupt, enable_rwble_interrupt,
disable_rwble_interrupt }, RWBT : { bind_rwbt_interrupt, enable_rwbt_interrupt,
disable_rwbt_interrupt }) (unstable)), (@ peri_type #[doc =
"CPU_CTRL peripheral singleton"] CPU_CTRL <= virtual() (unstable)), (@ peri_type
#[doc = "DAC1 peripheral singleton"] DAC1 <= virtual() (unstable)), (@ peri_type
#[doc = "DAC2 peripheral singleton"] DAC2 <= virtual() (unstable)), (@ peri_type
#[doc = "FLASH peripheral singleton"] FLASH <= virtual() (unstable)), (@
peri_type #[doc = "PSRAM peripheral singleton"] PSRAM <= virtual() (unstable)),
(@ peri_type #[doc = "SW_INTERRUPT peripheral singleton"] SW_INTERRUPT <=
virtual() (unstable)), (@ peri_type #[doc = "TOUCH peripheral singleton"] TOUCH
<= virtual() (unstable)))); _for_each_inner_peripheral!((singletons(GPIO0),
(GPIO1), (GPIO2), (GPIO3), (GPIO4), (GPIO5), (GPIO6), (GPIO7), (GPIO8), (GPIO9),
(GPIO10), (GPIO11), (GPIO12), (GPIO13), (GPIO14), (GPIO15), (GPIO16), (GPIO17),
(GPIO18), (GPIO19), (GPIO20), (GPIO21), (GPIO22), (GPIO23), (GPIO25), (GPIO26),
(GPIO27), (GPIO32), (GPIO33), (GPIO34), (GPIO35), (GPIO36), (GPIO37), (GPIO38),
(GPIO39), (AES(unstable)), (APB_CTRL(unstable)), (BB(unstable)),
(DPORT(unstable)), (SYSTEM(unstable)), (EMAC_DMA(unstable)),
(EMAC_EXT(unstable)), (EMAC_MAC(unstable)), (FLASH_ENCRYPTION(unstable)),
(FRC_TIMER(unstable)), (GPIO(unstable)), (GPIO_SD(unstable)), (HINF(unstable)),
(I2C0), (I2C1), (I2S0(unstable)), (I2S1(unstable)), (IO_MUX(unstable)),
(LEDC(unstable)), (MCPWM0(unstable)), (MCPWM1(unstable)), (NRX(unstable)),
(PCNT(unstable)), (RMT(unstable)), (RNG(unstable)), (RSA(unstable)),
(LPWR(unstable)), (RTC_I2C(unstable)), (RTC_IO(unstable)), (SDHOST(unstable)),
(SENS(unstable)), (SHA(unstable)), (SLC(unstable)), (SLCHOST(unstable)),
(SPI0(unstable)), (SPI1(unstable)), (SPI2), (SPI3), (TIMG0(unstable)),
(TIMG1(unstable)), (TWAI0(unstable)), (UART0), (UART1), (UART2),
(UHCI0(unstable)), (UHCI1(unstable)), (WIFI), (DMA_SPI2(unstable)),
(DMA_SPI3(unstable)), (DMA_I2S0(unstable)), (DMA_I2S1(unstable)),
(ADC1(unstable)), (ADC2(unstable)), (BT(unstable)), (CPU_CTRL(unstable)),
(DAC1(unstable)), (DAC2(unstable)), (FLASH(unstable)), (PSRAM(unstable)),
(SW_INTERRUPT(unstable)), (TOUCH(unstable))));
_for_each_inner_peripheral!((dma_eligible(I2S0, I2s0, 0), (I2S1, I2s1, 1), (SPI2,
Spi2, 2), (SPI3, Spi3, 3), (UHCI0, Uhci0, 4), (UHCI1, Uhci1, 5)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_gpio {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner_gpio { $(($pattern) => $code;)* ($other : tt) => {}
} _for_each_inner_gpio!((0, GPIO0(_5 => EMAC_TX_CLK) (_1 => CLK_OUT1 _5 =>
EMAC_TX_CLK) ([Input] [Output]))); _for_each_inner_gpio!((1, GPIO1(_5 =>
EMAC_RXD2) (_0 => U0TXD _1 => CLK_OUT3) ([Input] [Output])));
_for_each_inner_gpio!((2, GPIO2(_1 => HSPIWP _3 => HS2_DATA0 _4 => SD_DATA0) (_1
=> HSPIWP _3 => HS2_DATA0 _4 => SD_DATA0) ([Input] [Output])));
_for_each_inner_gpio!((3, GPIO3(_0 => U0RXD) (_1 => CLK_OUT2) ([Input]
[Output]))); _for_each_inner_gpio!((4, GPIO4(_1 => HSPIHD _3 => HS2_DATA1 _4 =>
SD_DATA1 _5 => EMAC_TX_ER) (_1 => HSPIHD _3 => HS2_DATA1 _4 => SD_DATA1 _5 =>
EMAC_TX_ER) ([Input] [Output]))); _for_each_inner_gpio!((5, GPIO5(_1 => VSPICS0
_3 => HS1_DATA6 _5 => EMAC_RX_CLK) (_1 => VSPICS0 _3 => HS1_DATA6) ([Input]
[Output]))); _for_each_inner_gpio!((6, GPIO6(_1 => SPICLK _4 => U1CTS) (_0 =>
SD_CLK _1 => SPICLK _3 => HS1_CLK) ([Input] [Output])));
_for_each_inner_gpio!((7, GPIO7(_0 => SD_DATA0 _1 => SPIQ _3 => HS1_DATA0) (_0 =>
SD_DATA0 _1 => SPIQ _3 => HS1_DATA0 _4 => U2RTS) ([Input] [Output])));
_for_each_inner_gpio!((8, GPIO8(_0 => SD_DATA1 _1 => SPID _3 => HS1_DATA1 _4 =>
U2CTS) (_0 => SD_DATA1 _1 => SPID _3 => HS1_DATA1) ([Input] [Output])));
_for_each_inner_gpio!((9, GPIO9(_0 => SD_DATA2 _1 => SPIHD _3 => HS1_DATA2 _4 =>
U1RXD) (_0 => SD_DATA2 _1 => SPIHD _3 => HS1_DATA2) ([Input] [Output])));
_for_each_inner_gpio!((10, GPIO10(_0 => SD_DATA3 _1 => SPIWP _3 => HS1_DATA3) (_0
=> SD_DATA3 _1 => SPIWP _3 => HS1_DATA3 _4 => U1TXD) ([Input] [Output])));
_for_each_inner_gpio!((11, GPIO11(_0 => SD_CMD _1 => SPICS0) (_0 => SD_CMD _1 =>
SPICS0 _3 => HS1_CMD _4 => U1RTS) ([Input] [Output])));
_for_each_inner_gpio!((12, GPIO12(_0 => MTDI _1 => HSPIQ _3 => HS2_DATA2 _4 =>
SD_DATA2) (_1 => HSPIQ _3 => HS2_DATA2 _4 => SD_DATA2 _5 => EMAC_TXD3) ([Input]
[Output]))); _for_each_inner_gpio!((13, GPIO13(_0 => MTCK _1 => HSPID _3 =>
HS2_DATA3 _4 => SD_DATA3 _5 => EMAC_RX_ER) (_1 => HSPID _3 => HS2_DATA3 _4 =>
SD_DATA3 _5 => EMAC_RX_ER) ([Input] [Output]))); _for_each_inner_gpio!((14,
GPIO14(_0 => MTMS _1 => HSPICLK) (_1 => HSPICLK _3 => HS2_CLK _4 => SD_CLK _5 =>
EMAC_TXD2) ([Input] [Output]))); _for_each_inner_gpio!((15, GPIO15(_1 => HSPICS0
_4 => SD_CMD _5 => EMAC_RXD3) (_0 => MTDO _1 => HSPICS0 _3 => HS2_CMD _4 =>
SD_CMD) ([Input] [Output]))); _for_each_inner_gpio!((16, GPIO16(_3 => HS1_DATA4
_4 => U2RXD) (_3 => HS1_DATA4 _5 => EMAC_CLK_OUT) ([Input] [Output])));
_for_each_inner_gpio!((17, GPIO17(_3 => HS1_DATA5) (_3 => HS1_DATA5 _4 => U2TXD
_5 => EMAC_CLK_180) ([Input] [Output]))); _for_each_inner_gpio!((18, GPIO18(_1 =>
VSPICLK _3 => HS1_DATA7) (_1 => VSPICLK _3 => HS1_DATA7) ([Input] [Output])));
_for_each_inner_gpio!((19, GPIO19(_1 => VSPIQ _3 => U0CTS) (_1 => VSPIQ _5 =>
EMAC_TXD0) ([Input] [Output]))); _for_each_inner_gpio!((20, GPIO20() () ([Input]
[Output]))); _for_each_inner_gpio!((21, GPIO21(_1 => VSPIHD) (_1 => VSPIHD _5 =>
EMAC_TX_EN) ([Input] [Output]))); _for_each_inner_gpio!((22, GPIO22(_1 => VSPIWP)
(_1 => VSPIWP _3 => U0RTS _5 => EMAC_TXD1) ([Input] [Output])));
_for_each_inner_gpio!((23, GPIO23(_1 => VSPID) (_1 => VSPID _3 => HS1_STROBE)
([Input] [Output]))); _for_each_inner_gpio!((25, GPIO25(_5 => EMAC_RXD0) ()
([Input] [Output]))); _for_each_inner_gpio!((26, GPIO26(_5 => EMAC_RXD1) ()
([Input] [Output]))); _for_each_inner_gpio!((27, GPIO27(_5 => EMAC_RX_DV) ()
([Input] [Output]))); _for_each_inner_gpio!((32, GPIO32() () ([Input]
[Output]))); _for_each_inner_gpio!((33, GPIO33() () ([Input] [Output])));
_for_each_inner_gpio!((34, GPIO34() () ([Input] []))); _for_each_inner_gpio!((35,
GPIO35() () ([Input] []))); _for_each_inner_gpio!((36, GPIO36() () ([Input]
[]))); _for_each_inner_gpio!((37, GPIO37() () ([Input] [])));
_for_each_inner_gpio!((38, GPIO38() () ([Input] []))); _for_each_inner_gpio!((39,
GPIO39() () ([Input] []))); _for_each_inner_gpio!((all(0, GPIO0(_5 =>
EMAC_TX_CLK) (_1 => CLK_OUT1 _5 => EMAC_TX_CLK) ([Input] [Output])), (1, GPIO1(_5
=> EMAC_RXD2) (_0 => U0TXD _1 => CLK_OUT3) ([Input] [Output])), (2, GPIO2(_1 =>
HSPIWP _3 => HS2_DATA0 _4 => SD_DATA0) (_1 => HSPIWP _3 => HS2_DATA0 _4 =>
SD_DATA0) ([Input] [Output])), (3, GPIO3(_0 => U0RXD) (_1 => CLK_OUT2) ([Input]
[Output])), (4, GPIO4(_1 => HSPIHD _3 => HS2_DATA1 _4 => SD_DATA1 _5 =>
EMAC_TX_ER) (_1 => HSPIHD _3 => HS2_DATA1 _4 => SD_DATA1 _5 => EMAC_TX_ER)
([Input] [Output])), (5, GPIO5(_1 => VSPICS0 _3 => HS1_DATA6 _5 => EMAC_RX_CLK)
(_1 => VSPICS0 _3 => HS1_DATA6) ([Input] [Output])), (6, GPIO6(_1 => SPICLK _4 =>
U1CTS) (_0 => SD_CLK _1 => SPICLK _3 => HS1_CLK) ([Input] [Output])), (7,
GPIO7(_0 => SD_DATA0 _1 => SPIQ _3 => HS1_DATA0) (_0 => SD_DATA0 _1 => SPIQ _3 =>
HS1_DATA0 _4 => U2RTS) ([Input] [Output])), (8, GPIO8(_0 => SD_DATA1 _1 => SPID
_3 => HS1_DATA1 _4 => U2CTS) (_0 => SD_DATA1 _1 => SPID _3 => HS1_DATA1) ([Input]
[Output])), (9, GPIO9(_0 => SD_DATA2 _1 => SPIHD _3 => HS1_DATA2 _4 => U1RXD) (_0
=> SD_DATA2 _1 => SPIHD _3 => HS1_DATA2) ([Input] [Output])), (10, GPIO10(_0 =>
SD_DATA3 _1 => SPIWP _3 => HS1_DATA3) (_0 => SD_DATA3 _1 => SPIWP _3 => HS1_DATA3
_4 => U1TXD) ([Input] [Output])), (11, GPIO11(_0 => SD_CMD _1 => SPICS0) (_0 =>
SD_CMD _1 => SPICS0 _3 => HS1_CMD _4 => U1RTS) ([Input] [Output])), (12,
GPIO12(_0 => MTDI _1 => HSPIQ _3 => HS2_DATA2 _4 => SD_DATA2) (_1 => HSPIQ _3 =>
HS2_DATA2 _4 => SD_DATA2 _5 => EMAC_TXD3) ([Input] [Output])), (13, GPIO13(_0 =>
MTCK _1 => HSPID _3 => HS2_DATA3 _4 => SD_DATA3 _5 => EMAC_RX_ER) (_1 => HSPID _3
=> HS2_DATA3 _4 => SD_DATA3 _5 => EMAC_RX_ER) ([Input] [Output])), (14, GPIO14(_0
=> MTMS _1 => HSPICLK) (_1 => HSPICLK _3 => HS2_CLK _4 => SD_CLK _5 => EMAC_TXD2)
([Input] [Output])), (15, GPIO15(_1 => HSPICS0 _4 => SD_CMD _5 => EMAC_RXD3) (_0
=> MTDO _1 => HSPICS0 _3 => HS2_CMD _4 => SD_CMD) ([Input] [Output])), (16,
GPIO16(_3 => HS1_DATA4 _4 => U2RXD) (_3 => HS1_DATA4 _5 => EMAC_CLK_OUT) ([Input]
[Output])), (17, GPIO17(_3 => HS1_DATA5) (_3 => HS1_DATA5 _4 => U2TXD _5 =>
EMAC_CLK_180) ([Input] [Output])), (18, GPIO18(_1 => VSPICLK _3 => HS1_DATA7) (_1
=> VSPICLK _3 => HS1_DATA7) ([Input] [Output])), (19, GPIO19(_1 => VSPIQ _3 =>
U0CTS) (_1 => VSPIQ _5 => EMAC_TXD0) ([Input] [Output])), (20, GPIO20() ()
([Input] [Output])), (21, GPIO21(_1 => VSPIHD) (_1 => VSPIHD _5 => EMAC_TX_EN)
([Input] [Output])), (22, GPIO22(_1 => VSPIWP) (_1 => VSPIWP _3 => U0RTS _5 =>
EMAC_TXD1) ([Input] [Output])), (23, GPIO23(_1 => VSPID) (_1 => VSPID _3 =>
HS1_STROBE) ([Input] [Output])), (25, GPIO25(_5 => EMAC_RXD0) () ([Input]
[Output])), (26, GPIO26(_5 => EMAC_RXD1) () ([Input] [Output])), (27, GPIO27(_5
=> EMAC_RX_DV) () ([Input] [Output])), (32, GPIO32() () ([Input] [Output])), (33,
GPIO33() () ([Input] [Output])), (34, GPIO34() () ([Input] [])), (35, GPIO35() ()
([Input] [])), (36, GPIO36() () ([Input] [])), (37, GPIO37() () ([Input] [])),
(38, GPIO38() () ([Input] [])), (39, GPIO39() () ([Input] []))));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_analog_function {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner_analog_function { $(($pattern) => $code;)* ($other :
tt) => {} } _for_each_inner_analog_function!((ADC2_CH1, GPIO0));
_for_each_inner_analog_function!((TOUCH1, GPIO0));
_for_each_inner_analog_function!((ADC2_CH2, GPIO2));
_for_each_inner_analog_function!((TOUCH2, GPIO2));
_for_each_inner_analog_function!((ADC2_CH0, GPIO4));
_for_each_inner_analog_function!((TOUCH0, GPIO4));
_for_each_inner_analog_function!((ADC2_CH5, GPIO12));
_for_each_inner_analog_function!((TOUCH5, GPIO12));
_for_each_inner_analog_function!((ADC2_CH4, GPIO13));
_for_each_inner_analog_function!((TOUCH4, GPIO13));
_for_each_inner_analog_function!((ADC2_CH6, GPIO14));
_for_each_inner_analog_function!((TOUCH6, GPIO14));
_for_each_inner_analog_function!((ADC2_CH3, GPIO15));
_for_each_inner_analog_function!((TOUCH3, GPIO15));
_for_each_inner_analog_function!((DAC1, GPIO25));
_for_each_inner_analog_function!((ADC2_CH8, GPIO25));
_for_each_inner_analog_function!((DAC2, GPIO26));
_for_each_inner_analog_function!((ADC2_CH9, GPIO26));
_for_each_inner_analog_function!((ADC2_CH7, GPIO27));
_for_each_inner_analog_function!((TOUCH7, GPIO27));
_for_each_inner_analog_function!((XTAL_32K_P, GPIO32));
_for_each_inner_analog_function!((ADC1_CH4, GPIO32));
_for_each_inner_analog_function!((TOUCH9, GPIO32));
_for_each_inner_analog_function!((XTAL_32K_N, GPIO33));
_for_each_inner_analog_function!((ADC1_CH5, GPIO33));
_for_each_inner_analog_function!((TOUCH8, GPIO33));
_for_each_inner_analog_function!((ADC1_CH6, GPIO34));
_for_each_inner_analog_function!((ADC1_CH7, GPIO35));
_for_each_inner_analog_function!((ADC_H, GPIO36));
_for_each_inner_analog_function!((ADC1_CH0, GPIO36));
_for_each_inner_analog_function!((ADC_H, GPIO37));
_for_each_inner_analog_function!((ADC1_CH1, GPIO37));
_for_each_inner_analog_function!((ADC_H, GPIO38));
_for_each_inner_analog_function!((ADC1_CH2, GPIO38));
_for_each_inner_analog_function!((ADC_H, GPIO39));
_for_each_inner_analog_function!((ADC1_CH3, GPIO39));
_for_each_inner_analog_function!(((ADC2_CH1, ADCn_CHm, 2, 1), GPIO0));
_for_each_inner_analog_function!(((TOUCH1, TOUCHn, 1), GPIO0));
_for_each_inner_analog_function!(((ADC2_CH2, ADCn_CHm, 2, 2), GPIO2));
_for_each_inner_analog_function!(((TOUCH2, TOUCHn, 2), GPIO2));
_for_each_inner_analog_function!(((ADC2_CH0, ADCn_CHm, 2, 0), GPIO4));
_for_each_inner_analog_function!(((TOUCH0, TOUCHn, 0), GPIO4));
_for_each_inner_analog_function!(((ADC2_CH5, ADCn_CHm, 2, 5), GPIO12));
_for_each_inner_analog_function!(((TOUCH5, TOUCHn, 5), GPIO12));
_for_each_inner_analog_function!(((ADC2_CH4, ADCn_CHm, 2, 4), GPIO13));
_for_each_inner_analog_function!(((TOUCH4, TOUCHn, 4), GPIO13));
_for_each_inner_analog_function!(((ADC2_CH6, ADCn_CHm, 2, 6), GPIO14));
_for_each_inner_analog_function!(((TOUCH6, TOUCHn, 6), GPIO14));
_for_each_inner_analog_function!(((ADC2_CH3, ADCn_CHm, 2, 3), GPIO15));
_for_each_inner_analog_function!(((TOUCH3, TOUCHn, 3), GPIO15));
_for_each_inner_analog_function!(((DAC1, DACn, 1), GPIO25));
_for_each_inner_analog_function!(((ADC2_CH8, ADCn_CHm, 2, 8), GPIO25));
_for_each_inner_analog_function!(((DAC2, DACn, 2), GPIO26));
_for_each_inner_analog_function!(((ADC2_CH9, ADCn_CHm, 2, 9), GPIO26));
_for_each_inner_analog_function!(((ADC2_CH7, ADCn_CHm, 2, 7), GPIO27));
_for_each_inner_analog_function!(((TOUCH7, TOUCHn, 7), GPIO27));
_for_each_inner_analog_function!(((ADC1_CH4, ADCn_CHm, 1, 4), GPIO32));
_for_each_inner_analog_function!(((TOUCH9, TOUCHn, 9), GPIO32));
_for_each_inner_analog_function!(((ADC1_CH5, ADCn_CHm, 1, 5), GPIO33));
_for_each_inner_analog_function!(((TOUCH8, TOUCHn, 8), GPIO33));
_for_each_inner_analog_function!(((ADC1_CH6, ADCn_CHm, 1, 6), GPIO34));
_for_each_inner_analog_function!(((ADC1_CH7, ADCn_CHm, 1, 7), GPIO35));
_for_each_inner_analog_function!(((ADC1_CH0, ADCn_CHm, 1, 0), GPIO36));
_for_each_inner_analog_function!(((ADC1_CH1, ADCn_CHm, 1, 1), GPIO37));
_for_each_inner_analog_function!(((ADC1_CH2, ADCn_CHm, 1, 2), GPIO38));
_for_each_inner_analog_function!(((ADC1_CH3, ADCn_CHm, 1, 3), GPIO39));
_for_each_inner_analog_function!((all(ADC2_CH1, GPIO0), (TOUCH1, GPIO0),
(ADC2_CH2, GPIO2), (TOUCH2, GPIO2), (ADC2_CH0, GPIO4), (TOUCH0, GPIO4),
(ADC2_CH5, GPIO12), (TOUCH5, GPIO12), (ADC2_CH4, GPIO13), (TOUCH4, GPIO13),
(ADC2_CH6, GPIO14), (TOUCH6, GPIO14), (ADC2_CH3, GPIO15), (TOUCH3, GPIO15),
(DAC1, GPIO25), (ADC2_CH8, GPIO25), (DAC2, GPIO26), (ADC2_CH9, GPIO26),
(ADC2_CH7, GPIO27), (TOUCH7, GPIO27), (XTAL_32K_P, GPIO32), (ADC1_CH4, GPIO32),
(TOUCH9, GPIO32), (XTAL_32K_N, GPIO33), (ADC1_CH5, GPIO33), (TOUCH8, GPIO33),
(ADC1_CH6, GPIO34), (ADC1_CH7, GPIO35), (ADC_H, GPIO36), (ADC1_CH0, GPIO36),
(ADC_H, GPIO37), (ADC1_CH1, GPIO37), (ADC_H, GPIO38), (ADC1_CH2, GPIO38), (ADC_H,
GPIO39), (ADC1_CH3, GPIO39)));
_for_each_inner_analog_function!((all_expanded((ADC2_CH1, ADCn_CHm, 2, 1),
GPIO0), ((TOUCH1, TOUCHn, 1), GPIO0), ((ADC2_CH2, ADCn_CHm, 2, 2), GPIO2),
((TOUCH2, TOUCHn, 2), GPIO2), ((ADC2_CH0, ADCn_CHm, 2, 0), GPIO4), ((TOUCH0,
TOUCHn, 0), GPIO4), ((ADC2_CH5, ADCn_CHm, 2, 5), GPIO12), ((TOUCH5, TOUCHn, 5),
GPIO12), ((ADC2_CH4, ADCn_CHm, 2, 4), GPIO13), ((TOUCH4, TOUCHn, 4), GPIO13),
((ADC2_CH6, ADCn_CHm, 2, 6), GPIO14), ((TOUCH6, TOUCHn, 6), GPIO14), ((ADC2_CH3,
ADCn_CHm, 2, 3), GPIO15), ((TOUCH3, TOUCHn, 3), GPIO15), ((DAC1, DACn, 1),
GPIO25), ((ADC2_CH8, ADCn_CHm, 2, 8), GPIO25), ((DAC2, DACn, 2), GPIO26),
((ADC2_CH9, ADCn_CHm, 2, 9), GPIO26), ((ADC2_CH7, ADCn_CHm, 2, 7), GPIO27),
((TOUCH7, TOUCHn, 7), GPIO27), ((ADC1_CH4, ADCn_CHm, 1, 4), GPIO32), ((TOUCH9,
TOUCHn, 9), GPIO32), ((ADC1_CH5, ADCn_CHm, 1, 5), GPIO33), ((TOUCH8, TOUCHn, 8),
GPIO33), ((ADC1_CH6, ADCn_CHm, 1, 6), GPIO34), ((ADC1_CH7, ADCn_CHm, 1, 7),
GPIO35), ((ADC1_CH0, ADCn_CHm, 1, 0), GPIO36), ((ADC1_CH1, ADCn_CHm, 1, 1),
GPIO37), ((ADC1_CH2, ADCn_CHm, 1, 2), GPIO38), ((ADC1_CH3, ADCn_CHm, 1, 3),
GPIO39)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_lp_function {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner_lp_function { $(($pattern) => $code;)* ($other : tt)
=> {} } _for_each_inner_lp_function!((RTC_GPIO11, GPIO0));
_for_each_inner_lp_function!((SAR_I2C_SDA, GPIO0));
_for_each_inner_lp_function!((RTC_GPIO12, GPIO2));
_for_each_inner_lp_function!((SAR_I2C_SCL, GPIO2));
_for_each_inner_lp_function!((RTC_GPIO10, GPIO4));
_for_each_inner_lp_function!((SAR_I2C_SCL, GPIO4));
_for_each_inner_lp_function!((RTC_GPIO15, GPIO12));
_for_each_inner_lp_function!((RTC_GPIO14, GPIO13));
_for_each_inner_lp_function!((RTC_GPIO16, GPIO14));
_for_each_inner_lp_function!((RTC_GPIO13, GPIO15));
_for_each_inner_lp_function!((SAR_I2C_SDA, GPIO15));
_for_each_inner_lp_function!((RTC_GPIO6, GPIO25));
_for_each_inner_lp_function!((RTC_GPIO7, GPIO26));
_for_each_inner_lp_function!((RTC_GPIO17, GPIO27));
_for_each_inner_lp_function!((RTC_GPIO9, GPIO32));
_for_each_inner_lp_function!((RTC_GPIO8, GPIO33));
_for_each_inner_lp_function!((RTC_GPIO4, GPIO34));
_for_each_inner_lp_function!((RTC_GPIO5, GPIO35));
_for_each_inner_lp_function!((RTC_GPIO0, GPIO36));
_for_each_inner_lp_function!((RTC_GPIO1, GPIO37));
_for_each_inner_lp_function!((RTC_GPIO2, GPIO38));
_for_each_inner_lp_function!((RTC_GPIO3, GPIO39));
_for_each_inner_lp_function!(((RTC_GPIO11, RTC_GPIOn, 11), GPIO0));
_for_each_inner_lp_function!(((RTC_GPIO12, RTC_GPIOn, 12), GPIO2));
_for_each_inner_lp_function!(((RTC_GPIO10, RTC_GPIOn, 10), GPIO4));
_for_each_inner_lp_function!(((RTC_GPIO15, RTC_GPIOn, 15), GPIO12));
_for_each_inner_lp_function!(((RTC_GPIO14, RTC_GPIOn, 14), GPIO13));
_for_each_inner_lp_function!(((RTC_GPIO16, RTC_GPIOn, 16), GPIO14));
_for_each_inner_lp_function!(((RTC_GPIO13, RTC_GPIOn, 13), GPIO15));
_for_each_inner_lp_function!(((RTC_GPIO6, RTC_GPIOn, 6), GPIO25));
_for_each_inner_lp_function!(((RTC_GPIO7, RTC_GPIOn, 7), GPIO26));
_for_each_inner_lp_function!(((RTC_GPIO17, RTC_GPIOn, 17), GPIO27));
_for_each_inner_lp_function!(((RTC_GPIO9, RTC_GPIOn, 9), GPIO32));
_for_each_inner_lp_function!(((RTC_GPIO8, RTC_GPIOn, 8), GPIO33));
_for_each_inner_lp_function!(((RTC_GPIO4, RTC_GPIOn, 4), GPIO34));
_for_each_inner_lp_function!(((RTC_GPIO5, RTC_GPIOn, 5), GPIO35));
_for_each_inner_lp_function!(((RTC_GPIO0, RTC_GPIOn, 0), GPIO36));
_for_each_inner_lp_function!(((RTC_GPIO1, RTC_GPIOn, 1), GPIO37));
_for_each_inner_lp_function!(((RTC_GPIO2, RTC_GPIOn, 2), GPIO38));
_for_each_inner_lp_function!(((RTC_GPIO3, RTC_GPIOn, 3), GPIO39));
_for_each_inner_lp_function!((all(RTC_GPIO11, GPIO0), (SAR_I2C_SDA, GPIO0),
(RTC_GPIO12, GPIO2), (SAR_I2C_SCL, GPIO2), (RTC_GPIO10, GPIO4), (SAR_I2C_SCL,
GPIO4), (RTC_GPIO15, GPIO12), (RTC_GPIO14, GPIO13), (RTC_GPIO16, GPIO14),
(RTC_GPIO13, GPIO15), (SAR_I2C_SDA, GPIO15), (RTC_GPIO6, GPIO25), (RTC_GPIO7,
GPIO26), (RTC_GPIO17, GPIO27), (RTC_GPIO9, GPIO32), (RTC_GPIO8, GPIO33),
(RTC_GPIO4, GPIO34), (RTC_GPIO5, GPIO35), (RTC_GPIO0, GPIO36), (RTC_GPIO1,
GPIO37), (RTC_GPIO2, GPIO38), (RTC_GPIO3, GPIO39)));
_for_each_inner_lp_function!((all_expanded((RTC_GPIO11, RTC_GPIOn, 11), GPIO0),
((RTC_GPIO12, RTC_GPIOn, 12), GPIO2), ((RTC_GPIO10, RTC_GPIOn, 10), GPIO4),
((RTC_GPIO15, RTC_GPIOn, 15), GPIO12), ((RTC_GPIO14, RTC_GPIOn, 14), GPIO13),
((RTC_GPIO16, RTC_GPIOn, 16), GPIO14), ((RTC_GPIO13, RTC_GPIOn, 13), GPIO15),
((RTC_GPIO6, RTC_GPIOn, 6), GPIO25), ((RTC_GPIO7, RTC_GPIOn, 7), GPIO26),
((RTC_GPIO17, RTC_GPIOn, 17), GPIO27), ((RTC_GPIO9, RTC_GPIOn, 9), GPIO32),
((RTC_GPIO8, RTC_GPIOn, 8), GPIO33), ((RTC_GPIO4, RTC_GPIOn, 4), GPIO34),
((RTC_GPIO5, RTC_GPIOn, 5), GPIO35), ((RTC_GPIO0, RTC_GPIOn, 0), GPIO36),
((RTC_GPIO1, RTC_GPIOn, 1), GPIO37), ((RTC_GPIO2, RTC_GPIOn, 2), GPIO38),
((RTC_GPIO3, RTC_GPIOn, 3), GPIO39)));
};
}
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! define_io_mux_signals {
() => {
#[allow(non_camel_case_types, clippy::upper_case_acronyms)]
#[derive(Debug, PartialEq, Copy, Clone)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[doc(hidden)]
pub enum InputSignal {
SPICLK = 0,
SPIQ = 1,
SPID = 2,
SPIHD = 3,
SPIWP = 4,
SPICS0 = 5,
SPICS1 = 6,
SPICS2 = 7,
HSPICLK = 8,
HSPIQ = 9,
HSPID = 10,
HSPICS0 = 11,
HSPIHD = 12,
HSPIWP = 13,
U0RXD = 14,
U0CTS = 15,
U0DSR = 16,
U1RXD = 17,
U1CTS = 18,
I2S0O_BCK = 23,
I2S1O_BCK = 24,
I2S0O_WS = 25,
I2S1O_WS = 26,
I2S0I_BCK = 27,
I2S0I_WS = 28,
I2CEXT0_SCL = 29,
I2CEXT0_SDA = 30,
PWM0_SYNC0 = 31,
PWM0_SYNC1 = 32,
PWM0_SYNC2 = 33,
PWM0_F0 = 34,
PWM0_F1 = 35,
PWM0_F2 = 36,
PCNT0_SIG_CH0 = 39,
PCNT0_SIG_CH1 = 40,
PCNT0_CTRL_CH0 = 41,
PCNT0_CTRL_CH1 = 42,
PCNT1_SIG_CH0 = 43,
PCNT1_SIG_CH1 = 44,
PCNT1_CTRL_CH0 = 45,
PCNT1_CTRL_CH1 = 46,
PCNT2_SIG_CH0 = 47,
PCNT2_SIG_CH1 = 48,
PCNT2_CTRL_CH0 = 49,
PCNT2_CTRL_CH1 = 50,
PCNT3_SIG_CH0 = 51,
PCNT3_SIG_CH1 = 52,
PCNT3_CTRL_CH0 = 53,
PCNT3_CTRL_CH1 = 54,
PCNT4_SIG_CH0 = 55,
PCNT4_SIG_CH1 = 56,
PCNT4_CTRL_CH0 = 57,
PCNT4_CTRL_CH1 = 58,
HSPICS1 = 61,
HSPICS2 = 62,
VSPICLK = 63,
VSPIQ = 64,
VSPID = 65,
VSPIHD = 66,
VSPIWP = 67,
VSPICS0 = 68,
VSPICS1 = 69,
VSPICS2 = 70,
PCNT5_SIG_CH0 = 71,
PCNT5_SIG_CH1 = 72,
PCNT5_CTRL_CH0 = 73,
PCNT5_CTRL_CH1 = 74,
PCNT6_SIG_CH0 = 75,
PCNT6_SIG_CH1 = 76,
PCNT6_CTRL_CH0 = 77,
PCNT6_CTRL_CH1 = 78,
PCNT7_SIG_CH0 = 79,
PCNT7_SIG_CH1 = 80,
PCNT7_CTRL_CH0 = 81,
PCNT7_CTRL_CH1 = 82,
RMT_SIG_0 = 83,
RMT_SIG_1 = 84,
RMT_SIG_2 = 85,
RMT_SIG_3 = 86,
RMT_SIG_4 = 87,
RMT_SIG_5 = 88,
RMT_SIG_6 = 89,
RMT_SIG_7 = 90,
TWAI_RX = 94,
I2CEXT1_SCL = 95,
I2CEXT1_SDA = 96,
HOST_CARD_DETECT_N_1 = 97,
HOST_CARD_DETECT_N_2 = 98,
HOST_CARD_WRITE_PRT_1 = 99,
HOST_CARD_WRITE_PRT_2 = 100,
HOST_CARD_INT_N_1 = 101,
HOST_CARD_INT_N_2 = 102,
PWM1_SYNC0 = 103,
PWM1_SYNC1 = 104,
PWM1_SYNC2 = 105,
PWM1_F0 = 106,
PWM1_F1 = 107,
PWM1_F2 = 108,
PWM0_CAP0 = 109,
PWM0_CAP1 = 110,
PWM0_CAP2 = 111,
PWM1_CAP0 = 112,
PWM1_CAP1 = 113,
PWM1_CAP2 = 114,
I2S0I_DATA_0 = 140,
I2S0I_DATA_1 = 141,
I2S0I_DATA_2 = 142,
I2S0I_DATA_3 = 143,
I2S0I_DATA_4 = 144,
I2S0I_DATA_5 = 145,
I2S0I_DATA_6 = 146,
I2S0I_DATA_7 = 147,
I2S0I_DATA_8 = 148,
I2S0I_DATA_9 = 149,
I2S0I_DATA_10 = 150,
I2S0I_DATA_11 = 151,
I2S0I_DATA_12 = 152,
I2S0I_DATA_13 = 153,
I2S0I_DATA_14 = 154,
I2S0I_DATA_15 = 155,
I2S1I_BCK = 164,
I2S1I_WS = 165,
I2S1I_DATA_0 = 166,
I2S1I_DATA_1 = 167,
I2S1I_DATA_2 = 168,
I2S1I_DATA_3 = 169,
I2S1I_DATA_4 = 170,
I2S1I_DATA_5 = 171,
I2S1I_DATA_6 = 172,
I2S1I_DATA_7 = 173,
I2S1I_DATA_8 = 174,
I2S1I_DATA_9 = 175,
I2S1I_DATA_10 = 176,
I2S1I_DATA_11 = 177,
I2S1I_DATA_12 = 178,
I2S1I_DATA_13 = 179,
I2S1I_DATA_14 = 180,
I2S1I_DATA_15 = 181,
I2S0I_H_SYNC = 190,
I2S0I_V_SYNC = 191,
I2S0I_H_ENABLE = 192,
I2S1I_H_SYNC = 193,
I2S1I_V_SYNC = 194,
I2S1I_H_ENABLE = 195,
U2RXD = 198,
U2CTS = 199,
EMAC_MDC = 200,
EMAC_MDI = 201,
EMAC_CRS = 202,
EMAC_COL = 203,
PCMFSYNC = 204,
PCMCLK = 205,
PCMDIN = 206,
SD_CMD,
SD_DATA0,
SD_DATA1,
SD_DATA2,
SD_DATA3,
HS1_DATA0,
HS1_DATA1,
HS1_DATA2,
HS1_DATA3,
HS1_DATA4,
HS1_DATA5,
HS1_DATA6,
HS1_DATA7,
HS2_DATA0,
HS2_DATA1,
HS2_DATA2,
HS2_DATA3,
EMAC_TX_CLK,
EMAC_RXD2,
EMAC_TX_ER,
EMAC_RX_CLK,
EMAC_RX_ER,
EMAC_RXD3,
EMAC_RXD0,
EMAC_RXD1,
EMAC_RX_DV,
MTDI,
MTCK,
MTMS,
}
#[allow(non_camel_case_types, clippy::upper_case_acronyms)]
#[derive(Debug, PartialEq, Copy, Clone)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[doc(hidden)]
pub enum OutputSignal {
SPICLK = 0,
SPIQ = 1,
SPID = 2,
SPIHD = 3,
SPIWP = 4,
SPICS0 = 5,
SPICS1 = 6,
SPICS2 = 7,
HSPICLK = 8,
HSPIQ = 9,
HSPID = 10,
HSPICS0 = 11,
HSPIHD = 12,
HSPIWP = 13,
U0TXD = 14,
U0RTS = 15,
U0DTR = 16,
U1TXD = 17,
U1RTS = 18,
I2S0O_BCK = 23,
I2S1O_BCK = 24,
I2S0O_WS = 25,
I2S1O_WS = 26,
I2S0I_BCK = 27,
I2S0I_WS = 28,
I2CEXT0_SCL = 29,
I2CEXT0_SDA = 30,
SDIO_TOHOSTT = 31,
PWM0_0A = 32,
PWM0_0B = 33,
PWM0_1A = 34,
PWM0_1B = 35,
PWM0_2A = 36,
PWM0_2B = 37,
HSPICS1 = 61,
HSPICS2 = 62,
VSPICLK = 63,
VSPIQ = 64,
VSPID = 65,
VSPIHD = 66,
VSPIWP = 67,
VSPICS0 = 68,
VSPICS1 = 69,
VSPICS2 = 70,
LEDC_HS_SIG0 = 71,
LEDC_HS_SIG1 = 72,
LEDC_HS_SIG2 = 73,
LEDC_HS_SIG3 = 74,
LEDC_HS_SIG4 = 75,
LEDC_HS_SIG5 = 76,
LEDC_HS_SIG6 = 77,
LEDC_HS_SIG7 = 78,
LEDC_LS_SIG0 = 79,
LEDC_LS_SIG1 = 80,
LEDC_LS_SIG2 = 81,
LEDC_LS_SIG3 = 82,
LEDC_LS_SIG4 = 83,
LEDC_LS_SIG5 = 84,
LEDC_LS_SIG6 = 85,
LEDC_LS_SIG7 = 86,
RMT_SIG_0 = 87,
RMT_SIG_1 = 88,
RMT_SIG_2 = 89,
RMT_SIG_3 = 90,
RMT_SIG_4 = 91,
RMT_SIG_5 = 92,
RMT_SIG_6 = 93,
RMT_SIG_7 = 94,
I2CEXT1_SCL = 95,
I2CEXT1_SDA = 96,
HOST_CCMD_OD_PULLUP_EN_N = 97,
HOST_RST_N_1 = 98,
HOST_RST_N_2 = 99,
GPIO_SD0 = 100,
GPIO_SD1 = 101,
GPIO_SD2 = 102,
GPIO_SD3 = 103,
GPIO_SD4 = 104,
GPIO_SD5 = 105,
GPIO_SD6 = 106,
GPIO_SD7 = 107,
PWM1_0A = 108,
PWM1_0B = 109,
PWM1_1A = 110,
PWM1_1B = 111,
PWM1_2A = 112,
PWM1_2B = 113,
TWAI_TX = 123,
TWAI_BUS_OFF_ON = 124,
TWAI_CLKOUT = 125,
I2S0O_DATA_0 = 140,
I2S0O_DATA_1 = 141,
I2S0O_DATA_2 = 142,
I2S0O_DATA_3 = 143,
I2S0O_DATA_4 = 144,
I2S0O_DATA_5 = 145,
I2S0O_DATA_6 = 146,
I2S0O_DATA_7 = 147,
I2S0O_DATA_8 = 148,
I2S0O_DATA_9 = 149,
I2S0O_DATA_10 = 150,
I2S0O_DATA_11 = 151,
I2S0O_DATA_12 = 152,
I2S0O_DATA_13 = 153,
I2S0O_DATA_14 = 154,
I2S0O_DATA_15 = 155,
I2S0O_DATA_16 = 156,
I2S0O_DATA_17 = 157,
I2S0O_DATA_18 = 158,
I2S0O_DATA_19 = 159,
I2S0O_DATA_20 = 160,
I2S0O_DATA_21 = 161,
I2S0O_DATA_22 = 162,
I2S0O_DATA_23 = 163,
I2S1I_BCK = 164,
I2S1I_WS = 165,
I2S1O_DATA_0 = 166,
I2S1O_DATA_1 = 167,
I2S1O_DATA_2 = 168,
I2S1O_DATA_3 = 169,
I2S1O_DATA_4 = 170,
I2S1O_DATA_5 = 171,
I2S1O_DATA_6 = 172,
I2S1O_DATA_7 = 173,
I2S1O_DATA_8 = 174,
I2S1O_DATA_9 = 175,
I2S1O_DATA_10 = 176,
I2S1O_DATA_11 = 177,
I2S1O_DATA_12 = 178,
I2S1O_DATA_13 = 179,
I2S1O_DATA_14 = 180,
I2S1O_DATA_15 = 181,
I2S1O_DATA_16 = 182,
I2S1O_DATA_17 = 183,
I2S1O_DATA_18 = 184,
I2S1O_DATA_19 = 185,
I2S1O_DATA_20 = 186,
I2S1O_DATA_21 = 187,
I2S1O_DATA_22 = 188,
I2S1O_DATA_23 = 189,
U2TXD = 198,
U2RTS = 199,
EMAC_MDC = 200,
EMAC_MDO = 201,
EMAC_CRS = 202,
EMAC_COL = 203,
BT_AUDIO0RQ = 204,
BT_AUDIO1RQ = 205,
BT_AUDIO2RQ = 206,
BLE_AUDIO0RQ = 207,
BLE_AUDIO1RQ = 208,
BLE_AUDIO2RQ = 209,
PCMFSYNC = 210,
PCMCLK = 211,
PCMDOUT = 212,
BLE_AUDIO_SYNC0_P = 213,
BLE_AUDIO_SYNC1_P = 214,
BLE_AUDIO_SYNC2_P = 215,
ANT_SEL0 = 216,
ANT_SEL1 = 217,
ANT_SEL2 = 218,
ANT_SEL3 = 219,
ANT_SEL4 = 220,
ANT_SEL5 = 221,
ANT_SEL6 = 222,
ANT_SEL7 = 223,
SIGNAL_224 = 224,
SIGNAL_225 = 225,
SIGNAL_226 = 226,
SIGNAL_227 = 227,
SIGNAL_228 = 228,
GPIO = 256,
CLK_OUT1,
CLK_OUT2,
CLK_OUT3,
SD_CLK,
SD_CMD,
SD_DATA0,
SD_DATA1,
SD_DATA2,
SD_DATA3,
HS1_CLK,
HS1_CMD,
HS1_DATA0,
HS1_DATA1,
HS1_DATA2,
HS1_DATA3,
HS1_DATA4,
HS1_DATA5,
HS1_DATA6,
HS1_DATA7,
HS1_STROBE,
HS2_CLK,
HS2_CMD,
HS2_DATA0,
HS2_DATA1,
HS2_DATA2,
HS2_DATA3,
EMAC_TX_CLK,
EMAC_TX_ER,
EMAC_TXD3,
EMAC_RX_ER,
EMAC_TXD2,
EMAC_CLK_OUT,
EMAC_CLK_180,
EMAC_TXD0,
EMAC_TX_EN,
EMAC_TXD1,
MTDO,
}
};
}
#[macro_export]
#[expect(clippy::crate_in_macro_def)]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! define_io_mux_reg {
() => {
pub(crate) fn io_mux_reg(gpio_num: u8) -> &'static crate::pac::io_mux::GPIO0 {
let iomux = crate::peripherals::IO_MUX::regs();
match gpio_num {
0 => iomux.gpio0(),
1 => iomux.gpio1(),
2 => iomux.gpio2(),
3 => iomux.gpio3(),
4 => iomux.gpio4(),
5 => iomux.gpio5(),
6 => iomux.gpio6(),
7 => iomux.gpio7(),
8 => iomux.gpio8(),
9 => iomux.gpio9(),
10 => iomux.gpio10(),
11 => iomux.gpio11(),
12 => iomux.gpio12(),
13 => iomux.gpio13(),
14 => iomux.gpio14(),
15 => iomux.gpio15(),
16 => iomux.gpio16(),
17 => iomux.gpio17(),
18 => iomux.gpio18(),
19 => iomux.gpio19(),
20 => iomux.gpio20(),
21 => iomux.gpio21(),
22 => iomux.gpio22(),
23 => iomux.gpio23(),
25 => iomux.gpio25(),
26 => iomux.gpio26(),
27 => iomux.gpio27(),
32 => iomux.gpio32(),
33 => iomux.gpio33(),
34 => iomux.gpio34(),
35 => iomux.gpio35(),
36 => iomux.gpio36(),
37 => iomux.gpio37(),
38 => iomux.gpio38(),
39 => iomux.gpio39(),
other => panic!("GPIO {} does not exist", other),
}
}
};
}