Commit Graph

183 Commits

Author SHA1 Message Date
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
Dániel Buga
5de267ab09
Fix known SPI issues (#2179)
* Re-enable tests

* Clean up

* Pass two lengths to configure_datalen

* Add Dominic's test changes

* Ensure DMA buffers are properly aligned

* Impl Format on DmaDescriptor

* Fix waiting for transaction to complete

* Fix DMA transfers

* Changelog

* Avoid explicit panic in test case

* Remove redundant test case

* Reintroduce wait for ESP32
2024-09-19 18:00:50 +00:00
Dániel Buga
25eff6a255
Enable I2S tests on ESP32 and work around first sample issue (#2194)
* Enable I2S tests on ESP32 and work around first sample issue

* Fix sample->channel assignment inconsistency

* Add to changelog
2024-09-19 15:13:25 +00:00
Dániel Buga
46be3b19b5
Some minor I2S cleanups (#2190)
* Clean up rx_start

* Improve readability of register manipulation

* Enable failing tests on ESP32

* Improve consistency

* Merge tests

* Disable ESP32 for now

* Clean up some cfgs

* Avoid as pointer-casts

* Inline wait_for_dma_done

* Remove a level of indirection

* Fix typos

* Resolve questionmarks
2024-09-19 07:33:52 +00:00
Dániel Buga
b1ca30e404
Disable problematic ESP32 test (#2185) 2024-09-18 13:58:54 +00:00
Dániel Buga
d9532bbba7
Fix and enable I2S tests on ESP32-S2 (#2181)
* Fix PDMA channels, use peripheral signal instead of external connection

* Fix i2s test setup for esp32s2
2024-09-18 09:43:37 +00:00
Dániel Buga
344ee133bc
Move SPI tests into the same file (#2177)
* Implement Peripheral for Level

* Move SPI tests into the same file

* Fix test on H2

* Also fix C6 signal numbers
2024-09-18 07:08:51 +00:00
Dominic Fischer
9de459c663
Add more thorough I8080 HIL tests (#2173)
* Add I8080 HIL test

* add fixme comment

* fmt

---------

Co-authored-by: Dominic Fischer <git@dominicfischer.me>
2024-09-17 12:01:27 +00:00
Dániel Buga
65396dda1f
Fix UART when using RcFast clock source (#2170)
* Refactor test_send_receive_different_baud_rates_and_clock_sources

* Don't rely on external connections for UART test

* Enable (failing) RcFast for C2/C3

* Make sure fast clock is enabled
2024-09-16 20:48:25 +00:00
Dániel Buga
2971c08ed4
Fix double writes (#2159)
* Fix double writes

* Only flush if we need to read
2024-09-16 11:22:14 +00:00
Dániel Buga
2a74addee0
Fix DMA starving SPI (#2152)
* Fix DMA starving SPI

* Simplify cfgs

* Trigger an update before starting transaction

* Do not update after enable_dma, use start_operation
2024-09-13 08:51:31 +00:00