343 Commits

Author SHA1 Message Date
Dániel Buga
d5e6ba5ceb
SPI slave with_pin functions (#2485) 2024-11-08 07:29:37 +00:00
Dániel Buga
4233bddf23
Fix test warnings (#2483) 2024-11-07 15:05:49 +00:00
Dániel Buga
0da6eec089
Move I2S drivers to i2s::master and i2s::parallel (#2472)
* Move I2S drivers to i2s::master and i2s::parallel

* Remove mention of master mode
2024-11-07 09:39:08 +00:00
Dániel Buga
4c5be2c907
Interconnect: force signals through GPIO matrix if split (#2419)
* Allow splitting off of gpio drivers

* Extract and correct low level connection bits

* Add Input/OutputSignal::connect_to

* Remove unnecessary public API

* Fix typos

* Remove unused private methods

* Add separate Direct signals that do bypass the GPIO matrix

* Do not disable stage input

* Clean up spi_slave test

* Constrain to static Flex

* Improve docs

* Separate input_enable and open_drain parameters

* Link to the chapter

* Changelog

* Clarify
2024-11-06 13:55:34 +00:00
Dániel Buga
8860aba9b2
Spi master: remove public hidden APIs, add Config/apply_config (#2448)
* Remove hidden public SPI API

* Fix in_progress flags not being set

* Remove redundant checks, fix full-duplex flag

* Remove now-redundant Send impl

* apply_config

* SetConfig

* Return ConfigError

* Unwrap config result in ctor
2024-11-06 09:03:43 +00:00
Dániel Buga
665fb0e278
Flatten Uart module, remove unnecessary data, replace methods with apply_config (#2449)
* Flatten uart config

* Do not remember at_command config

* Don't save config values in memory

* Move config implementations to Info

* Changelog

* Remove unused methods

* apply_config, SetConfig

* Fix test

* simplify futures

* Update esp-hal/CHANGELOG.md

Co-authored-by: Sergio Gasquez Arcos <sergio.gasquez@gmail.com>

---------

Co-authored-by: Sergio Gasquez Arcos <sergio.gasquez@gmail.com>
2024-11-05 09:56:14 +00:00
Dániel Buga
1e6820d1a7
Systimer improvements (#2451)
* Do not read to set update bit

* Deduplicate

* Try to bind interrupts to the correct core

* Inline poll_count into read_count

* Clean up

* Make sure only a single update is done at a time

* Changelog

* Fix docs

* Correct the channel count

* Assign enough timers for HIL test

* Use a lock to prevent re-update

* Remove locking, use esp-idf implementation

* Document timer count requirement
2024-11-04 11:36:34 +00:00
Dániel Buga
0c86740418
Peripheral interconnect redo, vol 2 (split()) (#2418)
* Replace peripheral connection conversions with split

* Constrain Flex conversions
2024-11-04 11:29:28 +00:00
Dániel Buga
40c0a6944e
into_async (#2430)
* Remove configure_for_async

* Add into_async and into_blocking to I2c

* Add into_async and into_blocking to UsbSerialJtag

* Rework LCD_CAM

* Rmt

* RSA

* TWAI

* Uart

* Documentation

* Disable interrupts set on other core

* Move configure into RegisterAccess

* Disable interrupts on the other core

* Use EnumSet in RMT
2024-11-04 09:32:12 +00:00
Scott Mabin
c717f04d4d
Remove EspWifiInitFor & more granular init/deinit per driver (#2301)
* More granular init and deinit per driver

- Rework EspWifiInit
- No longer require EspWifiInitFor
- Add Drop impls for each driver, and add Drop for EspWifiController to
  fully deinit the stack

* unwrap! more stuff

* fixup examples and esp-now

* unwrap less stuff

* review feedback

* seal wifi traits, allow rng or trng to init esp-wifi

* changelog and migration guide

* return wifi error in esp now constructor instead of panic
2024-11-04 08:08:19 +00:00
Dániel Buga
f9c7d06a6e
Disable i2s test (#2439) 2024-10-31 14:16:39 +00:00
Björn Quentin
416c1481ae
Circular dma improvements (#2409)
* Check for error when pushing into a circular dma transaction too late

* Adapt tests

* Adapt example

* Don't block forever if trxing to pop from a circular DMA transfer too late

* Have a dedicated error for circular-DMA reading/writing too late

* Stop I2S RX before resetting it

* Migration guide

* Address review comment, make CI pass

* Adopt ideas from review

* Fix

* Update esp-hal/MIGRATING-0.21.md

Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>

* assert

---------

Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>
2024-10-30 16:25:29 +00:00
Dániel Buga
f07e25c970
Add option to disable waiti (#2329) 2024-10-30 08:12:15 +00:00
Dániel Buga
681f4ef0aa
Implement UART type erasure (#2381)
* Simplify test

* Remove unnecessary refs

* Improve readability

* Require Instance: PeripheralMarker

* Take &self

* Avoid unsafe code on non-s2

* SImplify drain_fifo

* Simplify read_bytes

* Avoid a register read on ESP32

* Deduplicate is_idle functions

* Add missing inlines

* Move code out of trait

* Erase UART instances

* Disable LTO
2024-10-25 08:03:20 +00:00
Dániel Buga
561b582a80
Overhaul peripheral signal system, first run (#2388)
* Remove redundant bound

* Remove redundant Dummy variant

* Make PeripheralOutput extend PeripehralInput

* Rename AnyInputSignal to InputConnection

* Add OutputConnection

* Convert into type-erased interconnect conections

* Clean up LCD/CAM

* Document changes

* Review changes

Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>

* Clean up

---------

Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>
2024-10-25 07:01:45 +00:00
Dániel Buga
2ac47868f7
Remove FullDuplexMode and HalfDuplexMode type params (#2373)
* Remove duplex type param

* Rename dma_ functions
2024-10-24 07:22:21 +00:00
Dániel Buga
c163b0586a
Erase TWAI (#2359)
* Swap order of generics

* Don't refer to Instance in irq handler

* Deduplicate a bit

* Take &self

* Reduce nesting

* Erase TWAI instance
2024-10-24 06:47:02 +00:00
Dániel Buga
e367c83bde
Erase i2c peripheral instances (#2361)
* Clean up

* Erase I2C instance type

* Clean up

* Implement Peripheral

* Changelog

* Remove with_timeout constructors
2024-10-23 06:31:08 +00:00
Dániel Buga
632bbc6461
Fix interrupt executors waking up thread-mode executors on the first core (#2377)
* Clean up

* Add failing multi-core test

* Reset interrupts before main

* Changelog

* Add test case
2024-10-22 14:45:06 +00:00
Björn Quentin
c574834ae3
Include ROM API symbols (#2374)
* Include ROM API symbols

* Fixes and CHANGELOG.md

* Fix

* Move migration steps to the right crate's migration guide

* Remove `-Trom_functions.x` where necessary
2024-10-22 10:02:49 +00:00
Dániel Buga
d914a0301f
Erase i2s (#2367)
* Implement I2S type erasure

* Clean up
2024-10-22 06:33:27 +00:00
Dániel Buga
a754e411b1
SPI type erasure (#2334)
* Move SPI peripheral type to the last position

* Implement AnySpi

* Convert peripheral types

* Add new_typed constructors

* Implement PDMA

* Fix conditional

* Clean up constructors

* Fix test

* Move stuff to utils

* Extract any macros

* Merge PeripheralMarker defs into peripherals macro

* Changelogs

* Implement fn degrade

* Changelog num

* Fix typo

* Rename type-erased dma channel

* Remove degrade fn

* Remove utils

* Explain peripherals macro
2024-10-21 14:03:14 +00:00
Dániel Buga
f2aa3f9863
Update embedded-test (#2375) 2024-10-21 09:35:15 +00:00
Dániel Buga
d32a7336bb
Simplify traits and erratum 36 workaround, add Pins::steal (#2335)
* Simplify erratum 36

* Add Pins::steal

* Fix typo

* Move pin operations into Flex

* Cleanup braces

* Avoid panicking when handling erratum

* Add disable_usb_pad to other devices

* Touch up changelog

* Fix changelog
2024-10-18 14:17:43 +00:00
Dániel Buga
99a579973a
Preparatory i2s refactor (#2316)
* Take self

* Consolidate signal impls

* Remove traits

* Deduplicate impls

* Seal AcceptedWord

* Changelog

* Migration guide

---------

Co-authored-by: Jesse Braham <jessebraham@users.noreply.github.com>
2024-10-16 13:04:00 +00:00
Dániel Buga
ef7842fab4
Reimplement blocking trait for async i2c (#2343) 2024-10-14 12:50:37 +00:00
Dániel Buga
ba8daafb0b
Require float-save-restore in esp-wifi (#2322)
* Add failing test case

* Make sure task contexts are properly initialised

* Require float-save-restore for esp-wifi
2024-10-10 08:24:50 +00:00
Scott Mabin
0142703112
I2c rename, small docs clean up (#2320)
* cleanup prelude docs

* fixups and i2c rename

* changelog and migration

* fixup docs and examples

* fix lint
2024-10-10 07:26:13 +00:00
Dániel Buga
c26600f943
Fix first UART print (#2318)
* Fix first UART print

* Add test case

* Explicitly set level to cause problems
2024-10-09 15:16:56 +00:00
Dániel Buga
be9dc0e0b7
Fix restoring of CPENABLE (#2315)
* Add tests Cp0Disabled issue

* Fix saving CPENABLE on context switch

* Fix position shift of registers

* Clean up
2024-10-09 10:33:31 +00:00
Dániel Buga
7ca1b4376f
Erase DMA type params (#2261)
* Split PdmaChannel into two

* Take &self in PDMA traits

* Implement type-erased PDMA channels

* Remove Degraded assoc type

* Move degrade fns to base trait

* Use PeripheralDmaChannel on constructors only

* Remove WithDmaAes use

* Erase DMA type params

* Clean up examples/tests

* Remove redundant trait bounds

* Remove peripheral-specific DMA traits

* Document i2s change

* Clean up parl_io

* Deduplicate InterruptAccess

* Fix cfg

* Implement runtime compatibility check

* Clean up a bit

* Document changes

* Swap Channel type params, erase dma channel

* Unsplit traits

* Remove redundant cfg

* Fix docs

* Simplify DmaEligible

* Remove unsafe code

* Revert "Swap Channel type params, erase dma channel"

This reverts commit 415e45e44b297fd3cb55b4261c9ce151cca4b9c9.

* Allow different degraded DMA types

* Allow converting into peripheral-specific DMA channel, use it for compat check

* Erase PDMA types without AnyPdmaChannel

* Hide degrade fns for now, remove from MG

* Clean up SPI slave

* Fix QSPI test

* Fix mem2mem, fix S3 peripherals

* Fix S2

* Remove AnyPdmaChannel

* Remove PeripheralDmaChannel

* Remove unnecessary degrade call
2024-10-08 14:09:27 +00:00
Scott Mabin
08030d5541
bump all semver compatible deps (#2303) 2024-10-08 12:56:30 +00:00
Dániel Buga
af3f892381
ESP32 spi slave mode (#2278)
* Enable test on ESP32

* Enable module on ESP32

* Add ESP32 signal map

* Change pins

* Remove unknown signals

* Return to low level in test

* Fix bitlength

* Merge enable and reset

* Impl debug traits on DMA flags

* Disallow mods 0 and 2

* Docs tweaks

* Changelog

* Undo wait change
2024-10-07 15:00:15 +00:00
Dániel Buga
3e16c5c623
Avoid moving inside SpiDmaBus, abort dropped transfers (#2216)
* Drop State from DMA

* Simplify Error paths

* Cancel dropped transfers, fix and test

* Fix C6

* Avoid cancelling a completed transaction

* Do not implement DmaTxRxBuf for references

* Remove unnecessary import

* Merge BufferRef structs

* Move wait impl to the peripheral

* Allow the current byte to complete

* Restore SpiDmaTransfer::is_done

* Explain cancel code

* Fix test formatting

* Changelog

* Simplify implementation

* Make sure everything gets dropped

* Remove unnecessary PhantomData

* Remove OptionalFuture

* Adjust test to a more realistic clock frequency
2024-10-07 10:04:50 +00:00
Dániel Buga
efe58e94a2
I2C: clean up and remove stop condition from the middle of write_read (#2276)
* Remove I2COperation

* Clean up peripheral reset/enable

* Remove match on peripheral number

* Remove seemingly duplicate register write

* Clippy

* Restore compatibility with slices, publish async transaction

* Maybe with a stop between?

* Add missing inlines

* Read from the correct address

* write_read: don't generate stop after write
2024-10-07 07:29:23 +00:00
Dániel Buga
5a993fed38
Fix Rx/Tx order in SPI slave driver (#2272)
* Add basic test and fix SPI slave dma_transfer arg order

* Reset peripheral

* Add safe way to read signal value
2024-10-04 06:56:34 +00:00
Dániel Buga
c7a2368845
Print test panics using semihosting (#2257)
* Print panic messages using semihosting

* Don't use defmt's asserts

* Make RA_OFFSET available without panic-handler

* Re-add defmt imports where missing

* Revert unintended test change

* Initialise hal in critical-section test

* Disable defmt in tests by default
2024-10-04 06:31:39 +00:00
Dominic Fischer
8789ca3c3d
Migrate I8080 driver to a move based API (#2191)
* Migrate I8080 driver to a move based API

* fmt

* comments

---------

Co-authored-by: Dominic Fischer <git@dominicfischer.me>
2024-10-02 13:23:10 +00:00
Björn Quentin
a3304c6cff
Fix eh0.2 set_high/set_low (#2265) 2024-10-02 12:45:11 +00:00
Dániel Buga
c481c49888
Fix incorrect QSPI setup (#2231)
* Fix QSPI mode on non-ESP32

* Update tests to count pulses on pins separately

* Fix ESP32 addressing phase issue

* Use defmt's assert

* Set fastrd bit

* Apply pulldowns to define signal level when not driven

* Transfer address bits in data phase on ESP32

* Changelog

* Use a separate buffer for the address, make the workaround configurable

* Remove now-unnecessary additions

* Force SpiDma to remain Send

* Clarify wording, remove prefix

* Clean up manual register manipulation

* Fix byte order
2024-09-26 15:28:18 +00:00
Dániel Buga
5076d1ee8f
DMA macro cleanup (#2226)
* Fix typo

* Deduplicate dma macro implementations

* Remove accidental defmt

* Extract count macro, use const block
2024-09-25 07:16:48 +00:00
Dániel Buga
04f43d28c3
Prevent reentry on single-core, add basic tests (#2209) 2024-09-24 20:17:27 +00:00
liebman
cf9050d5d7
Support PSRAM in DmaTxBuf (#2161)
* support psram in DmaTxBuf

* add example that sometimes works :-(

* fmt

* cleanups

* allow chunk_size upto (including) 4095

* this test is passing for me now

* remove chunk_size and compute based on block_size

* return error in `prepare_transfer` if psram is found on non-esp32s3
add `dma_tx_buffer` macro

* missing parens

* changelog

* default 4092 for esp32 & fmt

* no errors anymode

* use block_size is_some to flag invalid psram in prepare_transfer

* drop block_size from macro, the buffer allocation was not being aligned - its not needed for dram anyway.

* missed macro example

* use defmt::Format that decodes owner like Debug

* fix typo

* DmaTxBuf: its an error if buffer is in psram and block_size is none

* DmaTxBuf: its an error if buffer is in psram and block_size is none

* update for PSRAM feature changes

* address alignment comments
add simple test

* fmt

* better alignment test

* revert alignment test

---------

Co-authored-by: Juraj Sadel <juraj.sadel@espressif.com>
2024-09-24 15:21:58 +00:00
Jesse Braham
4534ee13ae
Implement embedded_hal_async::delay::DelayNs for TIMGx timers (#2084)
* Update `hil-test` package dependencies, add simple test for async delay with `SYSTIMER`

* Implement `embedded_hal_async::delay::DelayNs` for the `TIMGx` timers

* Improve tests slightly

* Update `CHANGELOG.md`

* Enable `delay` and `delay_async` tests for the ESP32-H2

* Fix error in `delay_async` test after rebasing

* ESP32 does not have `SYSTIMER`, so don't try to test it :)

* Protect int_ena modifications with INT_ENA_LOCK, clear int_clr in ISRs, move interrupt binds from Future constructor into new_async constructor

* Fix wrong imports

* Address reviews: Remove duplicated/useless code and add HIL test for delay_us and delay_ms

* Implement DelayNs on Target instead of Periodic

* clean dead code

* fix after rebase

* fix build errors

* More accurate nanos to ticks calculation

* Fix wrong handler passed to set_interrupt_handler()

* Update esp-hal/src/timer/timg.rs

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

* cleanup left over

---------

Co-authored-by: Juraj Sadel <juraj.sadel@espressif.com>
Co-authored-by: Juraj Sadel <jurajsadel@gmail.com>
Co-authored-by: Dániel Buga <bugadani@gmail.com>
2024-09-24 08:50:06 +00:00
Dániel Buga
02d221ee52
Fix TWAI on ESP32 (#2207)
* Some more gpio cleanup

* Allow TWAI loopback using the same pin, enable ESP32

* Impl Format for ErrorKind

* Generic frame constructors

* More TWAI cleanups

* Fix signals

* Set self-reception bit

* Teach users to use const blocks

* Fix resetting TWAI

* Set opmode when starting

* Apply errata workaround

* Fix ESP32 baudrate

* Clean up read_frame a bit

* Changelog

* Clean up clippy

* Fix compile errors

---------

Co-authored-by: Jesse Braham <jessebraham@users.noreply.github.com>
2024-09-23 15:24:27 +00:00
liebman
987f00bb1d
PARL_IO: fix for garbage output at the start of some TX operations (#2211)
* per TRM the TX clock should only be re-enabled after tx_start

* CHANGELOG

* added tests to check the for the correct number of clocks during valid

* parl_io: fix test for esp32h2

* tests: parl_io: h2 PCNT does not like 20MHz
2024-09-23 10:27:43 +00:00
Dániel Buga
89d9de67eb
Enable QSPI tests on ESP32 and clean up (#2198)
* Clean up qspi test cfgs, enable on ESP32

* Correct comments

* Clean up init_spi_data_mode

* Fix qspi_write on ESP32

* Further cleanup in SPI driver

* Clean up qspi_read

* Fix qspi_write_read test on ESP32

* Merge QSPI tests

* Clean up test

* Attempt to fix test GPIO assingment

* Update esp-hal/src/spi/master.rs

Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>

* Update esp-hal/src/spi/master.rs

* Make sure pins have no internal pullups

---------

Co-authored-by: Dominic Fischer <14130965+Dominaezzz@users.noreply.github.com>
2024-09-23 08:37:35 +00:00
Dániel Buga
d4e463b3ff
Slight general cleanup, enable dma-macros test, allow using virtual mem2mem channel on c2 (#2200)
* Cfg features, not devices

* Remove InterruptBinder

* Clean up allow(declare_interior_mutable_const)

* Small embassy cleanup

* Enable dma-macros for 32 and S2

* Use MEM2MEM1 on C2

* Remove esp32-specific code from test
2024-09-20 15:04:18 +00:00
Sergio Gasquez Arcos
3d0a1998fa
Allow configuring the watchdogs in the init config (#2180)
* feat: Allow configuring the watchdogs in the init config

* docs: Update changelog

* refactor: Remove unnecesary unsafe

* feat: Add a config module

* test: Add some init tests

* style: Rename all ocurrences to esp_hal::config::Config::default()

* style: Fix format

* fix: Doc errors

* revert: Move Config struct to lib.rs

* tests: Add default config test

* test: Add a test with CpuClock::max()

* test: Add timg1 test

* feat: Move Config struct to config module and reexport it in lib.rs

* fix: Fix init compilation for C2

* revert: Move Config struct to config module and reexport it in lib.rs

* fix: Use proper timergroup
2024-09-20 13:51:35 +00:00
Dániel Buga
d5afeeddc8
H2: enable TWAI, enable delay test (#2199)
* Add TWAI support for H2

* Enable delay test on h2

* Also enable example

* Changelog

* De-CAN the example
2024-09-20 07:04:52 +00:00