Skip to content

Commit

Permalink
Add support for the ESP32-C6 (#392)
Browse files Browse the repository at this point in the history
* Create the `esp32c6-hal` package

* Teach `esp-hal-common` about the ESP32-C6

* Get a number of peripheral drivers building for the ESP32-C6

bckup

initial clocks_ii

* Create the `esp32c6-hal` package

C6: update

* Simplify and fix the linker script

update

* C6: add I2S

* Create the `esp32c6-hal` package

* Teach `esp-hal-common` about the ESP32-C6

* Get a number of peripheral drivers building for the ESP32-C6

bckup

initial clocks_ii

* Create the `esp32c6-hal` package

* C6: update

* Simplify and fix the linker script

* update

* C6: add I2S

* update

* C6 Interrupts

* C6: Update build.rs, linker scripts and initial examples

* C6: RMT

* Fix interrupt handling

* Fix `ClockControl::configure`

* C6: revert to I2S0 instead of just I2S

* C6: rebase and update

* RTC not buildable

* Implement RWDT and SWD disable

* C6: working LEDC

* C6: working RMT

* C6: add aes

* C6: add mcpwm

* C6: add rtc_cntln - not finished

* C6: update and formatting

* C6: add pcnt

* C6: add examples and format

* Remove inline assembly, fix interrupts and linker scripts

* Remove unused features, update cargo config for atomic emu, misc cleanup

* Get ADC building and example "working" (as much as it ever does)

* Remove a bunch of unused constants which were copied from ESP-IDF

* The `mcpwm` example now works correctly

* Get `TWAI` peripheral driver building for C6

* Clean up the `rtc_cntl` module and get all the other HALs building again

* Add the C6 to our CI workflow

* Fix various things that have been missed when rebasing

Still missing a few examples (`clock_monitor`, `embassy_spi`, `ram`)

* C6: Small updates in wdt (#1)

* C6: Update WDT

* C6: Update examples with WDT update

* Update `esp-println` dependency to fix build errors

* Fix formatting issues causing pre-commit hook to fail

* Get some more examples working

* Working `ram` example

* Sync with changes in `main` after rebasing

* Working `embassy_spi` example

* Use a git dependency for the PAC until we publish a release

* Fix I2S for ESP32-C6

* Fix esp32c6 direct boot (#4)

* Add direct boot support for C6

* Fix direct boot for c6

- Actually copy into rtc ram
- remove dummy section that is no longer needed (was just a waste of
  flash space)
- Move RTC stuff before the no load sections

* Update RWDT and refactor RTC (#3)

* C6: Update RWDT and add example, refactor RTC and add not-really-good example

* Update based on review comments, resolve bunch of warnings and run cargo fmt

* Update C6 esp-pacs rev commit

* Fix clocks_ll/esp32c6.rs

* Fix riscv interrupts

* Remove clock_monitor example for now

* RAM example works in direct-boot mode

* Add a TODO for &mut TIMG0 and cargo fmt

* Fix linker script after a bad rebase

* Update CI and Cargo.toml embassy required features

* use riscv32imac-unknown-none-elf target for C6 in CI

* change default target to riscv32imac-unknown-none-elf

* add riscv32imac-unknown-none-elf target to MSRV job

* another cleanup

---------

Co-authored-by: bjoernQ <[email protected]>
Co-authored-by: Jesse Braham <[email protected]>

* Make required changes to include new `RADIO` peripheral

* Use published versions of PAC and `esp-println`

* Use the correct target extensions (`imac`)

* Fix the super watchdog timer, plus a few more examples

* Fix UART clock configuration

* Make sure to sync UART registers when configuring AT cmd detection

* Disable APM in direct-boot mode

* Address a number of review comments

* Fix `SPI` clocks and `rtc_watchdog` example  (#6)

* fix SPI clocks

* run cargo fmt

* Add comment about used default clk src

* Fix rtc_watchdog example in BL mode

* run cargo fmt

* Update rtc_watchdog example that it works in DB mode

* README and example fixes/cleanup

* Add I2C peripheral enable and reset

* Fix `ApbSarAdc` configuration in `system.rs`

---------

Co-authored-by: bjoernQ <[email protected]>
Co-authored-by: Juraj Sadel <[email protected]>
Co-authored-by: Juraj Sadel <[email protected]>
Co-authored-by: Scott Mabin <[email protected]>
  • Loading branch information
5 people authored Feb 27, 2023
1 parent bfa1bd9 commit d293d9f
Show file tree
Hide file tree
Showing 89 changed files with 6,695 additions and 257 deletions.
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
23 changes: 14 additions & 9 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,19 +65,21 @@ 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] | `no_std` Wi-Fi/Bluetooth LE support |

[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

The **M**inimum **S**upported **R**ust **V**ersions are:

- `1.65.0` for RISC-V devices (**ESP32-C2**, **ESP32-C3**)
- `1.65.0` for RISC-V devices (**ESP32-C2**, **ESP32-C3**, **ESP32-C6**)
- `1.65.0` for Xtensa devices (**ESP32**, **ESP32-S2**, **ESP32-S3**)
- `1.67.0` for all `async` examples (`embassy_hello_world`, `embassy_wait`, etc.)

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

0 comments on commit d293d9f

Please sign in to comment.