/** * @brief Enables or disables the specified DMAy Channelx interrupts. * @param DMAy_Channelx: where y can be 1 or 2 to select the DMA and * x can be 1 to 7 for DMA1 and 1 to 5 for DMA2 to select the DMA Channel. * @param DMA_IT: specifies the DMA interrupts sources to be enabled * or disabled. * This parameter can be any combination of the following values: * @arg DMA_IT_TC: Transfer complete interrupt mask * @arg DMA_IT_HT: Half transfer interrupt mask * @arg DMA_IT_TE: Transfer error interrupt mask * @param NewState: new state of the specified DMA interrupts. * This parameter can be: ENABLE or DISABLE. * @retval None */ void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState) { /* Check the parameters */ assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx)); assert_param(IS_DMA_CONFIG_IT(DMA_IT)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if(NewState != DISABLE) { /* Enable the selected DMA interrupts */ DMAy_Channelx->CCR |= DMA_IT; } else { /* Disable the selected DMA interrupts */ DMAy_Channelx->CCR &= ~DMA_IT; } }
/** * @簡述 使能或失能指定的 DMA y 通道 x 中斷. * @參數 DMAy_Channelx: y 可以是1 或者2 ,DMA1 的x 可以是1 到7 和DMA2 的x 可以是1 到5 來選擇各通道. * @參數 DMA_IT: 指定 DMA 的中斷. * 這個參數可以是下面值的任意組合: * DMA_IT_TC: 傳輸完成中斷屏蔽 * DMA_IT_HT: 傳輸過半中斷屏蔽 * DMA_IT_TE: 傳輸錯誤中斷屏蔽 * @參數 NewState: 指定的 DMA 中斷的新狀態. * 這個參數可以是: ENABLE 或 DISABLE. * @返回 沒有 */ void DMA_ITConfig(DMA_Channel_TypeDef* DMAy_Channelx, uint32_t DMA_IT, FunctionalState NewState) { /* 檢查參數 */ assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx)); assert_param(IS_DMA_CONFIG_IT(DMA_IT)); assert_param(IS_FUNCTIONAL_STATE(NewState)); if (NewState != DISABLE) { /* 使能指定的 DMA 中斷 */ DMAy_Channelx->CCR |= DMA_IT; } else { /* 失能指定的 DMA 中斷 */ DMAy_Channelx->CCR &= ~DMA_IT; } }
/** * @brief Enables or disables the specified DMAy Streamx interrupts. * @param DMAy_Streamx: where y can be 1 or 2 to select the DMA and x can be 0 * to 7 to select the DMA Stream. * @param DMA_IT: specifies the DMA interrupt sources to be enabled or disabled. * This parameter can be any combination of the following values: * @arg DMA_IT_TC: Transfer complete interrupt mask * @arg DMA_IT_HT: Half transfer complete interrupt mask * @arg DMA_IT_TE: Transfer error interrupt mask * @arg DMA_IT_FE: FIFO error interrupt mask * @param NewState: new state of the specified DMA interrupts. * This parameter can be: ENABLE or DISABLE. * @retval None */ void DMA_ITConfig(DMA_Stream_TypeDef* DMAy_Streamx, uint32_t DMA_IT, FunctionalState NewState) { /* Check the parameters */ assert_param(IS_DMA_ALL_PERIPH(DMAy_Streamx)); assert_param(IS_DMA_CONFIG_IT(DMA_IT)); assert_param(IS_FUNCTIONAL_STATE(NewState)); /* Check if the DMA_IT parameter contains a FIFO interrupt */ if ((DMA_IT & DMA_IT_FE) != 0) { if (NewState != DISABLE) { /* Enable the selected DMA FIFO interrupts */ DMAy_Streamx->FCR |= (uint32_t)DMA_IT_FE; } else { /* Disable the selected DMA FIFO interrupts */ DMAy_Streamx->FCR &= ~(uint32_t)DMA_IT_FE; } } /* Check if the DMA_IT parameter contains a Transfer interrupt */ if (DMA_IT != DMA_IT_FE) { if (NewState != DISABLE) { /* Enable the selected DMA transfer interrupts */ DMAy_Streamx->CR |= (uint32_t)(DMA_IT & TRANSFER_IT_ENABLE_MASK); } else { /* Disable the selected DMA transfer interrupts */ DMAy_Streamx->CR &= ~(uint32_t)(DMA_IT & TRANSFER_IT_ENABLE_MASK); } } }