Content-Length: 1336598 | pFad | http://github.com/stm32-rs/stm32f4xx-hal/commit/7c224176ef354a439211411792a99ea818eea7f1

52 gpio rcc · stm32-rs/stm32f4xx-hal@7c22417 · GitHub
Skip to content

Commit 7c22417

Browse files
committed
gpio rcc
1 parent 63e7ae9 commit 7c22417

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

+551
-583
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(

examples/f469disco-lcd-test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ fn main() -> ! {
5353
let cp = CorePeripherals::take().unwrap();
5454

5555
let hse_freq = 8.MHz();
56-
let rcc = dp
56+
let mut rcc = dp
5757
.RCC
5858
.freeze(Config::hse(hse_freq).pclk2(32.MHz()).sysclk(180.MHz()));
5959
let mut delay = cp.SYST.delay(&rcc.clocks);
6060

61-
let gpioh = dp.GPIOH.split();
61+
let gpioh = dp.GPIOH.split(&mut rcc);
6262

6363
// Reset display
6464
let mut lcd_reset = gpioh.ph7.into_push_pull_output();
@@ -107,7 +107,7 @@ fn main() -> ! {
107107
DISPLAY_CONFIGURATION,
108108
dsi_config,
109109
dp.DSI,
110-
&rcc.clocks,
110+
&mut rcc,
111111
)
112112
.unwrap();
113113

examples/fmc-sdram.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ impl XorShift32 {
4949
#[entry]
5050
fn main() -> ! {
5151
if let (Some(p), Some(cp)) = (pac::Peripherals::take(), Peripherals::take()) {
52-
let rcc = p.RCC.freeze(Config::hsi().sysclk(180.MHz()));
52+
let mut rcc = p.RCC.freeze(Config::hsi().sysclk(180.MHz()));
5353

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

56-
let gpioc = p.GPIOC.split();
57-
let gpiod = p.GPIOD.split();
58-
let gpioe = p.GPIOE.split();
59-
let gpiof = p.GPIOF.split();
60-
let gpiog = p.GPIOG.split();
61-
let gpioh = p.GPIOH.split();
62-
let gpioi = p.GPIOI.split();
56+
let gpioc = p.GPIOC.split(&mut rcc);
57+
let gpiod = p.GPIOD.split(&mut rcc);
58+
let gpioe = p.GPIOE.split(&mut rcc);
59+
let gpiof = p.GPIOF.split(&mut rcc);
60+
let gpiog = p.GPIOG.split(&mut rcc);
61+
let gpioh = p.GPIOH.split(&mut rcc);
62+
let gpioi = p.GPIOI.split(&mut rcc);
6363

6464
#[rustfmt::skip]
6565
let pins = fmc_pins! {

examples/hd44780.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ use stm32f4xx_hal::{pac, prelude::*};
2222
fn main() -> ! {
2323
let dp = pac::Peripherals::take().unwrap();
2424

25-
let rcc = dp.RCC.constrain();
26-
let gpiob = dp.GPIOB.split();
25+
let mut rcc = dp.RCC.constrain();
26+
let gpiob = dp.GPIOB.split(&mut rcc);
2727

28-
let mut delay = dp.TIM1.delay_us(&rcc.clocks);
28+
let mut delay = dp.TIM1.delay_us(&mut rcc);
2929

3030
let rs = gpiob.pb7.into_push_pull_output();
3131
let en = gpiob.pb8.into_push_pull_output();

examples/i2c_scanner.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ fn main() -> ! {
1919
rtt_init_print!();
2020
let dp = pac::Peripherals::take().unwrap();
2121

22-
let rcc = dp.RCC.constrain();
22+
let mut rcc = dp.RCC.constrain();
2323

24-
let gpiob = dp.GPIOB.split();
24+
let gpiob = dp.GPIOB.split(&mut rcc);
2525

2626
// Configure I2C1
2727
let scl = gpiob.pb8;
@@ -30,7 +30,7 @@ fn main() -> ! {
3030
dp.I2C1,
3131
(scl, sda),
3232
hal::i2c::Mode::standard(100.kHz()),
33-
&rcc.clocks,
33+
&mut rcc,
3434
);
3535

3636
rprintln!("Start i2c scanning...");

examples/i2s-audio-out.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,19 @@ fn main() -> ! {
9292
rtt_init_print!();
9393
let dp = Peripherals::take().unwrap();
9494

95-
let gpioa = dp.GPIOA.split();
96-
let gpioc = dp.GPIOC.split();
97-
9895
// The 61440 kHz frequency can be divided to get exactly 48 kHz sample rate even when
9996
// generating master clock
100-
let rcc = dp.RCC.freeze(
97+
let mut rcc = dp.RCC.freeze(
10198
Config::hse(8u32.MHz())
10299
.sysclk(96.MHz())
103100
.i2s_clk(61440.kHz()),
104101
);
105102

103+
let gpioa = dp.GPIOA.split(&mut rcc);
104+
let gpioc = dp.GPIOC.split(&mut rcc);
105+
106106
let i2s_pins = (gpioa.pa4, gpioc.pc10, NoPin::new(), gpioc.pc12);
107-
let i2s = I2s::new(dp.SPI3, i2s_pins, &rcc.clocks);
107+
let i2s = I2s::new(dp.SPI3, i2s_pins, &mut rcc);
108108
let i2s_config = I2sTransferConfig::new_master()
109109
.transmit()
110110
.standard(Philips)

examples/ist7920-bidi-normal-spi.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ fn main() -> ! {
1919
let dp = pac::Peripherals::take().unwrap();
2020
let cp = cortex_m::peripheral::Peripherals::take().unwrap();
2121

22-
let gpioa = dp.GPIOA.split();
23-
let gpiob = dp.GPIOB.split();
24-
let rcc = dp.RCC.constrain();
22+
let mut rcc = dp.RCC.constrain();
23+
24+
let gpioa = dp.GPIOA.split(&mut rcc);
25+
let gpiob = dp.GPIOB.split(&mut rcc);
2526

2627
let mut led = gpioa.pa5.into_push_pull_output();
2728
led.set_low();
@@ -41,9 +42,9 @@ fn main() -> ! {
4142
};
4243

4344
// Change spi transfer mode to Bidi for more efficient operations.
44-
// let spi = Spi::new(dp.SPI1, (sck, miso, mosi), mode, 8.MHz(), &rcc.clocks).to_bidi_transfer_mode();
45+
// let spi = Spi::new(dp.SPI1, (sck, miso, mosi), mode, 8.MHz(), &mut rcc).to_bidi_transfer_mode();
4546
// or
46-
let spi = dp.SPI1.spi_bidi((sck, mosi), mode, 8.MHz(), &rcc.clocks);
47+
let spi = dp.SPI1.spi_bidi((sck, mosi), mode, 8.MHz(), &mut rcc);
4748

4849
let iface = SPIInterface::new(spi, dc, cs);
4950

0 commit comments

Comments
 (0)








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/commit/7c224176ef354a439211411792a99ea818eea7f1

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy