aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/DMAv1
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2019-01-02 11:43:13 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2019-01-02 11:43:13 +0000
commitd5635adecc959228fefce27610f211087fefd87f (patch)
treeda768fca6a17255b1d9b82fab19cc87e992340e3 /os/hal/ports/STM32/LLD/DMAv1
parent60c04d66ec3c383febd9c9324e166aec2adb6e38 (diff)
downloadChibiOS-d5635adecc959228fefce27610f211087fefd87f.tar.gz
ChibiOS-d5635adecc959228fefce27610f211087fefd87f.tar.bz2
ChibiOS-d5635adecc959228fefce27610f211087fefd87f.zip
Mass update of all drivers to use the new DMA API. What could possibly go wrong?
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12521 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'os/hal/ports/STM32/LLD/DMAv1')
-rw-r--r--os/hal/ports/STM32/LLD/DMAv1/stm32_dma.c71
-rw-r--r--os/hal/ports/STM32/LLD/DMAv1/stm32_dma.h31
2 files changed, 56 insertions, 46 deletions
diff --git a/os/hal/ports/STM32/LLD/DMAv1/stm32_dma.c b/os/hal/ports/STM32/LLD/DMAv1/stm32_dma.c
index cabc8d5dc..f8aa1d7dc 100644
--- a/os/hal/ports/STM32/LLD/DMAv1/stm32_dma.c
+++ b/os/hal/ports/STM32/LLD/DMAv1/stm32_dma.c
@@ -504,13 +504,6 @@ void dmaInit(void) {
* @details The stream is allocated and, if required, the DMA clock enabled.
* The function also enables the IRQ vector associated to the stream
* and initializes its priority.
- * @pre The stream must not be already in use or an error is returned.
- * @post The stream is allocated and the default ISR handler redirected
- * to the specified function.
- * @post The stream ISR vector is enabled and its priority configured.
- * @post The stream must be freed using @p dmaStreamRelease() before it can
- * be reused with another peripheral.
- * @post The stream is in its post-reset state.
*
* @param[in] id numeric identifiers of a specific stream or:
* - @p STM32_DMA_STREAM_ID_ANY for any stream.
@@ -612,32 +605,34 @@ const stm32_dma_stream_t *dmaStreamAllocI(uint32_t id,
* @details The stream is allocated and, if required, the DMA clock enabled.
* The function also enables the IRQ vector associated to the stream
* and initializes its priority.
- * @pre The stream must not be already in use or an error is returned.
- * @post The stream is allocated and the default ISR handler redirected
- * to the specified function.
- * @post The stream ISR vector is enabled and its priority configured.
- * @post The stream must be freed using @p dmaStreamRelease() before it can
- * be reused with another peripheral.
- * @post The stream is in its post-reset state.
- * @note This function can be invoked in both ISR or thread context.
*
- * @param[in] dmastp pointer to a stm32_dma_stream_t structure
+ * @param[in] id numeric identifiers of a specific stream or:
+ * - @p STM32_DMA_STREAM_ID_ANY for any stream.
+ * - @p STM32_DMA_STREAM_ID_ANY_DMA1 for any stream
+ * on DMA1.
+ * - @p STM32_DMA_STREAM_ID_ANY_DMA2 for any stream
+ * on DMA2.
+ * .
* @param[in] priority IRQ priority for the DMA stream
* @param[in] func handling function pointer, can be @p NULL
* @param[in] param a parameter to be passed to the handling function
- * @return The operation status.
- * @retval false no error, stream taken.
- * @retval true error, stream already taken.
+ * @return Pointer to the allocated @p stm32_dma_stream_t
+ * structure.
+ * @retval NULL if a/the stream is not available.
*
- * @iclass
- * @deprecated
+ * @api
*/
-bool dmaStreamAllocate(const stm32_dma_stream_t *dmastp,
- uint32_t priority,
- stm32_dmaisr_t func,
- void *param) {
+const stm32_dma_stream_t *dmaStreamAlloc(uint32_t id,
+ uint32_t priority,
+ stm32_dmaisr_t func,
+ void *param) {
+ const stm32_dma_stream_t *dmastp;
+
+ osalSysLock();
+ dmastp = dmaStreamAllocI(id, priority, func, param);
+ osalSysUnlock();
- return dmaStreamAllocI(dmastp->selfindex, priority, func, param) == NULL;
+ return dmastp;
}
/**
@@ -645,15 +640,12 @@ bool dmaStreamAllocate(const stm32_dma_stream_t *dmastp,
* @details The stream is freed and, if required, the DMA clock disabled.
* Trying to release a unallocated stream is an illegal operation
* and is trapped if assertions are enabled.
- * @pre The stream must have been allocated using @p dmaStreamAllocate().
- * @post The stream is again available.
- * @note This function can be invoked in both ISR or thread context.
*
* @param[in] dmastp pointer to a stm32_dma_stream_t structure
*
- * @special
+ * @iclass
*/
-void dmaStreamRelease(const stm32_dma_stream_t *dmastp) {
+void dmaStreamFreeI(const stm32_dma_stream_t *dmastp) {
osalDbgCheck(dmastp != NULL);
@@ -693,6 +685,23 @@ void dmaStreamRelease(const stm32_dma_stream_t *dmastp) {
}
/**
+ * @brief Releases a DMA stream.
+ * @details The stream is freed and, if required, the DMA clock disabled.
+ * Trying to release a unallocated stream is an illegal operation
+ * and is trapped if assertions are enabled.
+ *
+ * @param[in] dmastp pointer to a stm32_dma_stream_t structure
+ *
+ * @api
+ */
+void dmaStreamFree(const stm32_dma_stream_t *dmastp) {
+
+ osalSysLock();
+ dmaStreamFreeI(dmastp);
+ osalSysUnlock();
+}
+
+/**
* @brief Serves a DMA IRQ.
*
* @param[in] dmastp pointer to a stm32_dma_stream_t structure
diff --git a/os/hal/ports/STM32/LLD/DMAv1/stm32_dma.h b/os/hal/ports/STM32/LLD/DMAv1/stm32_dma.h
index 3bb5ff4ca..0a25e48eb 100644
--- a/os/hal/ports/STM32/LLD/DMAv1/stm32_dma.h
+++ b/os/hal/ports/STM32/LLD/DMAv1/stm32_dma.h
@@ -79,22 +79,22 @@
#if (STM32_DMA_SUPPORTS_DMAMUX == FALSE) || defined(_DOXYGEN__)
/**
- * @brief Checks if a DMA channel is within the valid range.
+ * @brief Checks if a DMA stream id is within the valid range.
*
- * @param[in] ch DMA channel
+ * @param[in] id DMA stream id
* @retval The check result.
- * @retval FALSE invalid DMA channel.
- * @retval TRUE correct DMA channel.
+ * @retval false invalid DMA channel.
+ * @retval true correct DMA channel.
*/
-#define STM32_DMA_IS_VALID_CHANNEL(ch) (((ch) >= 0U) && \
- ((ch) < STM32_DMA_STREAMS))
+#define STM32_DMA_IS_VALID_STREAM(id) (((id) >= 0U) && \
+ ((id) < STM32_DMA_STREAMS))
#else /* STM32_DMA_SUPPORTS_DMAMUX == FALSE */
#if STM32_DMA2_NUM_CHANNELS > 0
-#define STM32_DMA_IS_VALID_CHANNEL(ch) (((ch) >= 0U) && \
- ((ch) <= (STM32_DMA_STREAMS + 2)))
+#define STM32_DMA_IS_VALID_STREAM(id) (((id) >= 0U) && \
+ ((id) <= (STM32_DMA_STREAMS + 2)))
#else
-#define STM32_DMA_IS_VALID_CHANNEL(ch) (((ch) >= 0U) && \
- ((ch) <= (STM32_DMA_STREAMS + 1)))
+#define STM32_DMA_IS_VALID_STREAM(id) (((id) >= 0U) && \
+ ((id) <= (STM32_DMA_STREAMS + 1)))
#endif
#endif /* STM32_DMA_SUPPORTS_DMAMUX == FALSE */
@@ -500,11 +500,12 @@ extern "C" {
uint32_t priority,
stm32_dmaisr_t func,
void *param);
- bool dmaStreamAllocate(const stm32_dma_stream_t *dmastp,
- uint32_t priority,
- stm32_dmaisr_t func,
- void *param);
- void dmaStreamRelease(const stm32_dma_stream_t *dmastp);
+ const stm32_dma_stream_t *dmaStreamAlloc(uint32_t id,
+ uint32_t priority,
+ stm32_dmaisr_t func,
+ void *param);
+ void dmaStreamFreeI(const stm32_dma_stream_t *dmastp);
+ void dmaStreamFree(const stm32_dma_stream_t *dmastp);
void dmaServeInterrupt(const stm32_dma_stream_t *dmastp);
#if STM32_DMA_SUPPORTS_DMAMUX == TRUE
void dmaSetRequestSource(const stm32_dma_stream_t *dmastp, uint32_t per);