From 743513a4b1b15901fd6ff35f9b3c8812dc96dcaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Fri, 13 Jan 2017 13:57:42 +0100 Subject: stm32: add dma_get_number_of_data Original discussion at: https://github.com/libopencm3/libopencm3/pull/702 --- include/libopencm3/stm32/common/dma_common_f24.h | 1 + include/libopencm3/stm32/common/dma_common_l1f013.h | 1 + lib/stm32/common/dma_common_f24.c | 14 ++++++++++++++ lib/stm32/common/dma_common_l1f013.c | 14 ++++++++++++++ 4 files changed, 30 insertions(+) diff --git a/include/libopencm3/stm32/common/dma_common_f24.h b/include/libopencm3/stm32/common/dma_common_f24.h index e32114b1..896f0ef5 100644 --- a/include/libopencm3/stm32/common/dma_common_f24.h +++ b/include/libopencm3/stm32/common/dma_common_f24.h @@ -613,6 +613,7 @@ void dma_disable_stream(uint32_t dma, uint8_t stream); void dma_set_peripheral_address(uint32_t dma, uint8_t stream, uint32_t address); void dma_set_memory_address(uint32_t dma, uint8_t stream, uint32_t address); void dma_set_memory_address_1(uint32_t dma, uint8_t stream, uint32_t address); +uint16_t dma_get_number_of_data(uint32_t dma, uint8_t stream); void dma_set_number_of_data(uint32_t dma, uint8_t stream, uint16_t number); END_DECLS diff --git a/include/libopencm3/stm32/common/dma_common_l1f013.h b/include/libopencm3/stm32/common/dma_common_l1f013.h index a00834ab..489c9def 100644 --- a/include/libopencm3/stm32/common/dma_common_l1f013.h +++ b/include/libopencm3/stm32/common/dma_common_l1f013.h @@ -410,6 +410,7 @@ void dma_disable_channel(uint32_t dma, uint8_t channel); void dma_set_peripheral_address(uint32_t dma, uint8_t channel, uint32_t address); void dma_set_memory_address(uint32_t dma, uint8_t channel, uint32_t address); +uint16_t dma_get_number_of_data(uint32_t dma, uint8_t channel); void dma_set_number_of_data(uint32_t dma, uint8_t channel, uint16_t number); END_DECLS diff --git a/lib/stm32/common/dma_common_f24.c b/lib/stm32/common/dma_common_f24.c index 6b655636..d706674f 100644 --- a/lib/stm32/common/dma_common_f24.c +++ b/lib/stm32/common/dma_common_f24.c @@ -774,6 +774,20 @@ void dma_set_memory_address_1(uint32_t dma, uint8_t stream, uint32_t address) } } +/*---------------------------------------------------------------------------*/ +/** @brief DMA Stream Get the Transfer Block Size + +@param[in] dma unsigned int32. DMA controller base address: DMA1 or DMA2 +@param[in] stream unsigned int8. Stream number: @ref dma_st_number +@returns unsigned int16. Number of remaining data words to transfer (65535 +maximum). +*/ + +uint16_t dma_get_number_of_data(uint32_t dma, uint8_t stream) +{ + return DMA_SNDTR(dma, stream); +} + /*---------------------------------------------------------------------------*/ /** @brief DMA Stream Set the Transfer Block Size diff --git a/lib/stm32/common/dma_common_l1f013.c b/lib/stm32/common/dma_common_l1f013.c index 0005c113..47abfa24 100644 --- a/lib/stm32/common/dma_common_l1f013.c +++ b/lib/stm32/common/dma_common_l1f013.c @@ -415,6 +415,20 @@ void dma_set_memory_address(uint32_t dma, uint8_t channel, uint32_t address) } } +/*---------------------------------------------------------------------------*/ +/** @brief DMA Channel Get the Transfer Block Size + +@param[in] dma unsigned int32. DMA controller base address: DMA1 or DMA2 +@param[in] channel unsigned int8. Channel number: 1-7 for DMA1 or 1-5 for DMA2 +@returns unsigned int16. Number of remaining data words to transfer (65535 +maximum). +*/ + +uint16_t dma_get_number_of_data(uint32_t dma, uint8_t channel) +{ + return DMA_CNDTR(dma, channel); +} + /*---------------------------------------------------------------------------*/ /** @brief DMA Channel Set the Transfer Block Size -- cgit v1.2.3