Skip to content

Commit

Permalink
Peripheral interconnect redo, vol 2 (split()) (#2418)
Browse files Browse the repository at this point in the history
* Replace peripheral connection conversions with split

* Constrain Flex conversions
  • Loading branch information
bugadani authored Nov 4, 2024
1 parent 177db10 commit 0c86740
Show file tree
Hide file tree
Showing 19 changed files with 353 additions and 216 deletions.
4 changes: 4 additions & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `DmaDescriptor` is now `Send` (#2456)
- `into_async` and `into_blocking` functions for most peripherals (#2430)
- API mode type parameter (currently always `Blocking`) to `master::Spi` and `slave::Spi` (#2430)
- `gpio::{GpioPin, AnyPin, Flex, Output, OutputOpenDrain}::split()` to obtain peripheral interconnect signals. (#2418)
- `gpio::Input::{split(), into_peripheral_output()}` when used with output pins. (#2418)
- `gpio::Output::peripheral_input()` (#2418)

### Changed

Expand All @@ -42,6 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- SPI interrupt listening is now only available in Blocking mode. The `set_interrupt_handler` is available via `InterruptConfigurable` (#2442)
- Allow users to create DMA `Preparation`s (#2455)
- The `rmt::asynch::RxChannelAsync` and `rmt::asynch::TxChannelAsync` traits have been moved to `rmt` (#2430)
- Calling `AnyPin::output_signals` on an input-only pin (ESP32 GPIO 34-39) will now result in a panic. (#2418)

### Fixed

Expand Down
21 changes: 20 additions & 1 deletion esp-hal/MIGRATING-0.21.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ You can now listen/unlisten multiple interrupt bits at once:
-uart0.listen_at_cmd();
-uart0.listen_rx_fifo_full();
+uart0.listen(UartInterrupt::AtCmd | UartConterrupt::RxFifoFull);
```˛
```

## Circular DMA transfer's `available` returns `Result<usize, DmaError>` now

In case of any error you should drop the transfer and restart it.
Expand All @@ -211,3 +212,21 @@ In case of any error you should drop the transfer and restart it.
+ },
+ };
```

## Removed `peripheral_input` and `into_peripheral_output` from GPIO pin types

Creating peripheral interconnect signals now consume the GPIO pin used for the connection.

The previous signal function have been replaced by `split`. This change affects the following APIs:

- `GpioPin`
- `AnyPin`

```diff
-let input_signal = gpioN.peripheral_input();
-let output_signal = gpioN.into_peripheral_output();
+let (input_signal, output_signal) = gpioN.split();
```

`into_peripheral_output`, `split` (for output pins only) and `peripheral_input` have been added to
the GPIO drivers (`Input`, `Output`, `OutputOpenDrain` and `Flex`) instead.
19 changes: 6 additions & 13 deletions esp-hal/src/gpio/interconnect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ impl PeripheralOutput for OutputConnection {}

/// A configurable input signal between a peripheral and a GPIO pin.
///
/// Obtained by calling [`super::GpioPin::peripheral_input()`],
/// [`super::Flex::peripheral_input()`] or [`super::Input::peripheral_input()`].
///
/// Multiple input signals can be connected to one pin.
pub struct InputSignal {
pin: AnyPin,
Expand Down Expand Up @@ -188,10 +185,6 @@ impl InputSignal {

/// A configurable output signal between a peripheral and a GPIO pin.
///
/// Obtained by calling [`super::GpioPin::into_peripheral_output()`],
/// [`super::Flex::into_peripheral_output()`] or
/// [`super::Output::into_peripheral_output()`].
///
/// Multiple pins can be connected to one output signal.
pub struct OutputSignal {
pin: AnyPin,
Expand Down Expand Up @@ -441,9 +434,9 @@ where
P: InputPin,
{
fn from(input: P) -> Self {
Self(InputConnectionInner::Input(
input.degrade().peripheral_input(),
))
Self(InputConnectionInner::Input(InputSignal::new(
input.degrade(),
)))
}
}

Expand Down Expand Up @@ -534,9 +527,9 @@ where
P: OutputPin,
{
fn from(input: P) -> Self {
Self(OutputConnectionInner::Output(
input.degrade().into_peripheral_output(),
))
Self(OutputConnectionInner::Output(OutputSignal::new(
input.degrade(),
)))
}
}

Expand Down
Loading

0 comments on commit 0c86740

Please sign in to comment.