2532 Commits

Author SHA1 Message Date
Dániel Buga
b346074de0
Release RTC_I2C resources when dropped (#4101) 2025-09-11 15:35:57 +00:00
Benedikt
97e3d00c90
RMT: Misc refactoring (#4100)
* RMT: move configure_*x_channel to Channel impl

These methods are essentially (unsafe) constructors for Channel, so it
makes sense for them to be part of the Channel rather than free-standing
functions.

Importantly, this refactoring also reorders channel configuration and
creation of GenericPeripheralGuard. Note that it's still not guranteed
that the peripheral is clocked when configuring it, since code like the
following compiles:

```
let ch0_creator = {
	let rmt = Rmt::new(peripherals.RMT, freq).unwrap();
	rmt.channel0;
	// Other fields of `rmt` are dropped, including the
	// `Rmt.peripheral: RMT` field.
	// Since not GenericPeripheralGuard has been created at this
	// point, this will disable the peripheral's clock.
};

// This re-enables RMT clocks. With this commit, it does so before
// actually accessing RMT registers. However, the clock configuration that
// happens in Rmt::new() will have been lost!
// -> will be fixed in a later PR
let ch0 = ch0_creator.configure_tx(pin, config).unwrap();
```

There's no change to the API here.

* RMT: merge transmit_continuously{,with_loopcount}

...by introducing an extra loopcount argument.

Add the LoopCount enum such that the resulting code remains readable.

This is in preparation for adding more variants of rx/tx methods in
order to avoid combinatoric explosion.

* RMT: use stop_tx if available, only for esp32 fill buffer with end markers

note that stop_tx requires an update() call (according to TRMs and to IDF code)

for consistency, this also removes all update() calls from the low-level
methods in favor of explicit calls
this de-duplicates some update calls for start_tx()

* RMT: deduplicate ContinuousTxTransaction::{stop, stop_next}

* RMT: remove spurious ch_tx_thr_event access on Rx channel

for esp32 + esp32s2, which don't support the ch_rx_thr_event (this was
partially cleaned up in #3701 already, but this instance was overseen)

* RMT: assert!(...is_ok()) -> unwrap in HIL tests
2025-09-11 14:15:38 +00:00
Dániel Buga
ba2d541624
Some mild scheduler cleanup (#4096)
* Clean up arch-specific task code

* Avoid a few redundant unwraps in run_scheduler

* Pass TaskPtr to alarm callback

* Ensure the radio runs on the scheduler's core

* clippy

* Add warnings
2025-09-11 12:11:23 +00:00
Kirill Mikhailov
b01f444822
Implement Error trait more (#4097)
* Implement `Error` trait more

fmt

* oi

* fix
2025-09-11 11:17:29 +00:00
Dániel Buga
d16b68396c
Try to explain preempt needs (#4092) 2025-09-11 08:37:21 +00:00
Dániel Buga
627a25e7dc
Disable wdt after test (#4095) 2025-09-11 10:36:35 +02:00
Dániel Buga
cf80e6a8f1
Implement priority levels (#4090)
* Add priority to tasks

* Separate Mutex out of counting Semaphore

* Add priority inheritance to mutexes

* Test priority inheritance, fix issues

* Compare against the owner's current priority
2025-09-11 08:03:44 +00:00
Björn Quentin
9e190f112d
Use riscv-rt's startup and trap-handling code (#3857)
* Use riscv-rt's startup code

* CHANGELOG.md

* Enable v-trap - get rid of one unused function

* Re-use riscv-rt's TrapFrame instead of keeping a copy of it

* fmt

* Update riscv-rt rev

* Enable defmt

* use riscv-rt's trap handling

* Compile on stable

* (Re)add the SP fixing code

* Move comment

* Update `riscv*` deps

* esp-riscv-rt: Remove the (unused) CI feature
2025-09-11 07:48:44 +00:00
Jesse Braham
6f033666c8
Move RTC clock enums/structs to clock module (#4089)
* Move RTC clock enums to `clock` module and fix naming violations

* Move `RtcClock` to `clock` module

* Update migration guide

* Update `CHANGELOG.md`

* Remove invalid attribute from enum variant
2025-09-10 09:47:07 +00:00
Dániel Buga
35e208236a
Add wait queues to semaphore/queue (#4086)
* Add wait queue to semaphores

* Spawn idle task, prevent re-waking a ready task

* Add wait queues to queues

* Clean up wait queues

* Remove task from wait queue on timeout/resume

* Do not re-schedule deleted task

* Implement simple stack overflow detection

* Task deletion: remove task from queues in one place

* Fix storing context into freed memory

* Restore idle task stack size

* Undo alloc changes

* Don't let task sleep if wakeup time is in the past

* Improve codegen of esp_preempt_now
2025-09-10 07:24:25 +00:00
Kirill Mikhailov
1597443bf1
Add new host-test xtask subcommand (#4085)
* Add new `host-test` xtask subcommand

+ smaller consistency and fmt fixes

* reviews

* reviews
2025-09-09 14:44:36 +00:00
Juraj Sadel
36634a4f92
Add Protocols to ClientConfig and EapClientConfig and apply them (#4080) 2025-09-09 10:06:26 +00:00
Dániel Buga
779f7a874f
esp-preempt: don't switch to sleeping tasks (#4081)
* Separate the alloc and run lists

* Replace circular task list with ready queue

* Remove separate SCHEDULER_STATE static

* Move scheduler to new file

* Reorganize, allow restarting scheduler

* Fix InternalMemory polyfill

* Use SingleShotTimer internally

* Implement a simple timer queue

* Extract run queue, wake tasks, store reason of scheduler event

* Add inherent function to get current task ptr

* Reimplement usleep with the timer queue

* Store current task in timer queue

* Sleep in timer queue task

* Remove ability to sleep arbitrary tasks

* More logging

* Clear timer interrupt in timer handler

* Even more logging

* Merge mutexes into semaphores
2025-09-09 09:57:35 +00:00
Juraj Sadel
e888f574fb
Update embassy-futures (#4079) 2025-09-08 14:39:42 +00:00
Dániel Buga
29ded39fe2
Add more implementation docs (#4078) 2025-09-08 13:46:57 +00:00
millibyte-products
e15e837246
Move adc channel from associated constant to function (#3942) (#3943)
* Move adc channel from associated constant to function

* Move adc channel from associated constant to function

* Syntax cleanup

* RISCV and Format fixes

* FIx xtensa

---------

Co-authored-by: Juraj Sadel <juraj.sadel@espressif.com>
2025-09-08 13:11:44 +00:00
Dániel Buga
779228ef28
Tweak driver to better model FreeRTOS APIs (#4076) 2025-09-08 12:44:29 +00:00
Dániel Buga
2b906e5b47
preempt - Abstract away blob ticks (#4063)
* Fix sleep

* Remove unused timeout from mutex_lock

* Abstract away blob ticks

* Update esp-radio/src/time.rs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Don't sleep for 10s

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-09-08 11:36:04 +00:00
Juraj Sadel
044e042eda
Try to run extras and host-tests on self-hosted(mac-mini) and GH-ubuntu-latest runners (#4052) 2025-09-08 10:08:47 +00:00
Björn Quentin
27c89c3adc
Fix wifi event names (#4065)
* Fix wifi event names

* CHANGELOG.md

---------

Co-authored-by: Juraj Sadel <juraj.sadel@espressif.com>
2025-09-08 07:09:04 +00:00
Fun Maker
bea71a1884
Bump embassy-embedded-hal version to 0.5.0 in esp-hal deps (#4075) 2025-09-07 14:50:27 +00:00
Juraj Sadel
15096b2d89
fix nightly ci (#4074) 2025-09-07 12:56:56 +00:00
Alexei Pastuchov
6aaf12a08d
examples/README.md: clarify xtask subcommand usage and arguments (#4067)
- 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>
2025-09-06 10:01:15 +00:00
Björn Quentin
7248d3d7d2
Make BLE work on ESP32-C2 with 26 MHz Xtal (#4062)
* Make BLE work on ESP32-C2 with 26 MHz Xtal

* CHANGELOG.md
2025-09-05 17:04:39 +00:00
Dániel Buga
445f6fc1ad
Add task priority to the preempt driver (#4064) 2025-09-05 16:30:16 +00:00
Dániel Buga
b9dd86258a
Add a function to retrieve a semaphore's counter value (#4066) 2025-09-05 15:37:41 +00:00
Dániel Buga
6dd0edd492
Teeny-tiny scheduler improvements (#4061)
* Avoid swapping to the same task

* Allow scheduling multiple tasks to be deleted

* Add task state
2025-09-05 15:01:17 +00:00
Dániel Buga
24d2122c14
Remove ConcurrentQueue & other minor tweaks (#4058)
* Remove ConcurrentQueue

* Unrequire preempt driver for 802.15.4
2025-09-05 14:59:08 +00:00
Björn Quentin
105c163306
Remove pointless functions (#4060)
* Remove pointless functions

* CHANGELOG
2025-09-05 14:10:43 +00:00
Dániel Buga
91e0cea412
Update embassy, embedded-test (#3945) 2025-09-05 13:51:26 +00:00
Jesse Braham
67e0b65ee4
Add a note regarding running on the second core to esp-radio documentation (#4037) 2025-09-05 11:59:13 +00:00
Jesse Braham
9be325cf83
Remove migration guides for old package versions (#4048) 2025-09-05 11:10:22 +00:00
Dániel Buga
74af7642c1
Merge some test suites (#4059) 2025-09-05 11:06:19 +00:00
Dániel Buga
61ad37dd8e
Add timers to preempt (#4053)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-09-05 09:37:16 +00:00
Dániel Buga
68a16055fc
Fix 802.15.4 (#4056) 2025-09-05 09:29:43 +00:00
Dániel Buga
2a06d38141
Only run the selected example, not all of them (#4057) 2025-09-05 09:04:04 +00:00
Dániel Buga
a84d3cc89f
Make timekeeping the driver's job (#4047) 2025-09-05 07:31:40 +00:00
Dominic Fischer
a5f929a663
ESP32-S3: Add RtcI2c driver (#4016)
* ESP32-S3: Add RtcI2c driver

* limit cfg

* un-hide traits

* fix macro and doc

* Document driver

* fix doc

* Add HIL test

* use builder lite for timings

* no-const

* review comments
2025-09-04 20:58:33 +00:00
Dániel Buga
5e13146842
Route logs to stdout (#4054) 2025-09-04 17:41:04 +00:00
Dániel Buga
cf2b162517
Add queues to esp-preempt (#4043) 2025-09-04 15:26:51 +00:00
Kirill Mikhailov
38fd991ff7
More cleanup in esp-radio (#4040)
* More cleanup in `esp-radio`

* misc

* address reviews

* docs update

* fmt
2025-09-04 14:03:19 +00:00
Dániel Buga
d9f6d7d73e
Fix endgroup syntax (#4051) 2025-09-04 13:13:02 +00:00
Dániel Buga
1c4db2f339
Fix failing ESP32 test case (#4036)
* Remove unnecessary allow

* Don't assume timing in HIL test
2025-09-04 12:21:03 +00:00
Juraj Sadel
34b908dc56
Remove wifi_state and split WifiState into WifiStaState and WifiApState (#4046)
* Remove wifi_state adn split WifiState into WifiStaState and WifiApState

* MG

* changelog

* review
2025-09-04 11:28:00 +00:00
Dániel Buga
227ad1fced
Fix example selection (#4045) 2025-09-04 11:22:08 +00:00
Dániel Buga
7305bc08dc
Add wifi init test case, fix logic bug in wifi::new (#4050) 2025-09-04 11:10:40 +00:00
Fun Maker
46eed04403
Add Config structure for I2s (#3985)
* Add Config structure for I2s

* Add apply_config for I2sTx/I2sRx
2025-09-04 10:16:49 +00:00
Dániel Buga
2e958d2bb7
Move mutexes to esp-preempt (#4041) 2025-09-04 07:38:43 +00:00
Dániel Buga
cc91bb1c9e
Move semaphore implementation to esp-preempt (#4038) 2025-09-03 14:21:47 +00:00
Benedikt
a13def7df6
RMT: Type-erase channels (#3980)
* 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
2025-09-03 12:15:51 +00:00