From 1adf2b4ae186bbff19a1c9ee1d613f6ef0d2b031 Mon Sep 17 00:00:00 2001 From: Jan Niehusmann Date: Sat, 24 Aug 2024 18:11:53 +0000 Subject: [PATCH] Port SPI changes from rp2040-hal to rp235x-hal The updates from #831 were only applied to rp2040-hal. This patch ports them to rp235x-hal. --- rp235x-hal/src/spi.rs | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/rp235x-hal/src/spi.rs b/rp235x-hal/src/spi.rs index 0414342df..61cf85f85 100644 --- a/rp235x-hal/src/spi.rs +++ b/rp235x-hal/src/spi.rs @@ -273,26 +273,9 @@ impl, const DS: u8> Spi, const DS: u8> Spi { - /// Create new not initialized Spi bus. Initialize it with [`.init`][Self::init] - /// or [`.init_slave`][Self::init_slave]. - /// - /// Valid pin sets are in the form of `(Tx, Sck)` or `(Tx, Rx, Sck)` - /// - /// If you pins are dynamically identified (`Pin`) they will first need to pass - /// validation using their corresponding [`ValidatedPinXX`](ValidatedPinTx). - pub fn new(device: D, pins: P) -> Spi { - Spi { - device, - pins, - state: PhantomData, - } - } /// Set format and datasize - fn set_format(&mut self, data_bits: u8, frame_format: FrameFormat) { + pub fn set_format(&mut self, data_bits: u8, frame_format: FrameFormat) { self.device.sspcr0().modify(|_, w| unsafe { w.dss().bits(data_bits - 1).frf().bits(match &frame_format { FrameFormat::MotorolaSpi(_) => 0x00, @@ -313,6 +296,23 @@ impl, const DS: u8> Spi { w }); } +} + +impl, const DS: u8> Spi { + /// Create new not initialized Spi bus. Initialize it with [`.init`][Self::init] + /// or [`.init_slave`][Self::init_slave]. + /// + /// Valid pin sets are in the form of `(Tx, Sck)` or `(Tx, Rx, Sck)` + /// + /// If your pins are dynamically identified (`Pin`) they will first need to pass + /// validation using their corresponding [`ValidatedPinXX`](ValidatedPinTx). + pub fn new(device: D, pins: P) -> Spi { + Spi { + device, + pins, + state: PhantomData, + } + } /// Set master/slave fn set_slave(&mut self, slave: bool) {