From 8352d13cfd7ea46abf8bd2bb460ff1ce32e7da8d Mon Sep 17 00:00:00 2001 From: swanandx <73115739+swanandx@users.noreply.github.com> Date: Wed, 3 Jan 2024 19:25:09 +0530 Subject: [PATCH] feat: new_txonly_nosck in spim --- embassy-nrf/src/spim.rs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index 5d3c3268c..ab16491a5 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs @@ -99,7 +99,7 @@ impl<'d, T: Instance> Spim<'d, T> { into_ref!(sck, miso, mosi); Self::new_inner( spim, - sck.map_into(), + Some(sck.map_into()), Some(miso.map_into()), Some(mosi.map_into()), config, @@ -115,7 +115,7 @@ impl<'d, T: Instance> Spim<'d, T> { config: Config, ) -> Self { into_ref!(sck, mosi); - Self::new_inner(spim, sck.map_into(), None, Some(mosi.map_into()), config) + Self::new_inner(spim, Some(sck.map_into()), None, Some(mosi.map_into()), config) } /// Create a new SPIM driver, capable of RX only (MISO only). @@ -127,12 +127,23 @@ impl<'d, T: Instance> Spim<'d, T> { config: Config, ) -> Self { into_ref!(sck, miso); - Self::new_inner(spim, sck.map_into(), Some(miso.map_into()), None, config) + Self::new_inner(spim, Some(sck.map_into()), Some(miso.map_into()), None, config) + } + + /// Create a new SPIM driver, capable of TX only (MOSI only), without SCK pin. + pub fn new_txonly_nosck( + spim: impl Peripheral
+ 'd,
+ _irq: impl interrupt::typelevel::Binding + 'd,
+ config: Config,
+ ) -> Self {
+ into_ref!(mosi);
+ Self::new_inner(spim, None, None, Some(mosi.map_into()), config)
}
fn new_inner(
spim: impl Peripheral + 'd,
- sck: PeripheralRef<'d, AnyPin>,
+ sck: Option