Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename stm32 to pac #101

Merged
merged 1 commit into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ let clocks = rcc
- The feature gate requires you to select a subvariant if possible. ([#75](https://github.com/stm32-rs/stm32f3xx-hal/pull/75))
- Split up `stm32f302` into sub-targets `stm32f302xb`,`stm32f302xc`,`stm32f302xd`,`stm32f302xe`
- Bump `stm32f3` dependency to `0.11.0` ([#97](https://github.com/stm32-rs/stm32f3xx-hal/pull/97))
- The `stm32f3` reexport is now renamed from `stm32` to `pac` ([#101](https://github.com/stm32-rs/stm32f3xx-hal/pull/101))

## [v0.4.3] - 2020-04-11

Expand Down
20 changes: 12 additions & 8 deletions examples/pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,24 @@

use panic_semihosting as _;

use stm32f3xx_hal as hal;

use cortex_m_rt::entry;

//use cortex_m_semihosting::hprintln;
use embedded_hal::PwmPin;
use stm32f3::stm32f303;
use stm32f3xx_hal::flash::FlashExt;
use stm32f3xx_hal::gpio::GpioExt;
use stm32f3xx_hal::pwm::{tim16, tim2, tim3, tim8};
use stm32f3xx_hal::rcc::RccExt;
use stm32f3xx_hal::time::U32Ext;
use hal::hal::PwmPin;

use hal::flash::FlashExt;
use hal::gpio::GpioExt;
use hal::pac;
use hal::pwm::{tim16, tim2, tim3, tim8};
use hal::rcc::RccExt;
use hal::time::U32Ext;

#[entry]
fn main() -> ! {
// Get our peripherals
let dp = stm32f303::Peripherals::take().unwrap();
let dp = pac::Peripherals::take().unwrap();

// Configure our clocks
let mut flash = dp.FLASH.constrain();
Expand Down
4 changes: 2 additions & 2 deletions examples/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ use stm32f3xx_hal as hal;

use cortex_m_rt::entry;

use hal::pac;
use hal::prelude::*;
use hal::spi::{Mode, Phase, Polarity, Spi};
use hal::stm32;

#[entry]
fn main() -> ! {
let dp = stm32::Peripherals::take().unwrap();
let dp = pac::Peripherals::take().unwrap();

let mut flash = dp.FLASH.constrain();
let mut rcc = dp.RCC.constrain();
Expand Down
8 changes: 5 additions & 3 deletions examples/toggle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@

use panic_semihosting as _;

use stm32f3xx_hal as hal;

use cortex_m_rt::entry;
use stm32f3xx_hal::prelude::*;
use stm32f3xx_hal::stm32;
use hal::pac;
use hal::prelude::*;

#[entry]
fn main() -> ! {
let dp = stm32::Peripherals::take().unwrap();
let dp = pac::Peripherals::take().unwrap();

let mut rcc = dp.RCC.constrain();
let mut gpioe = dp.GPIOE.split(&mut rcc.ahb);
Expand Down
17 changes: 11 additions & 6 deletions examples/usb_serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,21 @@

use panic_semihosting as _;

use stm32f3xx_hal as hal;

use cortex_m::asm::delay;
use cortex_m_rt::entry;
use stm32f3xx_hal::usb::{Peripheral, UsbBus};
use stm32f3xx_hal::{hal::digital::v2::OutputPin, prelude::*, stm32};

use hal::pac;
use hal::prelude::*;
use hal::usb::{Peripheral, UsbBus};

use usb_device::prelude::*;
use usbd_serial::{SerialPort, USB_CLASS_CDC};

#[entry]
fn main() -> ! {
let dp = stm32::Peripherals::take().unwrap();
let dp = pac::Peripherals::take().unwrap();

let mut flash = dp.FLASH.constrain();
let mut rcc = dp.RCC.constrain();
Expand All @@ -34,7 +39,7 @@ fn main() -> ! {
let mut led = gpioe
.pe13
.into_push_pull_output(&mut gpioe.moder, &mut gpioe.otyper);
led.set_low(); // Turn off
led.set_low().ok(); // Turn off

let mut gpioa = dp.GPIOA.split(&mut rcc.ahb);

Expand All @@ -45,7 +50,7 @@ fn main() -> ! {
let mut usb_dp = gpioa
.pa12
.into_push_pull_output(&mut gpioa.moder, &mut gpioa.otyper);
usb_dp.set_low();
usb_dp.set_low().ok();
delay(clocks.sysclk().0 / 100);

let usb_dm = gpioa.pa11.into_af14(&mut gpioa.moder, &mut gpioa.afrh);
Expand Down Expand Up @@ -76,7 +81,7 @@ fn main() -> ! {

match serial.read(&mut buf) {
Ok(count) if count > 0 => {
led.set_high(); // Turn on
led.set_high().ok(); // Turn on

// Echo back in upper case
for c in buf[0..count].iter_mut() {
Expand Down
2 changes: 1 addition & 1 deletion src/flash.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Flash memory

use crate::stm32::{flash, FLASH};
use crate::pac::{flash, FLASH};

/// Extension trait to constrain the FLASH peripheral
pub trait FlashExt {
Expand Down
4 changes: 2 additions & 2 deletions src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ macro_rules! gpio {
), not(any(
$(feature = $device_except,)*
))))]
use crate::stm32::$GPIOX;
use crate::pac::$GPIOX;
)+

pub enum Gpio {
Expand Down Expand Up @@ -249,7 +249,7 @@ macro_rules! gpio {
use crate::hal::digital::v2::StatefulOutputPin;
#[cfg(feature = "unproven")]
use crate::hal::digital::v2::toggleable;
use crate::stm32::{$gpioy, $GPIOX};
use crate::pac::{$gpioy, $GPIOX};

use crate::rcc::AHB;
#[allow(unused_imports)]
Expand Down
2 changes: 1 addition & 1 deletion src/i2c.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Inter-Integrated Circuit (I2C) bus

use crate::stm32::{I2C1, I2C2};
use crate::pac::{I2C1, I2C2};
use cast::u8;

use crate::gpio::gpioa::{PA10, PA9};
Expand Down
18 changes: 11 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ pub use nb;
pub use nb::block;

#[cfg(feature = "stm32f301")]
pub use stm32f3::stm32f301 as stm32;
pub use stm32f3::stm32f301 as pac;

#[cfg(feature = "stm32f302")]
pub use stm32f3::stm32f302 as stm32;
pub use stm32f3::stm32f302 as pac;

#[cfg(feature = "stm32f303")]
pub use stm32f3::stm32f303 as stm32;
pub use stm32f3::stm32f303 as pac;

#[cfg(feature = "stm32f373")]
pub use stm32f3::stm32f373 as stm32;
pub use stm32f3::stm32f373 as pac;

#[cfg(feature = "stm32f334")]
pub use stm32f3::stm32f3x4 as stm32;
pub use stm32f3::stm32f3x4 as pac;

#[cfg(any(
feature = "stm32f318",
Expand All @@ -110,11 +110,15 @@ pub use stm32f3::stm32f3x4 as stm32;
feature = "stm32f378",
feature = "stm32f398"
))]
pub use stm32f3::stm32f3x8 as stm32;
pub use stm32f3::stm32f3x8 as pac;

#[cfg(feature = "device-selected")]
#[deprecated(since = "0.5.0", note = "please use `pac` instead")]
pub use crate::pac as stm32;

// Enable use of interrupt macro
#[cfg(feature = "rt")]
pub use crate::stm32::interrupt;
pub use crate::pac::interrupt;

#[cfg(feature = "device-selected")]
pub mod delay;
Expand Down
15 changes: 7 additions & 8 deletions src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

pub use crate::flash::FlashExt as _stm32f3xx_hal_flash_FlashExt;
pub use crate::gpio::GpioExt as _stm32f3xx_hal_gpio_GpioExt;
#[cfg(feature = "unproven")]
pub use crate::hal::digital::v2::InputPin as _embedded_hal_digital_InputPin;
#[cfg(feature = "unproven")]
pub use crate::hal::digital::v2::OutputPin as _embedded_hal_digital_OutputPin;
#[cfg(feature = "unproven")]
pub use crate::hal::digital::v2::StatefulOutputPin as _embedded_hal_digital_StatefulOutputPin;
#[cfg(feature = "unproven")]
pub use crate::hal::digital::v2::ToggleableOutputPin as _embedded_hal_digital_ToggleableOutputPin;
pub use crate::hal::prelude::*;
pub use crate::rcc::RccExt as _stm32f3xx_hal_rcc_RccExt;
pub use crate::time::U32Ext as _stm32f3xx_hal_time_U32Ext;
#[cfg(feature = "unproven")]
pub use crate::{
hal::digital::v2::InputPin as _embedded_hal_digital_InputPin,
hal::digital::v2::OutputPin as _embedded_hal_digital_OutputPin,
hal::digital::v2::StatefulOutputPin as _embedded_hal_digital_StatefulOutputPin,
hal::digital::v2::ToggleableOutputPin as _embedded_hal_digital_ToggleableOutputPin,
};
24 changes: 12 additions & 12 deletions src/pwm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
we have no pins in use, but it cannot be used once we've used PA7.
*/

use crate::stm32::{TIM15, TIM16, TIM17, TIM2};
use crate::pac::{TIM15, TIM16, TIM17, TIM2};
use core::marker::PhantomData;
use embedded_hal::PwmPin;

Expand Down Expand Up @@ -381,8 +381,8 @@ use crate::gpio::gpiof::PF6;
))]
use crate::gpio::gpiof::PF9;

use crate::pac::RCC;
use crate::rcc::Clocks;
use crate::stm32::RCC;
use crate::time::Hertz;

/// Output Compare Channel 1 of Timer 1 (type state)
Expand Down Expand Up @@ -754,7 +754,7 @@ macro_rules! pwm_pin_for_pwm_n_channel {
))]
macro_rules! tim1_common {
() => {
use crate::stm32::TIM1;
use crate::pac::TIM1;

/// Output Compare Channel 1 of Timer 1 (type state)
pub struct TIM1_CH1 {}
Expand Down Expand Up @@ -964,7 +964,7 @@ pwm_channel4_pin!(TIM2, TIM2_CH4, output_to_pd6, PD6, AF2);
))]
macro_rules! tim3_common {
() => {
use crate::stm32::TIM3;
use crate::pac::TIM3;

/// Output Compare Channel 1 of Timer 3 (type state)
pub struct TIM3_CH1 {}
Expand Down Expand Up @@ -1103,7 +1103,7 @@ pwm_channel3_pin!(TIM3, TIM3_CH3, output_to_pb6, PB6, AF10);
))]
macro_rules! tim4_common {
() => {
use crate::stm32::TIM4;
use crate::pac::TIM4;

/// Output Compare Channel 1 of Timer 4 (type state)
pub struct TIM4_CH1 {}
Expand Down Expand Up @@ -1199,7 +1199,7 @@ tim4_ext!();
#[cfg(feature = "stm32f373")]
macro_rules! tim5 {
() => {
use crate::stm32::TIM5;
use crate::pac::TIM5;

/// Output Compare Channel 1 of Timer 5 (type state)
pub struct TIM5_CH1 {}
Expand Down Expand Up @@ -1257,7 +1257,7 @@ tim5!();
#[cfg(any(feature = "stm32f303", feature = "stm32f358", feature = "stm32f398"))]
macro_rules! tim8 {
() => {
use crate::stm32::TIM8;
use crate::pac::TIM8;

/// Output Compare Channel 1 of Timer 8 (type state)
pub struct TIM8_CH1 {}
Expand Down Expand Up @@ -1333,7 +1333,7 @@ pwm_channel4_pin!(TIM8, TIM8_CH4, output_to_pd1, PD1, AF4);
#[cfg(feature = "stm32f373")]
macro_rules! tim12 {
() => {
use crate::stm32::TIM12;
use crate::pac::TIM12;

/// Output Compare Channel 1 of Timer 12 (type state)
pub struct TIM12_CH1 {}
Expand Down Expand Up @@ -1381,7 +1381,7 @@ tim12!();
#[cfg(feature = "stm32f373")]
macro_rules! tim13 {
() => {
use crate::stm32::TIM13;
use crate::pac::TIM13;

/// Output Compare Channel 1 of Timer 13 (type state)
pub struct TIM13_CH1 {}
Expand Down Expand Up @@ -1424,7 +1424,7 @@ tim13!();
#[cfg(feature = "stm32f373")]
macro_rules! tim14 {
() => {
use crate::stm32::TIM14;
use crate::pac::TIM14;

/// Output Compare Channel 1 of Timer 14 (type state)
pub struct TIM14_CH1 {}
Expand Down Expand Up @@ -1592,7 +1592,7 @@ pwm_channel1n_pin!(TIM17, TIM17_CH1, output_to_pa13, PA13, AF1);
#[cfg(feature = "stm32f373")]
macro_rules! tim19 {
() => {
use crate::stm32::TIM19;
use crate::pac::TIM19;

/// Output Compare Channel 1 of Timer 19 (type state)
pub struct TIM19_CH1 {}
Expand Down Expand Up @@ -1650,7 +1650,7 @@ tim19!();
#[cfg(feature = "stm32f398")]
macro_rules! tim20 {
() => {
use crate::stm32::TIM20;
use crate::pac::TIM20;

/// Output Compare Channel 1 of Timer 20 (type state)
pub struct TIM20_CH1 {}
Expand Down
5 changes: 2 additions & 3 deletions src/rcc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Reset and Clock Control

use crate::stm32::{
use crate::pac::{
rcc::{self, cfgr, cfgr2},
RCC,
};
Expand Down Expand Up @@ -100,7 +100,6 @@ const HSI: u32 = 8_000_000; // Hz
#[cfg(any(feature = "stm32f301", feature = "stm32f334",))]
mod usb_clocking {
use crate::rcc::PllConfig;
use crate::stm32::rcc::cfgr;

pub(crate) fn is_valid(
_sysclk: u32,
Expand All @@ -127,8 +126,8 @@ mod usb_clocking {
feature = "stm32f398",
))]
mod usb_clocking {
use crate::pac::rcc::cfgr;
use crate::rcc::PllConfig;
use crate::stm32::rcc::cfgr;

/// Check for all clock options to be
pub(crate) fn is_valid(
Expand Down
2 changes: 1 addition & 1 deletion src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use core::ptr;

use crate::hal::blocking::serial::write::Default;
use crate::hal::serial;
use crate::stm32::{USART1, USART2, USART3};
use crate::pac::{USART1, USART2, USART3};
use nb;

use crate::gpio::gpioa::{PA10, PA2, PA3, PA9};
Expand Down
2 changes: 1 addition & 1 deletion src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core::ptr;

use crate::hal::spi::FullDuplex;
pub use crate::hal::spi::{Mode, Phase, Polarity};
use crate::stm32::{SPI1, SPI2, SPI3};
use crate::pac::{SPI1, SPI2, SPI3};
use nb;

use crate::gpio::gpioa::{PA5, PA6, PA7};
Expand Down