aboutsummaryrefslogtreecommitdiff
path: root/cyw43-pio/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cyw43-pio/src/lib.rs')
-rw-r--r--cyw43-pio/src/lib.rs7
1 files changed, 3 insertions, 4 deletions
diff --git a/cyw43-pio/src/lib.rs b/cyw43-pio/src/lib.rs
index 51d8ec3ae..c8715e662 100644
--- a/cyw43-pio/src/lib.rs
+++ b/cyw43-pio/src/lib.rs
@@ -13,7 +13,6 @@ use embassy_rp::gpio::{Drive, Level, Output, Pull, SlewRate};
13use embassy_rp::pio::program::pio_asm; 13use embassy_rp::pio::program::pio_asm;
14use embassy_rp::pio::{Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine}; 14use embassy_rp::pio::{Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine};
15use fixed::FixedU32; 15use fixed::FixedU32;
16use fixed::traits::LosslessTryInto;
17use fixed::types::extra::U8; 16use fixed::types::extra::U8;
18 17
19/// SPI comms driven by PIO. 18/// SPI comms driven by PIO.
@@ -64,7 +63,7 @@ where
64 let effective_pio_frequency = (clk_sys_freq() as f32 / clock_divider.to_num::<f32>()) as u32; 63 let effective_pio_frequency = (clk_sys_freq() as f32 / clock_divider.to_num::<f32>()) as u32;
65 64
66 #[cfg(feature = "defmt")] 65 #[cfg(feature = "defmt")]
67 defmt::trace!("Effective pio frequency: {}", effective_pio_frequency); 66 defmt::trace!("Effective pio frequency: {}Hz", effective_pio_frequency);
68 67
69 // Non-integer pio clock dividers are achieved by introducing clock jitter resulting in a 68 // Non-integer pio clock dividers are achieved by introducing clock jitter resulting in a
70 // combination of long and short cycles. The long and short cycles average to achieve the 69 // combination of long and short cycles. The long and short cycles average to achieve the
@@ -72,14 +71,14 @@ where
72 // This can be a problem for peripherals that expect a consistent clock / have a clock 71 // This can be a problem for peripherals that expect a consistent clock / have a clock
73 // speed upper bound that is violated by the short cycles. The cyw43 seems to handle the 72 // speed upper bound that is violated by the short cycles. The cyw43 seems to handle the
74 // jitter well, but we emit a warning to recommend an integer divider anyway. 73 // jitter well, but we emit a warning to recommend an integer divider anyway.
75 if let None = clock_divider.lossless_try_into<u32>() { 74 if clock_divider.frac() != FixedU32::<U8>::ZERO {
76 #[cfg(feature = "defmt")] 75 #[cfg(feature = "defmt")]
77 defmt::trace!( 76 defmt::trace!(
78 "Configured clock divider is not a whole number. Some clock cycles may violate the maximum recommended GSPI speed. Use at your own risk." 77 "Configured clock divider is not a whole number. Some clock cycles may violate the maximum recommended GSPI speed. Use at your own risk."
79 ); 78 );
80 } 79 }
81 80
82 // Different pio programs must be used for different pio clock speeds. 81 // Different pio programs must be used for different pio clock speeds.
83 // The programs used below are based on the pico SDK: https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.pio 82 // The programs used below are based on the pico SDK: https://github.com/raspberrypi/pico-sdk/blob/master/src/rp2_common/pico_cyw43_driver/cyw43_bus_pio_spi.pio
84 // The clock speed cutoff for each program has been determined experimentally: 83 // The clock speed cutoff for each program has been determined experimentally:
85 // > 100Mhz -> Overclock program 84 // > 100Mhz -> Overclock program