Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the ESP32-C6 #392

Merged
merged 64 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
a571bf6
Create the `esp32c6-hal` package
jessebraham Jan 5, 2023
a2c6145
Teach `esp-hal-common` about the ESP32-C6
jessebraham Jan 6, 2023
f358cad
Get a number of peripheral drivers building for the ESP32-C6
jessebraham Jan 6, 2023
fc65b3f
Create the `esp32c6-hal` package
jessebraham Jan 5, 2023
bea1242
Simplify and fix the linker script
bjoernQ Jan 20, 2023
5f8e2d1
C6: add I2S
JurajSadel Jan 25, 2023
6db490d
Create the `esp32c6-hal` package
jessebraham Jan 5, 2023
a38ced1
Teach `esp-hal-common` about the ESP32-C6
jessebraham Jan 6, 2023
730f57f
Get a number of peripheral drivers building for the ESP32-C6
jessebraham Jan 6, 2023
3cec8bb
Create the `esp32c6-hal` package
jessebraham Jan 5, 2023
1e5ef3c
C6: update
JurajSadel Jan 20, 2023
e6df68d
Simplify and fix the linker script
bjoernQ Jan 20, 2023
d2b0734
update
JurajSadel Jan 24, 2023
bde4bb5
C6: add I2S
JurajSadel Jan 25, 2023
6351eee
update
JurajSadel Jan 24, 2023
51cb4c0
C6 Interrupts
bjoernQ Jan 25, 2023
753414a
C6: Update build.rs, linker scripts and initial examples
JurajSadel Jan 27, 2023
dece8b4
C6: RMT
JurajSadel Jan 27, 2023
3ad20aa
Fix interrupt handling
bjoernQ Jan 26, 2023
731f1cb
Fix `ClockControl::configure`
bjoernQ Jan 27, 2023
b0e7a59
C6: revert to I2S0 instead of just I2S
JurajSadel Jan 30, 2023
ae4e4b5
C6: rebase and update
JurajSadel Feb 1, 2023
a4edc46
RTC not buildable
JurajSadel Feb 2, 2023
988b1d0
Implement RWDT and SWD disable
bjoernQ Feb 2, 2023
ac4c447
C6: working LEDC
JurajSadel Feb 3, 2023
8ddaf7e
C6: working RMT
JurajSadel Feb 3, 2023
2b7fd7d
C6: add aes
JurajSadel Feb 7, 2023
b100cb2
C6: add mcpwm
JurajSadel Feb 7, 2023
9968157
C6: add rtc_cntln - not finished
JurajSadel Feb 7, 2023
cfb8445
C6: update and formatting
JurajSadel Feb 7, 2023
f9b7e19
C6: add pcnt
JurajSadel Feb 7, 2023
a7e14a9
C6: add examples and format
JurajSadel Feb 7, 2023
b7f0316
Remove inline assembly, fix interrupts and linker scripts
jessebraham Feb 7, 2023
a2e4c93
Remove unused features, update cargo config for atomic emu, misc cleanup
jessebraham Feb 7, 2023
8217147
Get ADC building and example "working" (as much as it ever does)
jessebraham Feb 7, 2023
a933093
Remove a bunch of unused constants which were copied from ESP-IDF
jessebraham Feb 7, 2023
93f926f
The `mcpwm` example now works correctly
jessebraham Feb 7, 2023
59a599d
Get `TWAI` peripheral driver building for C6
jessebraham Feb 8, 2023
46487eb
Clean up the `rtc_cntl` module and get all the other HALs building again
jessebraham Feb 8, 2023
4f97342
Add the C6 to our CI workflow
jessebraham Feb 8, 2023
403c640
Fix various things that have been missed when rebasing
jessebraham Feb 8, 2023
08f6f19
C6: Small updates in wdt (#1)
JurajSadel Feb 9, 2023
730b6b3
Update `esp-println` dependency to fix build errors
jessebraham Feb 9, 2023
e903e90
Fix formatting issues causing pre-commit hook to fail
jessebraham Feb 9, 2023
3622bc1
Get some more examples working
jessebraham Feb 9, 2023
9747426
Working `ram` example
jessebraham Feb 10, 2023
e41ecdd
Sync with changes in `main` after rebasing
jessebraham Feb 10, 2023
28ece39
Working `embassy_spi` example
jessebraham Feb 10, 2023
dd7f469
Use a git dependency for the PAC until we publish a release
jessebraham Feb 10, 2023
7dd27e5
Fix I2S for ESP32-C6
bjoernQ Feb 14, 2023
39444ba
Fix esp32c6 direct boot (#4)
MabezDev Feb 22, 2023
d16cab7
Update RWDT and refactor RTC (#3)
JurajSadel Feb 23, 2023
87cf485
Make required changes to include new `RADIO` peripheral
jessebraham Feb 23, 2023
0d3fd81
Use published versions of PAC and `esp-println`
jessebraham Feb 23, 2023
a381487
Use the correct target extensions (`imac`)
jessebraham Feb 24, 2023
572e99d
Fix the super watchdog timer, plus a few more examples
jessebraham Feb 24, 2023
dc309ea
Fix UART clock configuration
jessebraham Feb 24, 2023
716163b
Make sure to sync UART registers when configuring AT cmd detection
bjoernQ Feb 27, 2023
2f5972b
Disable APM in direct-boot mode
bjoernQ Feb 27, 2023
3eb273a
Address a number of review comments
jessebraham Feb 27, 2023
6641a0d
Fix `SPI` clocks and `rtc_watchdog` example (#6)
JurajSadel Feb 27, 2023
9e5f298
README and example fixes/cleanup
jessebraham Feb 27, 2023
ed59cd9
Add I2C peripheral enable and reset
bjoernQ Feb 27, 2023
e678120
Fix `ApbSarAdc` configuration in `system.rs`
jessebraham Feb 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 44 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,49 @@ jobs:
# Subsequent steps can just check the examples instead, as we're already
# confident that they link.
- name: check esp32c3-hal (common features)
run: cargo check --manifest-path=esp32c3-hal/Cargo.toml --target=riscv32imc-unknown-none-elf --examples --features=eh1,smartled,ufmt
run: cd esp32c3-hal/ && cargo check --examples --features=eh1,smartled,ufmt
- name: check esp32c3-hal (async, systick)
run: cargo check --manifest-path=esp32c3-hal/Cargo.toml --target=riscv32imc-unknown-none-elf --example=embassy_hello_world --features=embassy,embassy-time-systick
run: cd esp32c3-hal/ && cargo check --example=embassy_hello_world --features=embassy,embassy-time-systick
- name: check esp32c3-hal (async, timg0)
run: cargo check --manifest-path=esp32c3-hal/Cargo.toml --target=riscv32imc-unknown-none-elf --example=embassy_hello_world --features=embassy,embassy-time-timg0
run: cd esp32c3-hal/ && cargo check --example=embassy_hello_world --features=embassy,embassy-time-timg0
- name: check esp32c3-hal (async, gpio)
run: cd esp32c3-hal/ && cargo check --example=embassy_wait --features=embassy,embassy-time-systick,async
- name: check esp32c3-hal (async, spi)
run: cd esp32c3-hal/ && cargo check --example=embassy_spi --features=embassy,embassy-time-systick,async

esp32c6-hal:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@v1
with:
target: riscv32imac-unknown-none-elf
toolchain: nightly
components: rust-src
- uses: Swatinem/rust-cache@v2

# Perform a full build initially to verify that the examples not only
# build, but also link successfully.
# We also use this as an opportunity to verify that the examples link
# for each supported image format.
- name: build esp32c6-hal (no features)
run: cd esp32c6-hal/ && cargo build --examples
- name: build esp32c6-hal (direct-boot)
run: cd esp32c6-hal/ && cargo build --examples --features=direct-boot
# Subsequent steps can just check the examples instead, as we're already
# confident that they link.
- name: check esp32c6-hal (common features)
run: cd esp32c6-hal/ && cargo check --examples --features=eh1,smartled,ufmt
- name: check esp32c6-hal (async, systick)
run: cd esp32c6-hal/ && cargo check --example=embassy_hello_world --features=embassy,embassy-time-systick
- name: check esp32c6-hal (async, timg0)
run: cd esp32c6-hal/ && cargo check --example=embassy_hello_world --features=embassy,embassy-time-timg0
- name: check esp32c6-hal (async, gpio)
run: cd esp32c6-hal/ && cargo check --example=embassy_wait --features=embassy,embassy-time-systick,async
- name: check esp32c6-hal (async, spi)
run: cd esp32c6-hal/ && cargo check --example=embassy_spi --features=embassy,embassy-time-systick,async

esp32s2-hal:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -190,7 +223,7 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@v1
with:
target: riscv32imc-unknown-none-elf
target: riscv32imc-unknown-none-elf, riscv32imac-unknown-none-elf
toolchain: "1.65.0"
- uses: Swatinem/rust-cache@v2

Expand All @@ -199,6 +232,8 @@ jobs:
run: cd esp32c2-hal/ && cargo check --features=eh1,ufmt
- name: msrv (esp32c3-hal)
run: cd esp32c3-hal/ && cargo check --features=eh1,ufmt,smartled
- name: msrv (esp32c6-hal)
run: cd esp32c6-hal/ && cargo check --features=eh1,ufmt,smartled

msrv-xtensa:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -238,6 +273,8 @@ jobs:
run: cargo +stable clippy --manifest-path=esp32c2-hal/Cargo.toml -- --no-deps
- name: clippy (esp32c3-hal)
run: cargo +stable clippy --manifest-path=esp32c3-hal/Cargo.toml -- --no-deps
- name: clippy (esp32c6-hal)
run: cargo +stable clippy --manifest-path=esp32c6-hal/Cargo.toml -- --no-deps

clippy-xtensa:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -286,7 +323,9 @@ jobs:
run: cargo fmt --all --manifest-path=esp32c2-hal/Cargo.toml -- --check
- name: rustfmt (esp32c3-hal)
run: cargo fmt --all --manifest-path=esp32c3-hal/Cargo.toml -- --check
- name: rustfmt (esp32c6-hal)
run: cargo fmt --all --manifest-path=esp32c6-hal/Cargo.toml -- --check
- name: rustfmt (esp32s2-hal)
run: cargo fmt --all --manifest-path=esp32s2-hal/Cargo.toml -- --check
- name: rustfmt (esp32s3-hal)
run: cargo fmt --all --manifest-path=esp32s3-hal/Cargo.toml -- --check
run: cargo fmt --all --manifest-path=esp32s3-hal/Cargo.toml -- --check
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@
![MIT/Apache-2.0 licensed](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue?style=flat-square)
[![Matrix](https://img.shields.io/matrix/esp-rs:matrix.org?label=join%20matrix&color=BEC5C9&logo=matrix&style=flat-square)](https://matrix.to/#/#esp-rs:matrix.org)

**H**ardware **A**bstraction **L**ayer crates for the **ESP32**, **ESP32-C2**, **ESP32-C3**, **ESP32-S2**, and **ESP32-S3** from Espressif.
**H**ardware **A**bstraction **L**ayer crates for the **ESP32**, **ESP32-C2/C3/C6**, and **ESP32-S2/S3** from Espressif.

These HALs are `no_std`; if you are looking for `std` support, please use [esp-idf-hal] instead.

This project is still in the early stages of development, and as such there should be no expectation of API stability. A significant number of peripherals currently have drivers implemented (you can see a full list [here]) but have varying levels of functionality. For most basic tasks, this should be usable already.

If you have any questions, comments, or concerns, please [open an issue], [start a new discussion], or join us on [Matrix]. For additional information regarding any of the crates in this repository, please refer to the crate's README.

| Crate | Target | Technical Reference Manual |
| :-----------: | :-----------------------------------------------------------------: | :------------------------: |
| [esp32-hal] | `xtensa-esp32-none-elf` | [ESP32] |
| [esp32c2-hal] | `riscv32imc-unknown-none-elf` | [ESP32-C2] |
| [esp32c3-hal] | `riscv32imc-unknown-none-elf` | [ESP32-C3] |
| [esp32s2-hal] | `xtensa-esp32s2-none-elf` | [ESP32-S2] |
| [esp32s3-hal] | `xtensa-esp32s3-none-elf` | [ESP32-S3] |
| Crate | Target | Technical Reference Manual |
| :-----------: | :----------------------------: | :------------------------: |
| [esp32-hal] | `xtensa-esp32-none-elf` | [ESP32] |
| [esp32c2-hal] | `riscv32imc-unknown-none-elf` | [ESP32-C2] |
| [esp32c3-hal] | `riscv32imc-unknown-none-elf` | [ESP32-C3] |
| [esp32c6-hal] | `riscv32imac-unknown-none-elf` | [ESP32-C6] |
| [esp32s2-hal] | `xtensa-esp32s2-none-elf` | [ESP32-S2] |
| [esp32s3-hal] | `xtensa-esp32s3-none-elf` | [ESP32-S3] |

[here]: https://github.com/esp-rs/esp-hal/issues/19
[esp-idf-hal]: https://github.com/esp-rs/esp-idf-hal
Expand All @@ -28,11 +29,13 @@ If you have any questions, comments, or concerns, please [open an issue], [start
[esp32-hal]: https://github.com/esp-rs/esp-hal/tree/main/esp32-hal
[esp32c2-hal]: https://github.com/esp-rs/esp-hal/tree/main/esp32c2-hal
[esp32c3-hal]: https://github.com/esp-rs/esp-hal/tree/main/esp32c3-hal
[esp32c6-hal]: https://github.com/esp-rs/esp-hal/tree/main/esp32c6-hal
[esp32s2-hal]: https://github.com/esp-rs/esp-hal/tree/main/esp32s2-hal
[esp32s3-hal]: https://github.com/esp-rs/esp-hal/tree/main/esp32s3-hal
[esp32]: https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf
[esp32-c2]: https://www.espressif.com/sites/default/files/documentation/esp8684_technical_reference_manual_en.pdf
[esp32-c3]: https://www.espressif.com/sites/default/files/documentation/esp32-c3_technical_reference_manual_en.pdf
[esp32-c6]: https://www.espressif.com/sites/default/files/documentation/esp32-c6_technical_reference_manual_en.pdf
[esp32-s2]: https://www.espressif.com/sites/default/files/documentation/esp32-s2_technical_reference_manual_en.pdf
[esp32-s3]: https://www.espressif.com/sites/default/files/documentation/esp32-s3_technical_reference_manual_en.pdf
[atomic emulation]: https://github.com/esp-rs/riscv-atomic-emulation-trap
Expand Down Expand Up @@ -62,13 +65,15 @@ There are a number of other crates within the [esp-rs organization] which can be
| [esp-backtrace] | Backtrace support for bare-metal applications |
| [esp-println] | Provides `print!` and `println!` implementations |
| [esp-storage] | Implementation of [embedded-storage] traits to access unencrypted flash memory |
| [esp-wifi] | Experimental `no_std` Wi-Fi/Bluetooth LE support |
jessebraham marked this conversation as resolved.
Show resolved Hide resolved

[esp-rs organization]: https://github.com/esp-rs
[esp-alloc]: https://github.com/esp-rs/esp-alloc
[esp-backtrace]: https://github.com/esp-rs/esp-backtrace
[esp-println]: https://github.com/esp-rs/esp-println
[esp-storage]: https://github.com/esp-rs/esp-storage
[embedded-storage]: https://github.com/rust-embedded-community/embedded-storage
[esp-wifi]: https://github.com/esp-rs/esp-wifi

## MSRV

Expand Down
9 changes: 5 additions & 4 deletions esp-hal-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,19 @@ ufmt-write = { version = "0.1.0", optional = true }

# IMPORTANT:
# Each supported device MUST have its PAC included below along with a
# corresponding feature. We rename the PAC packages because we cannot
# have dependencies and features with the same names.
# corresponding feature.
esp32 = { version = "0.21.0", features = ["critical-section"], optional = true }
esp32c2 = { version = "0.8.0", features = ["critical-section"], optional = true }
esp32c3 = { version = "0.11.0", features = ["critical-section"], optional = true }
esp32c6 = { version = "0.1.0", features = ["critical-section"], optional = true }
esp32s2 = { version = "0.12.0", features = ["critical-section"], optional = true }
esp32s3 = { version = "0.15.0", features = ["critical-section"], optional = true }

[features]
esp32 = ["esp32/rt" , "xtensa", "xtensa-lx/esp32", "xtensa-lx-rt/esp32", "lock_api", "procmacros/esp32"]
esp32c2 = ["esp32c2/rt", "riscv", "procmacros/esp32c2"]
esp32c3 = ["esp32c3/rt", "riscv", "procmacros/esp32c3"]
esp32c2 = ["esp32c2/rt", "riscv", "procmacros/esp32c2"]
esp32c3 = ["esp32c3/rt", "riscv", "procmacros/esp32c3"]
esp32c6 = ["esp32c6/rt", "riscv", "procmacros/esp32c6"]
esp32s2 = ["esp32s2/rt", "xtensa", "xtensa-lx/esp32s2", "xtensa-lx-rt/esp32s2", "esp-synopsys-usb-otg", "usb-device", "procmacros/esp32s2"]
esp32s3 = ["esp32s3/rt", "xtensa", "xtensa-lx/esp32s3", "xtensa-lx-rt/esp32s3", "lock_api", "esp-synopsys-usb-otg", "usb-device", "procmacros/esp32s3"]

Expand Down
1 change: 1 addition & 0 deletions esp-hal-common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This crate should not be used directly; you should use one of the device-specifi
- [esp32-hal](../esp32-hal/README.md)
- [esp32c2-hal](../esp32c2-hal/README.md)
- [esp32c3-hal](../esp32c3-hal/README.md)
- [esp32c6-hal](../esp32c6-hal/README.md)
- [esp32s2-hal](../esp32s2-hal/README.md)
- [esp32s3-hal](../esp32s3-hal/README.md)

Expand Down
21 changes: 20 additions & 1 deletion esp-hal-common/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ fn main() {
let esp32 = cfg!(feature = "esp32");
let esp32c2 = cfg!(feature = "esp32c2");
let esp32c3 = cfg!(feature = "esp32c3");
let esp32c6 = cfg!(feature = "esp32c6");
let esp32s2 = cfg!(feature = "esp32s2");
let esp32s3 = cfg!(feature = "esp32s3");

// Ensure that exactly one chip has been specified
let chip_features = [esp32, esp32c2, esp32c3, esp32s2, esp32s3];
let chip_features = [esp32, esp32c2, esp32c3, esp32c6, esp32s2, esp32s3];
match chip_features.iter().filter(|&&f| f).count() {
1 => {}
n => panic!("Exactly 1 chip must be enabled via its Cargo feature, {n} provided"),
Expand Down Expand Up @@ -46,6 +47,7 @@ fn main() {
// - 'usb_otg'
// - 'usb_serial_jtag'
// - 'aes'
// - 'plic'
// - 'radio'
//
// New symbols can be added as needed, but please be sure to update both this
Expand Down Expand Up @@ -94,6 +96,23 @@ fn main() {
"aes",
"radio",
]
} else if esp32c6 {
vec![
"esp32c6",
"riscv",
"single_core",
"gdma",
"i2s",
"mcpwm",
"rmt",
"systimer",
"timg0",
"timg1",
"usb_serial_jtag",
"plic",
"aes",
"radio",
]
} else if esp32s2 {
vec![
"esp32s2",
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion esp-hal-common/src/aes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ use crate::{
#[cfg_attr(esp32, path = "esp32.rs")]
#[cfg_attr(esp32s3, path = "esp32s3.rs")]
#[cfg_attr(esp32s2, path = "esp32s2.rs")]
#[cfg_attr(esp32c3, path = "esp32c3.rs")]
#[cfg_attr(esp32c3, path = "esp32cX.rs")]
#[cfg_attr(esp32c6, path = "esp32cX.rs")]
mod aes_spec_impl;

const ALIGN_SIZE: usize = core::mem::size_of::<u32>();
Expand Down
32 changes: 29 additions & 3 deletions esp-hal-common/src/analog/adc/riscv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,30 @@ macro_rules! impl_adc_interface {

pub use impl_adc_interface;

#[cfg(esp32c2)]
pub mod implementation {
//! Analog to digital (ADC) conversion support.
//!
//! This module provides functions for reading analog values from the
//! analog to digital converter available on the ESP32-C2: `ADC1`.

use embedded_hal::adc::Channel;

use super::impl_adc_interface;
pub use crate::analog::{adc::*, ADC1};
use crate::gpio::*;

impl_adc_interface! {
ADC1 [
(Gpio0, 0),
(Gpio1, 1),
(Gpio2, 2),
(Gpio3, 3),
(Gpio4, 4),
]
}
}

#[cfg(esp32c3)]
pub mod implementation {
//! Analog to digital (ADC) conversion support.
Expand Down Expand Up @@ -318,12 +342,12 @@ pub mod implementation {
}
}

#[cfg(esp32c2)]
#[cfg(esp32c6)]
pub mod implementation {
//! Analog to digital (ADC) conversion support.
//!
//! This module provides functions for reading analog values from the
//! analog to digital converter available on the ESP32-C2: `ADC1`.
//! This module provides functions for reading analog values from one
//! analog to digital converter available on the ESP32-C6: `ADC1`.

use embedded_hal::adc::Channel;

Expand All @@ -338,6 +362,8 @@ pub mod implementation {
(Gpio2, 2),
(Gpio3, 3),
(Gpio4, 4),
(Gpio5, 5),
(Gpio6, 6),
]
}
}
41 changes: 8 additions & 33 deletions esp-hal-common/src/analog/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#[cfg_attr(esp32, path = "adc/esp32.rs")]
#[cfg_attr(esp32c2, path = "adc/riscv.rs")]
#[cfg_attr(esp32c3, path = "adc/riscv.rs")]
#[cfg_attr(esp32s2, path = "adc/xtensa.rs")]
#[cfg_attr(esp32s3, path = "adc/xtensa.rs")]
#[cfg_attr(any(esp32c2, esp32c3, esp32c6), path = "adc/riscv.rs")]
#[cfg_attr(any(esp32s2, esp32s3), path = "adc/xtensa.rs")]
pub mod adc;
#[cfg(dac)]
pub mod dac;

pub struct ADC1 {
_private: (),
}

pub struct ADC2 {
_private: (),
}
Expand Down Expand Up @@ -95,6 +94,7 @@ impl crate::peripheral::sealed::Sealed for DAC1 {}

impl crate::peripheral::Peripheral for DAC2 {
type P = DAC2;

#[inline]
unsafe fn clone_unchecked(&mut self) -> Self::P {
DAC2 { _private: () }
Expand All @@ -103,6 +103,7 @@ impl crate::peripheral::Peripheral for DAC2 {

impl crate::peripheral::Peripheral for &mut DAC2 {
type P = DAC2;

#[inline]
unsafe fn clone_unchecked(&mut self) -> Self::P {
DAC2 { _private: () }
Expand All @@ -114,7 +115,6 @@ impl crate::peripheral::sealed::Sealed for DAC2 {}

cfg_if::cfg_if! {
if #[cfg(any(esp32, esp32s2, esp32s3))] {

use crate::peripherals::SENS;

pub struct AvailableAnalog {
Expand Down Expand Up @@ -151,12 +151,12 @@ cfg_if::cfg_if! {
}

cfg_if::cfg_if! {
if #[cfg(esp32c3)] {

if #[cfg(any(esp32c2, esp32c3, esp32c6))] {
use crate::peripherals::APB_SARADC;

pub struct AvailableAnalog {
pub adc1: ADC1,
#[cfg(esp32c3)]
pub adc2: ADC2,
}

Expand All @@ -171,6 +171,7 @@ cfg_if::cfg_if! {
adc1: ADC1 {
_private: (),
},
#[cfg(esp32c3)]
adc2: ADC2 {
_private: (),
},
Expand All @@ -179,29 +180,3 @@ cfg_if::cfg_if! {
}
}
}

cfg_if::cfg_if! {
if #[cfg(esp32c2)] {

use crate::peripherals::APB_SARADC;

pub struct AvailableAnalog {
pub adc1: ADC1,
}

/// Extension trait to split a APB_SARADC peripheral in independent parts
pub trait SarAdcExt {
fn split(self) -> AvailableAnalog;
}

impl<'d, T: crate::peripheral::Peripheral<P = APB_SARADC> + 'd> SarAdcExt for T {
fn split(self) -> AvailableAnalog {
AvailableAnalog {
adc1: ADC1 {
_private: (),
},
}
}
}
}
}
Loading