原创 汉化STM32F2.02版固件库之十一(DMA)

2008-8-7 21:31 7510 6 6 分类: MCU/ 嵌入式

/*******************************************************************************
* 函数名称: DMA_DeInit
* 功能描述: 将DMA各通道寄存器复位为默认的复位值.
* 输入参数: DMAy_Channelx:y可以是1或者2,DMA1的x可以是1到7 和DMA2的x可以是1到5来选择各通道
* 输出参数: 无
* 返回参数: 无
*******************************************************************************/
void DMA_DeInit(DMA_Channel_TypeDef* DMAy_Channelx)
{
  /* Check the parameters [检查参数]*/
  assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));


  /* Disable the selected DMAy Channelx [禁止选择的DMAy 通道x]*/
  DMAy_Channelx->CCR &= CCR_ENABLE_Reset;


  /* Reset DMAy Channelx control register [复位DMAy Channelx的控制寄存器]*/
  DMAy_Channelx->CCR  = 0;
 
  /* Reset DMAy Channelx remaining bytes register [复位DMAy Channelx的剩余字节寄存器]*/
  DMAy_Channelx->CNDTR = 0;
 
  /* Reset DMAy Channelx peripheral address register [复位DMAy Channelx外围设备地址寄存器]*/
  DMAy_Channelx->CPAR  = 0;
 
  /* Reset DMAy Channelx memory address register [复位DMAy Channelx内存地址寄存器]*/
  DMAy_Channelx->CMAR = 0;


  switch (*(u32*)&DMAy_Channelx)
  {
    case DMA1_Channel1_BASE:
      /* Reset interrupt pending bits for DMA1 Channel1 [复位DMA1 Channel1中断挂起位]*/
      DMA1->IFCR |= DMA1_Channel1_IT_Mask;
      break;


    case DMA1_Channel2_BASE:
      /* Reset interrupt pending bits for DMA1 Channel2 [复位DMA1 Channel2中断挂起位]*/
      DMA1->IFCR |= DMA1_Channel2_IT_Mask;
      break;


    case DMA1_Channel3_BASE:
      /* Reset interrupt pending bits for DMA1 Channel3 [复位DMA1 Channel3中断挂起位]*/
      DMA1->IFCR |= DMA1_Channel3_IT_Mask;
      break;


    case DMA1_Channel4_BASE:
      /* Reset interrupt pending bits for DMA1 Channel4 [复位DMA1 Channel4中断挂起位]*/
      DMA1->IFCR |= DMA1_Channel4_IT_Mask;
      break;


    case DMA1_Channel5_BASE:
      /* Reset interrupt pending bits for DMA1 Channel5 [复位DMA1 Channel5中断挂起位]*/
      DMA1->IFCR |= DMA1_Channel5_IT_Mask;
      break;


    case DMA1_Channel6_BASE:
      /* Reset interrupt pending bits for DMA1 Channel6 [复位DMA1 Channel6中断挂起位]*/
      DMA1->IFCR |= DMA1_Channel6_IT_Mask;
      break;


    case DMA1_Channel7_BASE:
      /* Reset interrupt pending bits for DMA1 Channel7 [复位DMA1 Channel7中断挂起位]*/
      DMA1->IFCR |= DMA1_Channel7_IT_Mask;
      break;


    case DMA2_Channel1_BASE:
      /* Reset interrupt pending bits for DMA2 Channel1 [复位DMA2 Channel1中断挂起位]*/
      DMA2->IFCR |= DMA2_Channel1_IT_Mask;
      break;


    case DMA2_Channel2_BASE:
      /* Reset interrupt pending bits for DMA2 Channel2 [复位DMA2 Channel2中断挂起位]*/
      DMA2->IFCR |= DMA2_Channel2_IT_Mask;
      break;


    case DMA2_Channel3_BASE:
      /* Reset interrupt pending bits for DMA2 Channel3 [复位DMA2 Channel3中断挂起位]*/
      DMA2->IFCR |= DMA2_Channel3_IT_Mask;
      break;


    case DMA2_Channel4_BASE:
      /* Reset interrupt pending bits for DMA2 Channel4 [复位DMA2 Channel4中断挂起位]*/
      DMA2->IFCR |= DMA2_Channel4_IT_Mask;
      break;


    case DMA2_Channel5_BASE:
      /* Reset interrupt pending bits for DMA2 Channel5 [复位DMA2 Channel5中断挂起位]*/
      DMA2->IFCR |= DMA2_Channel5_IT_Mask;
      break;
     
    default:
      break;
  }
}


完整stm32f10x_dma.c点击下载请您在下载的同时到左上角顶我一下,以示支持!谢谢

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
6
关闭 站长推荐上一条 /3 下一条