summaryrefslogtreecommitdiff
path: root/reset-controller/fw/src/dma_util.c
diff options
context:
space:
mode:
authorjaseg <git-bigdata-wsl-arch@jaseg.de>2021-04-09 18:38:02 +0200
committerjaseg <git-bigdata-wsl-arch@jaseg.de>2021-04-09 18:38:57 +0200
commit50998fcfb916ae251309bd4b464f2c122e8cb30d (patch)
tree4ecf7a7443b75ab51c4dc0c0fc9289342dc7d6a0 /reset-controller/fw/src/dma_util.c
parent312fee491cfab436d52db4b6265107e20f3e1293 (diff)
downloadmaster-thesis-50998fcfb916ae251309bd4b464f2c122e8cb30d.tar.gz
master-thesis-50998fcfb916ae251309bd4b464f2c122e8cb30d.tar.bz2
master-thesis-50998fcfb916ae251309bd4b464f2c122e8cb30d.zip
Repo re-org
Diffstat (limited to 'reset-controller/fw/src/dma_util.c')
-rw-r--r--reset-controller/fw/src/dma_util.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/reset-controller/fw/src/dma_util.c b/reset-controller/fw/src/dma_util.c
new file mode 100644
index 0000000..48de215
--- /dev/null
+++ b/reset-controller/fw/src/dma_util.c
@@ -0,0 +1,46 @@
+
+#include <assert.h>
+
+#include "dma_util.h"
+
+uint8_t dma_get_isr_and_clear(DMA_TypeDef *dma, int ch) {
+ uint8_t isr_val;
+ switch(ch) {
+ case 0:
+ isr_val = dma->LISR & 0x3f;
+ dma->LIFCR = isr_val;
+ return isr_val;
+ case 1:
+ isr_val = dma->LISR>>6 & 0x3f;
+ dma->LIFCR = isr_val<<6;
+ return isr_val;
+ case 2:
+ isr_val = dma->LISR>>16 & 0x3f;
+ dma->LIFCR = isr_val<<16;
+ return isr_val;
+ case 3:
+ isr_val = dma->LISR>>6>>16 & 0x3f;
+ dma->LIFCR = isr_val<<6<<16;
+ return isr_val;
+ case 4:
+ isr_val = dma->HISR & 0x3f;
+ dma->HIFCR = isr_val;
+ return isr_val;
+ case 5:
+ isr_val = dma->HISR>>6 & 0x3f;
+ dma->HIFCR = isr_val<<6;
+ return isr_val;
+ case 6:
+ isr_val = dma->HISR>>16 & 0x3f;
+ dma->HIFCR = isr_val<<16;
+ return isr_val;
+ case 7:
+ isr_val = dma->HISR>>6>>16 & 0x3f;
+ dma->HIFCR = isr_val<<6<<16;
+ return isr_val;
+ default:
+ assert(0);
+ return 0;
+ }
+}
+