2205 Commits

Author SHA1 Message Date
9names
c896e6c8d2 Fixed defmt on direct-boot mode 2022-09-07 06:20:24 +02:00
Björn Quentin
dd1f94f347
Merge pull request #181 from JurajSadel/refactor/LEDC_ctor
Make it impossible to create multiple instances of LEDC
2022-09-06 11:50:43 +02:00
Juraj Sadel
f11a23dddb Make it impossible to create multiple instances of LEDC 2022-09-06 11:37:05 +02:00
Juraj Sadel
e9f22aca63
Merge pull request #176 from bjoernQ/bugfix/pin-paste-to-fix-sudden-build-errors
Pin version of paste to fix build errors
2022-08-31 16:28:03 +02:00
bjoernQ
b9f38aae7c Pin version of paste to fix build errors 2022-08-31 11:28:42 +02:00
Jesse Braham
797d9b5e02 Minor CI tweaks 2022-08-30 11:32:31 -07:00
har7an
8b9fd8b7a0
embedded-hal SpiDevice on all esp32 variants (#106)
* WIP: common/spi: Implement `SpiDevice`

to get shared access to an SPI bus directly via the HAL.

* WIP: common/spi: add SpiBusDevice::new

to create instances via a function call.

* esp32/examples: Add example for spi device trait

* common/spi: Finish "SpiDevice" implementation

for esp32. Abandons the approach of having the user pass in some generic
mutex in favor of creating the Mutex as part of the API so it isn't
exposed to the user in the first place.

* common/spi: Add more thorough docs

* esp32/examples: Fix example for eh1 "SpiDevice"

* common/spi: Implement `SpiDevice` for xtensa arch

and move the code into a submodule that is fenced with conditional
compilation directives.

* esp32/examples: Update spi device example

to the changed APIs for the timers and clocks, and add more transmission
tests to the example code.

* common/spi: Create devices from buscontroller

directly, instead of offering only the `new` method.

* common/spi: Finish `SpiBusDevice` trait

from embedded-hal 1.0.0-alpha.8.

* esp32: Update `SpiBusDevice` usage example.

* common/spi: Fix mutex types for xtensa32 esp

because the esp32/esp32s3 can use `SpinLockMutex`, whereas the esp32s2
has access only to `CriticalSectionMutex`.

* common/spi: Implement `SpiBusDevice` for riscv

based esp32c3.

* general: Add examples for spi device loopback

to all esp variants.

* common: Use esp_backtrace in spi_eh1_device examples

* common/spi: Update module documentation.

* common/spi: Use `critical_section::Mutex`

to unify locking across all esp variants.

* esp32c3-hal: Fix spi device example

* esp32c3/examples: Fix typo in used spi pins

Co-authored-by: Jesse Braham <jessebraham@users.noreply.github.com>

Co-authored-by: Jesse Braham <jessebraham@users.noreply.github.com>
2022-08-30 06:55:53 -07:00
Björn Quentin
46a8470ff5
Merge pull request #173 from JurajSadel/fix/floats
Replace all float calculations with fixed ones
2022-08-30 15:23:56 +02:00
Juraj Sadel
9911a1e359 Replace all float calculations with fixed ones 2022-08-30 13:43:48 +02:00
Björn Quentin
32368c6b2b
Merge pull request #171 from maximeborges/features/gpio_into
gpio: Impl From<>
2022-08-29 08:25:03 +02:00
Maxime Borges
04c8721e60 gpio: Impl From<> 2022-08-28 01:22:33 +02:00
Jesse Braham
36e13b0d7c Bump esp32-hal version number to 0.4.0 2022-08-25 09:48:01 -07:00
Jesse Braham
6f20358124
Update the Cargo manifests and top-level README (#168)
* Add the `rust-version` key to each Cargo manifest

* Normalize dependencies and features in each Cargo manifest

* Enable all features in CI when checking examples

* Update the top-level README
v0.1.0
2022-08-25 09:20:05 -07:00
Scott Mabin
b30886cce6
Periodic system timer & esp32s2 fixes & edge interrupt fixes (#167)
* Add Periodic mode to SYSTIMER

* Deduplicate shared code in SYSTIMER

* esp32s2 edge mode systimer interrupt

- Make systimer interrupts edge mode
- fix examples for s3 & s2

* Fix TPS for esp32s2, clean up examples
2022-08-25 07:13:56 -07:00
bjoernQ
5e6234dcc4 Fix embedded-hal 0.2.x SPI implementation 2022-08-24 19:49:47 +02:00
Scott Mabin
4c943378f8 Use vscode multi-root ws for esp-hal 2022-08-23 21:24:04 +02:00
Björn Quentin
22ac479bff
Optimize the ESP32-S3 linker script (#164)
* Optimize the ESP32-S3 linker script

* Incorporate suggestions from review

* Extend the size of dram_seg as suggested in the review
2022-08-23 08:00:20 -07:00
Björn Quentin
daecc305d7
Merge pull request #163 from jessebraham/fixes/pacs
No longer alias the PAC package names
2022-08-23 08:11:40 +02:00
Jesse Braham
81ea741a81 No longer alias the PAC package names 2022-08-22 12:22:42 -07:00
Scott Mabin
be184a552d
critical_section implementations & esp_backtrace (#151)
* CS impl

* use CS Mutex in C3 examples

* use CS Mutex in S2 examples

* Update esp32 example

* run fmt

* Update S3 examples

* Remove uses of unsafe where no longer required

* use esp_backtrace in examples

* fix import & fmt once more

* Bump MSRV to 1.60.0

Co-authored-by: Jesse Braham <jesse@beta7.io>
2022-08-22 20:02:28 +01:00
Björn Quentin
b354a29bc4
Merge pull request #161 from bjoernQ/bugfix/fix-esp32s2-iram-dram-overlap
Fix IRAM/DRAM overlap for ESP32-S2
2022-08-22 16:29:48 +02:00
bjoernQ
b9f59c436c Rename RESERVE_DRAM to RESERVE_CACHES, revert change of reserved_for_boot_seg 2022-08-22 15:42:12 +02:00
Björn Quentin
520f8d6f41
Update esp32s2-hal/ld/link-esp32s2.x
Co-authored-by: Gustavo Henrique Nihei <38959758+gustavonihei@users.noreply.github.com>
2022-08-22 15:25:09 +02:00
Björn Quentin
92d618a8e5
Update esp32s2-hal/ld/memory.x
Co-authored-by: Gustavo Henrique Nihei <38959758+gustavonihei@users.noreply.github.com>
2022-08-22 15:25:04 +02:00
bjoernQ
468d4a90c5 Fix IRAM/DRAM overlap for ESP32-S2 2022-08-22 11:29:33 +02:00
Björn Quentin
f7c9b0869e
Merge pull request #157 from jessebraham/fixes/pacs
Use the published version of the PACs
2022-08-22 08:53:54 +02:00
Gustavo Henrique Nihei
9d0a1f6685 esp32[c3|s2|s3]-hal: Add example for monitoring the XTAL frequency
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2022-08-19 21:55:54 +02:00
Gustavo Henrique Nihei
61c0731b62 rtc: Add support for monitoring of XTAL clock
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2022-08-19 21:55:54 +02:00
Gustavo Henrique Nihei
a1c417c037 esp32-s2: Fix stack area overlapping with ROM data reserved region
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2022-08-19 21:28:50 +02:00
Jesse Braham
f0335ade53 Use the published version of the PACs 2022-08-19 10:45:32 -07:00
Anthony Grondin
ede5007f71 Fix change detection of linker script on build files
In 7b59c9e76d
linker scripts have been moved in the ld/ sub-folder for every target.
The change detection path in build.rs of every target hasn't been updated, resulting in
the build script running at every code change, rather than only when there's a change in memory.x
2022-08-18 05:36:23 +02:00
har7an
2fe27536aa
SPI: Implement more SPI traits from embedded-hal 1.0.0-alpha.8 (#101)
* common/spi: Turn fifo size into const

instead of hard-coding it into the code in various places.

* common/spi: Alias `write_bytes` to `send_bytes`

since they share the same interface and the same code anyway.

* common/spi: Implement `read_bytes`

as counterpart to `send_bytes` that is responsible only for reading
bytes received via SPI.

* common/spi: Rewrite `transfer`

to use `send_bytes` and `read_bytes` under the hood and remove duplicate
code.

* common/spi: Create submodule for embedded_hal_1

that is re-exported when the `eh1` feature flag is active. This removes
lots of duplicate `#[cfg(...)]` macros previously part of the code.

* common/spi: Implement `SpiBus` and `SpiBusWrite`

traits from the `embedded-hal 1.0.0-alpha.8`.

* common/spi: Make `mosi` pin optional

* esp32-hal: Add new SPI example with `eh1` traits

* esp32-hal/examples/spi_eh1: Add huge transfer

and bump the SPI speed to 1 MHz.

* common/spi: Apply rustfmt

* common/spi: Use `memcpy` to read from registers

This cuts down the time between consecutive transfers from about 2 ms
to less than 1 ms.

* WIP: common/spi: Use `ptr::copy` to fill write FIFO

cutting down the time between transfers from just below 1 ms to ~370 us.

The implementation is currently broken in that it will always fill the
entire FIFO from the input it is given, even if that isn't FIFO-sized...

* common/spi: Add more documentation

* esp32/examples/spi_eh1: Fix `transfer_in_place`

* esp32/examples/spi_eh1: Add conditional compile

and compile a dummy instead when the "eh1" feature isn't present.

* esp32-hal: Ignore spi_eh1 example

in normal builds, where the feature flag "eh1" isn't given. Building the
example directly via `cargo build --example spi_eh1_loopback` will now
print an error that this requires a feature flag to be active.

* common/spi: Use `write_bytes`

and drop `send_bytes` instead. Previoulsy, both served the same purpose,
but `send_bytes` was introduced more recently and is hence less likely
to cause breaking changes in existing code.

* common/spi: Fix mosi pin setup

* Add SPI examples with ehal 1.0.0-alpha8 traits

to all targets.

* common/spi: Fix `read` behavior

The previous `read` implementation would only read the contents of the
SPI receive FIFO and return that as data. However, the `SpiBusRead`
trait defines that while reading, bytes should be written out to the bus
(Because SPI is transactional, without writing nothing can be read).

Reimplements the `embedded-hal` traits to correctly implement this
behavior.

* common/spi: Use full FIFO size on all variants

All esp variants except for the esp32s2 have a 64 byte FIFO, whereas the
esp32s2 has a 72 byte FIFO.

* common/spi: Use common pad byte for empty writes

* common/spi: Fix reading bytes from FIFO

by reverting to the old method of reading 32 bytes at a time and
assembling the return buffer from that. It turns out that the previous
`core::slice::from_raw_parts()` doesn't work for the esp32s2 and esp32s3
variants, returning bogus data even though the correct data is present
in the registers.

* common/spi: Fix typos

* examples: Fix spi_eh1_loopback examples
2022-08-17 11:57:55 +01:00
Gustavo Henrique Nihei
6e037b08ca ESP32-S2: Fix broken reference in documentation
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2022-08-16 19:57:55 +02:00
har7an
26a5029edf
common/gpio: Allow disconnecting IO from peripheral (#147)
* common/gpio: Allow disconnecting IO from peripheral

* common/gpio: Allow disconnecting input from peripheral

* common/gpio: Document functions for disconnecting

IOs from peripherals.

* common/gpio: Use generic alternate function

passed in from the gpio configuration.
2022-08-16 08:52:07 -07:00
Gustavo Henrique Nihei
3cbabe3247
ESP32[-C3]: Fix broken references in documentation (#153)
* esp32c3: Fix broken references to esptool repository

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

* esp32: Fix broken reference to esp-idf repository

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2022-08-16 08:32:47 -07:00
Björn Quentin
97d1c1e997
Merge pull request #152 from gustavonihei/bugfix/early_rwdt_disable
rtc: Disable Flashboot mode when disabling RTC Watchdog timer
2022-08-16 17:25:19 +02:00
Gustavo Henrique Nihei
a7c788ff02 rtc: Disable Flashboot mode when disabling RTC Watchdog timer
This commit fixes a regression to Direct Boot support introduced on
routine.

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2022-08-16 11:43:57 -03:00
Björn Quentin
978b322b94
Merge pull request #148 from bjoernQ/bugfix/fix-esp32c3-linker-error
Fix ESP32-C3 builds on latest nightlies
2022-08-16 10:04:14 +02:00
bjoernQ
49841c295d Fix ESP32-C3 builds on latest nightlies 2022-08-16 09:42:36 +02:00
Björn Quentin
35e568dd38
Merge pull request #145 from esp-rs/bugfix/db-bss-section
include bss size when calculating rwtext address
2022-08-10 08:31:16 +02:00
Scott Mabin
99ae152f55 Fix bss section placement in db mode
If bss contained anything a linker error was emitted about overlapping
sections. Moving the .bss section to after the .rwtext, and adding a dummy
section to pad data bus access to the bss section fixes this.
2022-08-09 23:51:28 +01:00
bjoernQ
91373ac6a0 Make RMT TX larger than one block work on ESP32-C3 and ESP32-S3 2022-08-09 16:30:19 +02:00
Björn Quentin
4c44f3ea8e
Merge pull request #139 from gustavonihei/feature/rwdt_esp32_s2_s3
rtc: Add RWDT examples for ESP32, ESP32-S2 and ESP32-S3
2022-08-09 08:28:51 +02:00
Gustavo Henrique Nihei
a33c0de7f6 rtc: Add RWDT examples for ESP32, ESP32-S2 and ESP32-S3
Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2022-08-08 13:34:22 -03:00
Gustavo Henrique Nihei
91ea205446
ESP32-C3: Add driver for RTC Watchdog Timer (RWDT) (#134)
* esp32: Fix typo in Frequency word in some identifiers

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

* esp32c3: Add support for PLL clock configuration

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

* clock: Move definition of Clock types to common level

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

* esp32c3: Add support for RTC Clock configuration

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>

* esp32c3: Add example for the RTC Watchdog Timer driver

Signed-off-by: Gustavo Henrique Nihei <gustavo.nihei@espressif.com>
2022-08-08 15:36:19 +01:00
Björn Quentin
98d0fe8ece
Merge pull request #138 from bjoernQ/bugfix/fix-ledc-clock
Fix LEDC divider calculation, use REF_TICK when needed
2022-08-08 15:28:58 +02:00
bjoernQ
c19a1fa13f Cleanup ESP32-S3 LEDC example 2022-08-08 15:15:30 +02:00
bjoernQ
275cede963 Fix LEDC divider calculation, use REF_TICK when needed 2022-08-08 14:41:55 +02:00
Björn Quentin
2a1ab6da0e
Use the correct AlternateFunction for GPIO (#137) 2022-08-08 12:02:40 +01:00
Jesse Braham
82371f526c Add jobs to the CI workflow to verify the MSRV 2022-08-03 17:12:18 +02:00