aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/STM32/LLD/BDMAv1
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/BDMAv1
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/BDMAv1')
-rw-r--r--os/hal/ports/STM32/LLD/BDMAv1/stm32_bdma.c66
-rw-r--r--os/hal/ports/STM32/LLD/BDMAv1/stm32_bdma.h23
2 files changed, 48 insertions, 41 deletions
diff --git a/os/hal/ports/STM32/LLD/BDMAv1/stm32_bdma.c b/os/hal/ports/STM32/LLD/BDMAv1/stm32_bdma.c
index fcb2fc192..52e42e49c 100644
--- a/os/hal/ports/STM32/LLD/BDMAv1/stm32_bdma.c
+++ b/os/hal/ports/STM32/LLD/BDMAv1/stm32_bdma.c
@@ -279,13 +279,6 @@ void bdmaInit(void) {
* @details The stream is allocated and, if required, the BDMA 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_BDMA_STREAM_ID_ANY for any stream.
@@ -363,31 +356,30 @@ const stm32_bdma_stream_t *bdmaStreamAllocI(uint32_t id,
* @details The stream is allocated and, if required, the BDMA 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 bdmaStreamRelease() 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] stp pointer to an @p stm32_bdma_stream_t structure
+ * @param[in] id numeric identifiers of a specific stream or:
+ * - @p STM32_BDMA_STREAM_ID_ANY for any stream.
+ * .
* @param[in] priority IRQ priority for the BDMA 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_bdma_stream_t
+ * structure.
+ * @retval NULL if a/the stream is not available.
*
- * @special
+ * @api
*/
-bool bdmaStreamAllocate(const stm32_bdma_stream_t *stp,
- uint32_t priority,
- stm32_bdmaisr_t func,
- void *param) {
+const stm32_bdma_stream_t *bdmaStreamAlloc(uint32_t id,
+ uint32_t priority,
+ stm32_bdmaisr_t func,
+ void *param) {
+ const stm32_bdma_stream_t *stp;
+
+ osalSysLock();
+ stp = bdmaStreamAllocI(id, priority, func, param);
+ osalSysUnlock();
- return bdmaStreamAllocI(stp->selfindex, priority, func, param) == NULL;
+ return stp;
}
/**
@@ -395,15 +387,12 @@ bool bdmaStreamAllocate(const stm32_bdma_stream_t *stp,
* @details The stream is freed and, if required, the BDMA 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 bdmaStreamAllocate().
- * @post The stream is again available.
- * @note This function can be invoked in both ISR or thread context.
*
* @param[in] stp pointer to an @p stm32_bdma_stream_t structure
*
- * @special
+ * @iclass
*/
-void bdmaStreamRelease(const stm32_bdma_stream_t *stp) {
+void bdmaStreamFreeI(const stm32_bdma_stream_t *stp) {
osalDbgCheck(stp != NULL);
@@ -428,6 +417,23 @@ void bdmaStreamRelease(const stm32_bdma_stream_t *stp) {
}
/**
+ * @brief Releases a BDMA stream.
+ * @details The stream is freed and, if required, the BDMA clock disabled.
+ * Trying to release a unallocated stream is an illegal operation
+ * and is trapped if assertions are enabled.
+ *
+ * @param[in] stp pointer to an @p stm32_bdma_stream_t structure
+ *
+ * @api
+ */
+void bdmaStreamFree(const stm32_bdma_stream_t *stp) {
+
+ osalSysLock();
+ bdmaStreamFreeI(stp);
+ osalSysUnlock();
+}
+
+/**
* @brief Associates a peripheral request to a BDMA stream.
* @note This function can be invoked in both ISR or thread context.
*
diff --git a/os/hal/ports/STM32/LLD/BDMAv1/stm32_bdma.h b/os/hal/ports/STM32/LLD/BDMAv1/stm32_bdma.h
index 337dcfcb9..1cd94a59a 100644
--- a/os/hal/ports/STM32/LLD/BDMAv1/stm32_bdma.h
+++ b/os/hal/ports/STM32/LLD/BDMAv1/stm32_bdma.h
@@ -53,15 +53,15 @@
#define STM32_BDMA_IS_VALID_PRIORITY(prio) (((prio) >= 0U) && ((prio) <= 3U))
/**
- * @brief Checks if a BDMA channel is within the valid range.
+ * @brief Checks if a BDMA stream id is within the valid range.
*
- * @param[in] ch BDMA channel
+ * @param[in] id BDMA stream id
* @retval The check result.
- * @retval FALSE invalid DMA channel.
- * @retval TRUE correct DMA channel.
+ * @retval false invalid DMA stream.
+ * @retval true correct DMA stream.
*/
-#define STM32_BDMA_IS_VALID_CHANNEL(ch) (((ch) >= 0U) && \
- ((ch) <= STM32_BDMA_STREAMS))
+#define STM32_BDMA_IS_VALID_STREAM(id) (((id) >= 0U) && \
+ ((id) <= STM32_BDMA_STREAMS))
/**
* @name Special stream identifiers
@@ -421,11 +421,12 @@ extern "C" {
uint32_t priority,
stm32_bdmaisr_t func,
void *param);
- bool bdmaStreamAllocate(const stm32_bdma_stream_t *stp,
- uint32_t priority,
- stm32_bdmaisr_t func,
- void *param);
- void bdmaStreamRelease(const stm32_bdma_stream_t *stp);
+ const stm32_bdma_stream_t *bdmaStreamAlloc(uint32_t id,
+ uint32_t priority,
+ stm32_bdmaisr_t func,
+ void *param);
+ void bdmaStreamFreeI(const stm32_bdma_stream_t *stp);
+ void bdmaStreamFree(const stm32_bdma_stream_t *stp);
void bdmaSetRequestSource(const stm32_bdma_stream_t *stp, uint32_t per);
#ifdef __cplusplus
}