diff options
| author | xoviat <[email protected]> | 2025-12-08 08:19:24 -0600 |
|---|---|---|
| committer | xoviat <[email protected]> | 2025-12-08 08:19:24 -0600 |
| commit | c93da8fc6d76cd6978c0cfbfb3ab42b0285af8d8 (patch) | |
| tree | e745116af2890bdd54821eeb44aed44a3cffff3b /embassy-stm32/src/spi | |
| parent | 2a738c147111569e4f0968020eec6fb5d5d4e754 (diff) | |
low-power: use scoped block stop
Co-authored-by: hjeldin <[email protected]>
Diffstat (limited to 'embassy-stm32/src/spi')
| -rw-r--r-- | embassy-stm32/src/spi/mod.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/embassy-stm32/src/spi/mod.rs b/embassy-stm32/src/spi/mod.rs index 3b39fd2fb..c90e0cef4 100644 --- a/embassy-stm32/src/spi/mod.rs +++ b/embassy-stm32/src/spi/mod.rs | |||
| @@ -230,7 +230,7 @@ impl<'d, M: PeriMode, CM: CommunicationMode> Spi<'d, M, CM> { | |||
| 230 | let cpol = config.raw_polarity(); | 230 | let cpol = config.raw_polarity(); |
| 231 | let lsbfirst = config.raw_byte_order(); | 231 | let lsbfirst = config.raw_byte_order(); |
| 232 | 232 | ||
| 233 | self.info.rcc.enable_and_reset(); | 233 | self.info.rcc.enable_and_reset_without_stop(); |
| 234 | 234 | ||
| 235 | /* | 235 | /* |
| 236 | - Software NSS management (SSM = 1) | 236 | - Software NSS management (SSM = 1) |
| @@ -848,6 +848,7 @@ impl<'d> Spi<'d, Async, Master> { | |||
| 848 | impl<'d, CM: CommunicationMode> Spi<'d, Async, CM> { | 848 | impl<'d, CM: CommunicationMode> Spi<'d, Async, CM> { |
| 849 | /// SPI write, using DMA. | 849 | /// SPI write, using DMA. |
| 850 | pub async fn write<W: Word>(&mut self, data: &[W]) -> Result<(), Error> { | 850 | pub async fn write<W: Word>(&mut self, data: &[W]) -> Result<(), Error> { |
| 851 | let _scoped_block_stop = self.info.rcc.block_stop(); | ||
| 851 | if data.is_empty() { | 852 | if data.is_empty() { |
| 852 | return Ok(()); | 853 | return Ok(()); |
| 853 | } | 854 | } |
| @@ -879,6 +880,7 @@ impl<'d, CM: CommunicationMode> Spi<'d, Async, CM> { | |||
| 879 | /// SPI read, using DMA. | 880 | /// SPI read, using DMA. |
| 880 | #[cfg(any(spi_v4, spi_v5, spi_v6))] | 881 | #[cfg(any(spi_v4, spi_v5, spi_v6))] |
| 881 | pub async fn read<W: Word>(&mut self, data: &mut [W]) -> Result<(), Error> { | 882 | pub async fn read<W: Word>(&mut self, data: &mut [W]) -> Result<(), Error> { |
| 883 | let _scoped_block_stop = self.info.rcc.block_stop(); | ||
| 882 | if data.is_empty() { | 884 | if data.is_empty() { |
| 883 | return Ok(()); | 885 | return Ok(()); |
| 884 | } | 886 | } |
| @@ -966,6 +968,7 @@ impl<'d, CM: CommunicationMode> Spi<'d, Async, CM> { | |||
| 966 | /// SPI read, using DMA. | 968 | /// SPI read, using DMA. |
| 967 | #[cfg(any(spi_v1, spi_v2, spi_v3))] | 969 | #[cfg(any(spi_v1, spi_v2, spi_v3))] |
| 968 | pub async fn read<W: Word>(&mut self, data: &mut [W]) -> Result<(), Error> { | 970 | pub async fn read<W: Word>(&mut self, data: &mut [W]) -> Result<(), Error> { |
| 971 | let _scoped_block_stop = self.info.rcc.block_stop(); | ||
| 969 | if data.is_empty() { | 972 | if data.is_empty() { |
| 970 | return Ok(()); | 973 | return Ok(()); |
| 971 | } | 974 | } |
| @@ -1013,6 +1016,7 @@ impl<'d, CM: CommunicationMode> Spi<'d, Async, CM> { | |||
| 1013 | } | 1016 | } |
| 1014 | 1017 | ||
| 1015 | async fn transfer_inner<W: Word>(&mut self, read: *mut [W], write: *const [W]) -> Result<(), Error> { | 1018 | async fn transfer_inner<W: Word>(&mut self, read: *mut [W], write: *const [W]) -> Result<(), Error> { |
| 1019 | let _scoped_block_stop = self.info.rcc.block_stop(); | ||
| 1016 | assert_eq!(read.len(), write.len()); | 1020 | assert_eq!(read.len(), write.len()); |
| 1017 | if read.len() == 0 { | 1021 | if read.len() == 0 { |
| 1018 | return Ok(()); | 1022 | return Ok(()); |
| @@ -1064,6 +1068,8 @@ impl<'d, CM: CommunicationMode> Spi<'d, Async, CM> { | |||
| 1064 | /// The transfer runs for `max(read.len(), write.len())` bytes. If `read` is shorter extra bytes are ignored. | 1068 | /// The transfer runs for `max(read.len(), write.len())` bytes. If `read` is shorter extra bytes are ignored. |
| 1065 | /// If `write` is shorter it is padded with zero bytes. | 1069 | /// If `write` is shorter it is padded with zero bytes. |
| 1066 | pub async fn transfer<W: Word>(&mut self, read: &mut [W], write: &[W]) -> Result<(), Error> { | 1070 | pub async fn transfer<W: Word>(&mut self, read: &mut [W], write: &[W]) -> Result<(), Error> { |
| 1071 | let _scoped_block_stop = self.info.rcc.block_stop(); | ||
| 1072 | |||
| 1067 | self.transfer_inner(read, write).await | 1073 | self.transfer_inner(read, write).await |
| 1068 | } | 1074 | } |
| 1069 | 1075 | ||
| @@ -1071,6 +1077,8 @@ impl<'d, CM: CommunicationMode> Spi<'d, Async, CM> { | |||
| 1071 | /// | 1077 | /// |
| 1072 | /// This writes the contents of `data` on MOSI, and puts the received data on MISO in `data`, at the same time. | 1078 | /// This writes the contents of `data` on MOSI, and puts the received data on MISO in `data`, at the same time. |
| 1073 | pub async fn transfer_in_place<W: Word>(&mut self, data: &mut [W]) -> Result<(), Error> { | 1079 | pub async fn transfer_in_place<W: Word>(&mut self, data: &mut [W]) -> Result<(), Error> { |
| 1080 | let _scoped_block_stop = self.info.rcc.block_stop(); | ||
| 1081 | |||
| 1074 | self.transfer_inner(data, data).await | 1082 | self.transfer_inner(data, data).await |
| 1075 | } | 1083 | } |
| 1076 | } | 1084 | } |
