Skip to content

Commit

Permalink
Merge branch 'main' into make-bootloader-ram-available
Browse files Browse the repository at this point in the history
  • Loading branch information
JurajSadel authored Sep 6, 2024
2 parents cbf25b1 + b5f0246 commit 03ef081
Show file tree
Hide file tree
Showing 119 changed files with 3,170 additions and 2,650 deletions.
4 changes: 3 additions & 1 deletion .github/actions/check-esp-hal/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,7 @@ runs:
--target=${{ inputs.target }} \
esp-hal
- name: Build (examples)
env:
CI: 1
shell: bash
run: cargo +${{ inputs.toolchain }} xtask build-examples esp-hal ${{ inputs.device }}
run: cargo +${{ inputs.toolchain }} xtask build-examples esp-hal ${{ inputs.device }} --debug
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:
push:
branches-ignore:
- "gh-readonly-queue/**"
- "main"
merge_group:
workflow_dispatch:

Expand Down Expand Up @@ -139,7 +140,7 @@ jobs:
cargo xtask build-package --features=esp32c3,wifi,ble,async --target=riscv32imc-unknown-none-elf esp-wifi
cargo xtask build-package --features=esp32c6,wifi,ble,async --target=riscv32imac-unknown-none-elf esp-wifi
cargo xtask build-package --features=esp32h2,ble,async --target=riscv32imac-unknown-none-elf esp-wifi
# Verify the MSRV for all Xtensa chips:
- name: msrv Xtensa (esp-hal)
run: |
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/hil.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ jobs:
- soc: esp32h2
rust-target: riscv32imac-unknown-none-elf
# # Xtensa devices:
- soc: esp32
rust-target: xtensa-esp32-none-elf
- soc: esp32s2
rust-target: xtensa-esp32s2-none-elf
- soc: esp32s3
Expand Down Expand Up @@ -168,6 +170,10 @@ jobs:
host: armv7
hubs: "1-1"
# Xtensa devices:
- soc: esp32
runner: esp32-jtag
host: aarch64
hubs: "1 3"
- soc: esp32s2
runner: esp32s2-jtag
host: armv7
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/issue_handler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ jobs:
- uses: actions/[email protected]
with:
project-url: https://github.com/orgs/esp-rs/projects/2
github-token: ${{ secrets.PAT }}
labeled: status:needs-attention
github-token: ${{ secrets.PAT }}
1 change: 1 addition & 0 deletions documentation/API-GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ The following paragraphs contain additional recommendations.
- Common cases of useless type info is storing pin information - this is usually not required after configuring the pins and will bloat the complexity of the type massively. When following the `PeripheralRef` pattern it's not needed in order to keep users from re-using the pin while in use
- Avoiding `&mut self` when `&self` is safe to use. `&self` is generally easier to use as an API. Typical applications of this are where the methods just do writes to registers which don't have side effects.
- For example starting a timer is fine for `&self`, worst case a timer will be started twice if two parts of the program call it. You can see a real example of this [here](https://github.com/esp-rs/esp-hal/pull/1500#pullrequestreview-2015911974)
- Maintain order consistency in the API, such as in the case of pairs like RX/TX.

## Maintainability

Expand Down
6 changes: 3 additions & 3 deletions esp-hal-embassy/src/time_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use embassy_time_driver::{AlarmHandle, Driver};
use esp_hal::{
interrupt::{InterruptHandler, Priority},
prelude::*,
time::current_time,
time::now,
timer::{ErasedTimer, OneShotTimer},
};

Expand Down Expand Up @@ -119,7 +119,7 @@ impl EmbassyTimer {
}

fn arm(timer: &mut Timer, timestamp: u64) {
let now = current_time().duration_since_epoch();
let now = now().duration_since_epoch();
let ts = timestamp.micros();
// if the TS is already in the past make the timer fire immediately
let timeout = if ts > now { ts - now } else { 0.micros() };
Expand All @@ -130,7 +130,7 @@ impl EmbassyTimer {

impl Driver for EmbassyTimer {
fn now(&self) -> u64 {
current_time().ticks()
now().ticks()
}

unsafe fn allocate_alarm(&self) -> Option<AlarmHandle> {
Expand Down
2 changes: 1 addition & 1 deletion esp-hal-procmacros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ document-features = "0.2.10"
litrs = "0.4.1"
object = { version = "0.36.4", optional = true, default-features = false, features = ["read_core", "elf"] }
proc-macro-crate = "3.2.0"
proc-macro-error = "1.0.4"
proc-macro-error2 = "2.0.0"
proc-macro2 = "1.0.86"
quote = "1.0.37"
syn = { version = "2.0.76", features = ["extra-traits", "full"] }
Expand Down
77 changes: 0 additions & 77 deletions esp-hal-procmacros/src/enum_dispatch.rs

This file was deleted.

41 changes: 4 additions & 37 deletions esp-hal-procmacros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ use proc_macro::TokenStream;

#[cfg(feature = "embassy")]
mod embassy;
#[cfg(feature = "enum-dispatch")]
mod enum_dispatch;
#[cfg(feature = "interrupt")]
mod interrupt;
#[cfg(any(
Expand Down Expand Up @@ -130,11 +128,11 @@ struct RamArgs {
/// [`bytemuck::Zeroable`]: https://docs.rs/bytemuck/1.9.0/bytemuck/trait.Zeroable.html
#[cfg(feature = "ram")]
#[proc_macro_attribute]
#[proc_macro_error::proc_macro_error]
#[proc_macro_error2::proc_macro_error]
pub fn ram(args: TokenStream, input: TokenStream) -> TokenStream {
use darling::{ast::NestedMeta, Error, FromMeta};
use proc_macro::Span;
use proc_macro_error::abort;
use proc_macro_error2::abort;
use syn::{parse, Item};

let attr_args = match NestedMeta::parse_meta_list(args.into()) {
Expand Down Expand Up @@ -243,7 +241,7 @@ pub fn ram(args: TokenStream, input: TokenStream) -> TokenStream {
///
/// If no priority is given, `Priority::min()` is assumed
#[cfg(feature = "interrupt")]
#[proc_macro_error::proc_macro_error]
#[proc_macro_error2::proc_macro_error]
#[proc_macro_attribute]
pub fn handler(args: TokenStream, input: TokenStream) -> TokenStream {
use darling::{ast::NestedMeta, FromMeta};
Expand Down Expand Up @@ -339,37 +337,6 @@ pub fn handler(args: TokenStream, input: TokenStream) -> TokenStream {
.into()
}

/// Create an enum for erased GPIO pins, using the enum-dispatch pattern
///
/// Only used internally
#[cfg(feature = "enum-dispatch")]
#[proc_macro]
pub fn make_gpio_enum_dispatch_macro(input: TokenStream) -> TokenStream {
use quote::{format_ident, quote};

use self::enum_dispatch::{build_match_arms, MakeGpioEnumDispatchMacro};

let input = syn::parse_macro_input!(input as MakeGpioEnumDispatchMacro);

let macro_name = format_ident!("{}", input.name);
let arms = build_match_arms(input);

quote! {
#[doc(hidden)]
#[macro_export]
macro_rules! #macro_name {
($m:ident, $target:ident, $body:block) => {
match $m {
#(#arms)*
}
}
}

pub(crate) use #macro_name;
}
.into()
}

/// Load code to be run on the LP/ULP core.
///
/// ## Example
Expand All @@ -385,7 +352,7 @@ pub fn load_lp_code(input: TokenStream) -> TokenStream {

/// Marks the entry function of a LP core / ULP program.
#[cfg(any(feature = "is-lp-core", feature = "is-ulp-core"))]
#[proc_macro_error::proc_macro_error]
#[proc_macro_error2::proc_macro_error]
#[proc_macro_attribute]
pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
lp_core::entry(args, input)
Expand Down
14 changes: 14 additions & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Implement `embedded-hal` output pin traits for `DummyPin` (#2019)
- Added `esp_hal::init` to simplify HAL initialisation (#1970, #1999)
- Added GpioPin::degrade to create ErasePins easily. Same for AnyPin by accident. (#2075)
- Added missing functions to `Flex`: `unlisten`, `is_interrupt_set`, `wakeup_enable`, `wait_for_high`, `wait_for_low`, `wait_for_rising_edge`, `wait_for_falling_edge`, `wait_for_any_edge`. (#2075)
- `Flex` now implements `Wait`. (#2075)
- Added sleep and wakeup support for esp32c2 (#1922)
- Previously unavailable memory is available via `.dram2_uninit` section (#2079)

### Changed
- Make saving and restoring SHA digest state an explicit operation (#2049)
- Reordered RX-TX pairs in all APIs to be consistent (#2074)

- `Delay::new()` is now a `const` function (#1999)
- You can now create an `AnyPin` out of an `ErasedPin`. (#2072)
- `Input`, `Output`, `OutputOpenDrain` and `Flex` are now type-erased by default. Use the new `new_typed` constructor to keep using the ZST pin types. (#2075)
- To avoid confusion with the `Rtc::current_time` wall clock time APIs, we've renamed `esp_hal::time::current_time` to `esp_hal::time::now`. (#2091)

### Fixed
- SHA driver can now be safely used in multiple contexts concurrently (#2049)

- Fixed an issue with DMA transfers potentially not waking up the correct async task (#2065)
- Fixed an issue with LCD_CAM i8080 where it would send double the clocks in 16bit mode (#2085)
- Fix i2c embedded-hal transaction (#2028)

### Removed
- Removed `digest::Digest` implementation from SHA (#2049)

- Removed `NoPinType` in favour of `DummyPin`. (#2068)
- Removed the `async`, `embedded-hal-02`, `embedded-hal`, `embedded-io`, `embedded-io-async`, and `ufmt` features (#2070)
- Removed the `GpioN` type aliasses. Use `GpioPin<N>` instead. (#2073)
- Removed `Peripherals::take`. Use `esp_hal::init` to obtain `Peripherals` (#1999)
- Removed `AnyInputOnlyPin` in favour of `AnyPin`. (#2071)

## [0.20.1] - 2024-08-30

Expand Down
43 changes: 42 additions & 1 deletion esp-hal/MIGRATING-0.20.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,45 @@ Instead of manually grabbing peripherals and setting up clocks, you should now c

## GPIO changes

The `GpioN` type aliasses are no longer available. You can use `GpioPin<N>` instead.
- The `GpioN` type aliasses are no longer available. You can use `GpioPin<N>` instead.
- The `AnyInputOnlyPin` has been removed. Replace any use with `AnyPin`.
- The `NoPinType` has been removed. You can use `DummyPin` in its place.

### Type-erased GPIO drivers

You no longer have to spell out the GPIO pin type for `Input`, `Output`, `OutputOpenDrain` or `Flex`.
However, if you want to, you can keep using their typed form!

```rust
let pin = Input::new(io.gpio0); // pin will have the type `Input<'some>` (or `Input<'some, ErasedPin>` if you want to be explicit about it)
let pin = Input::new_typed(io.gpio0); // pin will have the type `Input<'some, GpioPin<0>>`
```

## `esp_hal::time::current_time` rename

To avoid confusion with the `Rtc::current_time` wall clock time APIs, we've renamed `esp_hal::time::current_time` to `esp_hal::time::now()`.

```diff
- use esp_hal::time::current_time;
+ use esp_hal::time::now;
```

## RX/TX Order

Previously, our API was pretty inconsitent with the RX/TX ordering, and different peripherals had different order. Now, all
the peripherals use rx-tx. Make sure your methods are expecting the rigth RX/TX order, for example an SPI DMA app should be updated to:

```diff
- let (tx_buffer, tx_descriptors, rx_buffer, rx_descriptors) = dma_buffers!(4);
+ let (rx_buffer, rx_descriptors, tx_buffer, tx_descriptors) = dma_buffers!(4);
let mut dma_tx_buf = DmaTxBuf::new(tx_descriptors, tx_buffer).unwrap();
let dma_rx_buf = DmaRxBuf::new(rx_descriptors, rx_buffer).unwrap();

...

let transfer = spi
- .dma_transfer(dma_tx_buf, dma_rx_buf)
+ .dma_transfer(dma_rx_buf, dma_tx_buf)
.map_err(|e| e.0)
.unwrap();
```
Loading

0 comments on commit 03ef081

Please sign in to comment.