Skip to content

Commit c4ad055

Browse files
committed
Soft-deprecate stm32 for PAC access and use pac instead
Signed-off-by: Daniel Egger <[email protected]>
1 parent 0ff6b0c commit c4ad055

32 files changed

+92
-84
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- Use `pac` instead of `stm32` for PAC access and soft-deprecate the former
13+
1014
### Added
1115

1216
- Another example resembling a stop watch controlled via serial interface

examples/adc_values.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use panic_halt as _;
55

66
use stm32f0xx_hal as hal;
77

8-
use crate::hal::{prelude::*, stm32};
8+
use crate::hal::{prelude::*, pac};
99

1010
use cortex_m::{interrupt::Mutex, peripheral::syst::SystClkSource::Core};
1111
use cortex_m_rt::{entry, exception};
@@ -14,15 +14,15 @@ use core::{cell::RefCell, fmt::Write};
1414

1515
struct Shared {
1616
adc: hal::adc::Adc,
17-
tx: hal::serial::Tx<stm32::USART1>,
17+
tx: hal::serial::Tx<pac::USART1>,
1818
}
1919

2020
static SHARED: Mutex<RefCell<Option<Shared>>> = Mutex::new(RefCell::new(None));
2121

2222
#[entry]
2323
fn main() -> ! {
2424
if let (Some(p), Some(cp)) = (
25-
hal::stm32::Peripherals::take(),
25+
hal::pac::Peripherals::take(),
2626
cortex_m::peripheral::Peripherals::take(),
2727
) {
2828
cortex_m::interrupt::free(move |cs| {

examples/blinky.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use panic_halt as _;
55

66
use stm32f0xx_hal as hal;
77

8-
use crate::hal::{prelude::*, stm32};
8+
use crate::hal::{prelude::*, pac};
99

1010
use cortex_m_rt::entry;
1111

1212
#[entry]
1313
fn main() -> ! {
14-
if let Some(mut p) = stm32::Peripherals::take() {
14+
if let Some(mut p) = pac::Peripherals::take() {
1515
let mut led = cortex_m::interrupt::free(|cs| {
1616
let mut rcc = p.RCC.configure().sysclk(8.mhz()).freeze(&mut p.FLASH);
1717

examples/blinky_adc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ use panic_halt as _;
55

66
use stm32f0xx_hal as hal;
77

8-
use crate::hal::{adc::Adc, delay::Delay, prelude::*, stm32};
8+
use crate::hal::{adc::Adc, delay::Delay, prelude::*, pac};
99

1010
use cortex_m::peripheral::Peripherals;
1111
use cortex_m_rt::entry;
1212

1313
#[entry]
1414
fn main() -> ! {
15-
if let (Some(mut p), Some(cp)) = (stm32::Peripherals::take(), Peripherals::take()) {
15+
if let (Some(mut p), Some(cp)) = (pac::Peripherals::take(), Peripherals::take()) {
1616
cortex_m::interrupt::free(move |cs| {
1717
let mut rcc = p.RCC.configure().sysclk(8.mhz()).freeze(&mut p.FLASH);
1818

examples/blinky_delay.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ use panic_halt as _;
55

66
use stm32f0xx_hal as hal;
77

8-
use crate::hal::{delay::Delay, prelude::*, stm32};
8+
use crate::hal::{delay::Delay, prelude::*, pac};
99

1010
use cortex_m::peripheral::Peripherals;
1111
use cortex_m_rt::entry;
1212

1313
#[entry]
1414
fn main() -> ! {
15-
if let (Some(mut p), Some(cp)) = (stm32::Peripherals::take(), Peripherals::take()) {
15+
if let (Some(mut p), Some(cp)) = (pac::Peripherals::take(), Peripherals::take()) {
1616
cortex_m::interrupt::free(move |cs| {
1717
let mut rcc = p.RCC.configure().sysclk(8.mhz()).freeze(&mut p.FLASH);
1818

examples/blinky_multiple.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ use panic_halt as _;
55

66
use stm32f0xx_hal as hal;
77

8-
use crate::hal::{delay::Delay, prelude::*, stm32};
8+
use crate::hal::{delay::Delay, prelude::*, pac};
99

1010
use cortex_m::peripheral::Peripherals;
1111
use cortex_m_rt::entry;
1212

1313
#[entry]
1414
fn main() -> ! {
15-
if let (Some(mut p), Some(cp)) = (stm32::Peripherals::take(), Peripherals::take()) {
15+
if let (Some(mut p), Some(cp)) = (pac::Peripherals::take(), Peripherals::take()) {
1616
cortex_m::interrupt::free(move |cs| {
1717
let mut rcc = p.RCC.configure().sysclk(8.mhz()).freeze(&mut p.FLASH);
1818

examples/blinky_timer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use panic_halt as _;
55

66
use stm32f0xx_hal as hal;
77

8-
use crate::hal::{prelude::*, stm32, time::Hertz, timers::*};
8+
use crate::hal::{prelude::*, pac, time::Hertz, timers::*};
99

1010
use cortex_m_rt::entry;
1111

1212
#[entry]
1313
fn main() -> ! {
14-
if let Some(mut p) = stm32::Peripherals::take() {
14+
if let Some(mut p) = pac::Peripherals::take() {
1515
cortex_m::interrupt::free(move |cs| {
1616
let mut rcc = p.RCC.configure().sysclk(8.mhz()).freeze(&mut p.FLASH);
1717

examples/blinky_timer_irq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use stm32f0xx_hal as hal;
77

88
use crate::hal::{
99
gpio::*,
10+
pac::{interrupt, Interrupt, Peripherals, TIM7},
1011
prelude::*,
11-
stm32::{interrupt, Interrupt, Peripherals, TIM7},
1212
time::Hertz,
1313
timers::*,
1414
};

examples/dac.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use panic_halt as _;
99
use stm32f0xx_hal as hal;
1010

1111
use crate::hal::dac::*;
12+
use crate::hal::pac;
1213
use crate::hal::prelude::*;
13-
use crate::hal::stm32;
1414

1515
use rt::entry;
1616

@@ -21,7 +21,7 @@ enum Direction {
2121

2222
#[entry]
2323
fn main() -> ! {
24-
if let (Some(mut dp), Some(_cp)) = (stm32::Peripherals::take(), cortex_m::Peripherals::take()) {
24+
if let (Some(mut dp), Some(_cp)) = (pac::Peripherals::take(), cortex_m::Peripherals::take()) {
2525
cortex_m::interrupt::free(move |cs| {
2626
let mut rcc = dp.RCC.configure().sysclk(8.mhz()).freeze(&mut dp.FLASH);
2727

examples/flash_systick.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use panic_halt as _;
55

66
use stm32f0xx_hal as hal;
77

8-
use crate::hal::{gpio::*, prelude::*, stm32};
8+
use crate::hal::{gpio::*, prelude::*, pac};
99

1010
use cortex_m::{interrupt::Mutex, peripheral::syst::SystClkSource::Core, Peripherals};
1111
use cortex_m_rt::{entry, exception};
@@ -18,7 +18,7 @@ static GPIO: Mutex<RefCell<Option<gpioa::PA1<Output<PushPull>>>>> = Mutex::new(R
1818

1919
#[entry]
2020
fn main() -> ! {
21-
if let (Some(mut p), Some(cp)) = (stm32::Peripherals::take(), Peripherals::take()) {
21+
if let (Some(mut p), Some(cp)) = (pac::Peripherals::take(), Peripherals::take()) {
2222
cortex_m::interrupt::free(move |cs| {
2323
let mut rcc = p.RCC.configure().sysclk(48.mhz()).freeze(&mut p.FLASH);
2424

examples/flash_systick_fancier.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use panic_halt as _;
55

66
use stm32f0xx_hal as hal;
77

8-
use crate::hal::{gpio::*, prelude::*, stm32};
8+
use crate::hal::{gpio::*, prelude::*, pac};
99

1010
use cortex_m::{interrupt::Mutex, peripheral::syst::SystClkSource::Core, Peripherals};
1111
use cortex_m_rt::{entry, exception};
@@ -21,7 +21,7 @@ static GPIO: Mutex<RefCell<Option<LEDPIN>>> = Mutex::new(RefCell::new(None));
2121

2222
#[entry]
2323
fn main() -> ! {
24-
if let (Some(mut p), Some(cp)) = (stm32::Peripherals::take(), Peripherals::take()) {
24+
if let (Some(mut p), Some(cp)) = (pac::Peripherals::take(), Peripherals::take()) {
2525
cortex_m::interrupt::free(move |cs| {
2626
let mut rcc = p.RCC.configure().sysclk(48.mhz()).freeze(&mut p.FLASH);
2727

examples/i2c_find_address.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ use panic_halt as _;
55

66
use stm32f0xx_hal as hal;
77

8-
use crate::hal::{i2c::I2c, prelude::*, stm32};
8+
use crate::hal::{i2c::I2c, prelude::*, pac};
99

1010
use cortex_m_rt::entry;
1111

1212
/* Example meant for stm32f030xc MCUs with i2c devices connected on PB7 and PB8 */
1313

1414
#[entry]
1515
fn main() -> ! {
16-
if let Some(p) = stm32::Peripherals::take() {
16+
if let Some(p) = pac::Peripherals::take() {
1717
cortex_m::interrupt::free(move |cs| {
1818
let mut flash = p.FLASH;
1919
let mut rcc = p.RCC.configure().freeze(&mut flash);

examples/led_hal_button_irq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use stm32f0xx_hal as hal;
88
use crate::hal::{
99
delay::Delay,
1010
gpio::*,
11+
pac::{interrupt, Interrupt, Peripherals, EXTI},
1112
prelude::*,
12-
stm32::{interrupt, Interrupt, Peripherals, EXTI},
1313
};
1414

1515
use cortex_m::{interrupt::Mutex, peripheral::Peripherals as c_m_Peripherals};

examples/serial_echo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use panic_halt as _;
55

66
use stm32f0xx_hal as hal;
77

8-
use crate::hal::{prelude::*, serial::Serial, stm32};
8+
use crate::hal::{prelude::*, serial::Serial, pac};
99

1010
use cortex_m_rt::entry;
1111

1212
#[entry]
1313
fn main() -> ! {
14-
if let Some(p) = stm32::Peripherals::take() {
14+
if let Some(p) = pac::Peripherals::take() {
1515
cortex_m::interrupt::free(move |cs| {
1616
let mut flash = p.FLASH;
1717
let mut rcc = p.RCC.configure().sysclk(48.mhz()).freeze(&mut flash);

examples/serial_spi_bridge.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::hal::{
1010
serial::Serial,
1111
spi::Spi,
1212
spi::{Mode, Phase, Polarity},
13-
stm32,
13+
pac,
1414
};
1515

1616
use nb::block;
@@ -30,7 +30,7 @@ fn main() -> ! {
3030
phase: Phase::CaptureOnSecondTransition,
3131
};
3232

33-
if let Some(p) = stm32::Peripherals::take() {
33+
if let Some(p) = pac::Peripherals::take() {
3434
cortex_m::interrupt::free(move |cs| {
3535
let mut flash = p.FLASH;
3636
let mut rcc = p.RCC.configure().freeze(&mut flash);

examples/serial_stopwatch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use panic_halt as _;
66
use stm32f0xx_hal as hal;
77

88
use crate::hal::{
9+
pac::{interrupt, Interrupt, Peripherals, TIM7},
910
prelude::*,
1011
serial::Serial,
11-
stm32::{interrupt, Interrupt, Peripherals, TIM7},
1212
timers::{Event, Timer},
1313
};
1414
use core::cell::RefCell;

examples/spi_hal_apa102c.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::hal::{
99
prelude::*,
1010
spi::Spi,
1111
spi::{Mode, Phase, Polarity},
12-
stm32,
12+
pac,
1313
};
1414

1515
use cortex_m_rt::entry;
@@ -21,7 +21,7 @@ fn main() -> ! {
2121
phase: Phase::CaptureOnSecondTransition,
2222
};
2323

24-
if let Some(p) = stm32::Peripherals::take() {
24+
if let Some(p) = pac::Peripherals::take() {
2525
cortex_m::interrupt::free(move |cs| {
2626
let mut flash = p.FLASH;
2727
let mut rcc = p.RCC.configure().freeze(&mut flash);

examples/usb_serial.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ extern crate panic_halt;
77

88
use cortex_m_rt::entry;
99
use stm32f0xx_hal::usb::{Peripheral, UsbBus};
10-
use stm32f0xx_hal::{prelude::*, stm32};
10+
use stm32f0xx_hal::{prelude::*, pac};
1111
use usb_device::prelude::*;
1212
use usbd_serial::{SerialPort, USB_CLASS_CDC};
1313

1414
#[entry]
1515
fn main() -> ! {
16-
let mut dp = stm32::Peripherals::take().unwrap();
16+
let mut dp = pac::Peripherals::take().unwrap();
1717

1818
/* Uncomment the following lines if you have a chip in TSSOP20 (STM32F042F)
1919
or UFQFPN28 (STM32F042G) package

examples/watchdog.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use panic_halt as _;
66
use stm32f0xx_hal as hal;
77

88
use crate::hal::{
9-
delay::Delay, prelude::*, serial::Serial, stm32, time::Hertz, watchdog::Watchdog,
9+
delay::Delay, prelude::*, serial::Serial, pac, time::Hertz, watchdog::Watchdog,
1010
};
1111

1212
use cortex_m::peripheral::Peripherals;
@@ -16,7 +16,7 @@ use core::fmt::Write;
1616

1717
#[entry]
1818
fn main() -> ! {
19-
if let (Some(p), Some(cp)) = (stm32::Peripherals::take(), Peripherals::take()) {
19+
if let (Some(p), Some(cp)) = (pac::Peripherals::take(), Peripherals::take()) {
2020
cortex_m::interrupt::free(move |cs| {
2121
let mut flash = p.FLASH;
2222
let mut rcc = p.RCC.configure().sysclk(8.mhz()).freeze(&mut flash);

src/adc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
//! ``` no_run
99
//! use stm32f0xx_hal as hal;
1010
//!
11-
//! use crate::hal::stm32;
11+
//! use crate::hal::pac;
1212
//! use crate::hal::prelude::*;
1313
//! use crate::hal::adc::Adc;
1414
//!
1515
//! cortex_m::interrupt::free(|cs| {
16-
//! let mut p = stm32::Peripherals::take().unwrap();
16+
//! let mut p = pac::Peripherals::take().unwrap();
1717
//! let mut rcc = p.RCC.configure().freeze(&mut p.FLASH);
1818
//!
1919
//! let gpioa = p.GPIOA.split(&mut rcc);
@@ -52,14 +52,14 @@ use embedded_hal::{
5252
use crate::{
5353
delay::Delay,
5454
gpio::*,
55-
rcc::Rcc,
56-
stm32::{
55+
pac::{
5756
adc::{
5857
cfgr1::{ALIGN_A, RES_A},
5958
smpr::SMP_A,
6059
},
6160
ADC,
6261
},
62+
rcc::Rcc,
6363
};
6464

6565
/// Analog to Digital converter interface

src/dac.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//!
1616
//!use stm32f0xx_hal as hal;
1717
//!
18-
//!use crate::hal::stm32;
18+
//!use crate::hal::pac;
1919
//!use crate::hal::prelude::*;
2020
//!use crate::hal::dac::*;
2121
//!
@@ -28,7 +28,7 @@
2828
//!
2929
//!#[entry]
3030
//!fn main() -> ! {
31-
//! if let (Some(mut dp), Some(_cp)) = (stm32::Peripherals::take(), cortex_m::Peripherals::take()) {
31+
//! if let (Some(mut dp), Some(_cp)) = (pac::Peripherals::take(), cortex_m::Peripherals::take()) {
3232
//! cortex_m::interrupt::free(move |cs| {
3333
//! let mut rcc = dp.RCC.configure().sysclk(8.mhz()).freeze(&mut dp.FLASH);
3434
//!
@@ -72,8 +72,8 @@ use core::mem;
7272

7373
use crate::gpio::gpioa::{PA4, PA5};
7474
use crate::gpio::Analog;
75+
use crate::pac::DAC;
7576
use crate::rcc::Rcc;
76-
use crate::stm32::DAC;
7777

7878
pub struct C1;
7979
pub struct C2;

src/delay.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
//! ``` no_run
1111
//! use stm32f0xx_hal as hal;
1212
//!
13-
//! use crate::hal::stm32;
13+
//! use crate::hal::pac;
1414
//! use crate::hal::prelude::*;
1515
//! use crate::hal::delay::Delay;
1616
//! use cortex_m::peripheral::Peripherals;
1717
//!
18-
//! let mut p = stm32::Peripherals::take().unwrap();
18+
//! let mut p = pac::Peripherals::take().unwrap();
1919
//! let mut cp = cortex_m::Peripherals::take().unwrap();
2020
//!
2121
//! let mut rcc = p.RCC.configure().freeze(&mut p.FLASH);

0 commit comments

Comments
 (0)