Skip to content

Commit cdeebd5

Browse files
committed
Merge remote-tracking branch 'upstream/main' into dpi_driver
2 parents 2afc12e + c6404fe commit cdeebd5

File tree

319 files changed

+14920
-13713
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

319 files changed

+14920
-13713
lines changed

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[alias]
22
xtask = "run --package xtask --"
3+
xfmt = "xtask fmt-packages"

.github/workflows/changelog.yml

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@ name: Changelog check
22

33
on:
44
pull_request:
5-
# We will not track changes for the following packages.
5+
# We will not track changes for the following packages/directories.
66
paths-ignore:
7-
- "/xtask/"
8-
- "/esp-build/"
9-
- "/esp-hal-procmacros/"
10-
- "/esp-metadata/"
117
- "/examples/"
12-
- "/hil-tests/"
138
- "/extras/"
9+
- "/hil-tests/"
1410
- "/resources/"
11+
- "/xtask/"
1512
# Run on labeled/unlabeled in addition to defaults to detect
1613
# adding/removing skip-changelog labels.
1714
types: [opened, reopened, labeled, unlabeled, synchronize]
@@ -33,24 +30,34 @@ jobs:
3330
- 'esp-alloc/**'
3431
esp-backtrace:
3532
- 'esp-backtrace/**'
33+
esp-build:
34+
- 'esp-build/**'
35+
esp-config:
36+
- 'esp-config/**'
3637
esp-hal:
3738
- 'esp-hal/**'
3839
esp-hal-embassy:
3940
- 'esp-hal-embassy/**'
41+
esp-hal-procmacros:
42+
- 'esp-hal-procmacros/**'
4043
esp-ieee802154:
4144
- 'esp-ieee802154/**'
4245
esp-lp-hal:
4346
- 'esp-lp-hal/**'
47+
esp-metadata:
48+
- 'esp-metadata/**'
4449
esp-println:
4550
- 'esp-println/**'
4651
esp-riscv-rt:
4752
- 'esp-riscv-rt/**'
48-
xtensa-lx-rt:
49-
- 'xtensa-lx-rt/**'
5053
esp-storage:
5154
- 'esp-storage/**'
5255
esp-wifi:
5356
- 'esp-wifi/**'
57+
xtensa-lx:
58+
- 'xtensa-lx/**'
59+
xtensa-lx-rt:
60+
- 'xtensa-lx-rt/**'
5461
5562
- name: Check that changelog updated (esp-alloc)
5663
if: steps.changes.outputs.esp-alloc == 'true'
@@ -68,6 +75,22 @@ jobs:
6875
skipLabels: "skip-changelog"
6976
missingUpdateErrorMessage: "Please add a changelog entry in the esp-backtrace/CHANGELOG.md file."
7077

78+
- name: Check that changelog updated (esp-build)
79+
if: steps.changes.outputs.esp-build == 'true'
80+
uses: dangoslen/changelog-enforcer@v3
81+
with:
82+
changeLogPath: esp-build/CHANGELOG.md
83+
skipLabels: "skip-changelog"
84+
missingUpdateErrorMessage: "Please add a changelog entry in the esp-build/CHANGELOG.md file."
85+
86+
- name: Check that changelog updated (esp-config)
87+
if: steps.changes.outputs.esp-config == 'true'
88+
uses: dangoslen/changelog-enforcer@v3
89+
with:
90+
changeLogPath: esp-config/CHANGELOG.md
91+
skipLabels: "skip-changelog"
92+
missingUpdateErrorMessage: "Please add a changelog entry in the esp-config/CHANGELOG.md file."
93+
7194
- name: Check that changelog updated (esp-hal)
7295
if: steps.changes.outputs.esp-hal == 'true'
7396
uses: dangoslen/changelog-enforcer@v3
@@ -84,6 +107,14 @@ jobs:
84107
skipLabels: "skip-changelog"
85108
missingUpdateErrorMessage: "Please add a changelog entry in the esp-hal-embassy/CHANGELOG.md file."
86109

110+
- name: Check that changelog updated (esp-hal-procmacros)
111+
if: steps.changes.outputs.esp-hal-procmacros == 'true'
112+
uses: dangoslen/changelog-enforcer@v3
113+
with:
114+
changeLogPath: esp-hal-procmacros/CHANGELOG.md
115+
skipLabels: "skip-changelog"
116+
missingUpdateErrorMessage: "Please add a changelog entry in the esp-hal-procmacros/CHANGELOG.md file."
117+
87118
- name: Check that changelog updated (esp-ieee802154)
88119
if: steps.changes.outputs.esp-ieee802154 == 'true'
89120
uses: dangoslen/changelog-enforcer@v3
@@ -131,3 +162,19 @@ jobs:
131162
changeLogPath: esp-wifi/CHANGELOG.md
132163
skipLabels: "skip-changelog"
133164
missingUpdateErrorMessage: "Please add a changelog entry in the esp-wifi/CHANGELOG.md file."
165+
166+
- name: Check that changelog updated (xtensa-lx)
167+
if: steps.changes.outputs.xtensa-lx == 'true'
168+
uses: dangoslen/changelog-enforcer@v3
169+
with:
170+
changeLogPath: xtensa-lx/CHANGELOG.md
171+
skipLabels: "skip-changelog"
172+
missingUpdateErrorMessage: "Please add a changelog entry in the xtensa-lx/CHANGELOG.md file."
173+
174+
- name: Check that changelog updated (xtensa-lx-rt)
175+
if: steps.changes.outputs.xtensa-lx-rt == 'true'
176+
uses: dangoslen/changelog-enforcer@v3
177+
with:
178+
changeLogPath: xtensa-lx-rt/CHANGELOG.md
179+
skipLabels: "skip-changelog"
180+
missingUpdateErrorMessage: "Please add a changelog entry in the xtensa-lx-rt/CHANGELOG.md file."

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ jobs:
137137
138138
- name: msrv RISCV (esp-wifi)
139139
run: |
140-
cargo xtask build-package --features=esp32c2,wifi,ble,async --target=riscv32imc-unknown-none-elf esp-wifi
141-
cargo xtask build-package --features=esp32c3,wifi,ble,async --target=riscv32imc-unknown-none-elf esp-wifi
142-
cargo xtask build-package --features=esp32c6,wifi,ble,async --target=riscv32imac-unknown-none-elf esp-wifi
143-
cargo xtask build-package --features=esp32h2,ble,async --target=riscv32imac-unknown-none-elf esp-wifi
140+
cargo xtask build-package --features=esp32c2,wifi,ble --target=riscv32imc-unknown-none-elf esp-wifi
141+
cargo xtask build-package --features=esp32c3,wifi,ble --target=riscv32imc-unknown-none-elf esp-wifi
142+
cargo xtask build-package --features=esp32c6,wifi,ble --target=riscv32imac-unknown-none-elf esp-wifi
143+
cargo xtask build-package --features=esp32h2,ble --target=riscv32imac-unknown-none-elf esp-wifi
144144
145145
# Verify the MSRV for all Xtensa chips:
146146
- name: msrv Xtensa (esp-hal)
@@ -151,9 +151,9 @@ jobs:
151151
152152
- name: msrv Xtensa (esp-wifi)
153153
run: |
154-
cargo xtask build-package --toolchain=esp --features=esp32,wifi,ble,async --target=xtensa-esp32-none-elf esp-wifi
155-
cargo xtask build-package --toolchain=esp --features=esp32s2,wifi,async --target=xtensa-esp32s2-none-elf esp-wifi
156-
cargo xtask build-package --toolchain=esp --features=esp32s3,wifi,ble,async --target=xtensa-esp32s3-none-elf esp-wifi
154+
cargo xtask build-package --toolchain=esp --features=esp32,wifi,ble --target=xtensa-esp32-none-elf esp-wifi
155+
cargo xtask build-package --toolchain=esp --features=esp32s2,wifi --target=xtensa-esp32s2-none-elf esp-wifi
156+
cargo xtask build-package --toolchain=esp --features=esp32s3,wifi,ble --target=xtensa-esp32s3-none-elf esp-wifi
157157
158158
- name: msrv (esp-lp-hal)
159159
run: |

documentation/API-GUIDELINES.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,29 @@ The following paragraphs contain additional recommendations.
1515

1616
## Construction and Destruction of Drivers
1717

18-
- Drivers take peripherals and pins via the `PeripheralRef` pattern - they don't consume peripherals/pins.
18+
- Drivers should take peripherals via the `PeripheralRef` pattern - they don't consume peripherals directly.
19+
- If a driver requires pins, those pins should be configured using `fn with_signal_name(self, pin: impl Peripheral<P = InputConnection> + 'd) -> Self)` or `fn with_signal_name(self, pin: impl Peripheral<P = OutputConnection> + 'd) -> Self)`
20+
- If a driver supports multiple peripheral instances (for example, I2C0 is one such instance):
21+
- The peripheral instance type should be positioned as the last type parameter of the driver type.
22+
- The peripheral instance type should default to a type that supports any of the peripheral instances.
23+
- The author is encouraged to use `crate::any_peripheral` to define the "any" peripheral instance type.
24+
- The driver should implement a `new` constructor that automatically converts the peripheral instance into the any type, and a `new_typed` that preserves the peripheral type.
25+
- If a driver only supports a single peripheral instance, no instance type parameter is necessary.
26+
- If a driver implements both blocking and async operations, or only implements blocking operations, but may support asynchronous ones in the future, the driver's type signature should include a `crate::Mode` type parameter.
27+
- By default, constructors should configure the driver for blocking mode. The driver should implement `into_async` (and a matching `into_blocking`) function that reconfigures the driver.
28+
- `into_async` should configure the driver and/or the associated DMA channels. This most often means enabling an interrupt handler.
29+
- `into_blocking` should undo the configuration done by `into_async`.
30+
- The asynchronous driver implemntation should also expose the blocking methods (except for interrupt related functions).
1931
- Consider adding a `Drop` implementation resetting the peripheral to idle state.
20-
- Consider using a builder-like pattern for configuration which must be done during initialization.
32+
- Consider using a builder-like pattern for driver construction.
2133

2234
## Interoperability
2335

2436
- `cfg` gated `defmt` derives and impls are added to new structs and enums.
2537
- see [this example](https://github.com/esp-rs/esp-hal/blob/df2b7bd8472cc1d18db0d9441156575570f59bb3/esp-hal/src/spi/mod.rs#L15)
2638
- e.g. `#[cfg_attr(feature = "defmt", derive(defmt::Format))]`
2739
- Don't use `log::XXX!` macros directly - use the wrappers in `fmt.rs` (e.g. just `info!` instead of `log::info!` or importing `log::*`)!
40+
- Consider implementing common ecosystem traits, like the ones in `embedded-hal` or `embassy-embedded-hal`.
2841

2942
## API Surface
3043

@@ -45,6 +58,9 @@ The following paragraphs contain additional recommendations.
4558
- For example starting a timer is fine for `&self`, worst case a timer will be started twice if two parts of the program call it. You can see a real example of this [here](https://github.com/esp-rs/esp-hal/pull/1500#pullrequestreview-2015911974)
4659
- Maintain order consistency in the API, such as in the case of pairs like RX/TX.
4760
- If your driver provides a way to listen for interrupts, the interrupts should be listed in a `derive(EnumSetType)` enum as opposed to one function per interrupt flag.
61+
- If a driver only implements a subset of a peripheral's capabilities, it should be placed in the `peripheral::subcategory` module.
62+
- For example, if a driver implements the slave-mode I2C driver, it should be placed into `i2c::slave`.
63+
- This helps us reducing the need of introducing breaking changes if we implement additional functionalities.
4864

4965
## Maintainability
5066

@@ -56,6 +72,15 @@ The following paragraphs contain additional recommendations.
5672
- All `Future` objects (public or private) must be marked with ``#[must_use = "futures do nothing unless you `.await` or poll them"]``.
5773
- Prefer `cfg_if!` over multiple exclusive `#[cfg]` attributes. `cfg_if!` visually divides the options, often results in simpler conditions and simplifies adding new branches in the future.
5874

75+
## Driver implementation
76+
77+
- If a common `Instance` trait is used for multiple peripherals, those traits should not have any logic implemented in them.
78+
- The `Instance` traits should only be used to access information about a peripheral instance.
79+
- The internal implementation of the driver should be non-generic over the peripheral instance. This helps the compiler produce smaller code.
80+
- The author is encouraged to return a static shared reference to an `Info` and a `State` structure from the `Instance` trait.
81+
- The `Info` struct should describe the peripheral. Do not use any interior mutability.
82+
- The `State` struct should contain counters, wakers and other, mutable state. As this is accessed via a shared reference, interior mutability and atomic variables are preferred.
83+
5984
## Modules Documentation
6085

6186
Modules should have the following documentation format:
@@ -88,4 +113,5 @@ Modules should have the following documentation format:
88113
```
89114
#![doc = concat!("[ESP-IDF documentation](https://docs.espressif.com/projects/esp-idf/en/latest/", crate::soc::chip!(), "/api-reference/peripherals/etm.html)")]
90115
```
91-
- Documentation examples should be short and basic, for more complex scenarios, create an example.
116+
- In case of referencing a TRM chapter, use the `crate::trm_markdown_link!()` macro. If you are referring to a particular chapter, you may use `crate::trm_markdown_link!("#chapter_anchor")`.
117+
- Documentation examples should be short and basic. For more complex scenarios, create an example.

esp-build/CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
12+
### Fixed
13+
14+
### Changed
15+
16+
- Use `panic` instead of `process::exit` in esp-build (#2402 )
17+
18+
### Removed
19+
20+
## [0.1.0] - 2024-04-17
21+
22+
- Initial release
23+
24+
[Unreleased]: https://github.com/esp-rs/esp-hal/commits/main/esp-build?since=2024-04-17

esp-config/CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
12+
### Fixed
13+
14+
### Changed
15+
16+
### Removed
17+
18+
## [0.1.0] - 2024-10-10
19+
20+
- Initial release
21+
22+
[Unreleased]: https://github.com/esp-rs/esp-hal/commits/main/esp-config?since=2024-10-10

0 commit comments

Comments
 (0)