Skip to content

Commit c0a4bc1

Browse files
committed
Move the rendering over to Core 1.
Requires a bunch of patches to the HAL.
1 parent 750babc commit c0a4bc1

2 files changed

Lines changed: 425 additions & 224 deletions

File tree

src/main.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn main() -> ! {
154154
// sio is the *Single-cycle Input/Output* peripheral. It has all our GPIO
155155
// pins, as well as some mailboxes and other useful things for inter-core
156156
// communications.
157-
let sio = hal::sio::Sio::new(pac.SIO);
157+
let mut sio = hal::sio::Sio::new(pac.SIO);
158158

159159
// Configure and grab all the RP2040 pins the Pico exposes.
160160
let pins = pico::Pins::new(
@@ -186,24 +186,22 @@ fn main() -> ! {
186186
let _blue2 = pins.gpio12.into_mode::<hal::gpio::FunctionPio0>();
187187
let _blue3 = pins.gpio13.into_mode::<hal::gpio::FunctionPio0>();
188188

189-
vga::init(pac.PIO0, pac.DMA, &mut pac.RESETS);
190-
191-
core.SYST
192-
.set_clock_source(cortex_m::peripheral::syst::SystClkSource::External);
193-
core.SYST.set_reload(0x00FF_FFFF);
194-
core.SYST.clear_current();
195-
core.SYST.enable_counter();
196-
197-
let mut video = vga::VideoEngine::new();
189+
vga::init(
190+
pac.PIO0,
191+
pac.DMA,
192+
&mut pac.RESETS,
193+
&mut pac.PPB,
194+
&mut sio.fifo,
195+
&mut pac.PSM,
196+
);
198197

199198
loop {
200199
cortex_m::asm::wfi();
201-
// This function currently consumes about 70% CPU (or rather, 90% CPU
202-
// on each of 400 lines, and 0% CPU on the other 50 lines)
203-
video.poll();
204200
}
205201
}
206202

203+
/// Called when DMA raises IRQ0; i.e. when a DMA transfer to the pixel FIFO or
204+
/// the timing FIFO has completed.
207205
#[interrupt]
208206
fn DMA_IRQ_0() {
209207
unsafe {

0 commit comments

Comments
 (0)