From 6d5e80ffbcd8181a3f1b2951e2eb210534caf033 Mon Sep 17 00:00:00 2001 From: stnolting <22944758+stnolting@users.noreply.github.com> Date: Sat, 7 Oct 2023 10:23:28 +0200 Subject: [PATCH] [sw] update DMA test programs --- sw/example/demo_dma/main.c | 9 ++++----- sw/example/processor_check/main.c | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sw/example/demo_dma/main.c b/sw/example/demo_dma/main.c index 91df0e812..57a036cab 100644 --- a/sw/example/demo_dma/main.c +++ b/sw/example/demo_dma/main.c @@ -202,8 +202,7 @@ int main() { neorv32_cpu_sleep(); // check if transfer was successful - rc = neorv32_dma_status(); - if ((rc == DMA_STATUS_ERR_RD) || (rc == DMA_STATUS_ERR_WR)) { + if (neorv32_dma_status() != DMA_STATUS_IDLE) { neorv32_uart0_printf("Transfer failed!\n"); } @@ -242,9 +241,9 @@ int main() { // sleep until interrupt (from DMA) neorv32_cpu_sleep(); - // check DMA status - rc = neorv32_dma_status(); - if ((rc == DMA_STATUS_ERR_RD) || (rc == DMA_STATUS_ERR_WR)) { + // transfer successful (and actually executed)? + if ((neorv32_dma_done() == 0) || // check if the DMA has actually completed a transfer + (neorv32_dma_status() != DMA_STATUS_IDLE)) { // DMA is in idle mode without errors neorv32_uart0_printf("Transfer failed!\n"); } diff --git a/sw/example/processor_check/main.c b/sw/example/processor_check/main.c index 81b69a795..5cfe325bf 100644 --- a/sw/example/processor_check/main.c +++ b/sw/example/processor_check/main.c @@ -1489,6 +1489,7 @@ int main() { if ((neorv32_cpu_csr_read(CSR_MCAUSE) == DMA_TRAP_CODE) && // correct interrupt source (neorv32_crc_get() == 0x31DC476E) && // correct CRC sum + (neorv32_dma_done() != 0) && // DMA has actually attempted a transfer (neorv32_dma_status() == DMA_STATUS_IDLE)) { // DMA back in idle mode without errors test_ok(); }