mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-29 21:30:39 +00:00
Also add into_async for ParlIO (#2461)
This commit is contained in:
parent
ca9ee23b5e
commit
ed7960ce8b
@ -24,7 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- I2S Parallel output driver for ESP32. (#2348, #2436)
|
||||
- Add an option to configure `WDT` action (#2330)
|
||||
- `DmaDescriptor` is now `Send` (#2456)
|
||||
- `into_async` and `into_blocking` functions for most peripherals (#2430)
|
||||
- `into_async` and `into_blocking` functions for most peripherals (#2430, #2461)
|
||||
- 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)
|
||||
@ -43,7 +43,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Circular DMA transfers now correctly error, `available` returns `Result<usize,DmaError>` now (#2409)
|
||||
- Interrupt listen/unlisten/clear functions now accept any type that converts into `EnumSet` (i.e. single interrupt flags). (#2442)
|
||||
- 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)
|
||||
- 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)
|
||||
|
||||
|
@ -54,6 +54,7 @@ use crate::{
|
||||
peripheral::{self, Peripheral},
|
||||
peripherals::{self, Interrupt, PARL_IO},
|
||||
system::PeripheralClockControl,
|
||||
Async,
|
||||
Blocking,
|
||||
InterruptConfigurable,
|
||||
Mode,
|
||||
@ -1017,12 +1018,9 @@ where
|
||||
pub rx: RxCreatorFullDuplex<'d, DM>,
|
||||
}
|
||||
|
||||
impl<'d, DM> ParlIoFullDuplex<'d, DM>
|
||||
where
|
||||
DM: Mode,
|
||||
{
|
||||
impl<'d> ParlIoFullDuplex<'d, Blocking> {
|
||||
/// Create a new instance of [ParlIoFullDuplex]
|
||||
pub fn new<CH>(
|
||||
pub fn new<CH, DM>(
|
||||
_parl_io: impl Peripheral<P = peripherals::PARL_IO> + 'd,
|
||||
dma_channel: Channel<'d, CH, DM>,
|
||||
tx_descriptors: &'static mut [DmaDescriptor],
|
||||
@ -1030,8 +1028,11 @@ where
|
||||
frequency: HertzU32,
|
||||
) -> Result<Self, Error>
|
||||
where
|
||||
DM: Mode,
|
||||
CH: DmaChannelConvert<<PARL_IO as DmaEligible>::Dma>,
|
||||
Channel<'d, CH, Blocking>: From<Channel<'d, CH, DM>>,
|
||||
{
|
||||
let dma_channel = Channel::<'d, CH, Blocking>::from(dma_channel);
|
||||
internal_init(frequency)?;
|
||||
|
||||
Ok(Self {
|
||||
@ -1047,9 +1048,29 @@ where
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl ParlIoFullDuplex<'_, Blocking> {
|
||||
/// Convert to an async version.
|
||||
pub fn into_async(self) -> ParlIoFullDuplex<'d, Async> {
|
||||
let channel = Channel {
|
||||
tx: self.tx.tx_channel,
|
||||
rx: self.rx.rx_channel,
|
||||
phantom: PhantomData::<Blocking>,
|
||||
};
|
||||
let channel = channel.into_async();
|
||||
ParlIoFullDuplex {
|
||||
tx: TxCreatorFullDuplex {
|
||||
tx_channel: channel.tx,
|
||||
descriptors: self.tx.descriptors,
|
||||
phantom: PhantomData,
|
||||
},
|
||||
rx: RxCreatorFullDuplex {
|
||||
rx_channel: channel.rx,
|
||||
descriptors: self.rx.descriptors,
|
||||
phantom: PhantomData,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the interrupt handler, enables it with
|
||||
/// [crate::interrupt::Priority::min()]
|
||||
///
|
||||
@ -1087,6 +1108,30 @@ impl InterruptConfigurable for ParlIoFullDuplex<'_, Blocking> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d> ParlIoFullDuplex<'d, Async> {
|
||||
/// Convert to a blocking version.
|
||||
pub fn into_blocking(self) -> ParlIoFullDuplex<'d, Blocking> {
|
||||
let channel = Channel {
|
||||
tx: self.tx.tx_channel,
|
||||
rx: self.rx.rx_channel,
|
||||
phantom: PhantomData::<Async>,
|
||||
};
|
||||
let channel = channel.into_blocking();
|
||||
ParlIoFullDuplex {
|
||||
tx: TxCreatorFullDuplex {
|
||||
tx_channel: channel.tx,
|
||||
descriptors: self.tx.descriptors,
|
||||
phantom: PhantomData,
|
||||
},
|
||||
rx: RxCreatorFullDuplex {
|
||||
rx_channel: channel.rx,
|
||||
descriptors: self.rx.descriptors,
|
||||
phantom: PhantomData,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Parallel IO in half duplex / TX only mode
|
||||
pub struct ParlIoTxOnly<'d, DM>
|
||||
where
|
||||
|
Loading…
x
Reference in New Issue
Block a user