aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32g4
diff options
context:
space:
mode:
Diffstat (limited to 'examples/stm32g4')
-rw-r--r--examples/stm32g4/src/bin/adc.rs16
-rw-r--r--examples/stm32g4/src/bin/pll.rs16
-rw-r--r--examples/stm32g4/src/bin/usb_serial.rs29
3 files changed, 34 insertions, 27 deletions
diff --git a/examples/stm32g4/src/bin/adc.rs b/examples/stm32g4/src/bin/adc.rs
index 35324d931..99e3ef63b 100644
--- a/examples/stm32g4/src/bin/adc.rs
+++ b/examples/stm32g4/src/bin/adc.rs
@@ -4,7 +4,7 @@
4use defmt::*; 4use defmt::*;
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_stm32::adc::{Adc, SampleTime}; 6use embassy_stm32::adc::{Adc, SampleTime};
7use embassy_stm32::rcc::{AdcClockSource, ClockSrc, Pll, PllM, PllN, PllR, PllSource}; 7use embassy_stm32::rcc::{AdcClockSource, Pll, PllMul, PllPreDiv, PllRDiv, Pllsrc, Sysclk};
8use embassy_stm32::Config; 8use embassy_stm32::Config;
9use embassy_time::{Delay, Timer}; 9use embassy_time::{Delay, Timer};
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
@@ -14,17 +14,17 @@ async fn main(_spawner: Spawner) {
14 let mut config = Config::default(); 14 let mut config = Config::default();
15 15
16 config.rcc.pll = Some(Pll { 16 config.rcc.pll = Some(Pll {
17 source: PllSource::HSI, 17 source: Pllsrc::HSI,
18 prediv_m: PllM::DIV4, 18 prediv: PllPreDiv::DIV4,
19 mul_n: PllN::MUL85, 19 mul: PllMul::MUL85,
20 div_p: None, 20 divp: None,
21 div_q: None, 21 divq: None,
22 // Main system clock at 170 MHz 22 // Main system clock at 170 MHz
23 div_r: Some(PllR::DIV2), 23 divr: Some(PllRDiv::DIV2),
24 }); 24 });
25 25
26 config.rcc.adc12_clock_source = AdcClockSource::SYS; 26 config.rcc.adc12_clock_source = AdcClockSource::SYS;
27 config.rcc.mux = ClockSrc::PLL; 27 config.rcc.sys = Sysclk::PLL1_R;
28 28
29 let mut p = embassy_stm32::init(config); 29 let mut p = embassy_stm32::init(config);
30 info!("Hello World!"); 30 info!("Hello World!");
diff --git a/examples/stm32g4/src/bin/pll.rs b/examples/stm32g4/src/bin/pll.rs
index 46ebe0b0d..5274de79d 100644
--- a/examples/stm32g4/src/bin/pll.rs
+++ b/examples/stm32g4/src/bin/pll.rs
@@ -3,7 +3,7 @@
3 3
4use defmt::*; 4use defmt::*;
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_stm32::rcc::{ClockSrc, Pll, PllM, PllN, PllR, PllSource}; 6use embassy_stm32::rcc::{Pll, PllMul, PllPreDiv, PllRDiv, Pllsrc, Sysclk};
7use embassy_stm32::Config; 7use embassy_stm32::Config;
8use embassy_time::Timer; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {defmt_rtt as _, panic_probe as _};
@@ -13,16 +13,16 @@ async fn main(_spawner: Spawner) {
13 let mut config = Config::default(); 13 let mut config = Config::default();
14 14
15 config.rcc.pll = Some(Pll { 15 config.rcc.pll = Some(Pll {
16 source: PllSource::HSI, 16 source: Pllsrc::HSI,
17 prediv_m: PllM::DIV4, 17 prediv: PllPreDiv::DIV4,
18 mul_n: PllN::MUL85, 18 mul: PllMul::MUL85,
19 div_p: None, 19 divp: None,
20 div_q: None, 20 divq: None,
21 // Main system clock at 170 MHz 21 // Main system clock at 170 MHz
22 div_r: Some(PllR::DIV2), 22 divr: Some(PllRDiv::DIV2),
23 }); 23 });
24 24
25 config.rcc.mux = ClockSrc::PLL; 25 config.rcc.sys = Sysclk::PLL1_R;
26 26
27 let _p = embassy_stm32::init(config); 27 let _p = embassy_stm32::init(config);
28 info!("Hello World!"); 28 info!("Hello World!");
diff --git a/examples/stm32g4/src/bin/usb_serial.rs b/examples/stm32g4/src/bin/usb_serial.rs
index c26fa76b7..d9207e4cd 100644
--- a/examples/stm32g4/src/bin/usb_serial.rs
+++ b/examples/stm32g4/src/bin/usb_serial.rs
@@ -3,7 +3,9 @@
3 3
4use defmt::{panic, *}; 4use defmt::{panic, *};
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_stm32::rcc::{Clock48MhzSrc, ClockSrc, Hsi48Config, Pll, PllM, PllN, PllQ, PllR, PllSource}; 6use embassy_stm32::rcc::{
7 Clock48MhzSrc, Hse, HseMode, Hsi48Config, Pll, PllMul, PllPreDiv, PllQDiv, PllRDiv, Pllsrc, Sysclk,
8};
7use embassy_stm32::time::Hertz; 9use embassy_stm32::time::Hertz;
8use embassy_stm32::usb::{self, Driver, Instance}; 10use embassy_stm32::usb::{self, Driver, Instance};
9use embassy_stm32::{bind_interrupts, peripherals, Config}; 11use embassy_stm32::{bind_interrupts, peripherals, Config};
@@ -24,25 +26,30 @@ async fn main(_spawner: Spawner) {
24 // Change this to `false` to use the HSE clock source for the USB. This example assumes an 8MHz HSE. 26 // Change this to `false` to use the HSE clock source for the USB. This example assumes an 8MHz HSE.
25 const USE_HSI48: bool = true; 27 const USE_HSI48: bool = true;
26 28
27 let plldivq = if USE_HSI48 { None } else { Some(PllQ::DIV6) }; 29 let plldivq = if USE_HSI48 { None } else { Some(PllQDiv::DIV6) };
30
31 config.rcc.hse = Some(Hse {
32 freq: Hertz(8_000_000),
33 mode: HseMode::Oscillator,
34 });
28 35
29 config.rcc.pll = Some(Pll { 36 config.rcc.pll = Some(Pll {
30 source: PllSource::HSE(Hertz(8_000_000)), 37 source: Pllsrc::HSE,
31 prediv_m: PllM::DIV2, 38 prediv: PllPreDiv::DIV2,
32 mul_n: PllN::MUL72, 39 mul: PllMul::MUL72,
33 div_p: None, 40 divp: None,
34 div_q: plldivq, 41 divq: plldivq,
35 // Main system clock at 144 MHz 42 // Main system clock at 144 MHz
36 div_r: Some(PllR::DIV2), 43 divr: Some(PllRDiv::DIV2),
37 }); 44 });
38 45
39 config.rcc.mux = ClockSrc::PLL; 46 config.rcc.sys = Sysclk::PLL1_R;
40 47
41 if USE_HSI48 { 48 if USE_HSI48 {
42 // Sets up the Clock Recovery System (CRS) to use the USB SOF to trim the HSI48 oscillator. 49 // Sets up the Clock Recovery System (CRS) to use the USB SOF to trim the HSI48 oscillator.
43 config.rcc.clock_48mhz_src = Some(Clock48MhzSrc::Hsi48(Hsi48Config { sync_from_usb: true })); 50 config.rcc.clk48_src = Some(Clock48MhzSrc::Hsi48(Hsi48Config { sync_from_usb: true }));
44 } else { 51 } else {
45 config.rcc.clock_48mhz_src = Some(Clock48MhzSrc::PllQ); 52 config.rcc.clk48_src = Some(Clock48MhzSrc::PllQ);
46 } 53 }
47 54
48 let p = embassy_stm32::init(config); 55 let p = embassy_stm32::init(config);