aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Otto2010-03-24 22:51:43 +0100
committerThomas Otto2010-03-24 22:51:43 +0100
commitd96b31879590c4d84eba90dfb263cb25d0f2e3ce (patch)
tree9635a2ef915f1a6a153b66d13950d523cc89315e
parenta0e026d110599697f976b07e36425edb6c2b2eee (diff)
Added some address setting functions to dma.
-rw-r--r--include/libopenstm32/dma.h11
-rw-r--r--lib/dma.c70
2 files changed, 81 insertions, 0 deletions
diff --git a/include/libopenstm32/dma.h b/include/libopenstm32/dma.h
index 42f9f5f..38d5654 100644
--- a/include/libopenstm32/dma.h
+++ b/include/libopenstm32/dma.h
@@ -687,6 +687,14 @@
/* MA[31:0]: Memory address */
+/* --- Generic values ------------------------------------------------------ */
+#define DMA_CHANNEL1 1
+#define DMA_CHANNEL2 2
+#define DMA_CHANNEL3 3
+#define DMA_CHANNEL4 4
+#define DMA_CHANNEL5 5
+#define DMA_CHANNEL6 6
+#define DMA_CHANNEL7 7
/* --- function prototypes ------------------------------------------------- */
@@ -707,5 +715,8 @@ void dma_enable_transfer_complete_interrupt(u32 dma, u8 channel);
void dma_disable_transfer_complete_interrupt(u32 dma, u8 channel);
void dma_enable_channel(u32 dma, u8 channel);
void dma_disable_channel(u32 dma, u8 channel);
+void dma_set_peripheral_address(u32 dma, u8 channel, u32 * address);
+void dma_set_memory_address(u32 dma, u8 channel, u32 * address);
+void dma_set_number_of_data(u32 dma, u8 channel, u16 number);
#endif
diff --git a/lib/dma.c b/lib/dma.c
index 2dbcc6b..50b50d9 100644
--- a/lib/dma.c
+++ b/lib/dma.c
@@ -473,3 +473,73 @@ void dma_disable_channel(u32 dma, u8 channel)
}
}
+void dma_set_peripheral_address(u32 dma, u8 channel, u32 * address)
+{
+ switch (channel)
+ {
+ case 1:
+ DMA_CPAR1(dma) = (u32)address;
+ case 2:
+ DMA_CPAR2(dma) = (u32)address;
+ case 3:
+ DMA_CPAR3(dma) = (u32)address;
+ case 4:
+ DMA_CPAR4(dma) = (u32)address;
+ case 5:
+ DMA_CPAR5(dma) = (u32)address;
+ case 6:
+ if (dma == DMA1)
+ DMA_CPAR6(dma) = (u32)address;
+ case 7:
+ if (dma == DMA1)
+ DMA_CPAR7(dma) = (u32)address;
+ }
+}
+
+void dma_set_memory_address(u32 dma, u8 channel, u32 * address)
+{
+ switch (channel)
+ {
+ case 1:
+ DMA_CMAR1(dma) = (u32)address;
+ case 2:
+ DMA_CMAR2(dma) = (u32)address;
+ case 3:
+ DMA_CMAR3(dma) = (u32)address;
+ case 4:
+ DMA_CMAR4(dma) = (u32)address;
+ case 5:
+ DMA_CMAR5(dma) = (u32)address;
+ case 6:
+ if (dma == DMA1)
+ DMA_CMAR6(dma) = (u32)address;
+ case 7:
+ if (dma == DMA1)
+ DMA_CMAR7(dma) = (u32)address;
+ }
+}
+
+void dma_set_number_of_data(u32 dma, u8 channel, u16 number)
+{
+ switch (channel)
+ {
+ case 1:
+ DMA_CNDTR1(dma) = number;
+ case 2:
+ DMA_CNDTR2(dma) = number;
+ case 3:
+ DMA_CNDTR3(dma) = number;
+ case 4:
+ DMA_CNDTR4(dma) = number;
+ case 5:
+ DMA_CNDTR5(dma) = number;
+ case 6:
+ if (dma == DMA1)
+ DMA_CNDTR6(dma) = number;
+ case 7:
+ if (dma == DMA1)
+ DMA_CNDTR7(dma) = number;
+ }
+}
+
+