Skip to content

Commit

Permalink
irqs with no prints -> main.rs works perfectly?
Browse files Browse the repository at this point in the history
  • Loading branch information
vk2seb committed Sep 23, 2023
1 parent e58b7a0 commit 9d1634f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
27 changes: 12 additions & 15 deletions firmware/litex-fw/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ use litex_pac as pac;
use litex_hal::prelude::*;
use litex_hal::uart::UartError;
use core::arch::asm;
use crate::BUF_IN_CP;
use core::sync::atomic::fence;
use core::sync::atomic::compiler_fence;
use core::sync::atomic::Ordering;

litex_hal::uart! {
Uart: pac::UART,
Expand Down Expand Up @@ -57,41 +61,34 @@ fn default_handler() {
let mut buf_copy: [u32; 0x10] = [0; 0x10];
let base = peripherals.DMA_WRITER0.base0.read().bits();
let buf = base as *const u32;
let mut hi = false;

fence(Ordering::Release);
compiler_fence(Ordering::Release);

if offset == 0x10 {
for i in 0..0x10 {
unsafe {
buf_copy[i] = *buf.add(i);
BUF_IN_CP[i] = *buf.add(i);
}
}
}

if offset == 0x1f {
for i in 0x0..0x10 {
for i in 0x10..0x20 {
unsafe {
buf_copy[i] = *buf.add(i+0x10);
BUF_IN_CP[i] = *buf.add(i+0x10);
}
}
hi = true;
}
}

for i in 0..0x10 {
let mut fac = 0;
if hi {
fac += 0x10;
}
info!("{:x}@{:x}", i+fac, buf_copy[i]);
}
} else if (pending & (1u32 << pac::Interrupt::DMA_READER0 as u32)) != 0 {
if (pending & (1u32 << pac::Interrupt::DMA_READER0 as u32)) != 0 {
let pending_type = peripherals.DMA_READER0.ev_pending.read().bits();
let offset = peripherals.DMA_READER0.offset.read().bits();
//info!("dmar0 {:x} {:x}", pending_type, offset);
unsafe {
peripherals.DMA_READER0.ev_pending.write(|w| w.bits(pending_type));
}
} else {
info!("unknown irq!!");
}
}

Expand Down
10 changes: 2 additions & 8 deletions firmware/litex-fw/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const BUF_SZ_BYTES: usize = BUF_SZ_WORDS * 4;
static mut BUF_OUT: [u32; BUF_SZ_WORDS] = [0; BUF_SZ_WORDS];
static mut BUF_IN: [u32; BUF_SZ_WORDS] = [0; BUF_SZ_WORDS];

static mut BUF_IN_CP: [u32; BUF_SZ_WORDS] = [0; BUF_SZ_WORDS]
static mut BUF_IN_CP: [u32; BUF_SZ_WORDS] = [0; BUF_SZ_WORDS];

#[entry]
fn main() -> ! {
Expand Down Expand Up @@ -83,19 +83,13 @@ fn main() -> ! {
}

loop {
/*
log::info!("READ");
unsafe {
fence(Ordering::Release);
compiler_fence(Ordering::Release);
log::info!("{:x}", peripherals.DMA_WRITER0.ev_pending.read().bits());
let buf_read = BUF_IN.clone();
for i in 0..BUF_SZ_WORDS {
log::info!("{:x}@{:x}", i, buf_read[i]);
log::info!("{:x}@{:x}", i, BUF_IN_CP[i]);

}
}
*/
/*
log::info!("jack_detect {:x}", peripherals.EURORACK_PMOD0.csr_jack.read().bits() as u8);
log::info!("input0 {}", peripherals.EURORACK_PMOD0.csr_cal_in0.read().bits() as i16);
Expand Down

0 comments on commit 9d1634f

Please sign in to comment.