Skip to content

Commit

Permalink
Dont enable pio-parser rp2350 feature by default
Browse files Browse the repository at this point in the history
  • Loading branch information
CBJamo committed Sep 27, 2024
1 parent 301f0e0 commit a587e90
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 22 deletions.
1 change: 0 additions & 1 deletion pio-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ license = "MIT"
repository = "https://github.com/rp-rs/pio-rs"

[features]
default = ["rp2350"]
rp2350 = ["pio/rp2350"]

[dependencies]
Expand Down
25 changes: 25 additions & 0 deletions pio-parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,22 @@ pub(crate) enum ParsedMovDestination {
PC,
ISR,
OSR,
#[cfg(feature = "rp2350")]
RXFIFOY,
#[cfg(feature = "rp2350")]
RXFIFO0,
#[cfg(feature = "rp2350")]
RXFIFO1,
#[cfg(feature = "rp2350")]
RXFIFO2,
#[cfg(feature = "rp2350")]
RXFIFO3,
}

#[derive(Debug)]
enum MovDestInternal {
Mov(MovDestination),
#[cfg(feature = "rp2350")]
Fifo(MovRxIndex),
}

Expand All @@ -128,10 +134,15 @@ impl From<ParsedMovDestination> for MovDestInternal {
ParsedMovDestination::PC => MovDestInternal::Mov(MovDestination::PC),
ParsedMovDestination::ISR => MovDestInternal::Mov(MovDestination::ISR),
ParsedMovDestination::OSR => MovDestInternal::Mov(MovDestination::OSR),
#[cfg(feature = "rp2350")]
ParsedMovDestination::RXFIFOY => MovDestInternal::Fifo(MovRxIndex::RXFIFOY),
#[cfg(feature = "rp2350")]
ParsedMovDestination::RXFIFO0 => MovDestInternal::Fifo(MovRxIndex::RXFIFO0),
#[cfg(feature = "rp2350")]
ParsedMovDestination::RXFIFO1 => MovDestInternal::Fifo(MovRxIndex::RXFIFO1),
#[cfg(feature = "rp2350")]
ParsedMovDestination::RXFIFO2 => MovDestInternal::Fifo(MovRxIndex::RXFIFO2),
#[cfg(feature = "rp2350")]
ParsedMovDestination::RXFIFO3 => MovDestInternal::Fifo(MovRxIndex::RXFIFO3),
}
}
Expand All @@ -146,16 +157,22 @@ pub(crate) enum ParsedMovSource {
STATUS,
ISR,
OSR,
#[cfg(feature = "rp2350")]
RXFIFOY,
#[cfg(feature = "rp2350")]
RXFIFO0,
#[cfg(feature = "rp2350")]
RXFIFO1,
#[cfg(feature = "rp2350")]
RXFIFO2,
#[cfg(feature = "rp2350")]
RXFIFO3,
}

#[derive(Debug)]
enum MovSrcInternal {
Mov(MovSource),
#[cfg(feature = "rp2350")]
Fifo(MovRxIndex),
}

Expand All @@ -169,10 +186,15 @@ impl From<ParsedMovSource> for MovSrcInternal {
ParsedMovSource::STATUS => MovSrcInternal::Mov(MovSource::STATUS),
ParsedMovSource::ISR => MovSrcInternal::Mov(MovSource::ISR),
ParsedMovSource::OSR => MovSrcInternal::Mov(MovSource::OSR),
#[cfg(feature = "rp2350")]
ParsedMovSource::RXFIFOY => MovSrcInternal::Fifo(MovRxIndex::RXFIFOY),
#[cfg(feature = "rp2350")]
ParsedMovSource::RXFIFO0 => MovSrcInternal::Fifo(MovRxIndex::RXFIFO0),
#[cfg(feature = "rp2350")]
ParsedMovSource::RXFIFO1 => MovSrcInternal::Fifo(MovRxIndex::RXFIFO1),
#[cfg(feature = "rp2350")]
ParsedMovSource::RXFIFO2 => MovSrcInternal::Fifo(MovRxIndex::RXFIFO2),
#[cfg(feature = "rp2350")]
ParsedMovSource::RXFIFO3 => MovSrcInternal::Fifo(MovRxIndex::RXFIFO3),
}
}
Expand Down Expand Up @@ -268,9 +290,11 @@ impl<'i> ParsedOperands<'i> {
let source_internal = (*source).into();
let dest_internal = (*destination).into();
match (source_internal, dest_internal) {
#[cfg(feature = "rp2350")]
(MovSrcInternal::Mov(MovSource::ISR), MovDestInternal::Fifo(index)) => {
InstructionOperands::MOVTORX { index }
}
#[cfg(feature = "rp2350")]
(MovSrcInternal::Fifo(index), MovDestInternal::Mov(MovDestination::OSR)) => {
InstructionOperands::MOVFROMRX { index }
}
Expand All @@ -279,6 +303,7 @@ impl<'i> ParsedOperands<'i> {
op: *op,
source: s,
},
#[cfg(feature = "rp2350")]
(d, s) => panic!("Illegal Mov src/dest combination: {:?} {:?}", d, s),
}
}
Expand Down
42 changes: 21 additions & 21 deletions pio-parser/src/rp2040.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use ::pio::{
WaitSource,
InSource,
OutDestination,
MovDestination,
MovOperation,
MovSource,
SetDestination,
};
use crate::{
Expand All @@ -17,6 +15,8 @@ use crate::{
ParsedDirective,
ParsedInstruction,
ParsedOperands,
ParsedMovDestination,
ParsedMovSource,
};

grammar();
Expand Down Expand Up @@ -139,9 +139,9 @@ Instruction: ParsedInstruction<'input> = {

BaseInstruction: ParsedOperands<'input> = {
"nop" => ParsedOperands::MOV {
destination: MovDestination::Y,
destination: ParsedMovDestination::Y,
op: MovOperation::None,
source: MovSource::Y,
source: ParsedMovSource::Y,
},
"jmp" <c:JmpCondition?> ","? <e:Expression> => ParsedOperands::JMP {
condition: match c {
Expand Down Expand Up @@ -178,7 +178,7 @@ BaseInstruction: ParsedOperands<'input> = {
None => true,
},
},
"mov" <d:MovDestination> ","? <o:MovOperation?> <s:MovSource> => ParsedOperands::MOV {
"mov" <d:ParsedMovDestination> ","? <o:MovOperation?> <s:ParsedMovSource> => ParsedOperands::MOV {
destination: d,
op: match o {
Some(o) => o,
Expand Down Expand Up @@ -245,14 +245,14 @@ ShouldBlock: bool = {
"noblock" => false,
};

MovDestination: MovDestination = {
"pins" => MovDestination::PINS,
"x" => MovDestination::X,
"y" => MovDestination::Y,
"exec" => MovDestination::EXEC,
"pc" => MovDestination::PC,
"isr" => MovDestination::ISR,
"osr" => MovDestination::OSR,
ParsedMovDestination: ParsedMovDestination = {
"pins" => ParsedMovDestination::PINS,
"x" => ParsedMovDestination::X,
"y" => ParsedMovDestination::Y,
"exec" => ParsedMovDestination::EXEC,
"pc" => ParsedMovDestination::PC,
"isr" => ParsedMovDestination::ISR,
"osr" => ParsedMovDestination::OSR,
};

MovOperation: MovOperation = {
Expand All @@ -261,14 +261,14 @@ MovOperation: MovOperation = {
"::" => MovOperation::BitReverse,
};

MovSource: MovSource = {
"pins" => MovSource::PINS,
"x" => MovSource::X,
"y" => MovSource::Y,
"null" => MovSource::NULL,
"status" => MovSource::STATUS,
"isr" => MovSource::ISR,
"osr" => MovSource::OSR,
ParsedMovSource: ParsedMovSource = {
"pins" => ParsedMovSource::PINS,
"x" => ParsedMovSource::X,
"y" => ParsedMovSource::Y,
"null" => ParsedMovSource::NULL,
"status" => ParsedMovSource::STATUS,
"isr" => ParsedMovSource::ISR,
"osr" => ParsedMovSource::OSR,
};

IrqModifier: (bool, bool) = {
Expand Down

0 comments on commit a587e90

Please sign in to comment.