STM32F0 Standard Peripheral bibliotheek  1.0
ST Microelectronics standard peripheral bibliotheek documentatie voor de STM32F0 familie
 All Data Structures Files Functions Variables Enumerations Enumerator Groups
stm32f0xx_dma.c File Reference

This file provides firmware functions to manage the following functionalities of the Direct Memory Access controller (DMA): More...

#include "stm32f0xx_dma.h"


#define CCR_CLEAR_MASK   ((uint32_t)0xFFFF800F) /* DMA Channel config registers Masks */


void DMA_DeInit (DMA_Channel_TypeDef *DMAy_Channelx)
 Deinitializes the DMAy Channelx registers to their default reset values. More...
void DMA_Init (DMA_Channel_TypeDef *DMAy_Channelx, DMA_InitTypeDef *DMA_InitStruct)
 Initializes the DMAy Channelx according to the specified parameters in the DMA_InitStruct. More...
void DMA_StructInit (DMA_InitTypeDef *DMA_InitStruct)
 Fills each DMA_InitStruct member with its default value. More...
void DMA_Cmd (DMA_Channel_TypeDef *DMAy_Channelx, FunctionalState NewState)
 Enables or disables the specified DMAy Channelx. More...
void DMA_SetCurrDataCounter (DMA_Channel_TypeDef *DMAy_Channelx, uint16_t DataNumber)
 Sets the number of data units in the current DMAy Channelx transfer. More...
uint16_t DMA_GetCurrDataCounter (DMA_Channel_TypeDef *DMAy_Channelx)
 Returns the number of remaining data units in the current DMAy Channelx transfer. More...
void DMA_ITConfig (DMA_Channel_TypeDef *DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState)
 Enables or disables the specified DMAy Channelx interrupts. More...
FlagStatus DMA_GetFlagStatus (uint32_t DMA_FLAG)
 Checks whether the specified DMAy Channelx flag is set or not. More...
void DMA_ClearFlag (uint32_t DMA_FLAG)
 Clears the DMAy Channelx's pending flags. More...
ITStatus DMA_GetITStatus (uint32_t DMA_IT)
 Checks whether the specified DMAy Channelx interrupt has occurred or not. More...
void DMA_ClearITPendingBit (uint32_t DMA_IT)
 Clears the DMAy Channelx's interrupt pending bits. More...

Detailed Description

This file provides firmware functions to manage the following functionalities of the Direct Memory Access controller (DMA):

MCD Application Team
  • Initialization and Configuration
  • Data Counter
  • Interrupts and flags management
                    ##### How to use this driver #####
  (#) Enable The DMA controller clock using 
      RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE) function for DMA1.
  (#) Enable and configure the peripheral to be connected to the DMA channel
     (except for internal SRAM / FLASH memories: no initialization is necessary).
  (#) For a given Channel, program the Source and Destination addresses, 
      the transfer Direction, the Buffer Size, the Peripheral and Memory 
      Incrementation mode and Data Size, the Circular or Normal mode, 
      the channel transfer Priority and the Memory-to-Memory transfer 
      mode (if needed) using the DMA_Init() function.
  (#) Enable the NVIC and the corresponding interrupt(s) using the function 
      DMA_ITConfig() if you need to use DMA interrupts.
  (#) Enable the DMA channel using the DMA_Cmd() function.
  (#) Activate the needed channel Request using PPP_DMACmd() function for 
      any PPP peripheral except internal SRAM and FLASH (ie. SPI, USART ...) 
      The function allowing this operation is provided in each PPP peripheral 
      driver (ie. SPI_DMACmd for SPI peripheral).
  (#) Optionally, you can configure the number of data to be transferred
      when the channel is disabled (ie. after each Transfer Complete event
      or when a Transfer Error occurs) using the function DMA_SetCurrDataCounter().
      And you can get the number of remaining data to be transferred using 
      the function DMA_GetCurrDataCounter() at run time (when the DMA channel is
      enabled and running).
  (#) To control DMA events you can use one of the following two methods:
      (##) Check on DMA channel flags using the function DMA_GetFlagStatus().
      (##) Use DMA interrupts through the function DMA_ITConfig() at initialization
           phase and DMA_GetITStatus() function into interrupt routines in
           communication phase.
           After checking on a flag you should clear it using DMA_ClearFlag()
           function. And after checking on an interrupt event you should 
           clear it using DMA_ClearITPendingBit() function.

© COPYRIGHT 2012 STMicroelectronics

Licensed under MCD-ST Liberty SW License Agreement V2, (the "License"); You may not use this file except in compliance with the License. You may obtain a copy of the License at:

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.