Skip to content

Commit

Permalink
Deprecate spi_common module
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeaurivage committed Aug 15, 2021
1 parent 1361d62 commit 5babe9a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ pub mod common {
pub use crate::sercom;
pub use crate::sleeping_delay;
#[cfg(feature = "device")]
#[allow(deprecated)]
pub use crate::spi_common;
pub use crate::time;
pub use crate::timer_params;
Expand Down
1 change: 1 addition & 0 deletions hal/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pub use crate::eic::pin::EicPin;
#[allow(deprecated)]
pub use crate::gpio::v1::GpioExt as _atsamd21_hal_gpio_GpioExt;
#[allow(deprecated)]
pub use crate::spi_common::CommonSpi as _atsamd_hal_spi_common_CommonSpi;
pub use crate::time::U32Ext as _atsamd21_hal_time_U32Ext;
pub use crate::timer_traits::InterruptDrivenTimer as _atsamd_hal_timer_traits_InterruptDrivenTimer;
Expand Down
8 changes: 7 additions & 1 deletion hal/src/spi_common.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
/// Consolidated common logic for dealing with ATSAMD SPI peripherals.
#![deprecated(
since = "0.13.0",
note = "The `spi_common` module is deprecated, and will be removed in a subsequent release.
Please use the `sercom::v2::spi::AnySpi` trait instead."
)]

use crate::hal::spi::{Mode, Phase, Polarity};
use crate::time::{Hertz, U32Ext};

Expand All @@ -13,6 +18,7 @@ use crate::target_device::sercom0::SPI;
))]
use crate::target_device::sercom0::SPIM as SPI;

/// Consolidated common logic for dealing with ATSAMD SPI peripherals.
pub trait CommonSpi {
/// Helper for accessing the spi member of the sercom instance
fn spi(&self) -> &SPI;
Expand Down
4 changes: 4 additions & 0 deletions hal/src/thumbv6m/sercom/v1/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::clock;
use crate::hal::spi::{FullDuplex, Mode, Phase, Polarity};
use crate::sercom::v1::pads::CompatiblePad;
use crate::sercom::v2::*;
#[allow(deprecated)]
use crate::spi_common::CommonSpi;
use crate::target_device::sercom0::SPI;
use crate::target_device::{PM, SERCOM0, SERCOM1};
Expand Down Expand Up @@ -126,6 +127,7 @@ macro_rules! spi_master {
sercom: $SERCOM,
}

#[allow(deprecated)]
impl<MISO, MOSI, SCK> CommonSpi for $Type<MISO, MOSI, SCK> {
/// Helper for accessing the spi member of the sercom instance
fn spi(&self) -> &SPI {
Expand All @@ -138,6 +140,7 @@ macro_rules! spi_master {
}
}

#[allow(deprecated)]
impl<MISO, MOSI, SCK> $Type<MISO, MOSI, SCK> {
/// Power on and configure SERCOMX to work as an SPI Master operating
/// with the specified frequency and SPI Mode. The padout specifies
Expand Down Expand Up @@ -232,6 +235,7 @@ macro_rules! spi_master {
}
}

#[allow(deprecated)]
impl<MISO, MOSI, SCK> FullDuplex<u8> for $Type<MISO, MOSI, SCK> {
type Error = Error;

Expand Down
4 changes: 4 additions & 0 deletions hal/src/thumbv7em/sercom/v1/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::clock;
use crate::hal::spi::{FullDuplex, Mode, Phase, Polarity};
use crate::sercom::v1::pads::CompatiblePad;
use crate::sercom::v2::*;
#[allow(deprecated)]
use crate::spi_common::CommonSpi;
use crate::target_device::sercom0::SPIM;
use crate::target_device::{MCLK, SERCOM0, SERCOM1, SERCOM2, SERCOM3, SERCOM4, SERCOM5};
Expand Down Expand Up @@ -127,6 +128,7 @@ macro_rules! spi_master {
sercom: $SERCOM,
}

#[allow(deprecated)]
impl<MISO, MOSI, SCK> CommonSpi for $Type<MISO, MOSI, SCK> {
/// Helper for accessing the spi member of the sercom instance
fn spi(&self) -> &SPIM {
Expand All @@ -139,6 +141,7 @@ macro_rules! spi_master {
}
}

#[allow(deprecated)]
impl<MISO, MOSI, SCK> $Type<MISO, MOSI, SCK> {
/// Power on and configure SERCOMX to work as an SPI Master operating
/// with the specified frequency and SPI Mode. The pinout specifies
Expand Down Expand Up @@ -229,6 +232,7 @@ macro_rules! spi_master {
}
}

#[allow(deprecated)]
impl<MISO, MOSI, SCK> FullDuplex<u8> for $Type<MISO, MOSI, SCK> {
type Error = Error;

Expand Down

0 comments on commit 5babe9a

Please sign in to comment.