diff options
| author | James Munns <[email protected]> | 2025-12-18 14:53:33 +0100 |
|---|---|---|
| committer | James Munns <[email protected]> | 2025-12-18 15:02:24 +0100 |
| commit | b0cf9b4626e7fa99d1da82a5eb745e9ed14508de (patch) | |
| tree | 8c8cdbf14561ac133d0fd377b9ebd57105495105 /examples/mcxa | |
| parent | c94c09c72d16fd5cc9cb7c925386e7a2d6de1dcd (diff) | |
First basic test works
Diffstat (limited to 'examples/mcxa')
| -rw-r--r-- | examples/mcxa/src/bin/clkout.rs | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/examples/mcxa/src/bin/clkout.rs b/examples/mcxa/src/bin/clkout.rs index e6e6a2d3d..94f7d7bbf 100644 --- a/examples/mcxa/src/bin/clkout.rs +++ b/examples/mcxa/src/bin/clkout.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | use embassy_executor::Spawner; | 4 | use embassy_executor::Spawner; |
| 5 | use embassy_mcxa::clkout::{ClockOut, ClockOutSel, Config, Div4}; | 5 | use embassy_mcxa::clkout::{ClockOut, ClockOutSel, Config, Div4}; |
| 6 | use embassy_mcxa::clocks::PoweredClock; | 6 | use embassy_mcxa::clocks::PoweredClock; |
| 7 | use embassy_mcxa::clocks::config::{SoscConfig, SoscMode}; | 7 | use embassy_mcxa::clocks::config::{SoscConfig, SoscMode, SpllConfig, SpllMode, SpllSource}; |
| 8 | use embassy_mcxa::gpio::{DriveStrength, Level, Output, SlewRate}; | 8 | use embassy_mcxa::gpio::{DriveStrength, Level, Output, SlewRate}; |
| 9 | use embassy_time::Timer; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; | 10 | use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; |
| @@ -18,6 +18,18 @@ async fn main(_spawner: Spawner) { | |||
| 18 | frequency: 8_000_000, | 18 | frequency: 8_000_000, |
| 19 | power: PoweredClock::NormalEnabledDeepSleepDisabled, | 19 | power: PoweredClock::NormalEnabledDeepSleepDisabled, |
| 20 | }); | 20 | }); |
| 21 | cfg.clock_cfg.spll = Some(SpllConfig { | ||
| 22 | source: SpllSource::Sirc, // 12MHz | ||
| 23 | // 12 x 32 => 384MHz | ||
| 24 | // 384 / (16 x 2) => 12.0MHz | ||
| 25 | mode: SpllMode::Mode1b { | ||
| 26 | m_mult: 32, | ||
| 27 | p_div: 16, | ||
| 28 | bypass_p2_div: false, | ||
| 29 | }, | ||
| 30 | power: PoweredClock::NormalEnabledDeepSleepDisabled, | ||
| 31 | pll1_clk_div: None, | ||
| 32 | }); | ||
| 21 | 33 | ||
| 22 | let p = hal::init(cfg); | 34 | let p = hal::init(cfg); |
| 23 | 35 | ||
| @@ -39,11 +51,18 @@ async fn main(_spawner: Spawner) { | |||
| 39 | div: const { Div4::from_divisor(16).unwrap() }, | 51 | div: const { Div4::from_divisor(16).unwrap() }, |
| 40 | level: PoweredClock::NormalEnabledDeepSleepDisabled, | 52 | level: PoweredClock::NormalEnabledDeepSleepDisabled, |
| 41 | }; | 53 | }; |
| 54 | const M1_CONFIG: Config = Config { | ||
| 55 | sel: ClockOutSel::Pll1Clk, | ||
| 56 | div: const { Div4::from_divisor(12).unwrap() }, | ||
| 57 | level: PoweredClock::NormalEnabledDeepSleepDisabled, | ||
| 58 | }; | ||
| 42 | 59 | ||
| 60 | #[rustfmt::skip] | ||
| 43 | let configs = [ | 61 | let configs = [ |
| 44 | ("16K -> /1 = 16K", K16_CONFIG), | 62 | ("16K -> /1 = 16K", K16_CONFIG), |
| 45 | ("12M -> /3 = 4M", M4_CONFIG), | 63 | ("12M -> /3 = 4M", M4_CONFIG), |
| 46 | ("8M -> /16 = 512K", K512_CONFIG), | 64 | ("8M -> /16 = 512K", K512_CONFIG), |
| 65 | ("12M-> /12 = 1M", M1_CONFIG), | ||
| 47 | ]; | 66 | ]; |
| 48 | 67 | ||
| 49 | loop { | 68 | loop { |
