diff options
| -rw-r--r-- | cyw43-pio/Cargo.toml | 2 | ||||
| -rw-r--r-- | cyw43-pio/src/lib.rs | 20 | ||||
| -rw-r--r-- | embassy-rp/Cargo.toml | 5 | ||||
| -rw-r--r-- | embassy-rp/src/pio/instr.rs | 158 | ||||
| -rw-r--r-- | embassy-rp/src/pio/mod.rs | 7 | ||||
| -rw-r--r-- | embassy-rp/src/pio_programs/hd44780.rs | 4 | ||||
| -rw-r--r-- | embassy-rp/src/pio_programs/i2s.rs | 2 | ||||
| -rw-r--r-- | embassy-rp/src/pio_programs/onewire.rs | 8 | ||||
| -rw-r--r-- | embassy-rp/src/pio_programs/pwm.rs | 2 | ||||
| -rw-r--r-- | embassy-rp/src/pio_programs/rotary_encoder.rs | 8 | ||||
| -rw-r--r-- | embassy-rp/src/pio_programs/stepper.rs | 2 | ||||
| -rw-r--r-- | embassy-rp/src/pio_programs/uart.rs | 4 | ||||
| -rw-r--r-- | examples/rp/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/rp/src/bin/pio_async.rs | 7 | ||||
| -rw-r--r-- | examples/rp/src/bin/pio_dma.rs | 3 | ||||
| -rw-r--r-- | examples/rp23/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/rp23/src/bin/pio_async.rs | 7 | ||||
| -rw-r--r-- | examples/rp23/src/bin/pio_dma.rs | 3 | ||||
| -rw-r--r-- | examples/rp23/src/bin/pio_rotary_encoder_rxf.rs | 3 | ||||
| -rw-r--r-- | tests/rp/Cargo.toml | 2 | ||||
| -rw-r--r-- | tests/rp/src/bin/pio_irq.rs | 3 | ||||
| -rw-r--r-- | tests/rp/src/bin/pio_multi_load.rs | 16 |
22 files changed, 137 insertions, 133 deletions
diff --git a/cyw43-pio/Cargo.toml b/cyw43-pio/Cargo.toml index f52788ba3..2397c76d3 100644 --- a/cyw43-pio/Cargo.toml +++ b/cyw43-pio/Cargo.toml | |||
| @@ -12,8 +12,6 @@ documentation = "https://docs.embassy.dev/cyw43-pio" | |||
| 12 | [dependencies] | 12 | [dependencies] |
| 13 | cyw43 = { version = "0.3.0", path = "../cyw43" } | 13 | cyw43 = { version = "0.3.0", path = "../cyw43" } |
| 14 | embassy-rp = { version = "0.3.0", path = "../embassy-rp" } | 14 | embassy-rp = { version = "0.3.0", path = "../embassy-rp" } |
| 15 | pio-proc = { git = "https://github.com/rp-rs/pio-rs", rev = "fa586448b0b223217eec8c92c19fe6823dd04cc4" } | ||
| 16 | pio = { git = "https://github.com/rp-rs/pio-rs", rev = "fa586448b0b223217eec8c92c19fe6823dd04cc4" } | ||
| 17 | fixed = "1.23.1" | 15 | fixed = "1.23.1" |
| 18 | defmt = { version = "0.3", optional = true } | 16 | defmt = { version = "0.3", optional = true } |
| 19 | 17 | ||
diff --git a/cyw43-pio/src/lib.rs b/cyw43-pio/src/lib.rs index 5fe7af95d..d0d504395 100644 --- a/cyw43-pio/src/lib.rs +++ b/cyw43-pio/src/lib.rs | |||
| @@ -8,11 +8,11 @@ use core::slice; | |||
| 8 | use cyw43::SpiBusCyw43; | 8 | use cyw43::SpiBusCyw43; |
| 9 | use embassy_rp::dma::Channel; | 9 | use embassy_rp::dma::Channel; |
| 10 | use embassy_rp::gpio::{Drive, Level, Output, Pull, SlewRate}; | 10 | use embassy_rp::gpio::{Drive, Level, Output, Pull, SlewRate}; |
| 11 | use embassy_rp::pio::{instr, Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine}; | 11 | use embassy_rp::pio::program::pio_asm; |
| 12 | use embassy_rp::pio::{Common, Config, Direction, Instance, Irq, PioPin, ShiftDirection, StateMachine}; | ||
| 12 | use embassy_rp::{Peripheral, PeripheralRef}; | 13 | use embassy_rp::{Peripheral, PeripheralRef}; |
| 13 | use fixed::types::extra::U8; | 14 | use fixed::types::extra::U8; |
| 14 | use fixed::FixedU32; | 15 | use fixed::FixedU32; |
| 15 | use pio_proc::pio_asm; | ||
| 16 | 16 | ||
| 17 | /// SPI comms driven by PIO. | 17 | /// SPI comms driven by PIO. |
| 18 | pub struct PioSpi<'d, PIO: Instance, const SM: usize, DMA> { | 18 | pub struct PioSpi<'d, PIO: Instance, const SM: usize, DMA> { |
| @@ -161,10 +161,10 @@ where | |||
| 161 | defmt::trace!("write={} read={}", write_bits, read_bits); | 161 | defmt::trace!("write={} read={}", write_bits, read_bits); |
| 162 | 162 | ||
| 163 | unsafe { | 163 | unsafe { |
| 164 | instr::set_x(&mut self.sm, write_bits as u32); | 164 | self.sm.set_x(write_bits as u32); |
| 165 | instr::set_y(&mut self.sm, read_bits as u32); | 165 | self.sm.set_y(read_bits as u32); |
| 166 | instr::set_pindir(&mut self.sm, 0b1); | 166 | self.sm.set_pindir(0b1); |
| 167 | instr::exec_jmp(&mut self.sm, self.wrap_target); | 167 | self.sm.exec_jmp(self.wrap_target); |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | self.sm.set_enable(true); | 170 | self.sm.set_enable(true); |
| @@ -192,10 +192,10 @@ where | |||
| 192 | defmt::trace!("cmd_read cmd = {:02x} len = {}", cmd, read.len()); | 192 | defmt::trace!("cmd_read cmd = {:02x} len = {}", cmd, read.len()); |
| 193 | 193 | ||
| 194 | unsafe { | 194 | unsafe { |
| 195 | instr::set_y(&mut self.sm, read_bits as u32); | 195 | self.sm.set_y(read_bits as u32); |
| 196 | instr::set_x(&mut self.sm, write_bits as u32); | 196 | self.sm.set_x(write_bits as u32); |
| 197 | instr::set_pindir(&mut self.sm, 0b1); | 197 | self.sm.set_pindir(0b1); |
| 198 | instr::exec_jmp(&mut self.sm, self.wrap_target); | 198 | self.sm.exec_jmp(self.wrap_target); |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | // self.cs.set_low(); | 201 | // self.cs.set_low(); |
diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index d681af915..539c579a3 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml | |||
| @@ -157,15 +157,14 @@ embedded-storage-async = { version = "0.4.1" } | |||
| 157 | rand_core = "0.6.4" | 157 | rand_core = "0.6.4" |
| 158 | fixed = "1.28.0" | 158 | fixed = "1.28.0" |
| 159 | 159 | ||
| 160 | rp-pac = { version = "7.0.0", feature = ["rt"] } | 160 | rp-pac = { version = "7.0.0" } |
| 161 | 161 | ||
| 162 | embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } | 162 | embedded-hal-02 = { package = "embedded-hal", version = "0.2.6", features = ["unproven"] } |
| 163 | embedded-hal-1 = { package = "embedded-hal", version = "1.0" } | 163 | embedded-hal-1 = { package = "embedded-hal", version = "1.0" } |
| 164 | embedded-hal-async = { version = "1.0" } | 164 | embedded-hal-async = { version = "1.0" } |
| 165 | embedded-hal-nb = { version = "1.0" } | 165 | embedded-hal-nb = { version = "1.0" } |
| 166 | 166 | ||
| 167 | pio-proc = { git = "https://github.com/rp-rs/pio-rs", rev = "fa586448b0b223217eec8c92c19fe6823dd04cc4" } | 167 | pio = { git = "https://github.com/rp-rs/pio-rs", rev = "506a51b9bc135845e8544a0debd75847b73754dc" } |
| 168 | pio = { git = "https://github.com/rp-rs/pio-rs", rev = "fa586448b0b223217eec8c92c19fe6823dd04cc4" } | ||
| 169 | rp2040-boot2 = "0.3" | 168 | rp2040-boot2 = "0.3" |
| 170 | document-features = "0.2.10" | 169 | document-features = "0.2.10" |
| 171 | sha2-const-stable = "0.1" | 170 | sha2-const-stable = "0.1" |
diff --git a/embassy-rp/src/pio/instr.rs b/embassy-rp/src/pio/instr.rs index 9a44088c6..b15d507de 100644 --- a/embassy-rp/src/pio/instr.rs +++ b/embassy-rp/src/pio/instr.rs | |||
| @@ -3,99 +3,101 @@ use pio::{InSource, InstructionOperands, JmpCondition, OutDestination, SetDestin | |||
| 3 | 3 | ||
| 4 | use crate::pio::{Instance, StateMachine}; | 4 | use crate::pio::{Instance, StateMachine}; |
| 5 | 5 | ||
| 6 | /// Set value of scratch register X. | 6 | impl<'d, PIO: Instance, const SM: usize> StateMachine<'d, PIO, SM> { |
| 7 | pub unsafe fn set_x<PIO: Instance, const SM: usize>(sm: &mut StateMachine<PIO, SM>, value: u32) { | 7 | /// Set value of scratch register X. |
| 8 | const OUT: u16 = InstructionOperands::OUT { | 8 | pub unsafe fn set_x(&mut self, value: u32) { |
| 9 | destination: OutDestination::X, | 9 | const OUT: u16 = InstructionOperands::OUT { |
| 10 | bit_count: 32, | 10 | destination: OutDestination::X, |
| 11 | bit_count: 32, | ||
| 12 | } | ||
| 13 | .encode(); | ||
| 14 | self.tx().push(value); | ||
| 15 | self.exec_instr(OUT); | ||
| 11 | } | 16 | } |
| 12 | .encode(); | ||
| 13 | sm.tx().push(value); | ||
| 14 | sm.exec_instr(OUT); | ||
| 15 | } | ||
| 16 | 17 | ||
| 17 | /// Get value of scratch register X. | 18 | /// Get value of scratch register X. |
| 18 | pub unsafe fn get_x<PIO: Instance, const SM: usize>(sm: &mut StateMachine<PIO, SM>) -> u32 { | 19 | pub unsafe fn get_x(&mut self) -> u32 { |
| 19 | const IN: u16 = InstructionOperands::IN { | 20 | const IN: u16 = InstructionOperands::IN { |
| 20 | source: InSource::X, | 21 | source: InSource::X, |
| 21 | bit_count: 32, | 22 | bit_count: 32, |
| 23 | } | ||
| 24 | .encode(); | ||
| 25 | self.exec_instr(IN); | ||
| 26 | self.rx().pull() | ||
| 22 | } | 27 | } |
| 23 | .encode(); | ||
| 24 | sm.exec_instr(IN); | ||
| 25 | sm.rx().pull() | ||
| 26 | } | ||
| 27 | 28 | ||
| 28 | /// Set value of scratch register Y. | 29 | /// Set value of scratch register Y. |
| 29 | pub unsafe fn set_y<PIO: Instance, const SM: usize>(sm: &mut StateMachine<PIO, SM>, value: u32) { | 30 | pub unsafe fn set_y(&mut self, value: u32) { |
| 30 | const OUT: u16 = InstructionOperands::OUT { | 31 | const OUT: u16 = InstructionOperands::OUT { |
| 31 | destination: OutDestination::Y, | 32 | destination: OutDestination::Y, |
| 32 | bit_count: 32, | 33 | bit_count: 32, |
| 34 | } | ||
| 35 | .encode(); | ||
| 36 | self.tx().push(value); | ||
| 37 | self.exec_instr(OUT); | ||
| 33 | } | 38 | } |
| 34 | .encode(); | ||
| 35 | sm.tx().push(value); | ||
| 36 | sm.exec_instr(OUT); | ||
| 37 | } | ||
| 38 | 39 | ||
| 39 | /// Get value of scratch register Y. | 40 | /// Get value of scratch register Y. |
| 40 | pub unsafe fn get_y<PIO: Instance, const SM: usize>(sm: &mut StateMachine<PIO, SM>) -> u32 { | 41 | pub unsafe fn get_y(&mut self) -> u32 { |
| 41 | const IN: u16 = InstructionOperands::IN { | 42 | const IN: u16 = InstructionOperands::IN { |
| 42 | source: InSource::Y, | 43 | source: InSource::Y, |
| 43 | bit_count: 32, | 44 | bit_count: 32, |
| 44 | } | 45 | } |
| 45 | .encode(); | 46 | .encode(); |
| 46 | sm.exec_instr(IN); | 47 | self.exec_instr(IN); |
| 47 | 48 | ||
| 48 | sm.rx().pull() | 49 | self.rx().pull() |
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | /// Set instruction for pindir destination. | 52 | /// Set instruction for pindir destination. |
| 52 | pub unsafe fn set_pindir<PIO: Instance, const SM: usize>(sm: &mut StateMachine<PIO, SM>, data: u8) { | 53 | pub unsafe fn set_pindir(&mut self, data: u8) { |
| 53 | let set: u16 = InstructionOperands::SET { | 54 | let set: u16 = InstructionOperands::SET { |
| 54 | destination: SetDestination::PINDIRS, | 55 | destination: SetDestination::PINDIRS, |
| 55 | data, | 56 | data, |
| 57 | } | ||
| 58 | .encode(); | ||
| 59 | self.exec_instr(set); | ||
| 56 | } | 60 | } |
| 57 | .encode(); | ||
| 58 | sm.exec_instr(set); | ||
| 59 | } | ||
| 60 | 61 | ||
| 61 | /// Set instruction for pin destination. | 62 | /// Set instruction for pin destination. |
| 62 | pub unsafe fn set_pin<PIO: Instance, const SM: usize>(sm: &mut StateMachine<PIO, SM>, data: u8) { | 63 | pub unsafe fn set_pin(&mut self, data: u8) { |
| 63 | let set: u16 = InstructionOperands::SET { | 64 | let set: u16 = InstructionOperands::SET { |
| 64 | destination: SetDestination::PINS, | 65 | destination: SetDestination::PINS, |
| 65 | data, | 66 | data, |
| 67 | } | ||
| 68 | .encode(); | ||
| 69 | self.exec_instr(set); | ||
| 66 | } | 70 | } |
| 67 | .encode(); | ||
| 68 | sm.exec_instr(set); | ||
| 69 | } | ||
| 70 | 71 | ||
| 71 | /// Out instruction for pin destination. | 72 | /// Out instruction for pin destination. |
| 72 | pub unsafe fn set_out_pin<PIO: Instance, const SM: usize>(sm: &mut StateMachine<PIO, SM>, data: u32) { | 73 | pub unsafe fn set_out_pin(&mut self, data: u32) { |
| 73 | const OUT: u16 = InstructionOperands::OUT { | 74 | const OUT: u16 = InstructionOperands::OUT { |
| 74 | destination: OutDestination::PINS, | 75 | destination: OutDestination::PINS, |
| 75 | bit_count: 32, | 76 | bit_count: 32, |
| 77 | } | ||
| 78 | .encode(); | ||
| 79 | self.tx().push(data); | ||
| 80 | self.exec_instr(OUT); | ||
| 76 | } | 81 | } |
| 77 | .encode(); | ||
| 78 | sm.tx().push(data); | ||
| 79 | sm.exec_instr(OUT); | ||
| 80 | } | ||
| 81 | 82 | ||
| 82 | /// Out instruction for pindir destination. | 83 | /// Out instruction for pindir destination. |
| 83 | pub unsafe fn set_out_pindir<PIO: Instance, const SM: usize>(sm: &mut StateMachine<PIO, SM>, data: u32) { | 84 | pub unsafe fn set_out_pindir(&mut self, data: u32) { |
| 84 | const OUT: u16 = InstructionOperands::OUT { | 85 | const OUT: u16 = InstructionOperands::OUT { |
| 85 | destination: OutDestination::PINDIRS, | 86 | destination: OutDestination::PINDIRS, |
| 86 | bit_count: 32, | 87 | bit_count: 32, |
| 88 | } | ||
| 89 | .encode(); | ||
| 90 | self.tx().push(data); | ||
| 91 | self.exec_instr(OUT); | ||
| 87 | } | 92 | } |
| 88 | .encode(); | ||
| 89 | sm.tx().push(data); | ||
| 90 | sm.exec_instr(OUT); | ||
| 91 | } | ||
| 92 | 93 | ||
| 93 | /// Jump instruction to address. | 94 | /// Jump instruction to address. |
| 94 | pub unsafe fn exec_jmp<PIO: Instance, const SM: usize>(sm: &mut StateMachine<PIO, SM>, to_addr: u8) { | 95 | pub unsafe fn exec_jmp(&mut self, to_addr: u8) { |
| 95 | let jmp: u16 = InstructionOperands::JMP { | 96 | let jmp: u16 = InstructionOperands::JMP { |
| 96 | address: to_addr, | 97 | address: to_addr, |
| 97 | condition: JmpCondition::Always, | 98 | condition: JmpCondition::Always, |
| 99 | } | ||
| 100 | .encode(); | ||
| 101 | self.exec_instr(jmp); | ||
| 98 | } | 102 | } |
| 99 | .encode(); | ||
| 100 | sm.exec_instr(jmp); | ||
| 101 | } | 103 | } |
diff --git a/embassy-rp/src/pio/mod.rs b/embassy-rp/src/pio/mod.rs index 2776f9e3c..880d6effd 100644 --- a/embassy-rp/src/pio/mod.rs +++ b/embassy-rp/src/pio/mod.rs | |||
| @@ -18,7 +18,10 @@ use crate::interrupt::typelevel::{Binding, Handler, Interrupt}; | |||
| 18 | use crate::relocate::RelocatedProgram; | 18 | use crate::relocate::RelocatedProgram; |
| 19 | use crate::{pac, peripherals, RegExt}; | 19 | use crate::{pac, peripherals, RegExt}; |
| 20 | 20 | ||
| 21 | pub mod instr; | 21 | mod instr; |
| 22 | |||
| 23 | #[doc(inline)] | ||
| 24 | pub use pio as program; | ||
| 22 | 25 | ||
| 23 | /// Wakers for interrupts and FIFOs. | 26 | /// Wakers for interrupts and FIFOs. |
| 24 | pub struct Wakers([AtomicWaker; 12]); | 27 | pub struct Wakers([AtomicWaker; 12]); |
| @@ -812,7 +815,7 @@ impl<'d, PIO: Instance + 'd, const SM: usize> StateMachine<'d, PIO, SM> { | |||
| 812 | } | 815 | } |
| 813 | 816 | ||
| 814 | if let Some(origin) = config.origin { | 817 | if let Some(origin) = config.origin { |
| 815 | unsafe { instr::exec_jmp(self, origin) } | 818 | unsafe { self.exec_jmp(origin) } |
| 816 | } | 819 | } |
| 817 | } | 820 | } |
| 818 | 821 | ||
diff --git a/embassy-rp/src/pio_programs/hd44780.rs b/embassy-rp/src/pio_programs/hd44780.rs index 9bbf44fc4..70129318b 100644 --- a/embassy-rp/src/pio_programs/hd44780.rs +++ b/embassy-rp/src/pio_programs/hd44780.rs | |||
| @@ -15,7 +15,7 @@ pub struct PioHD44780CommandWordProgram<'a, PIO: Instance> { | |||
| 15 | impl<'a, PIO: Instance> PioHD44780CommandWordProgram<'a, PIO> { | 15 | impl<'a, PIO: Instance> PioHD44780CommandWordProgram<'a, PIO> { |
| 16 | /// Load the program into the given pio | 16 | /// Load the program into the given pio |
| 17 | pub fn new(common: &mut Common<'a, PIO>) -> Self { | 17 | pub fn new(common: &mut Common<'a, PIO>) -> Self { |
| 18 | let prg = pio_proc::pio_asm!( | 18 | let prg = pio::pio_asm!( |
| 19 | r#" | 19 | r#" |
| 20 | .side_set 1 opt | 20 | .side_set 1 opt |
| 21 | .origin 20 | 21 | .origin 20 |
| @@ -46,7 +46,7 @@ impl<'a, PIO: Instance> PioHD44780CommandSequenceProgram<'a, PIO> { | |||
| 46 | /// Load the program into the given pio | 46 | /// Load the program into the given pio |
| 47 | pub fn new(common: &mut Common<'a, PIO>) -> Self { | 47 | pub fn new(common: &mut Common<'a, PIO>) -> Self { |
| 48 | // many side sets are only there to free up a delay bit! | 48 | // many side sets are only there to free up a delay bit! |
| 49 | let prg = pio_proc::pio_asm!( | 49 | let prg = pio::pio_asm!( |
| 50 | r#" | 50 | r#" |
| 51 | .origin 27 | 51 | .origin 27 |
| 52 | .side_set 1 | 52 | .side_set 1 |
diff --git a/embassy-rp/src/pio_programs/i2s.rs b/embassy-rp/src/pio_programs/i2s.rs index 87fb2e19f..a7b4f46a6 100644 --- a/embassy-rp/src/pio_programs/i2s.rs +++ b/embassy-rp/src/pio_programs/i2s.rs | |||
| @@ -16,7 +16,7 @@ pub struct PioI2sOutProgram<'a, PIO: Instance> { | |||
| 16 | impl<'a, PIO: Instance> PioI2sOutProgram<'a, PIO> { | 16 | impl<'a, PIO: Instance> PioI2sOutProgram<'a, PIO> { |
| 17 | /// Load the program into the given pio | 17 | /// Load the program into the given pio |
| 18 | pub fn new(common: &mut Common<'a, PIO>) -> Self { | 18 | pub fn new(common: &mut Common<'a, PIO>) -> Self { |
| 19 | let prg = pio_proc::pio_asm!( | 19 | let prg = pio::pio_asm!( |
| 20 | ".side_set 2", | 20 | ".side_set 2", |
| 21 | " set x, 14 side 0b01", // side 0bWB - W = Word Clock, B = Bit Clock | 21 | " set x, 14 side 0b01", // side 0bWB - W = Word Clock, B = Bit Clock |
| 22 | "left_data:", | 22 | "left_data:", |
diff --git a/embassy-rp/src/pio_programs/onewire.rs b/embassy-rp/src/pio_programs/onewire.rs index f3bc5fcd7..040333e76 100644 --- a/embassy-rp/src/pio_programs/onewire.rs +++ b/embassy-rp/src/pio_programs/onewire.rs | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | //! OneWire pio driver | 1 | //! OneWire pio driver |
| 2 | 2 | ||
| 3 | use crate::pio::{self, Common, Config, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine}; | 3 | use crate::pio::{Common, Config, Instance, LoadedProgram, PioPin, ShiftConfig, ShiftDirection, StateMachine}; |
| 4 | 4 | ||
| 5 | /// This struct represents an onewire driver program | 5 | /// This struct represents an onewire driver program |
| 6 | pub struct PioOneWireProgram<'a, PIO: Instance> { | 6 | pub struct PioOneWireProgram<'a, PIO: Instance> { |
| @@ -10,7 +10,7 @@ pub struct PioOneWireProgram<'a, PIO: Instance> { | |||
| 10 | impl<'a, PIO: Instance> PioOneWireProgram<'a, PIO> { | 10 | impl<'a, PIO: Instance> PioOneWireProgram<'a, PIO> { |
| 11 | /// Load the program into the given pio | 11 | /// Load the program into the given pio |
| 12 | pub fn new(common: &mut Common<'a, PIO>) -> Self { | 12 | pub fn new(common: &mut Common<'a, PIO>) -> Self { |
| 13 | let prg = pio_proc::pio_asm!( | 13 | let prg = pio::pio_asm!( |
| 14 | r#" | 14 | r#" |
| 15 | .wrap_target | 15 | .wrap_target |
| 16 | again: | 16 | again: |
| @@ -60,11 +60,11 @@ impl<'a, PIO: Instance> PioOneWireProgram<'a, PIO> { | |||
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | /// Pio backed OneWire driver | 62 | /// Pio backed OneWire driver |
| 63 | pub struct PioOneWire<'d, PIO: pio::Instance, const SM: usize> { | 63 | pub struct PioOneWire<'d, PIO: Instance, const SM: usize> { |
| 64 | sm: StateMachine<'d, PIO, SM>, | 64 | sm: StateMachine<'d, PIO, SM>, |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | impl<'d, PIO: pio::Instance, const SM: usize> PioOneWire<'d, PIO, SM> { | 67 | impl<'d, PIO: Instance, const SM: usize> PioOneWire<'d, PIO, SM> { |
| 68 | /// Create a new instance the driver | 68 | /// Create a new instance the driver |
| 69 | pub fn new( | 69 | pub fn new( |
| 70 | common: &mut Common<'d, PIO>, | 70 | common: &mut Common<'d, PIO>, |
diff --git a/embassy-rp/src/pio_programs/pwm.rs b/embassy-rp/src/pio_programs/pwm.rs index c6502387a..01ffe012a 100644 --- a/embassy-rp/src/pio_programs/pwm.rs +++ b/embassy-rp/src/pio_programs/pwm.rs | |||
| @@ -21,7 +21,7 @@ pub struct PioPwmProgram<'a, PIO: Instance> { | |||
| 21 | impl<'a, PIO: Instance> PioPwmProgram<'a, PIO> { | 21 | impl<'a, PIO: Instance> PioPwmProgram<'a, PIO> { |
| 22 | /// Load the program into the given pio | 22 | /// Load the program into the given pio |
| 23 | pub fn new(common: &mut Common<'a, PIO>) -> Self { | 23 | pub fn new(common: &mut Common<'a, PIO>) -> Self { |
| 24 | let prg = pio_proc::pio_asm!( | 24 | let prg = pio::pio_asm!( |
| 25 | ".side_set 1 opt" | 25 | ".side_set 1 opt" |
| 26 | "pull noblock side 0" | 26 | "pull noblock side 0" |
| 27 | "mov x, osr" | 27 | "mov x, osr" |
diff --git a/embassy-rp/src/pio_programs/rotary_encoder.rs b/embassy-rp/src/pio_programs/rotary_encoder.rs index 86423fd31..f2fb02aca 100644 --- a/embassy-rp/src/pio_programs/rotary_encoder.rs +++ b/embassy-rp/src/pio_programs/rotary_encoder.rs | |||
| @@ -3,7 +3,9 @@ | |||
| 3 | use fixed::traits::ToFixed; | 3 | use fixed::traits::ToFixed; |
| 4 | 4 | ||
| 5 | use crate::gpio::Pull; | 5 | use crate::gpio::Pull; |
| 6 | use crate::pio::{self, Common, Config, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine}; | 6 | use crate::pio::{ |
| 7 | Common, Config, Direction as PioDirection, FifoJoin, Instance, LoadedProgram, PioPin, ShiftDirection, StateMachine, | ||
| 8 | }; | ||
| 7 | 9 | ||
| 8 | /// This struct represents an Encoder program loaded into pio instruction memory. | 10 | /// This struct represents an Encoder program loaded into pio instruction memory. |
| 9 | pub struct PioEncoderProgram<'a, PIO: Instance> { | 11 | pub struct PioEncoderProgram<'a, PIO: Instance> { |
| @@ -13,7 +15,7 @@ pub struct PioEncoderProgram<'a, PIO: Instance> { | |||
| 13 | impl<'a, PIO: Instance> PioEncoderProgram<'a, PIO> { | 15 | impl<'a, PIO: Instance> PioEncoderProgram<'a, PIO> { |
| 14 | /// Load the program into the given pio | 16 | /// Load the program into the given pio |
| 15 | pub fn new(common: &mut Common<'a, PIO>) -> Self { | 17 | pub fn new(common: &mut Common<'a, PIO>) -> Self { |
| 16 | let prg = pio_proc::pio_asm!("wait 1 pin 1", "wait 0 pin 1", "in pins, 2", "push",); | 18 | let prg = pio::pio_asm!("wait 1 pin 1", "wait 0 pin 1", "in pins, 2", "push",); |
| 17 | 19 | ||
| 18 | let prg = common.load_program(&prg.program); | 20 | let prg = common.load_program(&prg.program); |
| 19 | 21 | ||
| @@ -39,7 +41,7 @@ impl<'d, T: Instance, const SM: usize> PioEncoder<'d, T, SM> { | |||
| 39 | let mut pin_b = pio.make_pio_pin(pin_b); | 41 | let mut pin_b = pio.make_pio_pin(pin_b); |
| 40 | pin_a.set_pull(Pull::Up); | 42 | pin_a.set_pull(Pull::Up); |
| 41 | pin_b.set_pull(Pull::Up); | 43 | pin_b.set_pull(Pull::Up); |
| 42 | sm.set_pin_dirs(pio::Direction::In, &[&pin_a, &pin_b]); | 44 | sm.set_pin_dirs(PioDirection::In, &[&pin_a, &pin_b]); |
| 43 | 45 | ||
| 44 | let mut cfg = Config::default(); | 46 | let mut cfg = Config::default(); |
| 45 | cfg.set_in_pins(&[&pin_a, &pin_b]); | 47 | cfg.set_in_pins(&[&pin_a, &pin_b]); |
diff --git a/embassy-rp/src/pio_programs/stepper.rs b/embassy-rp/src/pio_programs/stepper.rs index 0d58c754c..c8f74167d 100644 --- a/embassy-rp/src/pio_programs/stepper.rs +++ b/embassy-rp/src/pio_programs/stepper.rs | |||
| @@ -16,7 +16,7 @@ pub struct PioStepperProgram<'a, PIO: Instance> { | |||
| 16 | impl<'a, PIO: Instance> PioStepperProgram<'a, PIO> { | 16 | impl<'a, PIO: Instance> PioStepperProgram<'a, PIO> { |
| 17 | /// Load the program into the given pio | 17 | /// Load the program into the given pio |
| 18 | pub fn new(common: &mut Common<'a, PIO>) -> Self { | 18 | pub fn new(common: &mut Common<'a, PIO>) -> Self { |
| 19 | let prg = pio_proc::pio_asm!( | 19 | let prg = pio::pio_asm!( |
| 20 | "pull block", | 20 | "pull block", |
| 21 | "mov x, osr", | 21 | "mov x, osr", |
| 22 | "pull block", | 22 | "pull block", |
diff --git a/embassy-rp/src/pio_programs/uart.rs b/embassy-rp/src/pio_programs/uart.rs index c643f1063..641daca61 100644 --- a/embassy-rp/src/pio_programs/uart.rs +++ b/embassy-rp/src/pio_programs/uart.rs | |||
| @@ -19,7 +19,7 @@ pub struct PioUartTxProgram<'a, PIO: Instance> { | |||
| 19 | impl<'a, PIO: Instance> PioUartTxProgram<'a, PIO> { | 19 | impl<'a, PIO: Instance> PioUartTxProgram<'a, PIO> { |
| 20 | /// Load the uart tx program into the given pio | 20 | /// Load the uart tx program into the given pio |
| 21 | pub fn new(common: &mut Common<'a, PIO>) -> Self { | 21 | pub fn new(common: &mut Common<'a, PIO>) -> Self { |
| 22 | let prg = pio_proc::pio_asm!( | 22 | let prg = pio::pio_asm!( |
| 23 | r#" | 23 | r#" |
| 24 | .side_set 1 opt | 24 | .side_set 1 opt |
| 25 | 25 | ||
| @@ -99,7 +99,7 @@ pub struct PioUartRxProgram<'a, PIO: Instance> { | |||
| 99 | impl<'a, PIO: Instance> PioUartRxProgram<'a, PIO> { | 99 | impl<'a, PIO: Instance> PioUartRxProgram<'a, PIO> { |
| 100 | /// Load the uart rx program into the given pio | 100 | /// Load the uart rx program into the given pio |
| 101 | pub fn new(common: &mut Common<'a, PIO>) -> Self { | 101 | pub fn new(common: &mut Common<'a, PIO>) -> Self { |
| 102 | let prg = pio_proc::pio_asm!( | 102 | let prg = pio::pio_asm!( |
| 103 | r#" | 103 | r#" |
| 104 | ; Slightly more fleshed-out 8n1 UART receiver which handles framing errors and | 104 | ; Slightly more fleshed-out 8n1 UART receiver which handles framing errors and |
| 105 | ; break conditions more gracefully. | 105 | ; break conditions more gracefully. |
diff --git a/examples/rp/Cargo.toml b/examples/rp/Cargo.toml index e05c88a9a..a81166067 100644 --- a/examples/rp/Cargo.toml +++ b/examples/rp/Cargo.toml | |||
| @@ -55,8 +55,6 @@ embedded-storage = { version = "0.3" } | |||
| 55 | static_cell = "2.1" | 55 | static_cell = "2.1" |
| 56 | portable-atomic = { version = "1.5", features = ["critical-section"] } | 56 | portable-atomic = { version = "1.5", features = ["critical-section"] } |
| 57 | log = "0.4" | 57 | log = "0.4" |
| 58 | pio-proc = { git = "https://github.com/rp-rs/pio-rs", rev = "fa586448b0b223217eec8c92c19fe6823dd04cc4" } | ||
| 59 | pio = { git = "https://github.com/rp-rs/pio-rs", rev = "fa586448b0b223217eec8c92c19fe6823dd04cc4" } | ||
| 60 | rand = { version = "0.8.5", default-features = false } | 58 | rand = { version = "0.8.5", default-features = false } |
| 61 | embedded-sdmmc = "0.7.0" | 59 | embedded-sdmmc = "0.7.0" |
| 62 | 60 | ||
diff --git a/examples/rp/src/bin/pio_async.rs b/examples/rp/src/bin/pio_async.rs index ee248591b..08c702347 100644 --- a/examples/rp/src/bin/pio_async.rs +++ b/examples/rp/src/bin/pio_async.rs | |||
| @@ -6,6 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_rp::bind_interrupts; | 7 | use embassy_rp::bind_interrupts; |
| 8 | use embassy_rp::peripherals::PIO0; | 8 | use embassy_rp::peripherals::PIO0; |
| 9 | use embassy_rp::pio::program::pio_asm; | ||
| 9 | use embassy_rp::pio::{Common, Config, InterruptHandler, Irq, Pio, PioPin, ShiftDirection, StateMachine}; | 10 | use embassy_rp::pio::{Common, Config, InterruptHandler, Irq, Pio, PioPin, ShiftDirection, StateMachine}; |
| 10 | use fixed::traits::ToFixed; | 11 | use fixed::traits::ToFixed; |
| 11 | use fixed_macro::types::U56F8; | 12 | use fixed_macro::types::U56F8; |
| @@ -19,7 +20,7 @@ fn setup_pio_task_sm0<'a>(pio: &mut Common<'a, PIO0>, sm: &mut StateMachine<'a, | |||
| 19 | // Setup sm0 | 20 | // Setup sm0 |
| 20 | 21 | ||
| 21 | // Send data serially to pin | 22 | // Send data serially to pin |
| 22 | let prg = pio_proc::pio_asm!( | 23 | let prg = pio_asm!( |
| 23 | ".origin 16", | 24 | ".origin 16", |
| 24 | "set pindirs, 1", | 25 | "set pindirs, 1", |
| 25 | ".wrap_target", | 26 | ".wrap_target", |
| @@ -53,7 +54,7 @@ fn setup_pio_task_sm1<'a>(pio: &mut Common<'a, PIO0>, sm: &mut StateMachine<'a, | |||
| 53 | // Setupm sm1 | 54 | // Setupm sm1 |
| 54 | 55 | ||
| 55 | // Read 0b10101 repeatedly until ISR is full | 56 | // Read 0b10101 repeatedly until ISR is full |
| 56 | let prg = pio_proc::pio_asm!( | 57 | let prg = pio_asm!( |
| 57 | // | 58 | // |
| 58 | ".origin 8", | 59 | ".origin 8", |
| 59 | "set x, 0x15", | 60 | "set x, 0x15", |
| @@ -83,7 +84,7 @@ fn setup_pio_task_sm2<'a>(pio: &mut Common<'a, PIO0>, sm: &mut StateMachine<'a, | |||
| 83 | // Setup sm2 | 84 | // Setup sm2 |
| 84 | 85 | ||
| 85 | // Repeatedly trigger IRQ 3 | 86 | // Repeatedly trigger IRQ 3 |
| 86 | let prg = pio_proc::pio_asm!( | 87 | let prg = pio_asm!( |
| 87 | ".origin 0", | 88 | ".origin 0", |
| 88 | ".wrap_target", | 89 | ".wrap_target", |
| 89 | "set x,10", | 90 | "set x,10", |
diff --git a/examples/rp/src/bin/pio_dma.rs b/examples/rp/src/bin/pio_dma.rs index 02700269c..d00ed2142 100644 --- a/examples/rp/src/bin/pio_dma.rs +++ b/examples/rp/src/bin/pio_dma.rs | |||
| @@ -6,6 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_futures::join::join; | 7 | use embassy_futures::join::join; |
| 8 | use embassy_rp::peripherals::PIO0; | 8 | use embassy_rp::peripherals::PIO0; |
| 9 | use embassy_rp::pio::program::pio_asm; | ||
| 9 | use embassy_rp::pio::{Config, InterruptHandler, Pio, ShiftConfig, ShiftDirection}; | 10 | use embassy_rp::pio::{Config, InterruptHandler, Pio, ShiftConfig, ShiftDirection}; |
| 10 | use embassy_rp::{bind_interrupts, Peripheral}; | 11 | use embassy_rp::{bind_interrupts, Peripheral}; |
| 11 | use fixed::traits::ToFixed; | 12 | use fixed::traits::ToFixed; |
| @@ -32,7 +33,7 @@ async fn main(_spawner: Spawner) { | |||
| 32 | .. | 33 | .. |
| 33 | } = Pio::new(pio, Irqs); | 34 | } = Pio::new(pio, Irqs); |
| 34 | 35 | ||
| 35 | let prg = pio_proc::pio_asm!( | 36 | let prg = pio_asm!( |
| 36 | ".origin 0", | 37 | ".origin 0", |
| 37 | "set pindirs,1", | 38 | "set pindirs,1", |
| 38 | ".wrap_target", | 39 | ".wrap_target", |
diff --git a/examples/rp23/Cargo.toml b/examples/rp23/Cargo.toml index b7e7dd69a..f4dfae773 100644 --- a/examples/rp23/Cargo.toml +++ b/examples/rp23/Cargo.toml | |||
| @@ -55,8 +55,6 @@ embedded-storage = { version = "0.3" } | |||
| 55 | static_cell = "2.1" | 55 | static_cell = "2.1" |
| 56 | portable-atomic = { version = "1.5", features = ["critical-section"] } | 56 | portable-atomic = { version = "1.5", features = ["critical-section"] } |
| 57 | log = "0.4" | 57 | log = "0.4" |
| 58 | pio-proc = { git = "https://github.com/rp-rs/pio-rs", rev = "fa586448b0b223217eec8c92c19fe6823dd04cc4" } | ||
| 59 | pio = { git = "https://github.com/rp-rs/pio-rs", rev = "fa586448b0b223217eec8c92c19fe6823dd04cc4" } | ||
| 60 | rand = { version = "0.8.5", default-features = false } | 58 | rand = { version = "0.8.5", default-features = false } |
| 61 | embedded-sdmmc = "0.7.0" | 59 | embedded-sdmmc = "0.7.0" |
| 62 | 60 | ||
diff --git a/examples/rp23/src/bin/pio_async.rs b/examples/rp23/src/bin/pio_async.rs index ee248591b..08c702347 100644 --- a/examples/rp23/src/bin/pio_async.rs +++ b/examples/rp23/src/bin/pio_async.rs | |||
| @@ -6,6 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_rp::bind_interrupts; | 7 | use embassy_rp::bind_interrupts; |
| 8 | use embassy_rp::peripherals::PIO0; | 8 | use embassy_rp::peripherals::PIO0; |
| 9 | use embassy_rp::pio::program::pio_asm; | ||
| 9 | use embassy_rp::pio::{Common, Config, InterruptHandler, Irq, Pio, PioPin, ShiftDirection, StateMachine}; | 10 | use embassy_rp::pio::{Common, Config, InterruptHandler, Irq, Pio, PioPin, ShiftDirection, StateMachine}; |
| 10 | use fixed::traits::ToFixed; | 11 | use fixed::traits::ToFixed; |
| 11 | use fixed_macro::types::U56F8; | 12 | use fixed_macro::types::U56F8; |
| @@ -19,7 +20,7 @@ fn setup_pio_task_sm0<'a>(pio: &mut Common<'a, PIO0>, sm: &mut StateMachine<'a, | |||
| 19 | // Setup sm0 | 20 | // Setup sm0 |
| 20 | 21 | ||
| 21 | // Send data serially to pin | 22 | // Send data serially to pin |
| 22 | let prg = pio_proc::pio_asm!( | 23 | let prg = pio_asm!( |
| 23 | ".origin 16", | 24 | ".origin 16", |
| 24 | "set pindirs, 1", | 25 | "set pindirs, 1", |
| 25 | ".wrap_target", | 26 | ".wrap_target", |
| @@ -53,7 +54,7 @@ fn setup_pio_task_sm1<'a>(pio: &mut Common<'a, PIO0>, sm: &mut StateMachine<'a, | |||
| 53 | // Setupm sm1 | 54 | // Setupm sm1 |
| 54 | 55 | ||
| 55 | // Read 0b10101 repeatedly until ISR is full | 56 | // Read 0b10101 repeatedly until ISR is full |
| 56 | let prg = pio_proc::pio_asm!( | 57 | let prg = pio_asm!( |
| 57 | // | 58 | // |
| 58 | ".origin 8", | 59 | ".origin 8", |
| 59 | "set x, 0x15", | 60 | "set x, 0x15", |
| @@ -83,7 +84,7 @@ fn setup_pio_task_sm2<'a>(pio: &mut Common<'a, PIO0>, sm: &mut StateMachine<'a, | |||
| 83 | // Setup sm2 | 84 | // Setup sm2 |
| 84 | 85 | ||
| 85 | // Repeatedly trigger IRQ 3 | 86 | // Repeatedly trigger IRQ 3 |
| 86 | let prg = pio_proc::pio_asm!( | 87 | let prg = pio_asm!( |
| 87 | ".origin 0", | 88 | ".origin 0", |
| 88 | ".wrap_target", | 89 | ".wrap_target", |
| 89 | "set x,10", | 90 | "set x,10", |
diff --git a/examples/rp23/src/bin/pio_dma.rs b/examples/rp23/src/bin/pio_dma.rs index 02700269c..d00ed2142 100644 --- a/examples/rp23/src/bin/pio_dma.rs +++ b/examples/rp23/src/bin/pio_dma.rs | |||
| @@ -6,6 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_futures::join::join; | 7 | use embassy_futures::join::join; |
| 8 | use embassy_rp::peripherals::PIO0; | 8 | use embassy_rp::peripherals::PIO0; |
| 9 | use embassy_rp::pio::program::pio_asm; | ||
| 9 | use embassy_rp::pio::{Config, InterruptHandler, Pio, ShiftConfig, ShiftDirection}; | 10 | use embassy_rp::pio::{Config, InterruptHandler, Pio, ShiftConfig, ShiftDirection}; |
| 10 | use embassy_rp::{bind_interrupts, Peripheral}; | 11 | use embassy_rp::{bind_interrupts, Peripheral}; |
| 11 | use fixed::traits::ToFixed; | 12 | use fixed::traits::ToFixed; |
| @@ -32,7 +33,7 @@ async fn main(_spawner: Spawner) { | |||
| 32 | .. | 33 | .. |
| 33 | } = Pio::new(pio, Irqs); | 34 | } = Pio::new(pio, Irqs); |
| 34 | 35 | ||
| 35 | let prg = pio_proc::pio_asm!( | 36 | let prg = pio_asm!( |
| 36 | ".origin 0", | 37 | ".origin 0", |
| 37 | "set pindirs,1", | 38 | "set pindirs,1", |
| 38 | ".wrap_target", | 39 | ".wrap_target", |
diff --git a/examples/rp23/src/bin/pio_rotary_encoder_rxf.rs b/examples/rp23/src/bin/pio_rotary_encoder_rxf.rs index ca6b5222b..0216c131b 100644 --- a/examples/rp23/src/bin/pio_rotary_encoder_rxf.rs +++ b/examples/rp23/src/bin/pio_rotary_encoder_rxf.rs | |||
| @@ -8,6 +8,7 @@ use defmt::info; | |||
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_rp::gpio::Pull; | 9 | use embassy_rp::gpio::Pull; |
| 10 | use embassy_rp::peripherals::PIO0; | 10 | use embassy_rp::peripherals::PIO0; |
| 11 | use embassy_rp::pio::program::pio_asm; | ||
| 11 | use embassy_rp::{bind_interrupts, pio}; | 12 | use embassy_rp::{bind_interrupts, pio}; |
| 12 | use embassy_time::Timer; | 13 | use embassy_time::Timer; |
| 13 | use fixed::traits::ToFixed; | 14 | use fixed::traits::ToFixed; |
| @@ -46,7 +47,7 @@ impl<'d, T: Instance, const SM: usize> PioEncoder<'d, T, SM> { | |||
| 46 | 47 | ||
| 47 | sm.set_pin_dirs(pio::Direction::In, &[&pin_a, &pin_b]); | 48 | sm.set_pin_dirs(pio::Direction::In, &[&pin_a, &pin_b]); |
| 48 | 49 | ||
| 49 | let prg = pio_proc::pio_asm!( | 50 | let prg = pio_asm!( |
| 50 | "start:" | 51 | "start:" |
| 51 | // encoder count is stored in X | 52 | // encoder count is stored in X |
| 52 | "mov isr, x" | 53 | "mov isr, x" |
diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 5a6a6c75a..3d6cd6ab8 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml | |||
| @@ -33,8 +33,6 @@ embedded-io-async = { version = "0.6.1" } | |||
| 33 | embedded-storage = { version = "0.3" } | 33 | embedded-storage = { version = "0.3" } |
| 34 | static_cell = "2" | 34 | static_cell = "2" |
| 35 | portable-atomic = { version = "1.5", features = ["critical-section"] } | 35 | portable-atomic = { version = "1.5", features = ["critical-section"] } |
| 36 | pio-proc = { git = "https://github.com/rp-rs/pio-rs", rev = "fa586448b0b223217eec8c92c19fe6823dd04cc4" } | ||
| 37 | pio = { git = "https://github.com/rp-rs/pio-rs", rev = "fa586448b0b223217eec8c92c19fe6823dd04cc4" } | ||
| 38 | rand = { version = "0.8.5", default-features = false } | 36 | rand = { version = "0.8.5", default-features = false } |
| 39 | 37 | ||
| 40 | [profile.dev] | 38 | [profile.dev] |
diff --git a/tests/rp/src/bin/pio_irq.rs b/tests/rp/src/bin/pio_irq.rs index 33cdaaac9..1fee6dc2f 100644 --- a/tests/rp/src/bin/pio_irq.rs +++ b/tests/rp/src/bin/pio_irq.rs | |||
| @@ -6,6 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_rp::bind_interrupts; | 7 | use embassy_rp::bind_interrupts; |
| 8 | use embassy_rp::peripherals::PIO0; | 8 | use embassy_rp::peripherals::PIO0; |
| 9 | use embassy_rp::pio::program::pio_asm; | ||
| 9 | use embassy_rp::pio::{Config, InterruptHandler, Pio}; | 10 | use embassy_rp::pio::{Config, InterruptHandler, Pio}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 12 | ||
| @@ -24,7 +25,7 @@ async fn main(_spawner: Spawner) { | |||
| 24 | .. | 25 | .. |
| 25 | } = Pio::new(pio, Irqs); | 26 | } = Pio::new(pio, Irqs); |
| 26 | 27 | ||
| 27 | let prg = pio_proc::pio_asm!( | 28 | let prg = pio_asm!( |
| 28 | "irq set 0", | 29 | "irq set 0", |
| 29 | "irq wait 0", | 30 | "irq wait 0", |
| 30 | "irq set 1", | 31 | "irq set 1", |
diff --git a/tests/rp/src/bin/pio_multi_load.rs b/tests/rp/src/bin/pio_multi_load.rs index cd28f99b6..71321015b 100644 --- a/tests/rp/src/bin/pio_multi_load.rs +++ b/tests/rp/src/bin/pio_multi_load.rs | |||
| @@ -6,6 +6,7 @@ use defmt::info; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_rp::bind_interrupts; | 7 | use embassy_rp::bind_interrupts; |
| 8 | use embassy_rp::peripherals::PIO0; | 8 | use embassy_rp::peripherals::PIO0; |
| 9 | use embassy_rp::pio::program::pio_asm; | ||
| 9 | use embassy_rp::pio::{Config, InterruptHandler, LoadError, Pio}; | 10 | use embassy_rp::pio::{Config, InterruptHandler, LoadError, Pio}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 12 | ||
| @@ -27,7 +28,7 @@ async fn main(_spawner: Spawner) { | |||
| 27 | } = Pio::new(pio, Irqs); | 28 | } = Pio::new(pio, Irqs); |
| 28 | 29 | ||
| 29 | // load with explicit origin works | 30 | // load with explicit origin works |
| 30 | let prg1 = pio_proc::pio_asm!( | 31 | let prg1 = pio_asm!( |
| 31 | ".origin 4" | 32 | ".origin 4" |
| 32 | "nop", | 33 | "nop", |
| 33 | "nop", | 34 | "nop", |
| @@ -46,15 +47,14 @@ async fn main(_spawner: Spawner) { | |||
| 46 | assert_eq!(loaded1.wrap.target, 4); | 47 | assert_eq!(loaded1.wrap.target, 4); |
| 47 | 48 | ||
| 48 | // load without origin chooses a free space | 49 | // load without origin chooses a free space |
| 49 | let prg2 = pio_proc::pio_asm!("nop", "nop", "nop", "nop", "nop", "nop", "nop", "irq 1", "nop", "nop",); | 50 | let prg2 = pio_asm!("nop", "nop", "nop", "nop", "nop", "nop", "nop", "irq 1", "nop", "nop",); |
| 50 | let loaded2 = common.load_program(&prg2.program); | 51 | let loaded2 = common.load_program(&prg2.program); |
| 51 | assert_eq!(loaded2.origin, 14); | 52 | assert_eq!(loaded2.origin, 14); |
| 52 | assert_eq!(loaded2.wrap.source, 23); | 53 | assert_eq!(loaded2.wrap.source, 23); |
| 53 | assert_eq!(loaded2.wrap.target, 14); | 54 | assert_eq!(loaded2.wrap.target, 14); |
| 54 | 55 | ||
| 55 | // wrapping around the end of program space automatically works | 56 | // wrapping around the end of program space automatically works |
| 56 | let prg3 = | 57 | let prg3 = pio_asm!("nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "irq 2",); |
| 57 | pio_proc::pio_asm!("nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "nop", "irq 2",); | ||
| 58 | let loaded3 = common.load_program(&prg3.program); | 58 | let loaded3 = common.load_program(&prg3.program); |
| 59 | assert_eq!(loaded3.origin, 24); | 59 | assert_eq!(loaded3.origin, 24); |
| 60 | assert_eq!(loaded3.wrap.source, 3); | 60 | assert_eq!(loaded3.wrap.source, 3); |
| @@ -88,13 +88,13 @@ async fn main(_spawner: Spawner) { | |||
| 88 | 88 | ||
| 89 | // instruction memory is full now. all loads should fail. | 89 | // instruction memory is full now. all loads should fail. |
| 90 | { | 90 | { |
| 91 | let prg = pio_proc::pio_asm!(".origin 0", "nop"); | 91 | let prg = pio_asm!(".origin 0", "nop"); |
| 92 | match common.try_load_program(&prg.program) { | 92 | match common.try_load_program(&prg.program) { |
| 93 | Err(LoadError::AddressInUse(0)) => (), | 93 | Err(LoadError::AddressInUse(0)) => (), |
| 94 | _ => panic!("program loaded when it shouldn't"), | 94 | _ => panic!("program loaded when it shouldn't"), |
| 95 | }; | 95 | }; |
| 96 | 96 | ||
| 97 | let prg = pio_proc::pio_asm!("nop"); | 97 | let prg = pio_asm!("nop"); |
| 98 | match common.try_load_program(&prg.program) { | 98 | match common.try_load_program(&prg.program) { |
| 99 | Err(LoadError::InsufficientSpace) => (), | 99 | Err(LoadError::InsufficientSpace) => (), |
| 100 | _ => panic!("program loaded when it shouldn't"), | 100 | _ => panic!("program loaded when it shouldn't"), |
| @@ -106,13 +106,13 @@ async fn main(_spawner: Spawner) { | |||
| 106 | common.free_instr(loaded3.used_memory); | 106 | common.free_instr(loaded3.used_memory); |
| 107 | } | 107 | } |
| 108 | { | 108 | { |
| 109 | let prg = pio_proc::pio_asm!(".origin 0", "nop"); | 109 | let prg = pio_asm!(".origin 0", "nop"); |
| 110 | match common.try_load_program(&prg.program) { | 110 | match common.try_load_program(&prg.program) { |
| 111 | Ok(_) => (), | 111 | Ok(_) => (), |
| 112 | _ => panic!("program didn't loaded when it shouldn"), | 112 | _ => panic!("program didn't loaded when it shouldn"), |
| 113 | }; | 113 | }; |
| 114 | 114 | ||
| 115 | let prg = pio_proc::pio_asm!("nop"); | 115 | let prg = pio_asm!("nop"); |
| 116 | match common.try_load_program(&prg.program) { | 116 | match common.try_load_program(&prg.program) { |
| 117 | Ok(_) => (), | 117 | Ok(_) => (), |
| 118 | _ => panic!("program didn't loaded when it shouldn"), | 118 | _ => panic!("program didn't loaded when it shouldn"), |
