diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000000..920a5cb68d7 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Unreleased Changes + +--- + +Changelog tracking started at v0.13 diff --git a/README.md b/README.md index 0ad7705ad60..50a998c590e 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,79 @@ $ cargo build --examples ## How to use a BSP (i.e. getting started writing your own code) +A BSP (**B**oard **S**upport **P**ackage) is a crate that contains definitions specific to a particular board. These generally contain pin definitions, sometimes helper functions to setup certain peripherals, as well as examples to quickly get up and running with your board. BSPs are separated into 2 tiers: + +* Tier 1 boards are guaranteed to be up to date with the latest version of `atsamd-hal` + +* Tier 2 boards are tied to a specific version of `atsamd-hal`. They are not guaranteed to be updated when a new version of `atsamd-hal` gets released. + +### Tier 1 BSPs + +* `feather_m0` + +* `feather_m4` + +* `metro_m0` + +* `metro_m4` + +* `pygamer` + +* `samd11_bare` + +* `wio_terminal` + + +### Tier 2 BSPs + +* `arduino_mkr1000` + +* `arduino_mkrvidor4000` + +* `arduino_mkrzero` + +* `arduino_nano33iot` + +* `atsame54_xpro` + +* `circuit_playground_express` + +* `edgebadge` + +* `gemma_m0` + +* `grand_central_m4` + +* `itsybitsy_m0` + +* `itsybitsy_m4` + +* `p1am_100` + +* `pfza_proto1` + +* `pyportal` + +* `qt_py_m0` + +* `samd21_mini` + +* `serpente` + +* `sodaq_one` + +* `sodaq_sara_aff` + +* `trellis_m4` + +* `trinket_m0` + +* `wio_lite_mg126` + +* `wio_lite_w600` + +* `xiao_m0` + To bootstrap your own project you should be able to copy/paste the Rust code from the examples folder within the folder of the BSP you've chosen. But you shouldn't copy the `Cargo.toml` file from there, since that's not only used for the examples, but also for the whole BSP itself. You want to make your own `Cargo.toml` file. If you're new to this and have no clue what you're doing then this is probably the line you want in there: ```rust diff --git a/boards/arduino_mkr1000/Cargo.toml b/boards/arduino_mkr1000/Cargo.toml index 2252b218fbf..317a489a3e9 100644 --- a/boards/arduino_mkr1000/Cargo.toml +++ b/boards/arduino_mkr1000/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "arduino_mkr1000" -version = "0.3.0" +version = "0.4.0" authors = ["Eric Rushing "] description = "Board Support crate for the Arduino MKR 1000 WiFi" keywords = ["no-std", "arm", "cortex-m", "embedded-hal"] @@ -19,8 +19,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.usb-device] diff --git a/boards/arduino_mkrvidor4000/Cargo.toml b/boards/arduino_mkrvidor4000/Cargo.toml index 19f45cd3f84..96fca7385d7 100644 --- a/boards/arduino_mkrvidor4000/Cargo.toml +++ b/boards/arduino_mkrvidor4000/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "arduino_mkrvidor4000" -version = "0.4.0" +version = "0.5.0" authors = ["Sameer Puri "] description = "Board Support crate for the Arduino MKR VIDOR 4000" keywords = ["no-std", "arm", "cortex-m", "embedded-hal", "arduino"] @@ -19,8 +19,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dev-dependencies] diff --git a/boards/arduino_mkrzero/Cargo.toml b/boards/arduino_mkrzero/Cargo.toml index d2dc50be0f6..7058923df92 100644 --- a/boards/arduino_mkrzero/Cargo.toml +++ b/boards/arduino_mkrzero/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "arduino_mkrzero" -version = "0.10.0" +version = "0.11.0" authors = ["Wez Furlong ", "David McGillicuddy "] description = "Board Support crate for the Arduino MKRZERO" keywords = ["no-std", "arm", "cortex-m", "embedded-hal", "arduino"] @@ -19,8 +19,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.usb-device] diff --git a/boards/arduino_nano33iot/Cargo.toml b/boards/arduino_nano33iot/Cargo.toml index bb7d6374887..818291ea3db 100644 --- a/boards/arduino_nano33iot/Cargo.toml +++ b/boards/arduino_nano33iot/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "arduino_nano33iot" -version = "0.4.0" +version = "0.5.0" authors = ["Gus Wynn "] description = "Board Support crate for the Arduino Nano 33 IOT" keywords = ["no-std", "arm", "cortex-m", "embedded-hal", "arduino"] @@ -19,8 +19,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.usb-device] diff --git a/boards/atsame54_xpro/Cargo.toml b/boards/atsame54_xpro/Cargo.toml index 71792cab397..70e98211b20 100644 --- a/boards/atsame54_xpro/Cargo.toml +++ b/boards/atsame54_xpro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "atsame54_xpro" -version = "0.2.0" +version = "0.3.0" authors = [ "Karsten Große " ] @@ -21,8 +21,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.usb-device] diff --git a/boards/circuit_playground_express/Cargo.toml b/boards/circuit_playground_express/Cargo.toml index 4532339c7fc..0cfd365d9e6 100644 --- a/boards/circuit_playground_express/Cargo.toml +++ b/boards/circuit_playground_express/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "circuit_playground_express" -version = "0.9.0" +version = "0.10.0" authors = ["Paul Sajna "] description = "Board Support crate for the Adafruit Circuit Playground Express" keywords = ["no-std", "arm", "cortex-m", "embedded-hal"] @@ -15,8 +15,7 @@ embedded-hal = "0.2.3" nb = "0.1" [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dev-dependencies] diff --git a/boards/edgebadge/Cargo.toml b/boards/edgebadge/Cargo.toml index 7658c3503f9..cd1a565bd68 100644 --- a/boards/edgebadge/Cargo.toml +++ b/boards/edgebadge/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "edgebadge" -version = "0.7.0" +version = "0.8.0" authors = ["Jacob Rosenthal <@jacobrosenthal>"] description = "Board Support crate for the Adafruit EdgeBadge" keywords = ["no-std", "arm", "cortex-m", "embedded-hal"] @@ -22,8 +22,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.micromath] diff --git a/boards/feather_m0/Cargo.toml b/boards/feather_m0/Cargo.toml index c62ca204283..9f5ddaadb88 100644 --- a/boards/feather_m0/Cargo.toml +++ b/boards/feather_m0/Cargo.toml @@ -20,7 +20,7 @@ optional = true [dependencies.atsamd-hal] path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.panic_rtt] diff --git a/boards/feather_m4/Cargo.toml b/boards/feather_m4/Cargo.toml index 60ef51b65cd..639f7541705 100644 --- a/boards/feather_m4/Cargo.toml +++ b/boards/feather_m4/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "feather_m4" -version = "0.7.0" +version = "0.8.0" edition = "2018" authors = ["Theodore DeRego "] description = "Board Support crate for the Adafruit Feather M4" @@ -20,8 +20,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.usb-device] diff --git a/boards/gemma_m0/Cargo.toml b/boards/gemma_m0/Cargo.toml index 050c3bae0aa..93dd7f0ecd3 100644 --- a/boards/gemma_m0/Cargo.toml +++ b/boards/gemma_m0/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gemma_m0" -version = "0.9.0" +version = "0.10.0" authors = ["Wez Furlong "] description = "Board Support crate for the Adafruit Gemma M0" keywords = ["no-std", "arm", "cortex-m", "embedded-hal"] @@ -19,8 +19,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dev-dependencies] diff --git a/boards/grand_central_m4/Cargo.toml b/boards/grand_central_m4/Cargo.toml index e7f9d7fefda..9c6e394a87e 100644 --- a/boards/grand_central_m4/Cargo.toml +++ b/boards/grand_central_m4/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "grand_central_m4" -version = "0.3.0" +version = "0.4.0" authors = [ "Dustin Little " ] @@ -22,8 +22,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.usb-device] diff --git a/boards/itsybitsy_m0/Cargo.toml b/boards/itsybitsy_m0/Cargo.toml index aadb7250ecb..d4499c9b879 100644 --- a/boards/itsybitsy_m0/Cargo.toml +++ b/boards/itsybitsy_m0/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "itsybitsy_m0" -version = "0.10.0" +version = "0.11.0" authors = ["Ben Bergman "] description = "Board Support crate for the Adafruit ItsyBitsy M0" keywords = ["no-std", "arm", "cortex-m", "embedded-hal"] @@ -22,8 +22,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.usb-device] diff --git a/boards/itsybitsy_m4/Cargo.toml b/boards/itsybitsy_m4/Cargo.toml index 3e947b47fd6..812c4cc56d6 100644 --- a/boards/itsybitsy_m4/Cargo.toml +++ b/boards/itsybitsy_m4/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "itsybitsy_m4" -version = "0.5.0" +version = "0.6.0" authors = [ "Nic Hartley ", "Tom ", @@ -25,8 +25,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.usb-device] diff --git a/boards/metro_m0/Cargo.toml b/boards/metro_m0/Cargo.toml index 6e4a9558d48..9faf6259feb 100644 --- a/boards/metro_m0/Cargo.toml +++ b/boards/metro_m0/Cargo.toml @@ -20,7 +20,7 @@ optional = true [dependencies.atsamd-hal] path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.rtic-monotonic] diff --git a/boards/metro_m0/src/lib.rs b/boards/metro_m0/src/lib.rs index e4ff88181c4..c9e6ff5cbf3 100644 --- a/boards/metro_m0/src/lib.rs +++ b/boards/metro_m0/src/lib.rs @@ -9,8 +9,8 @@ pub use hal::pac; use hal::clock::GenericClockController; use hal::prelude::*; -use hal::sercom::v2::{spi, Sercom4, Sercom5}; -use hal::sercom::{I2CMaster3, UART0}; +use hal::sercom::v2::{spi, uart, Sercom0, Sercom4, Sercom5}; +use hal::sercom::I2CMaster3; use hal::time::{Hertz, MegaHertz}; #[cfg(feature = "usb")] @@ -286,8 +286,11 @@ pub fn i2c_master( I2CMaster3::new(clock, baud, sercom3, pm, sda, scl) } +/// UART pads +pub type UartPads = uart::Pads; + /// UART device for the labelled RX & TX pins -pub type Uart = UART0; +pub type Uart = uart::Uart, uart::Duplex>; /// Convenience for setting up the labelled RX, TX pins to /// operate as a UART device running at the specified baud. @@ -302,8 +305,10 @@ pub fn uart( let gclk0 = clocks.gclk0(); let clock = &clocks.sercom0_core(&gclk0).unwrap(); let baud = baud.into(); - let pads = (uart_rx.into(), uart_tx.into()); - UART0::new(clock, baud, sercom0, pm, pads) + let pads = uart::Pads::default().rx(uart_rx.into()).tx(uart_tx.into()); + uart::Config::new(pm, sercom0, pads, clock.freq()) + .baud(baud, uart::BaudMode::Fractional(uart::Oversampling::Bits16)) + .enable() } #[cfg(feature = "usb")] diff --git a/boards/metro_m4/Cargo.toml b/boards/metro_m4/Cargo.toml index a8e984c2b65..fc65909a675 100644 --- a/boards/metro_m4/Cargo.toml +++ b/boards/metro_m4/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "metro_m4" -version = "0.8.0" +version = "0.9.0" authors = ["Paul Sajna ", "Wez Furlong "] description = "Board Support crate for the Adafruit Metro M4" keywords = ["no-std", "arm", "cortex-m", "embedded-hal"] @@ -19,8 +19,7 @@ version = "0.6.13" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.usb-device] diff --git a/boards/p1am_100/Cargo.toml b/boards/p1am_100/Cargo.toml index 3ba3cd29a98..df52305256e 100644 --- a/boards/p1am_100/Cargo.toml +++ b/boards/p1am_100/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "p1am_100" -version = "0.1.0" +version = "0.2.0" authors = ["Quentin Smith "] description = "Board Support crate for the Facts Engineering P1AM-100" keywords = ["no-std", "arm", "cortex-m", "embedded-hal"] @@ -23,8 +23,7 @@ version = "0.5.1" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.panic_rtt] diff --git a/boards/pfza_proto1/Cargo.toml b/boards/pfza_proto1/Cargo.toml index 0a2ec105255..aa48275ada4 100644 --- a/boards/pfza_proto1/Cargo.toml +++ b/boards/pfza_proto1/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pfza_proto1" -version = "0.4.0" +version = "0.5.0" authors = ["Michael van Niekerk "] description = "Board Support crate for the PathfinderZA Proto1" keywords = ["no-std", "arm", "cortex-m", "embedded-hal"] @@ -19,8 +19,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dev-dependencies] diff --git a/boards/pygamer/Cargo.toml b/boards/pygamer/Cargo.toml index 64be67b78d2..e896f4f259e 100644 --- a/boards/pygamer/Cargo.toml +++ b/boards/pygamer/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pygamer" -version = "0.7.0" +version = "0.8.0" authors = [ "Paul Sajna ", "Wez Furlong " @@ -25,8 +25,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.micromath] diff --git a/boards/pyportal/Cargo.toml b/boards/pyportal/Cargo.toml index 84508438b5b..0585385c317 100644 --- a/boards/pyportal/Cargo.toml +++ b/boards/pyportal/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pyportal" -version = "0.7.0" +version = "0.8.0" authors = [ "Shella Stephens ", @@ -23,8 +23,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dev-dependencies] diff --git a/boards/qt_py_m0/Cargo.toml b/boards/qt_py_m0/Cargo.toml index bce5856169f..57cab447c3b 100644 --- a/boards/qt_py_m0/Cargo.toml +++ b/boards/qt_py_m0/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "qt_py_m0" -version = "0.9.0" +version = "0.10.0" authors = ["Garret Kelly "] description = "Board Support crate for the Adafruit QT Py" keywords = ["no-std", "arm", "cortex-m", "embedded-hal"] @@ -14,18 +14,12 @@ cortex-m = "0.6" embedded-hal = "0.2.3" nb = "0.1" cortex-m-rt = { version = "0.6.12", optional = true } -atsamd-hal = { path = "../../hal", version = "0.12", default-features = false } usb-device = { version = "0.2", optional = true } usbd-serial = { version = "0.1", optional = true } -# [dependencies.cortex-m-rt] -# version = "0.6.12" -# optional = true - -# [dependencies.atsamd-hal] -# path = "../../hal" -# version = "0.12" -# default-features = false +[dependencies.atsamd-hal] +version = "0.13" +default-features = false [dev-dependencies] panic-halt = "0.2" diff --git a/boards/samd11_bare/Cargo.toml b/boards/samd11_bare/Cargo.toml index 7bb3e121b40..449da259812 100644 --- a/boards/samd11_bare/Cargo.toml +++ b/boards/samd11_bare/Cargo.toml @@ -20,12 +20,20 @@ optional = true [dependencies.atsamd-hal] path = "../../hal" -version = "0.12" +version = "0.13" default-features = false +[dependencies.cortex-m-semihosting] +version = "0.3" +optional = true + +[dependencies.panic-semihosting] +version = "0.5" +optional = true + [dev-dependencies] panic-halt = "0.2" -panic-probe = "0.1.0" +panic-probe = "0.2.0" rtt-target = { version = "0.3.0", features = ["cortex-m"] } [features] @@ -33,7 +41,7 @@ rtt-target = { version = "0.3.0", features = ["cortex-m"] } default = ["rt", "atsamd-hal/samd11c"] rt = ["cortex-m-rt", "atsamd-hal/samd11c-rt"] unproven = ["atsamd-hal/unproven"] -use_semihosting = [] +use_semihosting = ["cortex-m-semihosting", "panic-semihosting"] [profile.release] debug = true @@ -44,7 +52,7 @@ chip = "ATSAMD11C14A" [[example]] name = "adc" -required-features = ["unproven", "rt"] +required-features = ["unproven", "rt", "use_semihosting"] [[example]] name = "blinky_basic" diff --git a/boards/samd11_bare/examples/adc.rs b/boards/samd11_bare/examples/adc.rs index ede022251da..ae2dafe956c 100644 --- a/boards/samd11_bare/examples/adc.rs +++ b/boards/samd11_bare/examples/adc.rs @@ -14,15 +14,17 @@ #![no_std] #![no_main] +use panic_probe as _; + use bsp::hal; use samd11_bare as bsp; use bsp::entry; use hal::adc::Adc; use hal::clock::GenericClockController; +use hal::gpio::v2::*; use hal::pac::{CorePeripherals, Peripherals}; use hal::prelude::*; -use panic_probe as _; use rtt_target::{rprintln, rtt_init_print}; #[entry] @@ -39,10 +41,10 @@ fn main() -> ! { &mut peripherals.NVMCTRL, ); let mut delay = hal::delay::Delay::new(core.SYST, &mut clocks); - let mut pins = bsp::Pins::new(peripherals.PORT); + let pins = bsp::Pins::new(peripherals.PORT); let mut adc = Adc::adc(peripherals.ADC, &mut peripherals.PM, &mut clocks); - let mut a0 = pins.d1.into_function_b(&mut pins.port); + let mut a0: Pin<_, AlternateB> = pins.d1.into_mode(); loop { let data: u16 = adc.read(&mut a0).unwrap(); diff --git a/boards/samd11_bare/examples/blinky_basic.rs b/boards/samd11_bare/examples/blinky_basic.rs index 1693217d472..15f6535f7b2 100644 --- a/boards/samd11_bare/examples/blinky_basic.rs +++ b/boards/samd11_bare/examples/blinky_basic.rs @@ -1,35 +1,34 @@ #![no_std] #![no_main] -use bsp::hal; #[cfg(not(feature = "use_semihosting"))] use panic_halt as _; #[cfg(feature = "use_semihosting")] use panic_semihosting as _; + +use bsp::hal; +use bsp::pac; use samd11_bare as bsp; use bsp::entry; use hal::clock::GenericClockController; use hal::delay::Delay; -use hal::pac::{CorePeripherals, Peripherals}; use hal::prelude::*; +use pac::{CorePeripherals, Peripherals}; #[entry] fn main() -> ! { let mut peripherals = Peripherals::take().unwrap(); let core = CorePeripherals::take().unwrap(); - let mut clocks = GenericClockController::with_internal_32kosc( peripherals.GCLK, &mut peripherals.PM, &mut peripherals.SYSCTRL, &mut peripherals.NVMCTRL, ); - - let mut pins = bsp::Pins::new(peripherals.PORT); - let mut red_led = pins.d2.into_open_drain_output(&mut pins.port); + let pins = bsp::Pins::new(peripherals.PORT); + let mut red_led: bsp::Led = pins.d2.into(); let mut delay = Delay::new(core.SYST, &mut clocks); - loop { delay.delay_ms(200u8); red_led.set_high().unwrap(); diff --git a/boards/samd11_bare/examples/pwm.rs b/boards/samd11_bare/examples/pwm.rs index d68005bd1ba..27b3eb5604c 100644 --- a/boards/samd11_bare/examples/pwm.rs +++ b/boards/samd11_bare/examples/pwm.rs @@ -1,19 +1,22 @@ #![no_std] #![no_main] -use bsp::hal; #[cfg(not(feature = "use_semihosting"))] use panic_halt as _; #[cfg(feature = "use_semihosting")] use panic_semihosting as _; + use samd11_bare as bsp; -use cortex_m_rt::entry; +use bsp::{hal, pac}; + +use bsp::entry; use hal::clock::GenericClockController; use hal::delay::Delay; -use hal::pac::{CorePeripherals, Peripherals}; +use hal::gpio::v2::*; use hal::prelude::*; use hal::pwm::{Channel, Pwm0}; +use pac::{CorePeripherals, Peripherals}; #[entry] fn main() -> ! { @@ -27,10 +30,10 @@ fn main() -> ! { &mut peripherals.NVMCTRL, ); let mut delay = Delay::new(core.SYST, &mut clocks); - let mut pins = bsp::Pins::new(peripherals.PORT); + let pins = bsp::Pins::new(peripherals.PORT); - let _d1 = pins.d1.into_function_f(&mut pins.port); - let _d14 = pins.d14.into_function_f(&mut pins.port); + let _d1: Pin<_, AlternateF> = pins.d1.into_mode(); + let _d14: Pin<_, AlternateF> = pins.d14.into_mode(); let gclk0 = clocks.gclk0(); let mut pwm0 = Pwm0::new( diff --git a/boards/samd11_bare/examples/serial.rs b/boards/samd11_bare/examples/serial.rs index 4b491c3a62e..cf74be7ddb3 100644 --- a/boards/samd11_bare/examples/serial.rs +++ b/boards/samd11_bare/examples/serial.rs @@ -2,21 +2,25 @@ #![no_main] use bsp::hal; +use samd11_bare as bsp; + +use bsp::entry; +use hal::clock::GenericClockController; +use hal::prelude::*; + #[cfg(not(feature = "use_semihosting"))] use panic_halt as _; #[cfg(feature = "use_semihosting")] use panic_semihosting as _; -use samd11_bare as bsp; -use bsp::entry; -use hal::clock::GenericClockController; use hal::delay::Delay; use hal::pac::{CorePeripherals, Peripherals}; -use hal::prelude::*; -use hal::pac::gclk::clkctrl::GEN_A; -use hal::pac::gclk::genctrl::SRC_A; -use hal::sercom::{PadPin, Sercom0Pad0, Sercom0Pad1, UART0}; +use hal::pac::gclk::{clkctrl::GEN_A, genctrl::SRC_A}; +use hal::sercom::v2::{ + uart::{self, BaudMode, Oversampling}, + Sercom0, +}; #[entry] fn main() -> ! { @@ -35,29 +39,26 @@ fn main() -> ! { .get_gclk(GEN_A::GCLK2) .expect("Could not get clock 2"); - let mut pins = bsp::Pins::new(peripherals.PORT); + let pins = bsp::Pins::new(peripherals.PORT); let mut delay = Delay::new(core.SYST, &mut clocks); - let rx: Sercom0Pad1<_> = pins - .d1 - .into_pull_down_input(&mut pins.port) - .into_pad(&mut pins.port); - let tx: Sercom0Pad0<_> = pins - .d14 - .into_pull_down_input(&mut pins.port) - .into_pad(&mut pins.port); + let rx: bsp::UartRx = pins.d1.into(); + let tx: bsp::UartTx = pins.d14.into(); let uart_clk = clocks .sercom0_core(&gclk2) .expect("Could not configure sercom0 clock"); - let mut uart = UART0::new( - &uart_clk, - 9600.hz(), - peripherals.SERCOM0, + let pads = uart::Pads::::default().rx(rx).tx(tx); + + let mut uart = uart::Config::new( &mut peripherals.PM, - (rx, tx), - ); + peripherals.SERCOM0, + pads, + uart_clk.freq(), + ) + .baud(9600.hz(), BaudMode::Fractional(Oversampling::Bits16)) + .enable(); loop { for byte in b"Hello, world!" { diff --git a/boards/samd11_bare/examples/timer.rs b/boards/samd11_bare/examples/timer.rs index dc808a294b4..5f8647c6340 100644 --- a/boards/samd11_bare/examples/timer.rs +++ b/boards/samd11_bare/examples/timer.rs @@ -1,18 +1,21 @@ #![no_std] #![no_main] -use bsp::hal; #[cfg(not(feature = "use_semihosting"))] use panic_halt as _; #[cfg(feature = "use_semihosting")] use panic_semihosting as _; + use samd11_bare as bsp; +use bsp::hal; +use bsp::pac; + use bsp::entry; use hal::clock::GenericClockController; -use hal::pac::Peripherals; use hal::prelude::*; use hal::timer::TimerCounter; +use pac::Peripherals; #[entry] fn main() -> ! { @@ -30,8 +33,8 @@ fn main() -> ! { let mut timer = TimerCounter::tc1_(&timer_clock, peripherals.TC1, &mut peripherals.PM); timer.start(1u32.hz()); - let mut pins = bsp::Pins::new(peripherals.PORT); - let mut d2 = pins.d2.into_open_drain_output(&mut pins.port); + let pins = bsp::Pins::new(peripherals.PORT); + let mut d2: bsp::Led = pins.d2.into(); loop { d2.set_high().unwrap(); diff --git a/boards/samd11_bare/src/lib.rs b/boards/samd11_bare/src/lib.rs index 9823f732acd..7e97aa987fd 100644 --- a/boards/samd11_bare/src/lib.rs +++ b/boards/samd11_bare/src/lib.rs @@ -1,85 +1,116 @@ #![no_std] -pub use atsamd_hal as hal; - #[cfg(feature = "rt")] extern crate cortex_m_rt; #[cfg(feature = "rt")] pub use cortex_m_rt::entry; -use hal::prelude::*; -use hal::*; - -pub use hal::common::*; - +pub use atsamd_hal as hal; +pub use embedded_hal as ehal; pub use hal::pac; -use gpio::{Floating, Input, PfC, Port}; - use hal::clock::GenericClockController; -use hal::sercom::{I2CMaster0, PadPin, UART0}; +use hal::sercom::{ + v2::{ + uart::{self, BaudMode, Oversampling}, + Sercom0, + }, + I2CMaster0, +}; use hal::time::Hertz; -define_pins!( - /// Maps the pins to their physical pins. - struct Pins, - pac: pac, - - pin d1 = a5, - pin d2 = a8, - pin d3 = a9, - pin d4 = a14, - pin d5 = a15, - pin d6 = a28, // RST - pin d7 = a30, - - pin d8 = a31, - pin d9 = a24, - pin d10 = a25, +hal::bsp_pins! { + PA05 { + name: d1 + aliases: { + AlternateC: UartRx + } + } + PA08 { + name: d2 + aliases: { + PushPullOutput: Led + } + } + PA09 { + name: d3 + } + PA14 { + name: d4 + aliases: { + AlternateC: Sda + } + } + PA15 { + name: d5 + aliases: { + AlternateC: Scl + } + } + PA28 { + /// RST pin + name: d6 + } + PA30 { + name: d7 + } + PA31 { + name: d8 + } + PA24 { + name: d9 + } + PA25 { + name: d10 + } + PA02 { + name: d13 + } + PA04 { + name: d14 + aliases: { + AlternateC: UartTx + } + } +} - // 11 & 12 are GND/VCC +pub type UartPads = uart::Pads; - pin d13 = a2, - pin d14 = a4, -); +/// UART device for the labelled RX & TX pins +pub type Uart = uart::Uart, uart::Duplex>; /// Convenience for setting up the D1 and D14 pins to /// operate as UART RX/TX (respectively) running at the specified baud. -pub fn uart>( +pub fn uart( clocks: &mut GenericClockController, - baud: F, + baud: impl Into, sercom0: pac::SERCOM0, pm: &mut pac::PM, - d1: gpio::Pa5>, - d14: gpio::Pa4>, - port: &mut Port, -) -> UART0>, hal::sercom::Sercom0Pad2>, (), ()> -{ + rx: impl Into, + tx: impl Into, +) -> Uart { let gclk0 = clocks.gclk0(); - - UART0::new( - &clocks.sercom0_core(&gclk0).unwrap(), - baud.into(), - sercom0, - pm, - (d1.into_pad(port), d14.into_pad(port)), - ) + let clock = &clocks.sercom0_core(&gclk0).unwrap(); + let baud = baud.into(); + let pads = uart::Pads::default().rx(rx.into()).tx(tx.into()); + uart::Config::new(pm, sercom0, pads, clock.freq()) + .baud(baud, BaudMode::Fractional(Oversampling::Bits16)) + .enable() } +/// I2C master for the labelled SDA & SCL pins +pub type I2C = I2CMaster0; + /// Convenience for setting up the D4 and D5 pins to operate as I²C /// SDA/SDL (respectively) running at the specified baud. -pub fn i2c_master>( +pub fn i2c_master( clocks: &mut GenericClockController, - bus_speed: F, + bus_speed: impl Into, sercom0: pac::SERCOM0, pm: &mut pac::PM, - sda: gpio::Pa14>, - scl: gpio::Pa15>, - port: &mut Port, -) -> I2CMaster0< - hal::sercom::Sercom0Pad0>, - hal::sercom::Sercom0Pad1>, -> { + sda: impl Into, + scl: impl Into, +) -> I2C { let gclk0 = clocks.gclk0(); I2CMaster0::new( @@ -87,7 +118,7 @@ pub fn i2c_master>( bus_speed.into(), sercom0, pm, - sda.into_pad(port), - scl.into_pad(port), + sda.into(), + scl.into(), ) } diff --git a/boards/samd21_mini/Cargo.toml b/boards/samd21_mini/Cargo.toml index d4b8b956528..f2eea87ebb2 100644 --- a/boards/samd21_mini/Cargo.toml +++ b/boards/samd21_mini/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "samd21_mini" -version = "0.8.0" +version = "0.9.0" authors = ["Ze'ev Klapow "] description = "Board Support crate for the Sparkfun SAMD21 Mini Breakout" keywords = ["no-std", "arm", "cortex-m", "embedded-hal"] @@ -19,8 +19,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dev-dependencies] diff --git a/boards/serpente/Cargo.toml b/boards/serpente/Cargo.toml index 904316dd0ff..bde385ad507 100644 --- a/boards/serpente/Cargo.toml +++ b/boards/serpente/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "serpente" -version = "0.5.0" +version = "0.6.0" authors = ["Jens Andersen "] description = "Board Support crate for the Serpente board" keywords = ["no-std", "arm", "cortex-m", "embedded-hal"] @@ -19,8 +19,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dev-dependencies] diff --git a/boards/sodaq_one/Cargo.toml b/boards/sodaq_one/Cargo.toml index 9a7c73f229c..dc5bcb5de41 100644 --- a/boards/sodaq_one/Cargo.toml +++ b/boards/sodaq_one/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sodaq_one" -version = "0.8.0" +version = "0.9.0" authors = ["Robert Hennig "] description = "Board Support crate for the SODAQ ONE" keywords = ["no-std", "arm", "cortex-m", "embedded-hal"] @@ -19,8 +19,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dev-dependencies] diff --git a/boards/sodaq_sara_aff/Cargo.toml b/boards/sodaq_sara_aff/Cargo.toml index f44d720b32c..82ed496b211 100644 --- a/boards/sodaq_sara_aff/Cargo.toml +++ b/boards/sodaq_sara_aff/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "sodaq_sara_aff" -version = "0.7.0" +version = "0.8.0" authors = ["Stefan de Lange "] description = "Board Support crate for the Sodaq SARA AFF" keywords = ["no-std", "arm", "cortex-m", "embedded-hal"] @@ -19,8 +19,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dev-dependencies] diff --git a/boards/trellis_m4/Cargo.toml b/boards/trellis_m4/Cargo.toml index 07ff218d49d..2a8259c7a80 100644 --- a/boards/trellis_m4/Cargo.toml +++ b/boards/trellis_m4/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trellis_m4" -version = "0.8.0" +version = "0.9.0" authors = [ "Tony Arcieri ", "Paul Sajna ", @@ -30,8 +30,7 @@ version = "0.4" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.keypad] diff --git a/boards/trinket_m0/Cargo.toml b/boards/trinket_m0/Cargo.toml index 017c6a2c5c2..2e85fffd82f 100644 --- a/boards/trinket_m0/Cargo.toml +++ b/boards/trinket_m0/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "trinket_m0" -version = "0.9.0" +version = "0.10.0" authors = ["Ben Bergman "] description = "Board Support crate for the Adafruit Trinket M0" keywords = ["no-std", "arm", "cortex-m", "embedded-hal"] @@ -22,8 +22,7 @@ version = "~0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.usb-device] diff --git a/boards/wio_lite_mg126/Cargo.toml b/boards/wio_lite_mg126/Cargo.toml index e037929c77f..2dbf7401483 100644 --- a/boards/wio_lite_mg126/Cargo.toml +++ b/boards/wio_lite_mg126/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "wio_lite_mg126" -version = "0.2.0" +version = "0.3.0" authors = ["Max Khardin ", "Tom " @@ -43,8 +43,7 @@ generic-array = { version = "0.14", optional = true } seeed-erpc = { version = "0.1.1", optional = true } [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dev-dependencies] diff --git a/boards/xiao_m0/Cargo.toml b/boards/xiao_m0/Cargo.toml index 6e3a0c7ee7c..3020dc6bf53 100644 --- a/boards/xiao_m0/Cargo.toml +++ b/boards/xiao_m0/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xiao_m0" -version = "0.9.0" +version = "0.10.0" authors = ["Garret Kelly "] description = "Board support crate for the Seeed Studio Seeeduino XIAO" keywords = ["no-std", "arm", "cortex-m", "embedded-hal"] @@ -19,8 +19,7 @@ version = "0.6.12" optional = true [dependencies.atsamd-hal] -path = "../../hal" -version = "0.12" +version = "0.13" default-features = false [dependencies.usb-device] diff --git a/crates.json b/crates.json index 34566eeee0f..12944b918bb 100644 --- a/crates.json +++ b/crates.json @@ -33,7 +33,7 @@ "build": "cargo build --examples --features=unproven,usb,dma,rtic" }, "feather_m4": { - "tier": 1, + "tier": 2, "build": "cargo build --examples --features=unproven,usb" }, "gemma_m0": { @@ -78,7 +78,7 @@ }, "samd11_bare": { "tier": 1, - "build": "cargo build --release --examples --features=unproven" + "build": "cargo build --release --examples --features=unproven,rt,use-semihosting" }, "samd21_mini": { "tier": 2, diff --git a/hal/Cargo.toml b/hal/Cargo.toml index 660da465a4d..47cc7443dff 100644 --- a/hal/Cargo.toml +++ b/hal/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "atsamd-hal" -version = "0.12.0" +version = "0.13.0" authors = [ "Wez Furlong ", "Paul Sajna ", diff --git a/hal/src/delay.rs b/hal/src/delay.rs index 13f7ad0da05..efb131a37b1 100644 --- a/hal/src/delay.rs +++ b/hal/src/delay.rs @@ -4,8 +4,8 @@ use cortex_m::peripheral::syst::SystClkSource; use cortex_m::peripheral::SYST; use crate::clock::GenericClockController; +use crate::ehal::blocking::delay::{DelayMs, DelayUs}; use crate::time::Hertz; -use hal::blocking::delay::{DelayMs, DelayUs}; /// System timer (SysTick) as a delay provider pub struct Delay { diff --git a/hal/src/gpio/mod.rs b/hal/src/gpio/mod.rs index f4d91482c7b..d56d58e64b0 100644 --- a/hal/src/gpio/mod.rs +++ b/hal/src/gpio/mod.rs @@ -97,6 +97,8 @@ //! [`bsp_pins`]: crate::bsp_pins pub mod v1; + +#[allow(deprecated)] pub use v1::*; pub mod v2; diff --git a/hal/src/gpio/v1.rs b/hal/src/gpio/v1.rs index 7959abdb3a4..10fdd1095ba 100644 --- a/hal/src/gpio/v1.rs +++ b/hal/src/gpio/v1.rs @@ -13,12 +13,16 @@ //! use of type states to make the interface (ideally, or at least practically) //! impossible to misuse. -use crate::pac::PORT; - -use hal::digital::v2::OutputPin; +#![deprecated( + since = "0.13.0", + note = "The gpio::v1 module is deprecated, and will be removed in a subsequent release. + Please use the gpio::v2 module instead." +)] +use crate::ehal::digital::v2::OutputPin; #[cfg(feature = "unproven")] -use hal::digital::v2::{InputPin, StatefulOutputPin, ToggleableOutputPin}; +use crate::ehal::digital::v2::{InputPin, StatefulOutputPin, ToggleableOutputPin}; +use crate::pac::PORT; use crate::gpio::v2::{self, Alternate, AlternateConfig, AnyPin, OutputConfig}; pub use crate::gpio::v2::{PinId, PinMode}; diff --git a/hal/src/gpio/v2/dynpin.rs b/hal/src/gpio/v2/dynpin.rs index a04745a9a46..0fe77ba5975 100644 --- a/hal/src/gpio/v2/dynpin.rs +++ b/hal/src/gpio/v2/dynpin.rs @@ -61,9 +61,9 @@ use core::convert::TryFrom; use paste::paste; -use hal::digital::v2::OutputPin; +use crate::ehal::digital::v2::OutputPin; #[cfg(feature = "unproven")] -use hal::digital::v2::{InputPin, StatefulOutputPin, ToggleableOutputPin}; +use crate::ehal::digital::v2::{InputPin, StatefulOutputPin, ToggleableOutputPin}; use super::pin::*; use super::reg::RegisterInterface; diff --git a/hal/src/gpio/v2/pin.rs b/hal/src/gpio/v2/pin.rs index 5d9f2e47535..52220004163 100644 --- a/hal/src/gpio/v2/pin.rs +++ b/hal/src/gpio/v2/pin.rs @@ -99,9 +99,9 @@ use core::convert::Infallible; use core::marker::PhantomData; use core::mem::transmute; -use hal::digital::v2::OutputPin; +use crate::ehal::digital::v2::OutputPin; #[cfg(feature = "unproven")] -use hal::digital::v2::{InputPin, StatefulOutputPin, ToggleableOutputPin}; +use crate::ehal::digital::v2::{InputPin, StatefulOutputPin, ToggleableOutputPin}; use paste::paste; use crate::pac::PORT; diff --git a/hal/src/lib.rs b/hal/src/lib.rs index e378ed7d9f7..e276991442c 100644 --- a/hal/src/lib.rs +++ b/hal/src/lib.rs @@ -1,6 +1,12 @@ #![no_std] -pub extern crate embedded_hal as hal; +#[deprecated( + since = "0.13.0", + note = "`atsamd_hal::hal` is deprecated and will be removed in a future release. \ + Use `atsamd_hal::ehal` instead" +)] +pub use embedded_hal as hal; +pub use embedded_hal as ehal; pub use paste; @@ -61,6 +67,14 @@ pub use atsame54n as pac; #[cfg(feature = "same54p")] pub use atsame54p as pac; +#[deprecated( + since = "0.13.0", + note = "`atsamd_hal::target_device` is deprecated and will be removed in a future release. \ + Use `atsamd_hal::pac` instead" +)] +#[cfg(not(feature = "library"))] +pub use pac as target_device; + #[cfg(feature = "use_rtt")] pub use jlink_rtt; @@ -128,6 +142,11 @@ pub mod pad { } // This module maintains backwards compatibility within this major release +#[deprecated( + since = "0.13.0", + note = "The `common` module is deprecated and will be removed in a future + release. Directly use modules from atsamd_hal instead." +)] #[macro_use] pub mod common { #[cfg(feature = "device")] @@ -142,6 +161,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; @@ -169,23 +189,43 @@ pub mod common { // should be removed. #[cfg(feature = "samd51")] +#[deprecated( + since = "0.13.0", + note = "The `samd51` module is deprecated and will be removed in a future + release." +)] pub mod samd51 { #[cfg(feature = "unproven")] pub use crate::pwm; } +#[deprecated( + since = "0.13.0", + note = "The `same51` module is deprecated and will be removed in a future + release." +)] #[cfg(feature = "same51")] pub mod same51 { #[cfg(feature = "unproven")] pub use crate::pwm; } +#[deprecated( + since = "0.13.0", + note = "The `same53` module is deprecated and will be removed in a future + release." +)] #[cfg(feature = "same53")] pub mod same53 { #[cfg(feature = "unproven")] pub use crate::pwm; } +#[deprecated( + since = "0.13.0", + note = "The `same54` module is deprecated and will be removed in a future + release." +)] #[cfg(feature = "same54")] pub mod same54 { #[cfg(feature = "unproven")] diff --git a/hal/src/prelude.rs b/hal/src/prelude.rs index c13bac876c9..0be95d3878b 100644 --- a/hal/src/prelude.rs +++ b/hal/src/prelude.rs @@ -1,6 +1,8 @@ //! Import the prelude to gain convenient access to helper traits pub use crate::eic::pin::EicPin; -pub use crate::gpio::GpioExt as _atsamd21_hal_gpio_GpioExt; +#[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; @@ -8,11 +10,11 @@ pub use crate::timer_traits::InterruptDrivenTimer as _atsamd_hal_timer_traits_In // embedded-hal doesn’t yet have v2 in its prelude, so we need to // export it ourselves #[cfg(feature = "unproven")] -pub use hal::digital::v2::InputPin as _atsamd_hal_embedded_hal_digital_v2_InputPin; -pub use hal::digital::v2::OutputPin as _atsamd_hal_embedded_hal_digital_v2_OutputPin; +pub use crate::ehal::digital::v2::InputPin as _atsamd_hal_embedded_hal_digital_v2_InputPin; +pub use crate::ehal::digital::v2::OutputPin as _atsamd_hal_embedded_hal_digital_v2_OutputPin; #[cfg(feature = "unproven")] -pub use hal::digital::v2::ToggleableOutputPin as _atsamd_hal_embedded_hal_digital_v2_ToggleableOutputPin; +pub use crate::ehal::digital::v2::ToggleableOutputPin as _atsamd_hal_embedded_hal_digital_v2_ToggleableOutputPin; -pub use hal::prelude::*; +pub use crate::ehal::prelude::*; pub use nb; diff --git a/hal/src/rtc.rs b/hal/src/rtc.rs index 5e316092476..1086187e32e 100644 --- a/hal/src/rtc.rs +++ b/hal/src/rtc.rs @@ -1,11 +1,11 @@ //! Real-time clock/counter +use crate::ehal::timer::{CountDown, Periodic}; use crate::pac::rtc::{MODE0, MODE2}; use crate::pac::RTC; use crate::time::{Hertz, Nanoseconds}; use crate::timer_traits::InterruptDrivenTimer; use crate::typelevel::Sealed; use core::marker::PhantomData; -use hal::timer::{CountDown, Periodic}; use void::Void; #[cfg(feature = "sdmmc")] diff --git a/hal/src/sercom/v1/pads.rs b/hal/src/sercom/v1/pads.rs index 57e389a5cac..38cbd416ee6 100644 --- a/hal/src/sercom/v1/pads.rs +++ b/hal/src/sercom/v1/pads.rs @@ -29,6 +29,8 @@ //! //! [`free`]: Pad::free +#![allow(deprecated)] + use core::marker::PhantomData; use paste::paste; diff --git a/hal/src/sleeping_delay.rs b/hal/src/sleeping_delay.rs index 587e0bd25ac..9eb317417ad 100644 --- a/hal/src/sleeping_delay.rs +++ b/hal/src/sleeping_delay.rs @@ -2,9 +2,9 @@ use core::sync::atomic; use cortex_m::asm; +use crate::ehal::blocking::delay::{DelayMs, DelayUs}; use crate::time::U32Ext; use crate::timer_traits::InterruptDrivenTimer; -use hal::blocking::delay::{DelayMs, DelayUs}; const NUM_US_IN_S: u32 = 1_000_000; diff --git a/hal/src/spi_common.rs b/hal/src/spi_common.rs index a9ba7c62fbe..360430ebe75 100644 --- a/hal/src/spi_common.rs +++ b/hal/src/spi_common.rs @@ -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}; @@ -13,6 +18,7 @@ use crate::pac::sercom0::SPI; ))] use crate::pac::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; diff --git a/hal/src/thumbv6m/adc.rs b/hal/src/thumbv6m/adc.rs index d9164069d9d..bf04ef4cc81 100644 --- a/hal/src/thumbv6m/adc.rs +++ b/hal/src/thumbv6m/adc.rs @@ -1,5 +1,6 @@ //! Analogue-to-Digital Conversion use crate::clock::GenericClockController; +#[allow(deprecated)] use crate::gpio::v1; use crate::gpio::v2::*; use crate::hal::adc::{Channel, OneShot}; @@ -179,6 +180,7 @@ macro_rules! adc_pins { /// Implement [`Channel`] for [`v1::Pin`]s based on the implementations for /// `v2` [`Pin`]s +#[allow(deprecated)] impl Channel for v1::Pin where I: PinId, diff --git a/hal/src/thumbv6m/eic/pin.rs b/hal/src/thumbv6m/eic/pin.rs index a29c39df5c7..4972c714504 100644 --- a/hal/src/thumbv6m/eic/pin.rs +++ b/hal/src/thumbv6m/eic/pin.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use crate::gpio::{ self, v2::AnyPin, v2::FloatingInterrupt, v2::Pin, v2::PinId, v2::PinMode, v2::PullDownInterrupt, v2::PullUpInterrupt, Port, diff --git a/hal/src/thumbv6m/sercom/v1.rs b/hal/src/thumbv6m/sercom/v1.rs index b94fc5192e5..34e105e71a0 100644 --- a/hal/src/thumbv6m/sercom/v1.rs +++ b/hal/src/thumbv6m/sercom/v1.rs @@ -13,5 +13,9 @@ pub mod spi; pub mod uart; pub use self::i2c::*; + +#[allow(deprecated)] pub use self::spi::*; + +#[allow(deprecated)] pub use self::uart::*; diff --git a/hal/src/thumbv6m/sercom/v1/spi.rs b/hal/src/thumbv6m/sercom/v1/spi.rs index 4a59dff3b9f..83d35a3c66a 100644 --- a/hal/src/thumbv6m/sercom/v1/spi.rs +++ b/hal/src/thumbv6m/sercom/v1/spi.rs @@ -1,3 +1,9 @@ +#![deprecated( + since = "0.13.0", + note = "The `sercom::v1::spi` module is deprecated, and will be removed in a subsequent release. + Please use the `sercom::v2::spi` module instead." +)] + use core::marker::PhantomData; use crate::clock; @@ -10,6 +16,7 @@ use crate::pac::{SERCOM2, SERCOM3}; use crate::pac::{SERCOM4, SERCOM5}; use crate::sercom::v1::pads::CompatiblePad; use crate::sercom::v2::*; +#[allow(deprecated)] use crate::spi_common::CommonSpi; use crate::time::Hertz; @@ -120,6 +127,7 @@ macro_rules! spi_master { sercom: $SERCOM, } + #[allow(deprecated)] impl CommonSpi for $Type { /// Helper for accessing the spi member of the sercom instance fn spi(&self) -> &SPI { @@ -132,6 +140,7 @@ macro_rules! spi_master { } } + #[allow(deprecated)] impl $Type { /// Power on and configure SERCOMX to work as an SPI Master operating /// with the specified frequency and SPI Mode. The padout specifies @@ -226,6 +235,7 @@ macro_rules! spi_master { } } + #[allow(deprecated)] impl FullDuplex for $Type { type Error = Error; @@ -258,13 +268,16 @@ macro_rules! spi_master { } } - impl ::hal::blocking::spi::transfer::Default + impl ::embedded_hal::blocking::spi::transfer::Default + for $Type + { + } + impl ::embedded_hal::blocking::spi::write::Default for $Type { } - impl ::hal::blocking::spi::write::Default for $Type {} #[cfg(feature = "unproven")] - impl ::hal::blocking::spi::write_iter::Default + impl ::embedded_hal::blocking::spi::write_iter::Default for $Type { } diff --git a/hal/src/thumbv6m/sercom/v1/uart.rs b/hal/src/thumbv6m/sercom/v1/uart.rs index 16243bc47d9..4ff944cae50 100644 --- a/hal/src/thumbv6m/sercom/v1/uart.rs +++ b/hal/src/thumbv6m/sercom/v1/uart.rs @@ -1,3 +1,9 @@ +#![deprecated( + since = "0.13.0", + note = "The `sercom::v1::uart` module is deprecated, and will be removed in a subsequent release. + Please use the `sercom::v2::uart` module instead." +)] + use crate::clock; use crate::hal::blocking::serial::{write::Default, Write}; use crate::hal::serial; diff --git a/hal/src/thumbv6m/timer.rs b/hal/src/thumbv6m/timer.rs index 942faa45e8a..e835fb21da6 100644 --- a/hal/src/thumbv6m/timer.rs +++ b/hal/src/thumbv6m/timer.rs @@ -1,4 +1,5 @@ //! Working with timer counter hardware +use crate::ehal::timer::{CountDown, Periodic}; #[cfg(feature = "samd11")] use crate::pac::tc1::COUNT16; #[cfg(feature = "samd21")] @@ -10,7 +11,6 @@ use crate::pac::{PM, TC1}; #[cfg(feature = "samd21")] use crate::pac::{PM, TC3, TC4, TC5}; use crate::timer_params::TimerParams; -use hal::timer::{CountDown, Periodic}; use crate::clock; use crate::time::{Hertz, Nanoseconds}; @@ -188,19 +188,26 @@ tc! { TimerCounter5: (TC5, tc5_, Tc4Tc5Clock), } +#[deprecated( + since = "0.13.0", + note = "`SpinTimer` is deprecated, and will be removed in a subsequent release." +)] #[derive(Clone, Copy)] pub struct SpinTimer { cycles: u32, } +#[allow(deprecated)] impl SpinTimer { pub fn new(cycles: u32) -> SpinTimer { SpinTimer { cycles } } } +#[allow(deprecated)] impl Periodic for SpinTimer {} +#[allow(deprecated)] impl CountDown for SpinTimer { type Time = u32; diff --git a/hal/src/thumbv6m/watchdog.rs b/hal/src/thumbv6m/watchdog.rs index a4a0a80d3e2..41a77ecdf60 100644 --- a/hal/src/thumbv6m/watchdog.rs +++ b/hal/src/thumbv6m/watchdog.rs @@ -1,5 +1,5 @@ +use crate::ehal::watchdog; use crate::pac::WDT; -use hal::watchdog; /// WatchdogTimeout enumerates usable values for configuring /// the timeout of the watchdog peripheral. diff --git a/hal/src/thumbv7em/adc.rs b/hal/src/thumbv7em/adc.rs index dbf26ec00bc..511cfac6e55 100644 --- a/hal/src/thumbv7em/adc.rs +++ b/hal/src/thumbv7em/adc.rs @@ -1,6 +1,7 @@ //! Analogue-to-Digital Conversion use crate::clock::GenericClockController; #[rustfmt::skip] +#[allow(deprecated)] use crate::gpio::v1; use crate::gpio::v2::*; use crate::hal::adc::{Channel, OneShot}; @@ -288,6 +289,7 @@ macro_rules! adc_pins { /// Implement [`Channel`] for [`v1::Pin`]s based on the implementations for /// `v2` [`Pin`]s +#[allow(deprecated)] impl Channel for v1::Pin where I: PinId, diff --git a/hal/src/thumbv7em/eic/pin.rs b/hal/src/thumbv7em/eic/pin.rs index 8a61c6072a6..94a3de68abe 100644 --- a/hal/src/thumbv7em/eic/pin.rs +++ b/hal/src/thumbv7em/eic/pin.rs @@ -1,3 +1,5 @@ +#![allow(deprecated)] + use crate::gpio::{ self, v2::AnyPin, v2::FloatingInterrupt, v2::Pin, v2::PinId, v2::PinMode, v2::PullDownInterrupt, v2::PullUpInterrupt, Port, diff --git a/hal/src/thumbv7em/sercom/v1.rs b/hal/src/thumbv7em/sercom/v1.rs index df4fd2bf7f4..b6306ec7fda 100644 --- a/hal/src/thumbv7em/sercom/v1.rs +++ b/hal/src/thumbv7em/sercom/v1.rs @@ -12,5 +12,9 @@ pub mod spi; pub mod uart; pub use self::i2c::*; + +#[allow(deprecated)] pub use self::spi::*; + +#[allow(deprecated)] pub use self::uart::*; diff --git a/hal/src/thumbv7em/sercom/v1/spi.rs b/hal/src/thumbv7em/sercom/v1/spi.rs index 4ffb7c7d4b6..7ad8f076035 100644 --- a/hal/src/thumbv7em/sercom/v1/spi.rs +++ b/hal/src/thumbv7em/sercom/v1/spi.rs @@ -1,3 +1,9 @@ +#![deprecated( + since = "0.13.0", + note = "The `sercom::v1::spi` module is deprecated, and will be removed in a subsequent release. + Please use the `sercom::v2::spi` module instead." +)] + use core::marker::PhantomData; use crate::clock; @@ -8,6 +14,7 @@ use crate::pac::{MCLK, SERCOM0, SERCOM1, SERCOM2, SERCOM3, SERCOM4, SERCOM5}; use crate::pac::{SERCOM6, SERCOM7}; use crate::sercom::v1::pads::CompatiblePad; use crate::sercom::v2::*; +#[allow(deprecated)] use crate::spi_common::CommonSpi; use crate::time::Hertz; @@ -121,6 +128,7 @@ macro_rules! spi_master { sercom: $SERCOM, } + #[allow(deprecated)] impl CommonSpi for $Type { /// Helper for accessing the spi member of the sercom instance fn spi(&self) -> &SPIM { @@ -133,6 +141,7 @@ macro_rules! spi_master { } } + #[allow(deprecated)] impl $Type { /// Power on and configure SERCOMX to work as an SPI Master operating /// with the specified frequency and SPI Mode. The pinout specifies @@ -223,6 +232,7 @@ macro_rules! spi_master { } } + #[allow(deprecated)] impl FullDuplex for $Type { type Error = Error; @@ -255,13 +265,16 @@ macro_rules! spi_master { } } - impl ::hal::blocking::spi::transfer::Default + impl ::embedded_hal::blocking::spi::transfer::Default + for $Type + { + } + impl ::embedded_hal::blocking::spi::write::Default for $Type { } - impl ::hal::blocking::spi::write::Default for $Type {} #[cfg(feature = "unproven")] - impl ::hal::blocking::spi::write_iter::Default + impl ::embedded_hal::blocking::spi::write_iter::Default for $Type { } diff --git a/hal/src/thumbv7em/sercom/v1/uart.rs b/hal/src/thumbv7em/sercom/v1/uart.rs index c2a589931a3..99765e604a2 100644 --- a/hal/src/thumbv7em/sercom/v1/uart.rs +++ b/hal/src/thumbv7em/sercom/v1/uart.rs @@ -1,3 +1,9 @@ +#![deprecated( + since = "0.13.0", + note = "The `sercom::v1::uart` module is deprecated, and will be removed in a subsequent release. + Please use the `sercom::v2::uart` module instead." +)] + use crate::clock; use crate::hal::blocking::serial::{write::Default, Write}; use crate::hal::serial; diff --git a/hal/src/thumbv7em/timer.rs b/hal/src/thumbv7em/timer.rs index d6fac32b0a8..cfe1793d91a 100644 --- a/hal/src/thumbv7em/timer.rs +++ b/hal/src/thumbv7em/timer.rs @@ -184,19 +184,26 @@ tc! { TimerCounter5: (TC5, tc5_, Tc4Tc5Clock, apbcmask), } +#[deprecated( + since = "0.13.0", + note = "`SpinTimer` is deprecated, and will be removed in a subsequent release." +)] #[derive(Clone, Copy)] pub struct SpinTimer { cycles: u32, } +#[allow(deprecated)] impl SpinTimer { pub fn new(cycles: u32) -> SpinTimer { SpinTimer { cycles } } } +#[allow(deprecated)] impl Periodic for SpinTimer {} +#[allow(deprecated)] impl CountDown for SpinTimer { type Time = u32; diff --git a/hal/src/thumbv7em/watchdog.rs b/hal/src/thumbv7em/watchdog.rs index 944e53712c4..a4faa1a5f04 100644 --- a/hal/src/thumbv7em/watchdog.rs +++ b/hal/src/thumbv7em/watchdog.rs @@ -1,5 +1,5 @@ +use crate::ehal::watchdog; use crate::pac::WDT; -use hal::watchdog; /// WatchdogTimeout enumerates usable values for configuring /// the timeout of the watchdog peripheral.