diff options
| -rw-r--r-- | cyw43-pio/CHANGELOG.md | 2 | ||||
| -rw-r--r-- | cyw43-pio/src/lib.rs | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/cyw43-pio/CHANGELOG.md b/cyw43-pio/CHANGELOG.md index 584df6689..c2d18919c 100644 --- a/cyw43-pio/CHANGELOG.md +++ b/cyw43-pio/CHANGELOG.md | |||
| @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 7 | 7 | ||
| 8 | <!-- next-header --> | 8 | <!-- next-header --> |
| 9 | ## Unreleased - ReleaseDate | 9 | ## Unreleased - ReleaseDate |
| 10 | |||
| 10 | - Select pio program based on core clock speed #4792 | 11 | - Select pio program based on core clock speed #4792 |
| 12 | |||
| 11 | ## 0.8.0 - 2025-08-28 | 13 | ## 0.8.0 - 2025-08-28 |
| 12 | 14 | ||
| 13 | - Bump cyw43 version | 15 | - Bump cyw43 version |
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}; | |||
| 13 | use embassy_rp::pio::program::pio_asm; | 13 | use embassy_rp::pio::program::pio_asm; |
| 14 | use embassy_rp::pio::{Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine}; | 14 | use embassy_rp::pio::{Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine}; |
| 15 | use fixed::FixedU32; | 15 | use fixed::FixedU32; |
| 16 | use fixed::traits::LosslessTryInto; | ||
| 17 | use fixed::types::extra::U8; | 16 | use 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 |
