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 = "esp32c2" => {
15            let _ = peripherals.I2C0.take().unwrap();
16        }
17        context = "esp32c3" => {
18            let _ = peripherals.I2C0.take().unwrap();
19        }
20        context = "esp32c6" => {
21            let _ = peripherals.I2C0.take().unwrap();
22        }
23        context = "esp32h2" => {
24            let _ = peripherals.I2C0.take().unwrap();
25            let _ = peripherals.I2C1.take().unwrap();
26        }
27        context = "esp32s2" => {
28            let _ = peripherals.I2C0.take().unwrap();
29            let _ = peripherals.I2C1.take().unwrap();
30        }
31        context = "esp32s3" => {
32            let _ = peripherals.I2C0.take().unwrap();
33            let _ = peripherals.I2C1.take().unwrap();
34        }
35        _ => {
36            compile_error!("this ESP32 chip is not supported");
37        }
38    }
39}