/*******************************************************************************
* 函数名称: 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;
}
}
文章评论(0条评论)
登录后参与讨论