Add macro to read DMA Current Target (CR:CT) on STM32 Topic is solved

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
User avatar
FXCoder
Posts: 384
Joined: Sun Jun 12, 2016 4:10 am
Location: Sydney, Australia
Has thanked: 180 times
Been thanked: 130 times

Add macro to read DMA Current Target (CR:CT) on STM32  Topic is solved

Postby FXCoder » Thu Jul 27, 2017 10:15 am

When using DMA double buffer mode, changing MxAR is allowed for the non-active MxAR.
The non-active MxAR is determined by reading the CT bit of the CR.
A macro to read the CT bit could be added in os\hal\ports\STM32\LLD\DMAv2\stm32_dma.h and become part of the standard Chibios DMA macro set.
Suggested implementation...

Code: Select all

/**
 * @brief   DMA stream current target.
 * @note    This function can be invoked in both ISR or thread context.
 * @pre     The stream must have been allocated using @p dmaStreamAllocate().
 * @post    After use the stream can be released using @p dmaStreamRelease().
 *
 * @param[in] dmastp    pointer to a stm32_dma_stream_t structure
 * @return  Current memory target index
 *
 * @special
 */
#define dmaStreamGetCurrentTarget(dmastp)                                              \
    ((uint8_t)(((dmastp)->stream->CR >> DMA_SxCR_CT_Pos) & 1U))

User avatar
Giovanni
Site Admin
Posts: 14457
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Add macro to read DMA Current Target (CR:CT) on STM32

Postby Giovanni » Sun Sep 24, 2017 4:27 pm

Hi,

Added to trunk but I removed the cast to uint8_t, those can make code slower on ARM.

Giovanni


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 36 guests