Content-Length: 1058015 | pFad | http://github.com/stm32-rs/stm32f4xx-hal/pull/836/commits/63e7ae9c431e64d88cfaf9b195514d8321a3fd2f

5E use &mut RCC by burrbull · Pull Request #836 · stm32-rs/stm32f4xx-hal · GitHub
Skip to content

use &mut RCC #836

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename CFGR to Config
  • Loading branch information
burrbull committed May 29, 2025
commit 63e7ae9c431e64d88cfaf9b195514d8321a3fd2f
4 changes: 2 additions & 2 deletions examples/analog-stopwatch-with-spi-ssd1306.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#![no_main]

use panic_semihosting as _;
use stm32f4xx_hal::{self as hal, rcc::CFGR};
use stm32f4xx_hal::{self as hal, rcc::Config};

use crate::hal::{
gpio::{Edge, Input, PA0},
Expand Down Expand Up @@ -223,7 +223,7 @@ fn main() -> ! {

fn setup_clocks(rcc: pac::RCC) -> Rcc {
rcc.freeze(
CFGR::hsi()
Config::hsi()
.hclk(180.MHz())
.sysclk(180.MHz())
.pclk1(45.MHz())
Expand Down
4 changes: 2 additions & 2 deletions examples/blinky-timer-irq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use panic_halt as _;

use stm32f4xx_hal::{self as hal, rcc::CFGR};
use stm32f4xx_hal::{self as hal, rcc::Config};

use crate::hal::{
gpio::{self, Output, PushPull},
Expand Down Expand Up @@ -66,7 +66,7 @@ fn TIM2() {
fn main() -> ! {
let dp = Peripherals::take().unwrap();

let rcc = dp.RCC.freeze(CFGR::hsi().sysclk(16.MHz()).pclk1(8.MHz()));
let rcc = dp.RCC.freeze(Config::hsi().sysclk(16.MHz()).pclk1(8.MHz()));

// Configure PA5 pin to blink LED
let gpioa = dp.GPIOA.split();
Expand Down
4 changes: 2 additions & 2 deletions examples/can-send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bxcan::filter::Mask32;
use bxcan::{Fifo, Frame, StandardId};
use cortex_m_rt::entry;
use nb::block;
use stm32f4xx_hal::rcc::CFGR;
use stm32f4xx_hal::rcc::Config;
use stm32f4xx_hal::{pac, prelude::*};

#[entry]
Expand All @@ -20,7 +20,7 @@ fn main() -> ! {
// To meet CAN clock accuracy requirements an external crystal or ceramic
// resonator must be used. The blue pill has a 8MHz external crystal.
// Other boards might have a crystal with another frequency or none at all.
let _rcc = dp.RCC.freeze(CFGR::hse(8.MHz()));
let _rcc = dp.RCC.freeze(Config::hse(8.MHz()));

let gpiob = dp.GPIOB.split();
let mut can1 = {
Expand Down
4 changes: 2 additions & 2 deletions examples/delay-syst-blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use panic_halt as _; // panic handler

use cortex_m_rt::entry;
use stm32f4xx_hal::{self as hal, rcc::CFGR};
use stm32f4xx_hal::{self as hal, rcc::Config};

use crate::hal::{pac, prelude::*};

Expand All @@ -24,7 +24,7 @@ fn main() -> ! {
let mut led = gpioa.pa5.into_push_pull_output();

// Set up the system clock. We want to run at 48MHz for this one.
let rcc = dp.RCC.freeze(CFGR::hsi().sysclk(48.MHz()));
let rcc = dp.RCC.freeze(Config::hsi().sysclk(48.MHz()));

// Create a delay abstraction based on SysTick
let mut delay = cp.SYST.delay(&rcc.clocks);
Expand Down
4 changes: 2 additions & 2 deletions examples/delay-timer-blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use panic_halt as _; // panic handler

use cortex_m_rt::entry;
use stm32f4xx_hal::{self as hal, rcc::CFGR};
use stm32f4xx_hal::{self as hal, rcc::Config};

use crate::hal::{pac, prelude::*};

Expand All @@ -24,7 +24,7 @@ fn main() -> ! {
let mut led = gpioc.pc13.into_push_pull_output();

// Set up the system clock. We want to run at 48MHz for this one.
let rcc = dp.RCC.freeze(CFGR::hse(25.MHz()).sysclk(48.MHz()));
let rcc = dp.RCC.freeze(Config::hse(25.MHz()).sysclk(48.MHz()));

// Create a delay abstraction based on general-pupose 32-bit timer TIM5
let mut delay = dp.TIM5.delay_us(&rcc.clocks);
Expand Down
4 changes: 2 additions & 2 deletions examples/display-touch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use stm32f4xx_hal::{
gpio::Speed,
pac,
prelude::*,
rcc::CFGR,
rcc::Config,
};

use embedded_graphics_07::{
Expand Down Expand Up @@ -53,7 +53,7 @@ fn main() -> ! {
let p = pac::Peripherals::take().unwrap();
let cp = cortex_m::Peripherals::take().unwrap();

let rcc = p.RCC.freeze(CFGR::hsi().sysclk(100.MHz()));
let rcc = p.RCC.freeze(Config::hsi().sysclk(100.MHz()));
let mut delay = cp.SYST.delay(&rcc.clocks);

let gpiob = p.GPIOB.split();
Expand Down
4 changes: 2 additions & 2 deletions examples/dwt-blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::hal::{
};
use cortex_m_rt::entry;
use panic_halt as _;
use stm32f4xx_hal::{self as hal, rcc::CFGR};
use stm32f4xx_hal::{self as hal, rcc::Config};

#[entry]
fn main() -> ! {
Expand All @@ -25,7 +25,7 @@ fn main() -> ! {
let mut led2 = gpiog.pg14.into_push_pull_output();

// Set up the system clock. We want to run at 48MHz for this one.
let rcc = dp.RCC.freeze(CFGR::hsi().sysclk(48.MHz()));
let rcc = dp.RCC.freeze(Config::hsi().sysclk(48.MHz()));

// Create a delay abstraction based on DWT cycle counter
let dwt = cp.DWT.constrain(cp.DCB, &rcc.clocks);
Expand Down
4 changes: 2 additions & 2 deletions examples/f413disco-lcd-ferris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use panic_halt as _;
use rtt_target::{self, rtt_init_print, ChannelMode};

use stm32f4xx_hal::{self as hal, rcc::CFGR};
use stm32f4xx_hal::{self as hal, rcc::Config};

use crate::hal::{
fsmc_lcd::{DataPins16, FsmcLcd, LcdPins, Timing},
Expand Down Expand Up @@ -705,7 +705,7 @@ fn main() -> ! {
let gpiog = p.GPIOG.split();

// Configure and lock the clocks at maximum warp
let rcc = p.RCC.freeze(CFGR::hsi().sysclk(100.MHz()));
let rcc = p.RCC.freeze(Config::hsi().sysclk(100.MHz()));

// Define the pins we need for our 16bit parallel bus
use stm32f4xx_hal::gpio::alt::fsmc as alt;
Expand Down
4 changes: 2 additions & 2 deletions examples/f469disco-lcd-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use cortex_m_rt::entry;
use defmt_rtt as _;
use panic_probe as _;

use stm32f4xx_hal::{self as hal, rcc::CFGR};
use stm32f4xx_hal::{self as hal, rcc::Config};

use crate::hal::{
dsi::{
Expand Down Expand Up @@ -55,7 +55,7 @@ fn main() -> ! {
let hse_freq = 8.MHz();
let rcc = dp
.RCC
.freeze(CFGR::hse(hse_freq).pclk2(32.MHz()).sysclk(180.MHz()));
.freeze(Config::hse(hse_freq).pclk2(32.MHz()).sysclk(180.MHz()));
let mut delay = cp.SYST.delay(&rcc.clocks);

let gpioh = dp.GPIOH.split();
Expand Down
4 changes: 2 additions & 2 deletions examples/fmc-sdram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use panic_probe as _;

use core::{mem, slice};
use stm32f4xx_hal::{fmc::FmcExt, gpio::alt::fmc as alt, pac, prelude::*, rcc::CFGR};
use stm32f4xx_hal::{fmc::FmcExt, gpio::alt::fmc as alt, pac, prelude::*, rcc::Config};

use cortex_m::peripheral::Peripherals;

Expand Down Expand Up @@ -49,7 +49,7 @@ impl XorShift32 {
#[entry]
fn main() -> ! {
if let (Some(p), Some(cp)) = (pac::Peripherals::take(), Peripherals::take()) {
let rcc = p.RCC.freeze(CFGR::hsi().sysclk(180.MHz()));
let rcc = p.RCC.freeze(Config::hsi().sysclk(180.MHz()));

let mut delay = cp.SYST.delay(&rcc.clocks);

Expand Down
10 changes: 6 additions & 4 deletions examples/i2s-audio-out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use stm32f4xx_hal::i2s::I2s;
use stm32f4xx_hal::nb::block;
use stm32f4xx_hal::pac::Peripherals;
use stm32f4xx_hal::prelude::*;
use stm32f4xx_hal::rcc::CFGR;
use stm32f4xx_hal::rcc::Config;

const SAMPLE_RATE: u32 = 48_000;

Expand Down Expand Up @@ -97,9 +97,11 @@ fn main() -> ! {

// The 61440 kHz frequency can be divided to get exactly 48 kHz sample rate even when
// generating master clock
let rcc = dp
.RCC
.freeze(CFGR::hse(8u32.MHz()).sysclk(96.MHz()).i2s_clk(61440.kHz()));
let rcc = dp.RCC.freeze(
Config::hse(8u32.MHz())
.sysclk(96.MHz())
.i2s_clk(61440.kHz()),
);

let i2s_pins = (gpioa.pa4, gpioc.pc10, NoPin::new(), gpioc.pc12);
let i2s = I2s::new(dp.SPI3, i2s_pins, &rcc.clocks);
Expand Down
4 changes: 2 additions & 2 deletions examples/ltdc-screen/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use stm32f4xx_hal::{
ltdc::{BluePins, GreenPins, Layer, LtdcPins, PixelFormat, RedPins},
pac,
prelude::*,
rcc::{Rcc, CFGR},
rcc::{Config, Rcc},
};

mod screen;
Expand Down Expand Up @@ -68,7 +68,7 @@ fn main() -> ! {
// HSE osc out in High Z
gpioh.ph1.into_floating_input();
let _rcc_hal = rcc_hal.freeze(
CFGR::hse(25.MHz())
Config::hse(25.MHz())
.bypass_hse_oscillator()
.sysclk(216.MHz())
.hclk(216.MHz()),
Expand Down
4 changes: 2 additions & 2 deletions examples/pwm-dead-time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
use panic_halt as _; // panic handler

use cortex_m_rt::entry;
use stm32f4xx_hal::{self as hal, rcc::CFGR};
use stm32f4xx_hal::{self as hal, rcc::Config};

use hal::{pac, prelude::*, timer::Polarity};

#[entry]
fn main() -> ! {
if let Some(dp) = pac::Peripherals::take() {
// Set up the system clock. We want to run at 84MHz for this one.
let rcc = dp.RCC.freeze(CFGR::hsi().sysclk(25.MHz()));
let rcc = dp.RCC.freeze(Config::hsi().sysclk(25.MHz()));

let gpioa = dp.GPIOA.split();

Expand Down
4 changes: 2 additions & 2 deletions examples/pwm-sinus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use panic_halt as _;
use core::f32::consts::FRAC_PI_2;
use cortex_m_rt::entry;
use micromath::F32Ext;
use stm32f4xx_hal::{pac, prelude::*, rcc::CFGR};
use stm32f4xx_hal::{pac, prelude::*, rcc::Config};

#[entry]
fn main() -> ! {
if let Some(dp) = pac::Peripherals::take() {
// Set up the system clock.
let rcc = dp.RCC.freeze(CFGR::hse(25.MHz()));
let rcc = dp.RCC.freeze(Config::hse(25.MHz()));

let gpioa = dp.GPIOA.split();

Expand Down
4 changes: 2 additions & 2 deletions examples/rng-display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#![no_main]

use stm32f4xx_hal as hal;
use stm32f4xx_hal::rcc::CFGR;
use stm32f4xx_hal::rcc::Config;

#[cfg(not(debug_assertions))]
use panic_halt as _;
Expand Down Expand Up @@ -59,7 +59,7 @@ fn main() -> ! {
// here we pick a simple clock configuration that ensures the pll48clk,
// from which RNG_CLK is derived, is about 48 MHz
// discovery board has 8 MHz crystal for HSE
let rcc = dp.RCC.freeze(CFGR::hse(8.MHz()).sysclk(128.MHz()));
let rcc = dp.RCC.freeze(Config::hse(8.MHz()).sysclk(128.MHz()));

let mut delay_source = cp.SYST.delay(&rcc.clocks);

Expand Down
2 changes: 1 addition & 1 deletion examples/rtc_alarm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn main() -> ! {

let mut p = hal::pac::Peripherals::take().unwrap();

let rcc = p.RCC.constrain();
let _rcc = p.RCC.constrain();
let mut rtc = Rtc::new(p.RTC, &mut p.PWR);

let today = date!(2023 - 05 - 28);
Expand Down
4 changes: 2 additions & 2 deletions examples/rtic-adc-dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ mod app {
dma::{config::DmaConfig, PeripheralToMemory, Stream0, StreamsTuple, Transfer},
pac::{self, ADC1, DMA2},
prelude::*,
rcc::CFGR,
rcc::Config,
signature::{VtempCal110, VtempCal30},
};

Expand All @@ -43,7 +43,7 @@ mod app {
let device: pac::Peripherals = cx.device;

let _rcc = device.RCC.freeze(
CFGR::hse(25.MHz())
Config::hse(25.MHz())
.require_pll48clk()
.sysclk(MONO_HZ.Hz())
.hclk(MONO_HZ.Hz())
Expand Down
4 changes: 2 additions & 2 deletions examples/rtic-button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod app {
use stm32f4xx_hal::{
gpio::{gpioa::PA0, gpioc::PC13, Edge, Input, Output, PinState, Pull},
prelude::*,
rcc::CFGR,
rcc::Config,
};
const SYSFREQ: u32 = 100_000_000;
// Shared resources go here
Expand All @@ -32,7 +32,7 @@ mod app {
let _rcc = ctx
.device
.RCC
.freeze(CFGR::hse(25.MHz()).sysclk(SYSFREQ.Hz()));
.freeze(Config::hse(25.MHz()).sysclk(SYSFREQ.Hz()));
// gpio ports A and C
let gpioa = ctx.device.GPIOA.split();
let gpioc = ctx.device.GPIOC.split();
Expand Down
4 changes: 2 additions & 2 deletions examples/rtic-dual-i2s-audio-in-out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ mod app {
RightLsb,
}

use stm32f4xx_hal::rcc::CFGR;
use stm32f4xx_hal::rcc::Config;
use FrameState::{LeftLsb, LeftMsb, RightLsb, RightMsb};

impl Default for FrameState {
Expand Down Expand Up @@ -154,7 +154,7 @@ mod app {
let gpiob = device.GPIOB.split();
let gpioc = device.GPIOC.split();
let rcc = device.RCC.freeze(
CFGR::hse(8u32.MHz())
Config::hse(8u32.MHz())
.sysclk(96.MHz())
.hclk(96.MHz())
.pclk1(50.MHz())
Expand Down
4 changes: 2 additions & 2 deletions examples/rtic-i2s-audio-in-out.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ mod app {
RightLsb,
}

use stm32f4xx_hal::rcc::CFGR;
use stm32f4xx_hal::rcc::Config;
use FrameState::{LeftLsb, LeftMsb, RightLsb, RightMsb};

impl Default for FrameState {
Expand Down Expand Up @@ -158,7 +158,7 @@ mod app {
let gpiob = device.GPIOB.split();
let gpioc = device.GPIOC.split();
let rcc = device.RCC.freeze(
CFGR::hse(8u32.MHz())
Config::hse(8u32.MHz())
.sysclk(96.MHz())
.hclk(96.MHz())
.pclk1(50.MHz())
Expand Down
4 changes: 2 additions & 2 deletions examples/rtic-spi-slave-dma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ mod app {
use panic_semihosting as _;
use systick_monotonic::*;

use stm32f4xx_hal::{self as hal, rcc::CFGR};
use stm32f4xx_hal::{self as hal, rcc::Config};

const ARRAY_SIZE: usize = 3;

Expand Down Expand Up @@ -56,7 +56,7 @@ mod app {

let _rcc = device_peripherals
.RCC
.freeze(CFGR::hsi().sysclk(100.MHz()).pclk1(36.MHz()));
.freeze(Config::hsi().sysclk(100.MHz()).pclk1(36.MHz()));

let mono = Systick::new(core.SYST, 100_000_000);

Expand Down
4 changes: 2 additions & 2 deletions examples/rtic-tick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod app {
gpio::{Output, PC13},
pac,
prelude::*,
rcc::CFGR,
rcc::Config,
timer::MonoTimer64Us, // Extended 64-bit timer for 16/32-bit TIMs
};

Expand All @@ -30,7 +30,7 @@ mod app {

#[init]
fn init(ctx: init::Context) -> (Shared, Local, init::Monotonics) {
let rcc = ctx.device.RCC.freeze(CFGR::DEFAULT.sysclk(48.MHz()));
let rcc = ctx.device.RCC.freeze(Config::DEFAULT.sysclk(48.MHz()));

let gpioc = ctx.device.GPIOC.split();
let led = gpioc.pc13.into_push_pull_output();
Expand Down
Loading
Loading








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/stm32-rs/stm32f4xx-hal/pull/836/commits/63e7ae9c431e64d88cfaf9b195514d8321a3fd2f

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy