Commit Graph

792 Commits

Author SHA1 Message Date
Sergio Gasquez Arcos
38ebf13bc9
Initial support for smartled in ESP32-H2 (#589)
* feat:  Add hello_rgb example

* feat:  Initial support for RMT

* fix: 🐛 Adjust frequency for H2

* docs: 📝 Update changelog

* build: 📌 Update H2 pacs
2023-06-14 01:52:23 -07:00
Björn Quentin
907fc1fc0f
Merge pull request #586 from teotwaki/fix-forgotten-feature
[Minor][ESP32] Update xtal feature check in build.rs
2023-06-14 09:39:38 +02:00
Sebastian Lauwers
8ec8855e26 Update xtal feature check in build.rs 2023-06-13 15:09:48 +02:00
Jesse Braham
fbe4ed1336
Add initial implementation of radio clocks for ESP32-H2 (#577)
* Add initial implementation of radio clocks for ESP32-H2

* Update CHANGELOG
2023-06-09 12:11:36 +00:00
Scott Mabin
8361ca308c
Move esp-riscv-rt into esp-hal (#578)
* Move esp-riscv-rt into esp-hal

* Add changelog entry
2023-06-07 08:15:47 -07:00
Juraj Sadel
aef0ff4e45
H2: Add timer_interrupt example (#576)
* H2: Use PLL_48M_CLK in Timg driver and add 	imer_interrupt example

* Clean timer driver, add helper configure_src_clk and configure_wdt_src_clk methods

* H2: Add 	imer_interrupt example

* add helper methods for selecting default clk src

* Change PR number in the Changelog
2023-06-06 07:18:20 -07:00
Kayo Phoenix
c6bdf8b8c0
Unified efuse field access (#567)
* Add efuse field tables from IDF

* Add efuse fields constants generator

* Fix MAC field in efuse tables

* Add common efuse field impl

* Add efuse fields support for chips

* Add efuse changes to changelog
2023-06-05 06:15:00 -07:00
Scott Mabin
34740c7f1c
Async GPIO multibank fix (#572)
* Async GPIO multibank fix

- Removes dead code from the default impl of the BankAccess trait
- Adds one new function to the async module to control the interrupt
  enable for any pin

* Add changelog entry
2023-06-01 07:35:52 -07:00
bjoernQ
3dabd57a1d Fix ESP32-H2 direct-boot 2023-05-31 08:39:39 -07:00
Jesse Braham
e096bca561
Add embassy_serial and embassy_wait examples for ESP32-H2 (#569)
* Add `embassy_{serial,wait}` examples for ESP32-H2

* Update the CHANGELOG
2023-05-31 07:17:39 -07:00
Jesse Braham
67e9c60a23
Simplify the Delay driver, derive Clone and Copy (#568)
* Simplify the `Delay` driver, derive `Clone` and `Copy`

The RISC-V and Xtensa implementations of the delay functionality are both safe to access from multiple contexts, and the `Delay` struct does not take ownership of any peripheral struct, so `Delay` is safe to clone/copy

* Update the CHANGELOG
2023-05-31 06:45:53 -07:00
Juraj Sadel
b1630db5d2
H2: Add initial ADC support with example (#565)
* H2: Add initial ADC support with example

* Add changelog
2023-05-31 06:03:27 -07:00
Jesse Braham
d86300f799
Add all SPI examples for the ESP32-H2 (#549)
* Update the `GDMA` driver to support the ESP32-H2

* Update the `SPI` driver to support the ESP32-H2

* Add `SPI` examples for ESP32-H2

* Update CHANGELOG

* Remove copy-pasted references to ESP32-C6

* Update GPIO pins used in SPI examples, add `qspi_flash` example

* Update SPI clock configuration to produce correct clock rate

* Correct comment regarding clock source frequency

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

* H2: Add PLL_48M_CLK src to ClockControl and RawClocks

* H2: Use PLL_48M_CLK as SPI clk src

* H2: cleanup commented block in SPI driver

* H2: update docs comment in embassy_spi example

* fmt

* Add a new line in embassy_spi example

---------

Co-authored-by: Sergio Gasquez Arcos <sergio.gasquez@gmail.com>
Co-authored-by: Juraj Sadel <juraj.sadel@espressif.com>
2023-05-31 09:49:13 +02:00
Sergio Gasquez Arcos
faf60b6d95
Initial support for ASSIST_DEBUG in ESP32-H2 (#566)
* feat:  Add debug_assist example

* feat:  Enable peripherals

* docs: 📝 Add RAM comments

* feat: ️ Update debug_assist example

* docs: 📝 Update changelog

* build: 📌 Update esp-pacs rev for h2

* style: 🎨 Move assist_debug_region* and assist_debug_sp* to peripherals defined by developers
2023-05-30 09:10:55 -07:00
Juraj Sadel
a82c9dbc45 H2: Add initial LEDC support with example 2023-05-29 07:11:44 -07:00
sethp
171e66e87a
feat(riscv): relocate .trap machinery to RAM (#541)
* feat: relocate riscv isr to iram

Previously, the trap vector itself and its immediate callees
(`_start_trap` and `_start_trap_rust_hal`) were located in the mapped
instruction flash range `0x420..`, increasing cache pressure and adding
variable latency to the very beginning of the interrupt/exception
service flow.

This change places those routines in iram directly:

```
   Num:    Value  Size Type    Bind   Vis      Ndx Name
 48177: 40380280  2428 FUNC    GLOBAL DEFAULT    6 _start_trap_rust_hal
 48197: 40380bfc    54 FUNC    GLOBAL DEFAULT    6 _start_trap_rust
 48265: 40380200     0 FUNC    GLOBAL DEFAULT    6 _vector_table
 48349: 40380100     0 NOTYPE  GLOBAL DEFAULT    6 default_start_trap
 48350: 40380100     0 NOTYPE  GLOBAL DEFAULT    6 _start_trap
```

As seen via `readelf -W -s -C ./target/riscv32imc-unknown-none-elf/debug/examples/gpio_interrupt | grep -E _start_trap\|_vector\|Ndx`

* feat(riscv): place .trap in RAM

This change follows through on relocating the `_vector_table`,
`_start_trap`, and `_start_trap_rust` functions for all present
build/link modes for the 'c2, 'c3, 'c6, and 'h2.

It has been tested by running the `software_interrupts` example for the
'c3 in direct-boot and esp-bootloader contexts, but I wasn't able to
identify how to run the `mcu-boot` mode for the 'c3, nor do I have
present access to any of the other devices for testing.

* docs: Update CHANGELOG.md
2023-05-26 20:48:49 +01:00
Dániel Buga
df76905408 Fix C3 ADC2 channel assignment 2023-05-26 10:38:57 -07:00
Jesse Braham
748512f849
Add interrupt-related examples for the ESP32-H2 (#557)
* Add interrupt-related examples for the ESP32-H2

* Update CI workflow to actually check `interrupt_preemption` examples
2023-05-25 09:22:26 -07:00
Jesse Braham
a92c46f309 Correct a number of comments in various examples 2023-05-25 06:02:15 -07:00
Björn Quentin
278ce406b6
Merge pull request #559 from BryanKadzban/add-dma-poll
Add a fn to poll a DMA transfer
2023-05-25 09:57:55 +02:00
Bryan Kadzban
a6835d9cec Add examples for polling DMA transfers.
Only in the SPI case, but the I2S case has the same API so this should
be fine.
2023-05-25 06:37:09 +00:00
Bryan Kadzban
8baf4df20b Add an is_done() poll method to DMA transfers
Implement it by forwarding to the DMA channel's existing is_done mehod.
Add the implementation to both SPI and I2S DMA transfer structs.
2023-05-25 04:48:21 +00:00
Sergio Gasquez Arcos
14ac8c3c80
Initial support for RMT in ESP32-H2 (#556)
* feat:  Enable RMT peripheral

* feat:  Rename RMT GPIOs

* feat:  Add clock source, ram size and ram start

* feat:  Rename GPIOs

* feat:  Add pulse_control example

* fix: 🐛 Fix example clock

* feat:  Initial support for H2

* fix: 📝 Fix typo

* ci:  Enable check on H2

* build: 📌 Update esp-pac revision, use fork

* docs: 📝 Update example documentation

* docs: 📝 Add todo

* docs: 📝 Update changelog

* feat:  Add ram example

* build: 📌 Update H2 PAC

* docs: 📝 Remove todo
2023-05-23 10:14:17 -07:00
Björn Quentin
7b3e19c4c6
Fix half-duplex SPI read (#552)
* Fix half-duplex SPI read

* Update CHANGELOG.md
2023-05-22 14:02:33 +02:00
Dániel Buga
02c7e38cf5
Remove a bunch of generic params from GpioPin (#553) 2023-05-22 12:27:36 +01:00
Dániel Buga
caec716c35
Set ADC attenuation for the correct ADC instance (#554)
* Set ADC attenuation for the correct ADC instance

* Add to changelog
2023-05-22 12:41:07 +02:00
Sergio Gasquez Arcos
2c2bb25262
Initial support for PCNT in ESP32-H2 (#551)
* feat:  Enable PCNT peripheral

* feat:  Rename PCNT GPIOs

* feat:  Add pcnt_encoder example

* build: ⬆️ Update esp-pacs revision

* docs: 📝 Update changelog
2023-05-19 09:27:11 +02:00
Jesse Braham
661a9de5eb
Add some miscellaneous examples for the ESP32-H2 (#548)
* Add some miscellaneous examples for the ESP32-H2

* Update the CHANGELOG
2023-05-17 07:13:47 -07:00
Björn Quentin
3be64df304
Merge pull request #546 from bjoernQ/esp32s3-move-psram-functions-to-ram
ESP32-S3: Move PSRAM functions to RAM
2023-05-17 15:37:03 +02:00
bjoernQ
b931e27d8e Update CHANGELOG.md 2023-05-17 12:38:14 +02:00
bjoernQ
fc25c84578 ESP32-S3: Move PSRAM functions to RAM 2023-05-17 12:35:59 +02:00
Scott Mabin
ffe167e64c Update changelog 2023-05-16 10:23:58 -07:00
Sergio Gasquez Arcos
a7e4400fb5
Initial support for MCPWM in ESP32-H2 (#544)
* feat:  Enable mcpwm peripheral

* feat:  Initial support MCPWM

* fix: 🐛 Select the rigth clock

* fix: 🐛 Select the XTAL clock

* docs: 📝 Update changelog
2023-05-16 09:00:11 -07:00
Scott Mabin
45f855abf5
Support for multicore async GPIO: (#542)
* Support for multicore async GPIO:

Use the correct registers depending on which core the interrupt is being
serviced on. Fixed a bug in the `esp32::gpio_intr` which would enable
the interrupt on both cores. It now enables the interrupt for the core
in which `listen()` is called.

* add changelog item

* Simplify GPIO interrupt status
2023-05-16 15:46:36 +01:00
Björn Quentin
d0a5e95f8c
Merge pull request #475 from BryanKadzban/add-hw-fade
Add LEDC duty-cycle fading support
2023-05-16 08:25:51 +02:00
Bryan Kadzban
01d4b8686a Add duty-cycle fading support
For now, only the -c3.

---

Open up LEDC fade support to all chips.

The C6 chip needs some special handling because its fade registers also
handle gamma, and the ESP chip needs some special handling because it
has two banks of channels.  The code to handle these is already present
in channel.rs, but needs to be copied and adapted.  Do that, and drop
all the esp32c3 feature checks.

---

Add a function to poll the duty-fade state

Use the unmasked interrupt bit in the LEDC register block, since that
will get updated by the hardware whether or not we've connected anything
to the interrupt source.  Also be sure to clear that bit before starting
a new fade, so it's always clear while fading.

This will allow dumb (non-async-code) polling of the fade state after
one is started by the start_duty_fade API.

---

Fix non-C3 devices to use the right int_raw bits

These are inconsistently named between the esp32 variants.

---

Add examples of hardware duty-cycle fading

Just a relatively simple zero to 100 and back to zero, over a total of 2
seconds, to get a breathing effect.

This does make the main loop{} have a 2-second period instead of the
current nearly-zero period, but nothing else is happening so that's
fine.

---

Fix two bugs in hardware fading

When figuring out how many duty-cycle changes need to happen per counter
overflow, we need to use the absolute value of the difference between
the start and end duty values, not the raw difference.  When fading from
(e.g.) 100% to 0, this will overflow, and both the debug-mode panic and
the release-mode wrapping behavior give the wrong delta value.

So calculate an absolute value difference first, and use that.

Then, when running through the while loop that allocates bits between
pwm_cycles and duty_cycle, the check on pwm_cycles was wrong -- since
the value reduces each time through the loop, we need to keep looping as
long as it's *above* some threshold, not below.

---

Simplify and refactor duty-cycle fade code

I'm not sure if this will fix the extremely-short fade times that we're
seeing with the older code, but we'll see.

Move all the calculations out of the ChannelHW implementations, and make
those *just* set registers.  The calculations are the same for all chip
variants, so don't need to be duplicated for each chip feature, like the
register macros are.

Change the calculations from a loop doing bit shifts, to an explicit
division and a couple of range checks.  This way we can get a lot closer
to the requested percentages and durations.

Use the u32::abs_diff function instead of open-coding it (now that I see
it exists).

Use u16::try_from() to limit the range of values, and use try_into<u16>
and map_err and the ? operator to more clearly handle numbers out of
range.

Drop the Result<> return type from the ChannelHW function, as it can't
fail anymore.

Fix the duty_range value -- before, when duty_exp was (say) 8,
duty_range would be 256, and if one of the *_duty_pct values was 100,
the start or end duty value would be too big.  The range of start and
end duty values is 0..255, so we have to subtract one to handle 100%.

Finally, add a comment on the is_duty_fade_running{,_hw} methods.

---

Some fades can't work; return errors for them.

Add a new Error enum value with a sub-error enum with more details.
Return it from the error cases in the fade method.

If the calculated cycles_per_step is more than 10 bits, fail as well;
the field in the register is only 10 bits wide.

Fix all the examples to run a 1-second fade instead of a 2-second, since
the 2-second fade will run into this error.  (Assert that, as well.)

---

When fading on a -c6 chip, set two more registers

The gamma functionality of -c6 chips needs two more fields set.  One
tells the chip how many gamma stages it should iterate through, but we
only implement linear fading, so always use 1.  The other tells the chip
to latch the value of the other gamma registers into the chosen slot, so
even though its value never changes, the write needs to happen.

---

Add changelog entry
2023-05-15 17:11:31 +00:00
dimi
c4fec98cb3 implement Copy and Eq for EspTwaiError 2023-05-15 08:20:12 -07:00
Sergio Gasquez Arcos
e2442f2d47
Initial support for I2C in ESP32-H2 (#538)
* feat:  Enable i2c peripheral

* feat:  Add I2cExt1 for H2

* feat:  Initial i2c support

* feat:  Add i2c examples

* ci:  Add embassy_i2c check

* ci: 🐛 Fix features

* docs: 📝 Update changelog

* feat:  Add read_efuse example
2023-05-15 16:20:01 +02:00
Björn Quentin
4dde817530
Merge pull request #536 from bjoernQ/bugfix/set-vecbase-for-core1
Bugfix/set vecbase for core1
2023-05-15 16:18:39 +02:00
bjoernQ
add8447df8 Add reference to the PR to changelog 2023-05-15 16:10:36 +02:00
bjoernQ
c0e67aa5c7 Update CHANGELOG 2023-05-15 16:10:12 +02:00
bjoernQ
7f769612b9 Set vecbase on core1 2023-05-15 16:09:43 +02:00
Scott Mabin
eb3a449d90
async gpio fixes (#537)
* async gpio fixes

- Fix pin number calculation for bank1
- Clear interrupt status after disabling interrupt to avoid hardware
  pending another interrupt
- Clear interrupt status per pin when we create the input future

* add changelog item
2023-05-15 14:53:04 +01:00
Sergio Gasquez Arcos
70e453902c
Initial support for RSA in ESP32-H2 (#526)
* feat:  Initial support for RSA

* docs: 📝 Update docstring

* docs: 📝 Update changelog

* fix: 🔥 Remove duplicated code
2023-05-15 09:42:19 +01:00
Sergio Gasquez Arcos
fa3627c1fd
Add blinky_erased_pins example for ESP32-H2 (#530)
* feat:  Add blinky_erased_pins example

* docs: 📝 Update docstrings

* docs: 📝 Update changelog
2023-05-12 14:18:04 +02:00
Sergio Gasquez Arcos
b90ea68931
Improve examples documentation (#533)
* docs: 📝 Doccument embassy I2C example

* docs: 📝 Improve documentation of embassy SPI example

* docs: 📝 Doccument AES and RSA example

* docs: 📝 Update changelog
2023-05-12 13:46:56 +02:00
Sergio Gasquez Arcos
5b47c37449
Initial support for AES in ESP32-H2 (#528)
* feat:  Initial support for AES

* docs: 📝 Update changelog
2023-05-12 13:46:22 +02:00
Sergio Gasquez
b811198939 docs: 📝 Update changelog 2023-05-11 09:30:40 -07:00
Sergio Gasquez
29757abe07 feat: Initial support for SHA 2023-05-11 09:30:40 -07:00
Jesse Braham
d316b066b0 Improve the pre-commit hook
Now handles directories starting with `esp` which do *not* contain a `Cargo.toml` file!
2023-05-11 08:53:03 -07:00