- Update example commands to use the new `--chip` argument format for `build examples` and `run example` subcommands.
- Improve clarity by showing explicit argument order and usage.
- Reflect recent changes in xtask interface for building and running examples.
Signed-off-by: Alexei Pastuchov <info@maximka.de>
* RMT: add HIL test that exercises all channels
to ensure that there are no issues with channel/register indexing; see
also the code comments.
no user-facing changes
* RMT: store ch_idx instead of channel number
`ConstChannelAccess` and `DynChannelAccess` used to store the channel number
and have a `Direction` generic parameter.
However, there are invalid combinations of `Direction` and the channel
number on some chips (e.g. on esp32c3, there is no channel with (Tx, 2),
because channel 2 and 3 only support Rx).
In constrast, the tuple `(Dir, ch_idx)` also uniquely identifies a
channel and its configuration, and any combination of it is valid as long as the
channel index is in bounds.
This makes it somewhat easier to work with; in particular, it will allow
removing bounds checks on ch_idx in a later commit by replacing
`ch_idx: u8` with an enum type.
This also refactors the `async_interrupt_handler` accordingly.
This is user-visible via the `ConstChannelAccess` type, however a later
commit in this PR will remove that entirely.
* RMT: elide bounds checks via ChannelIndex enum
If the channel index is not known at compile time in a given function,
the compiler will insert bounds checks on
- indexing the STATE global
- register access via the PAC
The compiler seems to be able to deduplicate them since low-level
functions are mostly inlined, but each function will retain at least one
bounds check.
This change helps the compiler to elide these checks by using a custom
type for channel indices that can only take values for which a channel
exists.
Specifically, this uses an enum to serve as a refinement of u8 to help
the compiler restrict value ranges. Due to inlining, this restricted
value range is propagated by the compiler until the potential bounds checks,
even if there's intermediate cast to u8,
cf. https://github.com/rust-lang/rust/issues/109958
There are no user-facing changes. (`ChannelIndex` is `pub` because it
appears in a `[doc(hidden)]` trait member.)
* RMT: always type-erase channels
- remove the `Raw` generic on `Channel`: This simplifies the types,
should have negligible performance impact (helped by elided bounds
checks via the recently introduced `ChannelIndex` enum), and greatly
reduce code size if several channels are used (by avoiding
monomorphization per channel)
- this also changed the arguments to configure_(tx,rx)_channel such that
they don't contain generics, again avoiding code bloat due to
monomorphization
This requires user code to change type annotations for channels and
transactions, and remove any manual type erasure (via `channel.degrade()`).
* RMT: impl blocking tx/rx methods directly on Channel
There's now only a single type that should implement these methods due
to erasing the channel index const generic, so the indirection via a
trait serves no purpose. Implementing methods directly on the channel
probably also helps to make the docs more discoverable.
This requires user code to remove the `TxChannel` and `RxChannel`
imports.
* RMT: impl async tx/rx methods directly on Channel
There's now only a single type that should implement these methods due
to erasing the channel index const generic, so the indirection via a
trait serves no purpose. Implementing methods directly on the channel
probably also helps to make the docs more discoverable.
This requires user code to remove the `TxChannelAsync` and `RxChannelAsync`
imports.
* RMT: impl *ChannelInternal traits only on DynChannelAccess
rather than as a blanket impl for RawChannelAccess, which includes
ConstChannelAccess: We don't intend to perform any accesses via
ConstChannelAccess anymore, so enforce that.
We could also get rid of the traits entirely and directly impl their
methods for DynChannelAccess, but it seems somewhat useful to keep them
around to guarantee that the interfaces in both chip_specific modules
are consistent.
There are no user-facing changes here.
* RMT: remove `pub` on various internal types
that used to be visible somewhere in the API's trait bounds, but are not
part of the API themselves
This is user-visible, but user code should not have used these types in
the first place.
* RMT: rm ConstChannelAccess, RawChannelAccess, private DynChannelAccess
now that Channel has no `Raw: RawChannelAccess` type parameter:
- we don't need low-level channel methods to be implemented for
ConstChannelAccess, since all accesses go through DynChannelAccess.
Thus, remove the *ChannelInternal traits and implement their methods directly
on DynChannelAccess
- none of these types need to be public (although one might consider
actually making them public with an unsafe constructor to provide an
unsafe low-level interface to the hardware)
This is user-visible (imports need to be removed; they're not used
anymore since the previous commit that always type-erased the `Raw`
parameter of `Channel`)
* RMT: changelog and migration guide for type-erased channels
* RMT: (review) remove stray comment
* RMT: (review) remove is_tx() from Direction trait
we can simply use the const item directly
* feat(example): Add SNTP example to show how to update Rtc
* Bump embassy-net to 0.7.0 for compatibility
* Revert back to task-arena to build on stable.
* Move `embassy_wifi_bench`, `wifi_bench`, and `wifi_csi` examples to `qa-test` package
* Remove blocking BLE example, replace Embassy example with trouble-based scanner
* Add BLE `bas_peripheral` example
* Split wifi feature into wifi-ap, wifi-sta and wifi-eap
* changelog
* Revert most of the changes, keep wifi and wifi-eap features only
* wifi-eap is unstable, include this feature into CI tests and documentation
* More consistent naming of interrupt-related functions
* MG entry
* changelog
* use correct package for MG
* fix hil
* other drivers
* address review comments
* s/esp-radio-preempt-baremetal/esp-preempt/g
esp-preempt will hopefully one day be more useful than just a scheduler
for esp-radio, therefore I've removed the radio prefix for that future
goal. I also felt that baremetal didn't really add much other than
noise, so I've removed that postfix too.
* fix xtask
* remove test code
* fixups
* Move all `embassy` examples to `async` and convert to individual projects
* Move all peripheral examples to `peripheral` and convert to individual projects
* Move all interrupt examples to `interrupt` and convert to individual projects
* Move all `ble` examples to `ble` and convert to individual projects
* Move all `esp-now` examples to `esp-now` and convert to individual projects
* Move all Wi-Fi examples to `wifi` and convert to individual projects
* Move all `ieee802154` examples to `ieee802154` and convert to individual projects
* Move all OTA examples to `ota` and convert to individual projects
* Remove files which are no longer required
* Update `xtask` to handle new examples project layout
* Update `examples/README.md`
* Don't hide TOML parsing error in `is_published`
* Update `fmt-packages` subcommand to handle new examples project layout
* RMT: make PulseCode a newtype rather than an extension trait on u32
This has several advantages:
- the meaning of `u32` used as pulse code becomes more explicit
- it allows using `PulseCode` methods in `const` context (which is otherwise
not possible because Rust does not presently support associated const
fn in traits).
- it allows providing custom `defmt::Format` and `core::fmt::Debug` impls
for `PulseCode`, greatly helping with debugging
I have taken the liberty to implement `core::fmt::Debug` in a slightly
non-standard way: The most natural implementation would probably use a
struct-style output like
PulseCode { length1: 42, level1: Level::High, length2: 24, level2: Level::Low }
However, that is very lengthy and not really human-readable anymore when
dealing with an array of `PulseCode`s. Thus, this uses the more compact format
PulseCode(H 42, L 24)
This provides `u32: From<PulseCode>` and `PulseCode: From<u32>` impls and
converts rx and tx methods to accept `impl Into<PulseCode>` and
`impl From<PulseCode>`, respectively.
This should help to reduce how much user code needs to change (but replacing
`u32` type annotations with `PulseCode` will be required).
By applying `#[repr(transparent)]` to `struct PulseCode`, it is
guaranteed to match the layout of `u32` such that accessing the hardware
buffer via `*mut PulseCode` pointers is valid.
* RMT: Address review on PulseCode refactor, further refine the interface a bit
- introduce Level::const_from and Level::const_into
- pre-compute a few more shifts and masks (this is unlikely to affect
generated code, since the compiler would have const propagated them
anyway, but it helps to keep the PulseCode impl more readable)
- improve docstrings
- remove PulseCode::empty in favor of PulseCode::default, keep
PulseCode::end_marker for now (but it's not completely clear that this
interface is optimal; see also the FIXME note on adding a variant of
this methods that supports settings levels and length1)
- make PulseCode::new_unchecked pub and shuffle it around in the code so
that it doesn't show up first in the docs
- factor out PulseCode::symbolX methods for internal use in debug
formatting
- sprinkle a few more #[inline] to be totally sure that this really adds
no overhead over having plain u32
- convert methods receivers from &self to self given that PulseCode is
Copy (which probably doesn't matter much since all these methods
should always be inlined)
- remove PulseCode::as_u32() and make the tuple field pub: There's no
safety implication of marking this pub, and field access still
provides a const-compatible way to obtain the wrapped value
* Provide malloc, free and friends in esp-alloc
* Mute warning
* Remove some (now unused) global symbols
* Have a way to opt-out of esp-alloc's malloc,free etc.
* Fixes
* Move some common C functions from esp-radio to esp-rom-sys
* Fix
* Make esp-readio symbols weakly linked
* CHANGELOG.md
* Align MSRV, cleanup visibility
* Init before `assume_init`
* Linker script fixes
* Fix examples
* Remove heapless - esp-radio is alloc
* Fix examples
* Whitespace
* realloc_internal
* Make `__esp_radio_putchar` a no-op if `sys-logs` is not enabled
* Move exception handler from esp-backtrace to esp-hal
* CHANGELOG.md
* Fix
* Only use defmt compatible display hints
* Workaround xtensa-lx-rt and riscv-rt not implementing defmt::Format
* Add `defmt` feature to xtensa-lx-rt and esp-riscv-rt
* Favor feature gates over random `allow`s - remove unnecessary `allow`s
* esp-wifi: Add unstable feature, mark ble, esp-now and csi features and APIs as unstable
* changelog
* fix hils
* rebase and reviews
* rebase
* Make at least wifi_embassy_dhcp work without unstable feature
* remove rand_core
* rebase
* Check if a feature is selected which needs unstable
* reviews and fix ci
* reviews
* rename `esp_wifi`-prefixed symbols to match new `esp-radio` crate name
* fmt
* rename the rest of functions + example variable renaming
* add migration guide
* reword 😅
* rename `esp-wifi` to `esp-radio`
* Add migration guide entry
* changelog entry
* address reviews
* more fixes
* address reviews
* Thank you for this rebase!
* mmm, rebase
* Remove unnecessary diff
bob
* get rid off all `esp-wifi` references
* drop the links ƒrom the table
* Expand peripheral metadata
* Generate peripherals macro call
* Remove paste from peripherals
* Add missing peris
* Fix ETM and TRACE0 naming
* Remove redundant tsens symbol
* Remove RTCIO stuff from h2
* Rename S2 RTC_CNTL
* Add missing SYSCON back to S2
* Do not mark the GPIO singleton stable
* Treat unlisted drivers as not available
* Assign stability based on driver info
* Fmt
* Remove unused info
* Move ROM function definitions to esp-hal-rom crate
* Patch ESP32 ROM-functions, use it in esp-storage
* Allow placing additional code in IRAM
* esp-storage depends on esp-hal-rom
* Move ROM function wrappers from esp-hal to esp-hal-rom
* Make bootloader-support crate use CRC ROM function
* Minor polishing
* changelogs
* Make CI green
* Define (some) spiflash ROM functions in esp-hal-rom
* Lint
* Avoid duplicate definition of `__assert_func`
* Rename to `esp-rom-sys`
* Mention versioning this crate in the README
* Fixes
* Check self-version
* Docs
* Clippy
* Check if version bump is allowed
* Unconditionally place spiflash ROM function patches (if present) in rwtext
* Cleanup
* Change how unacceptable version bump requests are detected
* Initial version 0.1.0
* Docs
* Use correct version
* Force esp-rom-sys bumps to patch
* Fix
* RMT: Move some methods from (Tx|Rx)ChannelInternal to ChannelInternal
Adds a new `ChannelInternal` trait implemented on `Channel`s, which
bundles some methods that conceptually make sense for both rx and tx
channels (whether the implementation is exactly the same is
chip-specific).
This avoids a small amount of code duplication.
* RMT: Define input/output signals via a const array
Allowing a default implementation of the getter functions in the ChannelInternal
trait, and more importantly, paving the way for type-erased channels
(where it will become necessary to map Channel number to signal at runtime).
The array is indexed by ch_index, i.e. the index of the channel among
channels of the same type (for devices with separate rx/tx channels).
* RMT: move some `Sized` bounds from methods to trait
To avoid repetition. There's no downside, since the trait is only
implemented for a single type anyway, which is Sized.
These traits are user-visible, but since they can't be implemented by users,
and this only makes the bounds stricter, it should require not changes
to user code.
* RMT: Use composition with ConstChannelAccess, reduces macro usage
instead of an extension trait implemened via the impl_*_channel macros.
This reduces macro usage, making the code easier to reason about, and it also
paves the way for type-erased channels by adding a second implementation
of RawChannelAccess.
This touches many lines, but is a fairly mechanical change that should
be easier to review by ignoring whitespace changes.
Previously, channel architecture was as follows:
- `Channel` is parameterized by a const generic `CHANNEL: u8` number
- low-level hardware operations are implemented via the
*ChannelInternal traits directly on `Channel`. This is done via the
`impl_*x_channel` macros to account for the different channel
capabilities (rx/tx only or rx+tx)
This PR changes this to:
- `Channel` contains an `Raw: RawChannelAccess<Dir=Rx|Tx>` where `Rx`
and `Tx` are ZSTs used as markers for a channel configured for a given
direction.
- low-level operations are implemented on the `Raw` type, depending on
a bound on RawChannelAccess::Dir
- the `Raw` types can only be constructed safely from the
`ChannelCreator`, which ensures that only valid combinations of channel
number and `Dir=Rx|Tx` can exist.
- currently, the only implementation of `RawChannelAccess` is
`ConstChannelAccess`, which has a `CHANNEL: u8` const generic
parameter, just as `Channel` did before. Thus, the compiler should be
able to inline and const-propagate code just as before.
These new types are user-visible. Thus, if code directly names `Channel`
types, it needs to be adapted. If it just uses a method chain such as
`rmt.channelX.configure(...).transmit(...)`, no changes should be
required.
* RMT: rm (Rx|Tx)ChannelCreatorAsync, use mode generic on (Rx|Tx)ChannelCreator
this de-duplicates some code,
and may be useful to implement user code (e.g. setup functions) that is
independent of DriverMode
* RMT: Rewrite pending_interrupt_for_channel using indexed PAC accessors
This deduplicates some code. I've also changed the return type
(usize -> u8) for better consistency, since channel indices are generally
typed as u8.
* RMT: add DynChannelAccess as basis for type-erased channels
Channels can now be `degrade`d to their type-erased variants.
* RMT: Move around some code
The channel definition used to be somewhere in the middle of channel
implementation. There's no change to the code other than its location.
* RMT: slightly more readable subsclicing
* RMT: Move some chip-specific code to a cfg_if! switch
There's no reason for these to reside in separate modules, and this
restructuring meshes well with moving the Rmt definition to a macro as
well, which will be done next.
* RMT: Declare Rmt struct via macro to avoid repetition
Reduces boilerplate at the cost of a somewhat complex macro.
* RMT: Move RmtState
Which was previously in the middle of channel implementation, but
conceptually is more global to the module, thus more natural define
earlier.
* RMT: explicity mark a few private functions in submodule as pub(super)
* RMT: use DynChannelAccess::conjure to simplify async_interrupt_handler
If the compiler decides to unroll the loops, the resulting code should
be essentially the same. Otherwise, it should be more compact. In any
case, from a developer point of view, this is much more concise and
removes one chip-specific case.
* RMT: Use type-erased channels for some HIL tests
* RMT: don't reset clock divider in start_tx
This seems to fix flaky loopback tests where tx/rx pulse code length
differs by 1.
This matches IDF, which also doesn't reset channels on each transmit
operation, but only once on channel creation, and when a sync_manager is
used (which the Rust driver doesn't support, and which would also need
to be handled differently anyway).
* RMT: implement degrade() even if the channel is already type-erased
This makes wrapping channels in custom structs slightly more convenient
since it allows taking any channel and type-erasing it in that structs
constructor.
* RMT: rename (Rx|Tx)ChannelCreator methods to avoid trait disambiguation problems
For devices with channels that support both Rx and Tx, Rust cannot
disambiguate the trait at the call site (because it doesn't look at the
argument types to do so).
Renaming the methods avoids that. The alternative is to use
fully-qualified names to call the trait methods (i.e. left-side
turbofish), or to import the traits only in a limited scope. Both are
much more verbose than the _rx/_tx suffixes to method names.
* RMT: add basic async HIL test
* RMT: remove overcomplicated WithMode trait from tests
according to a suggestion by @bugadani
---------
Co-authored-by: Scott Mabin <scott@mabez.dev>
* Fix esp-bootloader-esp-idf
* Use OTA enabled partition table for examples
* Add simple OTA example
* CHANGELOG.md
* Create a dummy `ota_image` in CI
* mkdir
* Remove unnecessary details from CHANGELOG
* Make non-Window's users life easier
* Test ROM function in esp-bootloader-esp-idf
* Fix
* Group optional dependencies
* Separate version from crate name
* Restore defmt-log mutual exclusivity
* Gate ufmt
* Remove usb-device
* Feature-gate unsable dependencies behind unstable
* S2: assume single core for portable-atomic
* Clean up feature flag docs
* Sack debug
* Fix clippy
* Update examples
* Fix usb-otg feature
* Fix fmt
* Add version to log dep
* Also mark bluetooth private
* Correct changelog/MG
* Clean up esp-hal-embassy
* Clean up ieee802154
* Clean up esp-println
* Move the timestamp function up
* Move info from readme to feature docs
* Clean up esp-storage
* Clean up esp-wifi
* Fix examples
* Add a note for the private features
* WIP
* Clean up init_gpio
* Expand docs a bit
* Remove Input/OutputConnection
* Not everything has PCNT and it's not important for the example
* Remove Frozen, enable input when creating the signal
* Hide fields, add getters
* Update MG
* Add force GPIO matrix fns
* Fix formatting
* Mention latency in the docs
* Rename number to gpio_number
* Deduplicate pin setup code
* Reword associated peripheral
* Rename with_inverted_input/output
* Remove link to doc-hidden OutputSignal
* Fix link syntax
* Make sure to enable relevant interrupts
* Fix more
* Make `current_runlevel` public
* Check that interrupts are enabled when initializing
* Try to be more honest in `is_in_isr`
* Adjust log levels
* Really fix ESP32 COEX
* Improve COEX example
* fmt
* CHANGELOG
* CHANGELOG
* Clarify on `esp_bt_controller_config_t`
* Take INTENABLE into account
* Test esp-wifi init fails
* Simplify test code
* Clarify comment
* fmt
* Rename
* Adapt the test
* Revert unrelated changes (esp_bt_controller_config_t)
* Align Xtensa (current_runlevel)
* Additional test
* Change test
* inter-state
* inter-state (2)
* warnings fix
* fix warnings
* fmt + changelogs
* another unsafe extern "C" doode
* real fmt now
* MSRV + format
* Ignore unsafe_op_in_unsafe_fn lint for now in esp-hal and esp-wifi
* msrv + fmt
* ugh....
* get lcd_cam example right
* expr_2021 -> expr experiment
* gagagugu
* reviews
* more unneeded unsafes (help)
* finish esp-hal unsafe cleanup
* each unsafe call is marked separately
fmt
* should be good now (?)
* piece was never an option...
* dumb