Skip to main content

ariel_os_esp/i2c/
mod.rs

1//! Provides support for the I2C communication bus.
2
3#[doc(alias = "master")]
4pub mod controller;
5
6#[doc(hidden)]
7pub fn init(peripherals: &mut crate::OptionalPeripherals) {
8    // Take all I2C peripherals and do nothing with them.
9    cfg_select! {
10        context = "esp32" => {
11            let _ = peripherals.I2C0.take().unwrap();
12            let _ = peripherals.I2C1.take().unwrap();
13        }
14        context = "esp32c3" => {
15            let _ = peripherals.I2C0.take().unwrap();
16        }
17        context = "esp32c6" => {
18            let _ = peripherals.I2C0.take().unwrap();
19        }
20        context = "esp32s2" => {
21            let _ = peripherals.I2C0.take().unwrap();
22            let _ = peripherals.I2C1.take().unwrap();
23        }
24        context = "esp32s3" => {
25            let _ = peripherals.I2C0.take().unwrap();
26            let _ = peripherals.I2C1.take().unwrap();
27        }
28        _ => {
29            compile_error!("this ESP32 chip is not supported");
30        }
31    }
32}