aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/DMAv2/stm32_dma.h
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-08-26 11:50:35 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-08-26 11:50:35 +0000
commit95229524a642ae2cfe7f19b79a82f3e8a274b3a3 (patch)
treeccfaa06d05131fac67664f9598e6343060871bef /os/hal/ports/STM32/LLD/DMAv2/stm32_dma.h
parentccef2d248b7269766f00b9122eb1930aa1100605 (diff)
downloadChibiOS-95229524a642ae2cfe7f19b79a82f3e8a274b3a3.tar.gz
ChibiOS-95229524a642ae2cfe7f19b79a82f3e8a274b3a3.tar.bz2
ChibiOS-95229524a642ae2cfe7f19b79a82f3e8a274b3a3.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8242 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/ports/STM32/LLD/DMAv2/stm32_dma.h')
-rw-r--r--os/hal/ports/STM32/LLD/DMAv2/stm32_dma.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/os/hal/ports/STM32/LLD/DMAv2/stm32_dma.h b/os/hal/ports/STM32/LLD/DMAv2/stm32_dma.h
index 49139f831..fdc76ee59 100644
--- a/os/hal/ports/STM32/LLD/DMAv2/stm32_dma.h
+++ b/os/hal/ports/STM32/LLD/DMAv2/stm32_dma.h
@@ -240,6 +240,9 @@ typedef void (*stm32_dmaisr_t)(void *p, uint32_t flags);
#if defined(STM32F7XX) || defined(__DOXYGEN__)
/**
* @brief Invalidates the data cache lines overlapping a DMA buffer.
+ * @details This function is meant to make sure that data written in
+ * data cache is invalidated. It is used for DMA buffers that
+ * must have been written by a DMA stream.
* @note On devices without data cache this function does nothing.
* @note The function takes care of cache lines alignment.
*
@@ -253,6 +256,31 @@ typedef void (*stm32_dmaisr_t)(void *p, uint32_t flags);
uint8_t *end = (uint8_t *)(((((uint32_t)(eaddr)) - 1U) | 0x1FU) + 1U); \
__DSB(); \
while (start < end) { \
+ SCB->DCIMVAC = (uint32_t)start; \
+ start += 32U; \
+ } \
+ __DSB(); \
+ __ISB(); \
+}
+
+/**
+ * @brief Flushes the data cache lines overlapping a DMA buffer.
+ * @details This function is meant to make sure that data written in
+ * data cache is flushed to RAM. It is used for DMA buffers that
+ * must be read by a DMA stream.
+ * @note On devices without data cache this function does nothing.
+ * @note The function takes care of cache lines alignment.
+ *
+ * @param[in] saddr start address of the DMA buffer, inclusive
+ * @param[in] eaddr end address of the DMA buffer, not inclusive
+ *
+ * @api
+ */
+#define dmaBufferFlush(saddr, eaddr) { \
+ uint8_t *start = (uint8_t *)(((uint32_t)(saddr)) & ~0x1FU); \
+ uint8_t *end = (uint8_t *)(((((uint32_t)(eaddr)) - 1U) | 0x1FU) + 1U); \
+ __DSB(); \
+ while (start < end) { \
SCB->DCCIMVAC = (uint32_t)start; \
start += 32U; \
} \
@@ -264,6 +292,10 @@ typedef void (*stm32_dmaisr_t)(void *p, uint32_t flags);
(void)(addr); \
(void)(size); \
}
+#define dmaBufferFlush(addr, size) { \
+ (void)(addr); \
+ (void)(size); \
+}
#endif
/**