summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2016-06-27 17:26:19 -0700
committerKeith Packard <keithp@keithp.com>2016-06-29 19:17:45 -0700
commitf418584d4d225827e08f56de86055eb3f074f8d1 (patch)
tree755f010881cf2d80b75fdae5cbd6b60302a3b232 /src
parent2e60cd22f6789c94343e6432822cedab028dc1ba (diff)
altos: Add STM DMA debugging
This provides a command that shows current DMA operations when compiled with -DDEBUG=1. Without that, this patch has no effect. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
-rw-r--r--src/stm/ao_dma_stm.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/src/stm/ao_dma_stm.c b/src/stm/ao_dma_stm.c
index 93b7fb47..0135de48 100644
--- a/src/stm/ao_dma_stm.c
+++ b/src/stm/ao_dma_stm.c
@@ -113,6 +113,40 @@ ao_dma_alloc(uint8_t index)
ao_dma_allocated[index] = 1;
}
+#if DEBUG
+void
+ao_dma_dump_cmd(void)
+{
+ int i;
+
+ ao_arch_critical(
+ if (ao_dma_active++ == 0)
+ stm_rcc.ahbenr |= (1 << STM_RCC_AHBENR_DMA1EN);
+ );
+ printf ("isr %08x ifcr%08x\n", stm_dma.isr, stm_dma.ifcr);
+ for (i = 0; i < NUM_DMA; i++)
+ printf("%d: done %d allocated %d mutex %2d ccr %04x cndtr %04x cpar %08x cmar %08x isr %08x\n",
+ i,
+ ao_dma_done[i],
+ ao_dma_allocated[i],
+ ao_dma_mutex[i],
+ stm_dma.channel[i].ccr,
+ stm_dma.channel[i].cndtr,
+ stm_dma.channel[i].cpar,
+ stm_dma.channel[i].cmar,
+ ao_dma_config[i].isr);
+ ao_arch_critical(
+ if (--ao_dma_active == 0)
+ stm_rcc.ahbenr &= ~(1 << STM_RCC_AHBENR_DMA1EN);
+ );
+}
+
+static const struct ao_cmds ao_dma_cmds[] = {
+ { ao_dma_dump_cmd, "D\0Dump DMA status" },
+ { 0, NULL }
+};
+#endif
+
void
ao_dma_init(void)
{
@@ -124,5 +158,7 @@ ao_dma_init(void)
ao_dma_allocated[index] = 0;
ao_dma_mutex[index] = 0;
}
-
+#if DEBUG
+ ao_cmd_register(&ao_dma_cmds[0]);
+#endif
}