From b11fc0fce8998b8b2bc3751e9a968a6132f383a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Wed, 13 Nov 2024 16:07:55 +0100 Subject: [PATCH] Remove NoClkPin (#2531) --- esp-hal/CHANGELOG.md | 1 + esp-hal/MIGRATING-0.21.md | 16 ++++++++++++++++ esp-hal/src/parl_io.rs | 20 ++++++++------------ examples/src/bin/embassy_parl_io_rx.rs | 11 +++++++++-- examples/src/bin/parl_io_rx.rs | 11 +++++++++-- 5 files changed, 43 insertions(+), 16 deletions(-) diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index 2bba6de8d..5acacce01 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -104,6 +104,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - The `TaskSet`, `TaskClear`, `TaskToggle` types have been replaced with `Task` (#2427) - `{Spi, SpiDma, SpiDmaBus}` configuration methods (#2448) - `Io::new_with_priority` and `Io::new_no_bind_interrupt`. (#2486) +- `parl_io::{no_clk_pin(), NoClkPin}` (#2531) ## [0.21.1] diff --git a/esp-hal/MIGRATING-0.21.md b/esp-hal/MIGRATING-0.21.md index ca6dfba8d..f24b6bef0 100644 --- a/esp-hal/MIGRATING-0.21.md +++ b/esp-hal/MIGRATING-0.21.md @@ -396,3 +396,19 @@ When trying to send a one-shot transmission will fail if it doesn't end with an - let transaction = channel.transmit(&data); + let transaction = channel.transmit(&data).unwrap(); ``` + + +## The `parl_io::NoClkPin` and `no_clk_pin()` have been removed + +You can use `gpio::NoPin` instead. + +```diff + use esp_hal:: { +- parl_io::no_clk_pin, ++ gpio::NoPin, + } + +-parl_io.rx.with_config(&mut rx_pins, no_clk_pin(), BitPackOrder::Msb, Some(0xfff)) ++let mut rx_clk_pin = NoPin; ++parl_io.rx.with_config(&mut rx_pins, &mut rx_clk_pin, BitPackOrder::Msb, Some(0xfff)) +``` diff --git a/esp-hal/src/parl_io.rs b/esp-hal/src/parl_io.rs index 57b558cc5..2d95e1427 100644 --- a/esp-hal/src/parl_io.rs +++ b/esp-hal/src/parl_io.rs @@ -49,7 +49,10 @@ use crate::{ Tx, WriteBuffer, }, - gpio::interconnect::{InputConnection, OutputConnection, PeripheralInput, PeripheralOutput}, + gpio::{ + interconnect::{InputConnection, OutputConnection, PeripheralInput, PeripheralOutput}, + NoPin, + }, interrupt::InterruptHandler, peripheral::{self, Peripheral}, peripherals::{self, Interrupt, PARL_IO}, @@ -260,24 +263,17 @@ pub enum EofMode { } /// Used to configure no pin as clock output -pub struct NoClkPin; -impl TxClkPin for NoClkPin { +impl TxClkPin for NoPin { fn configure(&mut self) { - // nothing + crate::gpio::OutputSignal::PARL_TX_CLK.connect_to(self); } } -impl RxClkPin for NoClkPin { +impl RxClkPin for NoPin { fn configure(&mut self) { - // nothing + crate::gpio::InputSignal::PARL_RX_CLK.connect_to(self); } } -/// This can be used to pass to the `with_config` functions -pub fn no_clk_pin() -> &'static mut NoClkPin { - static mut NO_CLK: NoClkPin = NoClkPin; - unsafe { &mut *core::ptr::addr_of_mut!(NO_CLK) } -} - /// Wraps a GPIO pin which will be used as the clock output signal pub struct ClkOutPin<'d> { pin: PeripheralRef<'d, OutputConnection>, diff --git a/examples/src/bin/embassy_parl_io_rx.rs b/examples/src/bin/embassy_parl_io_rx.rs index 9b589992d..33749c91f 100644 --- a/examples/src/bin/embassy_parl_io_rx.rs +++ b/examples/src/bin/embassy_parl_io_rx.rs @@ -16,7 +16,8 @@ use esp_backtrace as _; use esp_hal::{ dma::{Dma, DmaPriority}, dma_buffers, - parl_io::{no_clk_pin, BitPackOrder, ParlIoRxOnly, RxFourBits}, + gpio::NoPin, + parl_io::{BitPackOrder, ParlIoRxOnly, RxFourBits}, prelude::*, timer::systimer::{SystemTimer, Target}, }; @@ -41,6 +42,7 @@ async fn main(_spawner: Spawner) { peripherals.GPIO3, peripherals.GPIO4, ); + let mut rx_clk_pin = NoPin; let parl_io = ParlIoRxOnly::new( peripherals.PARL_IO, @@ -54,7 +56,12 @@ async fn main(_spawner: Spawner) { let mut parl_io_rx = parl_io .rx - .with_config(&mut rx_pins, no_clk_pin(), BitPackOrder::Msb, Some(0xfff)) + .with_config( + &mut rx_pins, + &mut rx_clk_pin, + BitPackOrder::Msb, + Some(0xfff), + ) .unwrap(); let buffer = rx_buffer; diff --git a/examples/src/bin/parl_io_rx.rs b/examples/src/bin/parl_io_rx.rs index 6f5d1c2f3..2a0390878 100644 --- a/examples/src/bin/parl_io_rx.rs +++ b/examples/src/bin/parl_io_rx.rs @@ -14,7 +14,8 @@ use esp_hal::{ delay::Delay, dma::{Dma, DmaPriority}, dma_buffers, - parl_io::{no_clk_pin, BitPackOrder, ParlIoRxOnly, RxFourBits}, + gpio::NoPin, + parl_io::{BitPackOrder, ParlIoRxOnly, RxFourBits}, prelude::*, }; use esp_println::println; @@ -34,6 +35,7 @@ fn main() -> ! { peripherals.GPIO3, peripherals.GPIO4, ); + let mut rx_clk_pin = NoPin; let parl_io = ParlIoRxOnly::new( peripherals.PARL_IO, @@ -45,7 +47,12 @@ fn main() -> ! { let mut parl_io_rx = parl_io .rx - .with_config(&mut rx_pins, no_clk_pin(), BitPackOrder::Msb, Some(0xfff)) + .with_config( + &mut rx_pins, + &mut rx_clk_pin, + BitPackOrder::Msb, + Some(0xfff), + ) .unwrap(); let mut buffer = rx_buffer;