Simon Neuenhausen 3d6e522cbc
Allow splitting control over modem clocks. (#3687)
* Minimal architecture for split RCC.

* Removed critical section.

* Add all modem clock controllers and adjust esp-ieee802154.

* Fixed incorrect cfg.

* Fixed unstable attribute usage.

* Replaced AtomicU8 with Cell<u8>

* Reverted example channel back to 15

* Added unstable attribute to ModemClockController impls.

* Remember to actually increase the ref count.

* Experimentally removed RadioClockController

* Merged ref counters and made decrease panic if zero is reached.

* Removed RADIO_CLK peripheral.

* Removed RADIO_CLK again.

* Revert "Removed RADIO_CLK again."

This reverts commit 6da2d2834850068aa21bc52b141de2cfd8154acc.

* Removed RADIO_CLK without reformatting the files.

* Applied changes to examples and hil-tests.

* Fixed OS adapter for C2 and H2

* Adjusted docs and used unwrap!

* Fixed comments.

* Added changelog.

* Fixed esp-wifi for esp32h2.

* Changed comment for PHY_CLOCK_REF_COUNTER.

* Fixed lint for esp32c2.

* Update esp-hal/src/clock/mod.rs

Co-authored-by: Dániel Buga <bugadani@gmail.com>

* Update esp-hal/src/clock/mod.rs

Co-authored-by: Dániel Buga <bugadani@gmail.com>

* Removed unnecessary comments and made init_radio_clocks unstable.

* Update esp-hal/src/clock/mod.rs

Co-authored-by: Dániel Buga <bugadani@gmail.com>

* Fixed lint.

* Removed clocks_ll functions for chips that don't have those peripherals.

* fmt

* Changed modem clock controller stealing.

* Added lifetime

* fixed peripheral stealing again

* Made modem_clock_controller not const.

* Used type alias instead of function for peripheral stealing.

* fmt

* Adjusted remaining comments.

* Added note about coex.

* fmt

* misc

* Revert "misc"

This reverts commit d8740421e0dff84af605160939e246f2308a48e1.

* Regenerated esp metadata

---------

Co-authored-by: Dániel Buga <bugadani@gmail.com>
2025-07-08 17:23:55 +00:00
..
2025-06-13 13:42:09 +00:00
2025-07-01 13:05:01 +00:00
2025-06-13 13:42:09 +00:00
2025-05-23 22:01:14 +00:00

Examples

This package contains a number of binary applications demonstrating the use of various hardware peripherals found within ESP32 the family of devices.

Each device has its own unique set of peripherals, and as such not every example will run on every device. We recommend building and flashing the examples using the xtask method documented below, which will greatly simplify the process.

To check if a device is compatible with a given example, check the metadata comments above the imports, which will list all supported devices following the //% CHIPS: designator. If this metadata is not present, then the example will work on any device supported by esp-hal.

As previously stated, we use the cargo-xtask pattern for automation. Commands invoking this tool must be run from the root of the repository.

Building Examples

You can build all examples for a given device using the build examples subcommand:

cargo xtask build examples esp-hal esp32

Note that we must specify which package to build the examples for, since this repository contains multiple packages (specifying esp-hal will build the examples in the examples package instead).

Running Examples

You can also build and then subsequently flash and run an example using the run example subcommand. With a target device connected to your host system, run:

cargo xtask run example esp-hal esp32c6 --example embassy_hello_world

Again, note that we must specify which package to build the example from, plus which example to build and flash to the target device.

Adding Examples

If you are contributing to esp-hal and would like to add an example, the process is generally the same as any other project.

One major difference in our case is the metadata comments which state the compatible devices and required features for an example. Both of these designators are optional; if //% CHIPS: is omitted then all devices considered to be supported, and if //% FEATURES: is omitted then no features are enabled at build time.

To demonstrated, in src/bin/embassy_hello_world.rs you will see the following:

//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
//% FEATURES: embassy esp-hal-embassy/integrated-timers

Another thing to be aware of is the GPIO pins being used. We have tried to use pins available the DevKit-C boards from Espressif, however this is being done on a best-effort basis.

In general, the following GPIO are recommended for use, though be conscious of whether certain pins are used for UART, strapping pins, etc. on some devices:

  • GPIO0
  • GPIO1
  • GPIO2
  • GPIO3
  • GPIO4
  • GPIO5
  • GPIO8
  • GPIO9
  • GPIO10