diff options
| -rw-r--r-- | embassy-rp/src/pio_programs/i2s.rs | 14 | ||||
| -rw-r--r-- | embassy-rp/src/pio_programs/pwm.rs | 9 | ||||
| -rw-r--r-- | embassy-rp/src/pio_programs/rotary_encoder.rs | 3 | ||||
| -rw-r--r-- | embassy-rp/src/pio_programs/stepper.rs | 3 | ||||
| -rw-r--r-- | embassy-rp/src/pio_programs/uart.rs | 15 | ||||
| -rw-r--r-- | embassy-rp/src/pio_programs/ws2812.rs | 14 |
6 files changed, 28 insertions, 30 deletions
diff --git a/embassy-rp/src/pio_programs/i2s.rs b/embassy-rp/src/pio_programs/i2s.rs index 3c8ef8bb6..e3f1f89d4 100644 --- a/embassy-rp/src/pio_programs/i2s.rs +++ b/embassy-rp/src/pio_programs/i2s.rs | |||
| @@ -1,15 +1,13 @@ | |||
| 1 | //! Pio backed I2s output | 1 | //! Pio backed I2s output |
| 2 | 2 | ||
| 3 | use crate::{ | ||
| 4 | dma::{AnyChannel, Channel, Transfer}, | ||
| 5 | into_ref, | ||
| 6 | pio::{ | ||
| 7 | Common, Config, Direction, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, | ||
| 8 | }, | ||
| 9 | Peripheral, PeripheralRef, | ||
| 10 | }; | ||
| 11 | use fixed::traits::ToFixed; | 3 | use fixed::traits::ToFixed; |
| 12 | 4 | ||
| 5 | use crate::dma::{AnyChannel, Channel, Transfer}; | ||
| 6 | use crate::pio::{ | ||
| 7 | Common, Config, Direction, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, | ||
| 8 | }; | ||
| 9 | use crate::{into_ref, Peripheral, PeripheralRef}; | ||
| 10 | |||
| 13 | /// This struct represents an i2s output driver program | 11 | /// This struct represents an i2s output driver program |
| 14 | pub struct PioI2sOutProgram<'a, PIO: Instance> { | 12 | pub struct PioI2sOutProgram<'a, PIO: Instance> { |
| 15 | prg: LoadedProgram<'a, PIO>, | 13 | prg: LoadedProgram<'a, PIO>, |
diff --git a/embassy-rp/src/pio_programs/pwm.rs b/embassy-rp/src/pio_programs/pwm.rs index 5dfd70cc9..8a0f3d5ee 100644 --- a/embassy-rp/src/pio_programs/pwm.rs +++ b/embassy-rp/src/pio_programs/pwm.rs | |||
| @@ -2,13 +2,12 @@ | |||
| 2 | 2 | ||
| 3 | use core::time::Duration; | 3 | use core::time::Duration; |
| 4 | 4 | ||
| 5 | use crate::{ | ||
| 6 | clocks, | ||
| 7 | gpio::Level, | ||
| 8 | pio::{Common, Config, Direction, Instance, LoadedProgram, PioPin, StateMachine}, | ||
| 9 | }; | ||
| 10 | use pio::InstructionOperands; | 5 | use pio::InstructionOperands; |
| 11 | 6 | ||
| 7 | use crate::clocks; | ||
| 8 | use crate::gpio::Level; | ||
| 9 | use crate::pio::{Common, Config, Direction, Instance, LoadedProgram, PioPin, StateMachine}; | ||
| 10 | |||
| 12 | fn to_pio_cycles(duration: Duration) -> u32 { | 11 | fn to_pio_cycles(duration: Duration) -> u32 { |
| 13 | (clocks::clk_sys_freq() / 1_000_000) / 3 * duration.as_micros() as u32 // parentheses are required to prevent overflow | 12 | (clocks::clk_sys_freq() / 1_000_000) / 3 * duration.as_micros() as u32 // parentheses are required to prevent overflow |
| 14 | } | 13 | } |
diff --git a/embassy-rp/src/pio_programs/rotary_encoder.rs b/embassy-rp/src/pio_programs/rotary_encoder.rs index 323f839bc..86423fd31 100644 --- a/embassy-rp/src/pio_programs/rotary_encoder.rs +++ b/embassy-rp/src/pio_programs/rotary_encoder.rs | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | //! PIO backed quadrature encoder | 1 | //! PIO backed quadrature encoder |
| 2 | 2 | ||
| 3 | use fixed::traits::ToFixed; | ||
| 4 | |||
| 3 | use crate::gpio::Pull; | 5 | use crate::gpio::Pull; |
| 4 | use crate::pio::{self, Common, Config, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine}; | 6 | use crate::pio::{self, Common, Config, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine}; |
| 5 | use fixed::traits::ToFixed; | ||
| 6 | 7 | ||
| 7 | /// This struct represents an Encoder program loaded into pio instruction memory. | 8 | /// This struct represents an Encoder program loaded into pio instruction memory. |
| 8 | pub struct PioEncoderProgram<'a, PIO: Instance> { | 9 | pub struct PioEncoderProgram<'a, PIO: Instance> { |
diff --git a/embassy-rp/src/pio_programs/stepper.rs b/embassy-rp/src/pio_programs/stepper.rs index 0ecc4eff0..0d58c754c 100644 --- a/embassy-rp/src/pio_programs/stepper.rs +++ b/embassy-rp/src/pio_programs/stepper.rs | |||
| @@ -2,11 +2,12 @@ | |||
| 2 | 2 | ||
| 3 | use core::mem::{self, MaybeUninit}; | 3 | use core::mem::{self, MaybeUninit}; |
| 4 | 4 | ||
| 5 | use crate::pio::{Common, Config, Direction, Instance, Irq, LoadedProgram, PioPin, StateMachine}; | ||
| 6 | use fixed::traits::ToFixed; | 5 | use fixed::traits::ToFixed; |
| 7 | use fixed::types::extra::U8; | 6 | use fixed::types::extra::U8; |
| 8 | use fixed::FixedU32; | 7 | use fixed::FixedU32; |
| 9 | 8 | ||
| 9 | use crate::pio::{Common, Config, Direction, Instance, Irq, LoadedProgram, PioPin, StateMachine}; | ||
| 10 | |||
| 10 | /// This struct represents a Stepper driver program loaded into pio instruction memory. | 11 | /// This struct represents a Stepper driver program loaded into pio instruction memory. |
| 11 | pub struct PioStepperProgram<'a, PIO: Instance> { | 12 | pub struct PioStepperProgram<'a, PIO: Instance> { |
| 12 | prg: LoadedProgram<'a, PIO>, | 13 | prg: LoadedProgram<'a, PIO>, |
diff --git a/embassy-rp/src/pio_programs/uart.rs b/embassy-rp/src/pio_programs/uart.rs index f4b3b204e..c643f1063 100644 --- a/embassy-rp/src/pio_programs/uart.rs +++ b/embassy-rp/src/pio_programs/uart.rs | |||
| @@ -1,17 +1,16 @@ | |||
| 1 | //! Pio backed uart drivers | 1 | //! Pio backed uart drivers |
| 2 | 2 | ||
| 3 | use crate::{ | ||
| 4 | clocks::clk_sys_freq, | ||
| 5 | gpio::Level, | ||
| 6 | pio::{ | ||
| 7 | Common, Config, Direction as PioDirection, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, | ||
| 8 | StateMachine, | ||
| 9 | }, | ||
| 10 | }; | ||
| 11 | use core::convert::Infallible; | 3 | use core::convert::Infallible; |
| 4 | |||
| 12 | use embedded_io_async::{ErrorType, Read, Write}; | 5 | use embedded_io_async::{ErrorType, Read, Write}; |
| 13 | use fixed::traits::ToFixed; | 6 | use fixed::traits::ToFixed; |
| 14 | 7 | ||
| 8 | use crate::clocks::clk_sys_freq; | ||
| 9 | use crate::gpio::Level; | ||
| 10 | use crate::pio::{ | ||
| 11 | Common, Config, Direction as PioDirection, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine, | ||
| 12 | }; | ||
| 13 | |||
| 15 | /// This struct represents a uart tx program loaded into pio instruction memory. | 14 | /// This struct represents a uart tx program loaded into pio instruction memory. |
| 16 | pub struct PioUartTxProgram<'a, PIO: Instance> { | 15 | pub struct PioUartTxProgram<'a, PIO: Instance> { |
| 17 | prg: LoadedProgram<'a, PIO>, | 16 | prg: LoadedProgram<'a, PIO>, |
diff --git a/embassy-rp/src/pio_programs/ws2812.rs b/embassy-rp/src/pio_programs/ws2812.rs index 3fc7e1017..875f0209f 100644 --- a/embassy-rp/src/pio_programs/ws2812.rs +++ b/embassy-rp/src/pio_programs/ws2812.rs | |||
| @@ -1,16 +1,16 @@ | |||
| 1 | //! [ws2812](https://www.sparkfun.com/datasheets/LCD/HD44780.pdf) | 1 | //! [ws2812](https://www.sparkfun.com/datasheets/LCD/HD44780.pdf) |
| 2 | 2 | ||
| 3 | use crate::{ | ||
| 4 | clocks::clk_sys_freq, | ||
| 5 | dma::{AnyChannel, Channel}, | ||
| 6 | into_ref, | ||
| 7 | pio::{Common, Config, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine}, | ||
| 8 | Peripheral, PeripheralRef, | ||
| 9 | }; | ||
| 10 | use embassy_time::Timer; | 3 | use embassy_time::Timer; |
| 11 | use fixed::types::U24F8; | 4 | use fixed::types::U24F8; |
| 12 | use smart_leds::RGB8; | 5 | use smart_leds::RGB8; |
| 13 | 6 | ||
| 7 | use crate::clocks::clk_sys_freq; | ||
| 8 | use crate::dma::{AnyChannel, Channel}; | ||
| 9 | use crate::pio::{ | ||
| 10 | Common, Config, FifoJoin, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine, | ||
| 11 | }; | ||
| 12 | use crate::{into_ref, Peripheral, PeripheralRef}; | ||
| 13 | |||
| 14 | const T1: u8 = 2; // start bit | 14 | const T1: u8 = 2; // start bit |
| 15 | const T2: u8 = 5; // data bit | 15 | const T2: u8 = 5; // data bit |
| 16 | const T3: u8 = 3; // stop bit | 16 | const T3: u8 = 3; // stop bit |
