Skip to content

Commit 2c16f46

Browse files
Merge #260
260: add spi traits r=richardeoin a=andrewgazelka # Background SPIs didn't have proper traits, so it was hard/impossible to be generic overall SPis. # Description - Added `SpiEnabledExt` for enabled SPIs - Added `SpiDisabledExt` for disabled SPIs - Added `SpiAllExt` which `SpiEnabledExt` and `SpiDisabledExt` must implement. # Questions - These changes are breaking as people previously using the Spi will need to `use Spi{Enabled,Disabled,All}Ext`. We could also make the traits delegate to the previously existing implementations, but this might not be as clean in terms of hal code imo—and the version is `< 1.x.y` anyway. Thoughts? Co-authored-by: Andrew Gazelka <andrew.gazelka@gmail.com>
2 parents cee3b0e + 8b35339 commit 2c16f46

File tree

3 files changed

+175
-70
lines changed

3 files changed

+175
-70
lines changed

src/dma/macros.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ macro_rules! peripheral_target_instance {
125125
unsafe impl TargetAddress<M2P> for spi::Spi<$peripheral, spi::Disabled, $size> {
126126
#[inline(always)]
127127
fn address(&self) -> usize {
128+
use spi::SpiAll;
128129
&self.inner().$txreg as *const _ as usize
129130
}
130131

@@ -136,6 +137,7 @@ macro_rules! peripheral_target_instance {
136137
unsafe impl TargetAddress<P2M> for spi::Spi<$peripheral, spi::Disabled, $size> {
137138
#[inline(always)]
138139
fn address(&self) -> usize {
140+
use spi::SpiAll;
139141
&self.inner().$rxreg as *const _ as usize
140142
}
141143

src/prelude.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
pub use embedded_hal::prelude::*;
33

44
pub use crate::adc::AdcExt as _stm32h7xx_hal_adc_AdcExt;
5+
56
#[cfg(feature = "crc")]
67
pub use crate::crc::CrcExt as _stm32h7xx_hal_crc_CrcExt;
78
pub use crate::dac::DacExt as _stm32h7xx_hal_dac_DacExt;
@@ -22,6 +23,9 @@ pub use crate::sai::SaiPdmExt as _stm32h7xx_hal_spi_SaiPdmExt;
2223
#[cfg(feature = "sdmmc")]
2324
pub use crate::sdmmc::SdmmcExt as _stm32h7xx_hal_sdmmc_SdmmcExt;
2425
pub use crate::serial::SerialExt as _stm32h7xx_hal_serial_SerialExt;
26+
pub use crate::spi::SpiAll as _stm32h7xx_hal_spi_SpiAll;
27+
pub use crate::spi::SpiDisabled as _stm32h7xx_hal_spi_SpiDisabled;
28+
pub use crate::spi::SpiEnabled as _stm32h7xx_hal_spi_SpiEnabled;
2529
pub use crate::spi::SpiExt as _stm32h7xx_hal_spi_SpiExt;
2630
pub use crate::time::U32Ext as _stm32h7xx_hal_time_U32Ext;
2731
pub use crate::timer::TimerExt as _stm32h7xx_hal_timer_TimerExt;

0 commit comments

Comments
 (0)