Skip to content

Commit f2d333a

Browse files
committed
gpio rcc
1 parent 0ba01f4 commit f2d333a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+569
-592
lines changed

examples/analog-stopwatch-with-spi-ssd1306.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ fn main() -> ! {
8484
let cp = cortex_m::peripheral::Peripherals::take().unwrap();
8585
dp.RCC.apb2enr().write(|w| w.syscfgen().enabled());
8686

87-
let rcc = setup_clocks(dp.RCC);
87+
let mut rcc = setup_clocks(dp.RCC);
8888

89-
let mut syscfg = dp.SYSCFG.constrain();
89+
let mut syscfg = dp.SYSCFG.constrain(&mut rcc);
9090

91-
let gpioa = dp.GPIOA.split();
92-
let gpioe = dp.GPIOE.split();
91+
let gpioa = dp.GPIOA.split(&mut rcc);
92+
let gpioe = dp.GPIOE.split(&mut rcc);
9393

9494
let mut board_btn = gpioa.pa0.into_pull_down_input();
9595
board_btn.make_interrupt_source(&mut syscfg);
@@ -115,11 +115,11 @@ fn main() -> ! {
115115
phase: Phase::CaptureOnFirstTransition,
116116
},
117117
2000.kHz(),
118-
&rcc.clocks,
118+
&mut rcc,
119119
);
120120

121121
// Set up the LEDs. On the stm32f429i-disco they are connected to pin PG13 and PG14.
122-
let gpiog = dp.GPIOG.split();
122+
let gpiog = dp.GPIOG.split(&mut rcc);
123123
let mut led3 = gpiog.pg13.into_push_pull_output();
124124
let mut led4 = gpiog.pg14.into_push_pull_output();
125125

@@ -140,7 +140,7 @@ fn main() -> ! {
140140
disp.flush().unwrap();
141141

142142
// Create a 1ms periodic interrupt from TIM2
143-
let mut timer = FTimer::new(dp.TIM2, &rcc.clocks).counter();
143+
let mut timer = FTimer::new(dp.TIM2, &mut rcc).counter();
144144
timer.start(1.secs()).unwrap();
145145
timer.listen(Event::Update);
146146

examples/blinky-timer-irq.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@ fn TIM2() {
6666
fn main() -> ! {
6767
let dp = Peripherals::take().unwrap();
6868

69-
let rcc = dp.RCC.freeze(Config::hsi().sysclk(16.MHz()).pclk1(8.MHz()));
69+
let mut rcc = dp.RCC.freeze(Config::hsi().sysclk(16.MHz()).pclk1(8.MHz()));
7070

7171
// Configure PA5 pin to blink LED
72-
let gpioa = dp.GPIOA.split();
72+
let gpioa = dp.GPIOA.split(&mut rcc);
7373
let mut led = gpioa.pa5.into_push_pull_output();
7474
led.set_high(); // Turn off
7575

7676
// Move the pin into our global storage
7777
cortex_m::interrupt::free(|cs| *G_LED.borrow(cs).borrow_mut() = Some(led));
7878

7979
// Set up a timer expiring after 1s
80-
let mut timer = dp.TIM2.counter(&rcc.clocks);
80+
let mut timer = dp.TIM2.counter(&mut rcc);
8181
timer.start(1.secs()).unwrap();
8282

8383
// Generate an interrupt when the timer expires

examples/blinky.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ use cortex_m_rt::entry;
1616
fn main() -> ! {
1717
let p = pac::Peripherals::take().unwrap();
1818

19-
let gpioc = p.GPIOC.split();
19+
let mut rcc = p.RCC.constrain();
20+
21+
let gpioc = p.GPIOC.split(&mut rcc);
2022
let mut led = gpioc.pc13.into_push_pull_output();
2123

2224
loop {

examples/can-send.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,16 @@ fn main() -> ! {
2020
// To meet CAN clock accuracy requirements an external crystal or ceramic
2121
// resonator must be used. The blue pill has a 8MHz external crystal.
2222
// Other boards might have a crystal with another frequency or none at all.
23-
let _rcc = dp.RCC.freeze(Config::hse(8.MHz()));
23+
let mut rcc = dp.RCC.freeze(Config::hse(8.MHz()));
2424

25-
let gpiob = dp.GPIOB.split();
25+
let gpiob = dp.GPIOB.split(&mut rcc);
2626
let mut can1 = {
2727
let rx = gpiob.pb8;
2828
let tx = gpiob.pb9;
2929

3030
// let can = Can::new(dp.CAN1, (tx, rx));
3131
// or
32-
let can = dp.CAN1.can((tx, rx));
32+
let can = dp.CAN1.can((tx, rx), &mut rcc);
3333

3434
bxcan::Can::builder(can)
3535
// APB1 (PCLK1): 8MHz, Bit rate: 500kBit/s, Sample Point 87.5%
@@ -46,7 +46,7 @@ fn main() -> ! {
4646
let tx = gpiob.pb13;
4747
let rx = gpiob.pb12;
4848

49-
let can = dp.CAN2.can((tx, rx));
49+
let can = dp.CAN2.can((tx, rx), &mut rcc);
5050

5151
let can2 = bxcan::Can::builder(can)
5252
// APB1 (PCLK1): 8MHz, Bit rate: 500kBit/s, Sample Point 87.5%

examples/delay-syst-blinky.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ fn main() -> ! {
1919
pac::Peripherals::take(),
2020
cortex_m::peripheral::Peripherals::take(),
2121
) {
22+
// Set up the system clock. We want to run at 48MHz for this one.
23+
let mut rcc = dp.RCC.freeze(Config::hsi().sysclk(48.MHz()));
24+
2225
// Set up the LED. On the Nucleo-446RE it's connected to pin PA5.
23-
let gpioa = dp.GPIOA.split();
26+
let gpioa = dp.GPIOA.split(&mut rcc);
2427
let mut led = gpioa.pa5.into_push_pull_output();
2528

26-
// Set up the system clock. We want to run at 48MHz for this one.
27-
let rcc = dp.RCC.freeze(Config::hsi().sysclk(48.MHz()));
28-
2929
// Create a delay abstraction based on SysTick
3030
let mut delay = cp.SYST.delay(&rcc.clocks);
3131

examples/delay-timer-blinky.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ fn main() -> ! {
1919
pac::Peripherals::take(),
2020
cortex_m::peripheral::Peripherals::take(),
2121
) {
22+
// Set up the system clock. We want to run at 48MHz for this one.
23+
let mut rcc = dp.RCC.freeze(Config::hse(25.MHz()).sysclk(48.MHz()));
24+
2225
// Set up the LED. On the Mini-F4 it's connected to pin PC13.
23-
let gpioc = dp.GPIOC.split();
26+
let gpioc = dp.GPIOC.split(&mut rcc);
2427
let mut led = gpioc.pc13.into_push_pull_output();
2528

26-
// Set up the system clock. We want to run at 48MHz for this one.
27-
let rcc = dp.RCC.freeze(Config::hse(25.MHz()).sysclk(48.MHz()));
28-
2929
// Create a delay abstraction based on general-pupose 32-bit timer TIM5
30-
let mut delay = dp.TIM5.delay_us(&rcc.clocks);
30+
let mut delay = dp.TIM5.delay_us(&mut rcc);
3131

3232
loop {
3333
// On for 1s, off for 3s.

examples/display-touch.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ fn main() -> ! {
5353
let p = pac::Peripherals::take().unwrap();
5454
let cp = cortex_m::Peripherals::take().unwrap();
5555

56-
let rcc = p.RCC.freeze(Config::hsi().sysclk(100.MHz()));
56+
let mut rcc = p.RCC.freeze(Config::hsi().sysclk(100.MHz()));
5757
let mut delay = cp.SYST.delay(&rcc.clocks);
5858

59-
let gpiob = p.GPIOB.split();
60-
let gpioc = p.GPIOC.split();
61-
let gpiod = p.GPIOD.split();
62-
let gpioe = p.GPIOE.split();
63-
let gpiof = p.GPIOF.split();
64-
let gpiog = p.GPIOG.split();
59+
let gpiob = p.GPIOB.split(&mut rcc);
60+
let gpioc = p.GPIOC.split(&mut rcc);
61+
let gpiod = p.GPIOD.split(&mut rcc);
62+
let gpioe = p.GPIOE.split(&mut rcc);
63+
let gpiof = p.GPIOF.split(&mut rcc);
64+
let gpiog = p.GPIOG.split(&mut rcc);
6565

6666
// Pins connected to the LCD on the board
6767
use stm32f4xx_hal::gpio::alt::fsmc as alt;
@@ -120,7 +120,7 @@ fn main() -> ! {
120120
let read_timing = Timing::default().data(8).address_setup(8).bus_turnaround(0);
121121

122122
// Initialise FSMC memory provider
123-
let (_fsmc, interface) = FsmcLcd::new(p.FSMC, lcd_pins, &read_timing, &write_timing);
123+
let (_fsmc, interface) = FsmcLcd::new(p.FSMC, lcd_pins, &read_timing, &write_timing, &mut rcc);
124124

125125
// Pass display-interface instance ST7789 driver to setup a new display
126126
let mut disp = ST7789::new(
@@ -146,7 +146,7 @@ fn main() -> ! {
146146
// STM32F412 uses I2c1 type for i2c bus.
147147
// The pins are mentioned in documentation -um2135-discovery-kit-with-stm32f412zg-mcu-stmicroelectronics
148148
#[cfg(feature = "stm32f412")]
149-
let mut i2c = { I2c::new(p.I2C1, (gpiob.pb6, gpiob.pb7), 400.kHz(), &rcc.clocks) };
149+
let mut i2c = { I2c::new(p.I2C1, (gpiob.pb6, gpiob.pb7), 400.kHz(), &mut rcc) };
150150

151151
// STM32F413 uses FMPI2C1 type.
152152
// The pins are mentioned in documentation -um2135-discovery-kit-with-stm32f413zh-mcu-stmicroelectronics

examples/dwt-blinky.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ fn main() -> ! {
1919
pac::Peripherals::take(),
2020
cortex_m::peripheral::Peripherals::take(),
2121
) {
22+
// Set up the system clock. We want to run at 48MHz for this one.
23+
let mut rcc = dp.RCC.freeze(Config::hsi().sysclk(48.MHz()));
24+
2225
// Set up the LEDs. On the STM32F429I-DISC[O1] they are connected to pin PG13/14.
23-
let gpiog = dp.GPIOG.split();
26+
let gpiog = dp.GPIOG.split(&mut rcc);
2427
let mut led1 = gpiog.pg13.into_push_pull_output();
2528
let mut led2 = gpiog.pg14.into_push_pull_output();
2629

27-
// Set up the system clock. We want to run at 48MHz for this one.
28-
let rcc = dp.RCC.freeze(Config::hsi().sysclk(48.MHz()));
29-
3030
// Create a delay abstraction based on DWT cycle counter
3131
let dwt = cp.DWT.constrain(cp.DCB, &rcc.clocks);
3232
let mut delay = dwt.delay();

examples/dynamic-gpio.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ fn main() -> ! {
2020
// Take ownership over raw device and convert it into the corresponding HAL struct
2121
// Freeze the configuration of all the clocks in the system and store the frozen frequencies in
2222
// `clocks`
23-
let rcc = dp.RCC.constrain();
23+
let mut rcc = dp.RCC.constrain();
2424

2525
// Acquire the GPIOC peripheral
26-
let gpioc = dp.GPIOC.split();
26+
let gpioc = dp.GPIOC.split(&mut rcc);
2727

2828
let mut pin = gpioc.pc13.into_dynamic();
2929
// Configure the syst timer to trigger an update every second

examples/f413disco-lcd-ferris.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -697,15 +697,15 @@ fn main() -> ! {
697697
rtt_init_print!(ChannelMode::NoBlockTrim);
698698

699699
if let (Some(p), Some(cp)) = (Peripherals::take(), CorePeripherals::take()) {
700-
// Split all the GPIO blocks we need
701-
let gpiob = p.GPIOB.split();
702-
let gpiod = p.GPIOD.split();
703-
let gpioe = p.GPIOE.split();
704-
let gpiof = p.GPIOF.split();
705-
let gpiog = p.GPIOG.split();
706-
707700
// Configure and lock the clocks at maximum warp
708-
let rcc = p.RCC.freeze(Config::hsi().sysclk(100.MHz()));
701+
let mut rcc = p.RCC.freeze(Config::hsi().sysclk(100.MHz()));
702+
703+
// Split all the GPIO blocks we need
704+
let gpiob = p.GPIOB.split(&mut rcc);
705+
let gpiod = p.GPIOD.split(&mut rcc);
706+
let gpioe = p.GPIOE.split(&mut rcc);
707+
let gpiof = p.GPIOF.split(&mut rcc);
708+
let gpiog = p.GPIOG.split(&mut rcc);
709709

710710
// Define the pins we need for our 16bit parallel bus
711711
use stm32f4xx_hal::gpio::alt::fsmc as alt;
@@ -735,7 +735,8 @@ fn main() -> ! {
735735
let read_timing = Timing::default().data(8).address_setup(8).bus_turnaround(0);
736736

737737
// Initialise FSMC memory provider
738-
let (_fsmc, interface) = FsmcLcd::new(p.FSMC, lcd_pins, &read_timing, &write_timing);
738+
let (_fsmc, interface) =
739+
FsmcLcd::new(p.FSMC, lcd_pins, &read_timing, &write_timing, &mut rcc);
739740

740741
// Pass display-interface instance ST7789 driver to setup a new display
741742
let mut disp = ST7789::new(

0 commit comments

Comments
 (0)