CARME-M4 BSP  V1.5
Double Buffer mode functions

Double Buffer mode functions. More...

+ Collaboration diagram for Double Buffer mode functions:

Functions

void DMA_DoubleBufferModeConfig (DMA_Stream_TypeDef *DMAy_Streamx, uint32_t Memory1BaseAddr, uint32_t DMA_CurrentMemory)
 Configures, when the DMAy Streamx is disabled, the double buffer mode and the current memory target. More...
 
void DMA_DoubleBufferModeCmd (DMA_Stream_TypeDef *DMAy_Streamx, FunctionalState NewState)
 Enables or disables the double buffer mode for the selected DMA stream. More...
 
void DMA_MemoryTargetConfig (DMA_Stream_TypeDef *DMAy_Streamx, uint32_t MemoryBaseAddr, uint32_t DMA_MemoryTarget)
 Configures the Memory address for the next buffer transfer in double buffer mode (for dynamic use). This function can be called when the DMA Stream is enabled and when the transfer is ongoing. More...
 
uint32_t DMA_GetCurrentMemoryTarget (DMA_Stream_TypeDef *DMAy_Streamx)
 Returns the current memory target used by double buffer transfer. More...
 

Detailed Description

Double Buffer mode functions.

 ===============================================================================
                    ##### Double Buffer mode functions #####
 ===============================================================================  
    [..]
    This subsection provides function allowing to configure and control the double 
    buffer mode parameters.
    
    [..]
    The Double Buffer mode can be used only when Circular mode is enabled.
    The Double Buffer mode cannot be used when transferring data from Memory to Memory.
    
    [..]
    The Double Buffer mode allows to set two different Memory addresses from/to which
    the DMA controller will access alternatively (after completing transfer to/from 
    target memory 0, it will start transfer to/from target memory 1).
    This allows to reduce software overhead for double buffering and reduce the CPU
    access time.
    
    [..]
    Two functions must be called before calling the DMA_Init() function:
      (+) void DMA_DoubleBufferModeConfig(DMA_Stream_TypeDef* DMAy_Streamx, 
          uint32_t Memory1BaseAddr, uint32_t DMA_CurrentMemory);
      (+) void DMA_DoubleBufferModeCmd(DMA_Stream_TypeDef* DMAy_Streamx, FunctionalState NewState);
      
    [..]
    DMA_DoubleBufferModeConfig() is called to configure the Memory 1 base address 
    and the first Memory target from/to which the transfer will start after 
    enabling the DMA Stream. Then DMA_DoubleBufferModeCmd() must be called 
    to enable the Double Buffer mode (or disable it when it should not be used).
  
    [..]
    Two functions can be called dynamically when the transfer is ongoing (or when the DMA Stream is 
    stopped) to modify on of the target Memories addresses or to check wich Memory target is currently
    used:
      (+) void DMA_MemoryTargetConfig(DMA_Stream_TypeDef* DMAy_Streamx, 
                uint32_t MemoryBaseAddr, uint32_t DMA_MemoryTarget);
      (+) uint32_t DMA_GetCurrentMemoryTarget(DMA_Stream_TypeDef* DMAy_Streamx);
      
    [..]
    DMA_MemoryTargetConfig() can be called to modify the base address of one of 
    the two target Memories.
    The Memory of which the base address will be modified must not be currently 
    be used by the DMA Stream (ie. if the DMA Stream is currently transferring 
    from Memory 1 then you can only modify base address of target Memory 0 and vice versa).
    To check this condition, it is recommended to use the function DMA_GetCurrentMemoryTarget() which
    returns the index of the Memory target currently in use by the DMA Stream.

Function Documentation

void DMA_DoubleBufferModeCmd ( DMA_Stream_TypeDef *  DMAy_Streamx,
FunctionalState  NewState 
)

Enables or disables the double buffer mode for the selected DMA stream.

Note
This function can be called only when the DMA Stream is disabled.
Parameters
DMAy_Streamxwhere y can be 1 or 2 to select the DMA and x can be 0 to 7 to select the DMA Stream.
NewStatenew state of the DMAy Streamx double buffer mode. This parameter can be: ENABLE or DISABLE.
Return values
None

Definition at line 761 of file stm32f4xx_dma.c.

void DMA_DoubleBufferModeConfig ( DMA_Stream_TypeDef *  DMAy_Streamx,
uint32_t  Memory1BaseAddr,
uint32_t  DMA_CurrentMemory 
)

Configures, when the DMAy Streamx is disabled, the double buffer mode and the current memory target.

Parameters
DMAy_Streamxwhere y can be 1 or 2 to select the DMA and x can be 0 to 7 to select the DMA Stream.
Memory1BaseAddrthe base address of the second buffer (Memory 1)
DMA_CurrentMemoryspecifies which memory will be first buffer for the transactions when the Stream will be enabled. This parameter can be one of the following values:
  • DMA_Memory_0: Memory 0 is the current buffer.
  • DMA_Memory_1: Memory 1 is the current buffer.
Note
Memory0BaseAddr is set by the DMA structure configuration in DMA_Init().
Return values
None

Definition at line 730 of file stm32f4xx_dma.c.

uint32_t DMA_GetCurrentMemoryTarget ( DMA_Stream_TypeDef *  DMAy_Streamx)

Returns the current memory target used by double buffer transfer.

Parameters
DMAy_Streamxwhere y can be 1 or 2 to select the DMA and x can be 0 to 7 to select the DMA Stream.
Return values
Thememory target number: 0 for Memory0 or 1 for Memory1.

Definition at line 828 of file stm32f4xx_dma.c.

void DMA_MemoryTargetConfig ( DMA_Stream_TypeDef *  DMAy_Streamx,
uint32_t  MemoryBaseAddr,
uint32_t  DMA_MemoryTarget 
)

Configures the Memory address for the next buffer transfer in double buffer mode (for dynamic use). This function can be called when the DMA Stream is enabled and when the transfer is ongoing.

Parameters
DMAy_Streamxwhere y can be 1 or 2 to select the DMA and x can be 0 to 7 to select the DMA Stream.
MemoryBaseAddrThe base address of the target memory buffer
DMA_MemoryTargetNext memory target to be used. This parameter can be one of the following values:
  • DMA_Memory_0: To use the memory address 0
  • DMA_Memory_1: To use the memory address 1
Note
It is not allowed to modify the Base Address of a target Memory when this target is involved in the current transfer. ie. If the DMA Stream is currently transferring to/from Memory 1, then it not possible to modify Base address of Memory 1, but it is possible to modify Base address of Memory 0. To know which Memory is currently used, you can use the function DMA_GetCurrentMemoryTarget().
Return values
None

Definition at line 802 of file stm32f4xx_dma.c.