Skip to content

Commit ae239b5

Browse files
authored
Merge pull request #29 from jannic-dev-forks/const-instruction-encode
2 parents a097cdb + f07fd96 commit ae239b5

File tree

2 files changed

+16
-26
lines changed

2 files changed

+16
-26
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ defmt-rtt = "0.4"
2727
# Send panics to the debugger
2828
panic-probe = "0.2"
2929
# RP2040 PIO assembler
30-
pio = "0.2"
30+
pio = "0.2.1"
3131
# Macros for RP2040 PIO assembler
3232
pio-proc = "0.2"
3333
# Hardware locks for sharing data with interrupts

src/vga/mod.rs

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,33 +1284,23 @@ impl ScanlineTimingBuffer {
12841284
/// Returns a 32-bit value you can post to the Timing FIFO.
12851285
const fn make_timing(period: u32, hsync: bool, vsync: bool, raise_irq: bool) -> u32 {
12861286
let command = if raise_irq {
1287-
// This command sets IRQ 0. It is the same as:
1288-
//
1289-
// ```
1290-
// pio::InstructionOperands::IRQ {
1291-
// clear: false,
1292-
// wait: false,
1293-
// index: 0,
1294-
// relative: false,
1295-
// }.encode()
1296-
// ```
1297-
//
1298-
// Unfortunately encoding this isn't a const-fn, so we cheat:
1299-
0xc000
1287+
// This command sets IRQ 0
1288+
pio::InstructionOperands::IRQ {
1289+
clear: false,
1290+
wait: false,
1291+
index: 0,
1292+
relative: false,
1293+
}
1294+
.encode()
13001295
} else {
13011296
// This command is a no-op (it moves Y into Y)
1302-
//
1303-
// ```
1304-
// pio::InstructionOperands::MOV {
1305-
// destination: pio::MovDestination::Y,
1306-
// op: pio::MovOperation::None,
1307-
// source: pio::MovSource::Y,
1308-
// }.encode()
1309-
// ```
1310-
//
1311-
// Unfortunately encoding this isn't a const-fn, so we cheat:
1312-
0xa042
1313-
};
1297+
pio::InstructionOperands::MOV {
1298+
destination: pio::MovDestination::Y,
1299+
op: pio::MovOperation::None,
1300+
source: pio::MovSource::Y,
1301+
}
1302+
.encode()
1303+
} as u32;
13141304
let mut value: u32 = 0;
13151305
if hsync {
13161306
value |= 1 << 0;

0 commit comments

Comments
 (0)