diff options
| author | Timo Kröger <[email protected]> | 2022-06-24 14:31:30 +0200 |
|---|---|---|
| committer | Timo Kröger <[email protected]> | 2022-08-26 15:42:25 +0200 |
| commit | 61c666212fa04571a74c27f649526459a376aa8a (patch) | |
| tree | 404540d2c02e39e9c2ddebb7dc0a49fe4ff0c147 | |
| parent | 24ab21a7ddcf8dafd6f464e6d66c9011cc08047b (diff) | |
stm32wl: Do not require external SPI pins for SUBGHZ
For the Seeed Studio Lora-E5 those pins conflict with the radio frontend control GPIOS (PA4 and PA5).
| -rw-r--r-- | embassy-stm32/src/spi/mod.rs | 12 | ||||
| -rw-r--r-- | embassy-stm32/src/subghz/mod.rs | 7 | ||||
| -rw-r--r-- | examples/stm32wl/src/bin/lorawan.rs | 2 | ||||
| -rw-r--r-- | examples/stm32wl/src/bin/subghz.rs | 2 |
4 files changed, 16 insertions, 7 deletions
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index 26fb392ef..1a00f4187 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs | |||
| @@ -179,6 +179,18 @@ impl<'d, T: Instance, Tx, Rx> Spi<'d, T, Tx, Rx> { | |||
| 179 | ) | 179 | ) |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | /// Useful for on chip peripherals like SUBGHZ which are hardwired. | ||
| 183 | /// The bus can optionally be exposed externally with `Spi::new()` still. | ||
| 184 | pub fn new_internal( | ||
| 185 | peri: impl Peripheral<P = T> + 'd, | ||
| 186 | txdma: impl Peripheral<P = Tx> + 'd, | ||
| 187 | rxdma: impl Peripheral<P = Rx> + 'd, | ||
| 188 | freq: Hertz, | ||
| 189 | config: Config, | ||
| 190 | ) -> Self { | ||
| 191 | Self::new_inner(peri, None, None, None, txdma, rxdma, freq, config) | ||
| 192 | } | ||
| 193 | |||
| 182 | fn new_inner( | 194 | fn new_inner( |
| 183 | peri: impl Peripheral<P = T> + 'd, | 195 | peri: impl Peripheral<P = T> + 'd, |
| 184 | sck: Option<PeripheralRef<'d, AnyPin>>, | 196 | sck: Option<PeripheralRef<'d, AnyPin>>, |
diff --git a/embassy-stm32/src/subghz/mod.rs b/embassy-stm32/src/subghz/mod.rs index a74f9a6d5..33398fa1d 100644 --- a/embassy-stm32/src/subghz/mod.rs +++ b/embassy-stm32/src/subghz/mod.rs | |||
| @@ -81,7 +81,7 @@ pub use value_error::ValueError; | |||
| 81 | use crate::dma::NoDma; | 81 | use crate::dma::NoDma; |
| 82 | use crate::peripherals::SUBGHZSPI; | 82 | use crate::peripherals::SUBGHZSPI; |
| 83 | use crate::rcc::sealed::RccPeripheral; | 83 | use crate::rcc::sealed::RccPeripheral; |
| 84 | use crate::spi::{BitOrder, Config as SpiConfig, MisoPin, MosiPin, SckPin, Spi, MODE_0}; | 84 | use crate::spi::{BitOrder, Config as SpiConfig, Spi, MODE_0}; |
| 85 | use crate::time::Hertz; | 85 | use crate::time::Hertz; |
| 86 | use crate::{pac, Peripheral}; | 86 | use crate::{pac, Peripheral}; |
| 87 | 87 | ||
| @@ -212,9 +212,6 @@ impl<'d, Tx, Rx> SubGhz<'d, Tx, Rx> { | |||
| 212 | /// clock. | 212 | /// clock. |
| 213 | pub fn new( | 213 | pub fn new( |
| 214 | peri: impl Peripheral<P = SUBGHZSPI> + 'd, | 214 | peri: impl Peripheral<P = SUBGHZSPI> + 'd, |
| 215 | sck: impl Peripheral<P = impl SckPin<SUBGHZSPI>> + 'd, | ||
| 216 | mosi: impl Peripheral<P = impl MosiPin<SUBGHZSPI>> + 'd, | ||
| 217 | miso: impl Peripheral<P = impl MisoPin<SUBGHZSPI>> + 'd, | ||
| 218 | txdma: impl Peripheral<P = Tx> + 'd, | 215 | txdma: impl Peripheral<P = Tx> + 'd, |
| 219 | rxdma: impl Peripheral<P = Rx> + 'd, | 216 | rxdma: impl Peripheral<P = Rx> + 'd, |
| 220 | ) -> Self { | 217 | ) -> Self { |
| @@ -227,7 +224,7 @@ impl<'d, Tx, Rx> SubGhz<'d, Tx, Rx> { | |||
| 227 | let mut config = SpiConfig::default(); | 224 | let mut config = SpiConfig::default(); |
| 228 | config.mode = MODE_0; | 225 | config.mode = MODE_0; |
| 229 | config.bit_order = BitOrder::MsbFirst; | 226 | config.bit_order = BitOrder::MsbFirst; |
| 230 | let spi = Spi::new(peri, sck, mosi, miso, txdma, rxdma, clk, config); | 227 | let spi = Spi::new_internal(peri, txdma, rxdma, clk, config); |
| 231 | 228 | ||
| 232 | unsafe { wakeup() }; | 229 | unsafe { wakeup() }; |
| 233 | 230 | ||
diff --git a/examples/stm32wl/src/bin/lorawan.rs b/examples/stm32wl/src/bin/lorawan.rs index 7e8a8946d..fdd7eb8cf 100644 --- a/examples/stm32wl/src/bin/lorawan.rs +++ b/examples/stm32wl/src/bin/lorawan.rs | |||
| @@ -31,7 +31,7 @@ async fn main(_spawner: Spawner) { | |||
| 31 | let ctrl3 = Output::new(p.PC5.degrade(), Level::High, Speed::High); | 31 | let ctrl3 = Output::new(p.PC5.degrade(), Level::High, Speed::High); |
| 32 | let rfs = RadioSwitch::new(ctrl1, ctrl2, ctrl3); | 32 | let rfs = RadioSwitch::new(ctrl1, ctrl2, ctrl3); |
| 33 | 33 | ||
| 34 | let radio = SubGhz::new(p.SUBGHZSPI, p.PA5, p.PA7, p.PA6, NoDma, NoDma); | 34 | let radio = SubGhz::new(p.SUBGHZSPI, NoDma, NoDma); |
| 35 | 35 | ||
| 36 | let irq = interrupt::take!(SUBGHZ_RADIO); | 36 | let irq = interrupt::take!(SUBGHZ_RADIO); |
| 37 | static mut RADIO_STATE: SubGhzState<'static> = SubGhzState::new(); | 37 | static mut RADIO_STATE: SubGhzState<'static> = SubGhzState::new(); |
diff --git a/examples/stm32wl/src/bin/subghz.rs b/examples/stm32wl/src/bin/subghz.rs index c5e9bb597..8f674d796 100644 --- a/examples/stm32wl/src/bin/subghz.rs +++ b/examples/stm32wl/src/bin/subghz.rs | |||
| @@ -72,7 +72,7 @@ async fn main(_spawner: Spawner) { | |||
| 72 | unsafe { interrupt::SUBGHZ_RADIO::steal() }.disable(); | 72 | unsafe { interrupt::SUBGHZ_RADIO::steal() }.disable(); |
| 73 | }); | 73 | }); |
| 74 | 74 | ||
| 75 | let mut radio = SubGhz::new(p.SUBGHZSPI, p.PA5, p.PA7, p.PA6, NoDma, NoDma); | 75 | let mut radio = SubGhz::new(p.SUBGHZSPI, NoDma, NoDma); |
| 76 | 76 | ||
| 77 | defmt::info!("Radio ready for use"); | 77 | defmt::info!("Radio ready for use"); |
| 78 | 78 | ||
