diff options
| author | Caleb Jamison <[email protected]> | 2023-05-09 12:10:24 -0400 |
|---|---|---|
| committer | Caleb Jamison <[email protected]> | 2023-05-09 12:10:24 -0400 |
| commit | 5015c845c59e8769d404dce5ca618cdf6fd16aeb (patch) | |
| tree | 5adccf2cc27a2bb60c93d167f1a72917dae27642 /examples | |
| parent | c1eaad41f30d0b712b94e05f62dc7bb90fe8cc6d (diff) | |
Improve gpout example, clk_gpout_freq
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/rp/Cargo.toml | 3 | ||||
| -rw-r--r-- | examples/rp/src/bin/gpout.rs | 25 |
2 files changed, 22 insertions, 6 deletions
diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index d2829df99..7d5473f2c 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml | |||
| @@ -48,3 +48,6 @@ pio = "0.2.1" | |||
| 48 | 48 | ||
| 49 | [profile.release] | 49 | [profile.release] |
| 50 | debug = true | 50 | debug = true |
| 51 | |||
| 52 | [patch.crates-io] | ||
| 53 | rp-pac = {git = "https://github.com/CBJamo/rp-pac.git"} | ||
diff --git a/examples/rp/src/bin/gpout.rs b/examples/rp/src/bin/gpout.rs index 0503212e8..ea0efb859 100644 --- a/examples/rp/src/bin/gpout.rs +++ b/examples/rp/src/bin/gpout.rs | |||
| @@ -5,17 +5,30 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_rp::{clocks, pac}; | 7 | use embassy_rp::{clocks, pac}; |
| 8 | use embassy_time::{Duration, Timer}; | ||
| 8 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 10 | ||
| 10 | #[embassy_executor::main] | 11 | #[embassy_executor::main] |
| 11 | async fn main(_spawner: Spawner) { | 12 | async fn main(_spawner: Spawner) { |
| 12 | let p = embassy_rp::init(Default::default()); | 13 | let p = embassy_rp::init(Default::default()); |
| 13 | //let mut led = Output::new(p.PIN_25, Level::Low); | ||
| 14 | 14 | ||
| 15 | let gpout0 = clocks::Gpout0::new(p.PIN_21); | 15 | let gpout3 = clocks::Gpout::new(p.PIN_25); |
| 16 | gpout0.set_src(pac::clocks::vals::ClkGpout0ctrlAuxsrc::CLK_SYS); | 16 | gpout3.set_div(1000, 0); |
| 17 | gpout0.set_div(1000, 0); | 17 | gpout3.enable(); |
| 18 | gpout0.enable(); | ||
| 19 | 18 | ||
| 20 | info!("Pin 21 should be toggling at {} hz", clocks::clk_gpout0_freq()); | 19 | loop { |
| 20 | gpout3.set_src(pac::clocks::vals::ClkGpoutCtrlAuxsrc::CLK_SYS); | ||
| 21 | info!( | ||
| 22 | "Pin 25 is now outputing CLK_SYS/1000, should be toggling at {}", | ||
| 23 | clocks::clk_gpout_freq(&gpout3) | ||
| 24 | ); | ||
| 25 | Timer::after(Duration::from_secs(2)).await; | ||
| 26 | |||
| 27 | gpout3.set_src(pac::clocks::vals::ClkGpoutCtrlAuxsrc::CLK_REF); | ||
| 28 | info!( | ||
| 29 | "Pin 25 is now outputing CLK_REF/1000, should be toggling at {}", | ||
| 30 | clocks::clk_gpout_freq(&gpout3) | ||
| 31 | ); | ||
| 32 | Timer::after(Duration::from_secs(2)).await; | ||
| 33 | } | ||
| 21 | } | 34 | } |
