* 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
* Tweak I2C timeout defaults and stability
* Add some logs
* Set signal levels before releasing GPIOs
* Use a single option for the pins
* Don't use the hardware to detect idle state, stop when device releases SDA
* RMT: Encapsulate STATE accesses
Abstract away the unsafe AtomicU8 <-> RmtState conversion behind a safe
API. (See the code comments next to the `mod state` fore more details.)
This adds a few methods that are presently unused, but will be in future
PRs.
* RMT: remove unnecessary pub(crate) from *_SIGNAL arrays
* add #[inline] to (un)listen_(rx|tx)_interrupt
Ensure that these methods are always inlined (they probably would be
anyway, but better be sure):
- The `event` argument is usually known, which might allow for more
optimizations.
- Ideally, the compiler should be able to optimize away any complexity
that the `EnumSet` might add.
* RMT: inline Rmt::new_internal
given that there's only a single caller since a previous refactoring
* RMT: add test for channel RAM release on Drop
* RMT: macro simplification
- centralize all macros, getting close to a single source of truth for
the channel specification
- use paste! to avoid some repetitive macro arguments
- replace the tt-muncher by simple repeat patterns: This makes the macro
much easier to read. It would be possible to combine the
declare_channels!, declare_rx_channels!, declare_tx_channels! by using
one big complicated tt-muncher, but the cost in readability of the
macro seems excessive
- no need for absolute paths in these macros, we're the only user, and
they're only used at the top level of the module
* RMT: import crate::gpio to shorten paths
we keep the gpio prefix, since a later commit will also use
gpio::interconnect::{InputSignal, OutputSignal}
* AES-DMA work queue backend
Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>
* Clean up manual subslicing
* Don't copy in write_iv
* Add more to why we can use copy_from_nonoverlapping
* Replace buffers with NoBuffer
* Move buffers to backend
* Volatile-ly zero the key
* Make saving state the user's responsibility
* Ensure data is aligned on esp32
* Also make sure the DMA finishes in AesTransfer
* Deduplicate
* Fix paperwork
* Use the handler attribute
* Remove unused method
* Update esp-hal/MIGRATING-1.0.0-rc.0.md
Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>
* Fix build after rebase
* Add empty Final to NoBuffer
* Use the move api internally
* Make () the view type
---------
Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>
* 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
* Implement a generic work queue
* Implement AES work queue backend with software block modes
* Move tail after enqueueing
* Use NonNull more liberally
* Tweak the queue a bit
* Merge the AES-DMA test into the AES test suite
* Drop AesFlavour
* Document things
* Stop the driver when its handle is dropped
* Fix docs
* Address some correctness concerns
* 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
* RMT: add get_tx_status, get_rx_status methods
Unused right now; these methods allow to look at all flags without several
volatile reads (in contrast to calling is_tx_done/is_rx_done,
is_tx_threshold_set, is_error individually). `match`ing on their result
leads to very idiomatic code, and also result in blocking and async code
that is very similar.
The #[inline] attribute might not be required, but better be sure: We
really don't want the Option<Event> to actually be constructed, but
rather that the compiler completely optimized it away in favor of direct
bit tests in the calling function.
* RMT: optimize RmtTxFuture to avoid repeated register reads
* RMT: optimize RmtRxFuture to avoid repeated register reads
* RMT: Optimize ContinuousTxTransaction by avoiding repeated register reads
* RMT: Optimize/simplify SingleShotTxTransaction (1/2)
by merging two loops into one
* RMT: Optimize/simplify SingleShotTxTransaction (2/2)
by avoiding repeated register reads
* RMT: add poll() method to blocking transactions
This allows properly interleaving several such transactions (as the HIL
loopback tests do, in fact) or other work.
Regarding the implementation of the place_rmt_driver_in_ram feature for these
methods, note that `#[ram]` implies `[inline(never)]`.
Thus, this uses `#[inline(always)]` for `poll` and `wait` in that case,
which are rather simple methods.
If putting them in ram actually matters, the calling user code should
probably be placed in ram as well, and then, forced inlining of both
methods should have the desired effect.
`poll_internal` in turn
- contains more code and is called from `poll` and `wait`
-> it seems sensible that it is not inlined to reduce code size.
- includes the hot loop that copies to the hardware buffer
-> should be forced to ram
so `#[ram]` makes sense.
Note that none of this was benchmarked.
* RMT: Remove unused low-level methods
Their use has entirely be replaced by get_tx_status and get_rx_status
* 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
* Move macros to new crate
* Generate a single file
* Pre-generate esp-metadata-generated
* Move saving code to xtask
* Format with both rustfmt and prettyplease
* Fix doc build
* Unhide macros
* Fix doc string
* Update semver-check baseline
* 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>
* Reduce use of iter::chain
* Cache all symbols
* Trim xtensa-lx-rt deps
* Remove unused dep
* Replace chrono with jiff
* Yeet minijinja
* Save a bit on toml_edit
* Disable some default features
* Disable regex log filters
* Reduce xtensa-lx-rt build script
* Remove unnecessary dependencies
* Remove darling
* Update embedded-test
* lol
* Clean up
* Only validate loaded config once
* fmt
* Changelog
* 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
* Add failing test
* Reset FSM when cancelling a transaction
* Refactor clear_bus_blocking to avoid duplicating the logic
* Extract timeout from ClearBusFuture
* Clear bus immediately when cancelling an async transfer