/**
  ******************************************************************************
  * @file    lcm32f06x_dma.c
  * @author  System R&D Team
  * @version V2.0.2
  * @date    10-April-2025
  * @brief   This file provides all the DMA firmware functions.
  ******************************************************************************
  * @attention
  *
  * Copyright (c) Hangzhou Lingxin Microelectronics Co.
  * All rights reserved.
  *
  * This software is licensed under terms that can be found in the LICENSE file
  * in the root directory of this software component.
  * If no LICENSE file comes with this software, it is provided AS-IS.
  *
  ******************************************************************************
  */
/* Includes ------------------------------------------------------------------*/
#include "lcm32f06x_dma.h"

/**
  * @name   DMA_DeInit
  * @brief  EN: Deinitializes the DMAy_Channelx channel to their default reset values.
  *         CN: 将 DMAy_Channelx 通道初始化为其默认重置值。
  * @param  DMAy_Channelx: 
  *         EN: where y is 1 to select DMA, where x can be 0 or 1 to select DMAy channel.
  *         CN: 其中 y 是 1 以选择 DMA，其中 x 可以是 0 或 1 以选择 DMAy 通道。
  * @retval None
  */
void DMA_DeInit(DMA_Channel_TypeDef *DMAy_Channelx)
{
  /* Check the parameters */
  uint32_t tmpreg;
  uint32_t ch;

  assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));

  if (DMAy_Channelx == DMA1_Channel0)
    ch = 0;
  else if (DMAy_Channelx == DMA1_Channel1)
    ch = 1;
  //  else if(DMAy_Channelx==DMA1_Channel5)ch=5;
  //  else if(DMAy_Channelx==DMA1_Channel6)ch=6;//invaild
  else
    ch = 2;                // invaild
  DMA1->DmaCfgReg |= 0x01; //开启DMA模块
  tmpreg = DMA1->ChEnReg;
  tmpreg |= 1 << (ch + 8);
  tmpreg &= ~(1 << ch);
  DMA1->ChEnReg = tmpreg; //关闭对应通道
  DMAy_Channelx->SAR = 0x00;
  DMAy_Channelx->DAR = 0x00;
  DMAy_Channelx->CTL_L = 0x00; //将1个burst对应1个signal（默认是1个burst对应4个signal），方便对应到st。
  DMAy_Channelx->CTL_H = 0x00; /*已核对*/
  DMAy_Channelx->CFG_L = 0x00; /*使用硬件握手信号*/
  DMAy_Channelx->CFG_H = 0x04; /*PROTCTL=1*/

  DMA1->RawTfr &= ~(1 << ch);
  DMA1->RawBlock &= ~(1 << ch);
  DMA1->RawSrcTran &= ~(1 << ch);
  DMA1->RawDstTran &= ~(1 << ch);
  DMA1->RawErr &= ~(1 << ch);

  DMA1->StatusTfr &= ~(1 << ch);
  DMA1->StatusBlock &= ~(1 << ch);
  DMA1->StatusSrcTran &= ~(1 << ch);
  DMA1->StatusDstTran &= ~(1 << ch);
  DMA1->StatusErr &= ~(1 << ch);

  DMA1->ClearTfr = 1 << ch;
  DMA1->ClearBlock = 1 << ch;
  DMA1->ClearSrcTran = 1 << ch;
  DMA1->ClearDstTran = 1 << ch;
  DMA1->ClearErr = 1 << ch;
}

/**
  * @name   DMA_Init
  * @brief  EN: Initializes the DMA channel according to the specified.
  *             parameters in the DMA_InitStruct.
  *         CN: 根据 DMA_InitStruct 中指定的参数初始化 DMA 通道。
  * @param  DMAy_Channelx: 
  *         EN: where y is 1 to select DMA, where x can be 0 or 1 to select DMAy channel
  *         CN: 其中 y 是 1 以选择 DMA，其中 x 可以是 0 或 1 以选择 DMAy 通道。
  * @param  DMA_InitStruct:
  *         EN: pointer to a DMA_InitStruct structure that contains the 
  *             configuration information for the specified DMA peripheral.
  *         CN: 指向 DMA_InitStruct 结构的指针，该结构包含指定 DMA 外设的配置信息。
  * @retval None
  */
void DMA_Init(DMA_Channel_TypeDef *DMAy_Channelx, DMA_InitTypeDef *DMA_InitStruct)
{
  /* Check the parameters */
  assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
  assert_param(IS_DMA_DIR(DMA_InitStruct->DMA_DIR));
  assert_param(IS_DMA_PERIPHERAL_INC_STATE(DMA_InitStruct->DMA_PeripheralInc));
  assert_param(IS_DMA_MEMORY_INC_STATE(DMA_InitStruct->DMA_MemoryInc));
  assert_param(IS_DMA_PERIPHERAL_DATA_SIZE(DMA_InitStruct->DMA_PeripheralDataSize));
  assert_param(IS_DMA_MEMORY_DATA_SIZE(DMA_InitStruct->DMA_MemoryDataSize));
  assert_param(IS_DMA_MODE(DMA_InitStruct->DMA_Mode));
  assert_param(IS_DMA_PRIORITY(DMA_InitStruct->DMA_Priority));
  assert_param(IS_DMA_M2M_STATE(DMA_InitStruct->DMA_M2M));
  assert_param(IS_DMA_MSIZE(DMA_InitStruct->DMA_MSIZE));

  if (DMA_InitStruct->DMA_DIR == DMA_DIR_PeripheralSRC)
  {
    DMAy_Channelx->SAR = DMA_InitStruct->DMA_PeripheralBaseAddr;
    DMAy_Channelx->DAR = DMA_InitStruct->DMA_MemoryBaseAddr;
    DMAy_Channelx->CTL_L_b.SRC_TR_WIDTH = DMA_InitStruct->DMA_PeripheralDataSize;
    DMAy_Channelx->CTL_L_b.DST_TR_WIDTH = DMA_InitStruct->DMA_MemoryDataSize;
    DMAy_Channelx->CTL_L_b.SINC = DMA_InitStruct->DMA_PeripheralInc;
    DMAy_Channelx->CTL_L_b.DINC = DMA_InitStruct->DMA_MemoryInc;
  }
  else
  {
    DMAy_Channelx->DAR = DMA_InitStruct->DMA_PeripheralBaseAddr;
    DMAy_Channelx->SAR = DMA_InitStruct->DMA_MemoryBaseAddr;
    DMAy_Channelx->CTL_L_b.DST_TR_WIDTH = DMA_InitStruct->DMA_PeripheralDataSize;
    DMAy_Channelx->CTL_L_b.SRC_TR_WIDTH = DMA_InitStruct->DMA_MemoryDataSize;
    DMAy_Channelx->CTL_L_b.SINC = DMA_InitStruct->DMA_MemoryInc;
    DMAy_Channelx->CTL_L_b.DINC = DMA_InitStruct->DMA_PeripheralInc;
  }
  DMAy_Channelx->CTL_H_b.BLOCK_TS = DMA_InitStruct->DMA_BufferSize; /*the max vaild value is 4095 @zhang*/
  DMAy_Channelx->CTL_L_b.TT_FC = DMA_InitStruct->DMA_M2M;
  DMAy_Channelx->CTL_L_b.SRC_MSIZE = DMA_InitStruct->DMA_MSIZE;
  DMAy_Channelx->CTL_L_b.DEST_MSIZE = DMA_InitStruct->DMA_MSIZE;
}

/**
  * @name   DMA_StructInit
  * @brief  EN: Fills each DMA_InitStruct member with its default value.
  *         CN: 用默认值填充每个 DMA_InitStruct 成员。
  * @param  DMA_InitStruct:
  *         EN: pointer to a DMA_InitStruct structure that contains the 
  *             configuration information for the specified DMA peripheral.
  *         CN: 指向 DMA_InitStruct 结构的指针，该结构包含指定 DMA 外设的配置信息。
  * @retval None
  */
void DMA_StructInit(DMA_InitTypeDef *DMA_InitStruct)
{
  /*-------------- Reset DMA init structure parameters values ------------------*/
  /* Initialize the DMA_PeripheralBaseAddr member */
  DMA_InitStruct->DMA_PeripheralBaseAddr = 0;
  /* Initialize the DMA_MemoryBaseAddr member */
  DMA_InitStruct->DMA_MemoryBaseAddr = 0;
  /* Initialize the DMA_DIR member */
  DMA_InitStruct->DMA_DIR = DMA_DIR_PeripheralSRC;
  /* Initialize the DMA_BufferSize member */
  DMA_InitStruct->DMA_BufferSize = 0; /*这里指的是传输多少个signal transfer*/
  /* Initialize the DMA_PeripheralInc member */
  DMA_InitStruct->DMA_PeripheralInc = DMA_PeripheralInc_Disable;
  /* Initialize the DMA_MemoryInc member */
  DMA_InitStruct->DMA_MemoryInc = DMA_MemoryInc_Enable;
  /* Initialize the DMA_PeripheralDataSize member */
  DMA_InitStruct->DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte;
  /* Initialize the DMA_MemoryDataSize member */
  DMA_InitStruct->DMA_MemoryDataSize = DMA_MemoryDataSize_Byte;
  /* Initialize the DMA_M2M member */
  DMA_InitStruct->DMA_M2M = DMA_M2M_Enable;
     /* Initialize the DMA_MSIZE member */
  DMA_InitStruct->DMA_MSIZE = DMA_MSIZE_1;
}

/**
  * @name   DMA_Cmd
  * @brief  EN: Enables or disables the specified DMAy_Channelx.
  *         CN: 启用或禁止指定的 DMAy_Channelx。
  * @param  DMAy_Channelx: 
  *         EN: where y is 1 to select DMA, where x can be 0 or 1 to select DMAy channel.
  *         CN: 其中 y 是 1 以选择 DMA，其中 x 可以是 0 或 1 以选择 DMAy 通道。
  * @param  NewState: 
  *         EN: New state of the DMAy_Channelx.
  *         CN: DMAy_Channelx 的新状态。
  *             @arg ENABLE
  *             @arg DISABLE
  * @retval None
  */
void DMA_Cmd(DMA_Channel_TypeDef *DMAy_Channelx, FunctionalState NewState)
{
  /* Check the parameters */
  uint32_t ch;
  uint32_t tmpreg;
  assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
  assert_param(IS_FUNCTIONAL_STATE(NewState));

  if (DMAy_Channelx == DMA1_Channel0)
    ch = 0;
  else if (DMAy_Channelx == DMA1_Channel1)
    ch = 1;
  else
    ch = 2; // invaild
  tmpreg = DMA1->ChEnReg;
  if (NewState != DISABLE)
  {
    /* Enable the selected DMAy Channelx */
    tmpreg |= 0x101 << ch;
//    DMA1->ChEnReg |= 0x100 << ch;
//    DMA1->ChEnReg |= 0x001 << ch;
  }
  else
  {
    /* Disable the selected DMAy Channelx */
    tmpreg |= 0x100 << ch;
    tmpreg &= ~(1 << ch);
  }
  DMA1->ChEnReg = tmpreg;
  
}

/**
  * @name   DMA_SetCurrDataCounter
  * @brief  EN: Set the current block transfer size.
  *         CN: 设置当前的块传输大小。
  * @param  DMAy_Channelx: 
  *         EN: where y is 1 to select DMA, where x can be 0 or 1 to select DMAy channel.
  *         CN: 其中 y 是 1 以选择 DMA，其中 x 可以是 0 或 1 以选择 DMAy 通道。
  * @param  DataNumber: 
  *         EN: Block transfer size.
  *         CN: 块传输大小。
  * @retval None
  * @note   EN: This function can only be used when the DMAy_Channelx is disabled.
  *         CN: 这个函数只能在 DMAy_Channelx 禁用时使用。
  */
void DMA_SetCurrDataCounter(DMA_Channel_TypeDef *DMAy_Channelx, uint16_t DataNumber)
{
  /* Check the parameters */
  assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));

  /*Block Transfer Size */
  DMAy_Channelx->CTL_H = (0xFFF & DataNumber);
}

/**
  * @name   DMA_GetCurrDataCounter
  * @brief  EN: get the current block transfer size.
  *         CN: 获取当前的块传输大小。
  * @param  DMAy_Channelx: 
  *         EN: where y is 1 to select DMA, where x can be 0 or 1 to select DMAy channel.
  *         CN: 其中 y 是 1 以选择 DMA，其中 x 可以是 0 或 1 以选择 DMAy 通道。
  * @retval EN: The number of data read by the source peripheral
  *         CN: 源外设读取的数据数。
  * @note   EN: The return value after the start of transmission is the total 
  *             number of data read from the source peripheral.
  *         CN: 传输开始后的返回值为从源外设读取的数据总数。
  */
uint16_t DMA_GetCurrDataCounter(DMA_Channel_TypeDef *DMAy_Channelx)
{
  /* Check the parameters */
  assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
  /* Return the number of remaining data units for DMAy Channelx */

  return (uint16_t)((DMAy_Channelx->CTL_H) & 0xFFF);
}

/**
  * @name   DMA_ITConfig
  * @brief  EN: Enables or disables the specified DMAy Channelx interrupts.
  *         CN: 启用或禁止指定的 DMAy 通道 x 中断。
  * @param  DMAy_Channelx: 
  *         EN: where y is 1 to select DMA, where x can be 0 or 1 to select DMAy channel.
  *         CN: 其中 y 是 1 以选择 DMA，其中 x 可以是 0 或 1 以选择 DMAy 通道。
  * @param  DMA_IT: 
  *         EN: Clear or set the corresponding DMAy channel x interrupt.
  *         CN: 清除或设置对应 DMAy 通道 x 中断。
  *             @arg DMA1_IT_TC0
  *             @arg DMA1_IT_TE0
  *             @arg DMA1_IT_TC1
  *             @arg DMA1_IT_TE1
  * @param  NewState: 
  *         EN: The new state of DMA_IT (SET or RESET).
  *         CN: DMA_IT的新状态（SET或RESET）。
  * @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)
  {
    DMAy_Channelx->CTL_L_b.INT_EN = 1;
    /* Enable the selected DMA interrupts */
    if ((DMA_IT & 0xF0) == 0x00)
    {
      DMA1->MaskBlock = (0x101 << (DMA_IT & 0x0F));
    }
    if ((DMA_IT & 0xF0) == 0x10)
    {
      DMA1->MaskErr = 0x101 << (DMA_IT & 0x0F);
    }
  }
  else
  {
    DMAy_Channelx->CTL_L_b.INT_EN = 0;
    /* Disable the selected DMA interrupts */
    if ((DMA_IT & 0xF0) == 0x00)
    {
      DMA1->MaskBlock = (0x100 << (DMA_IT & 0x0F));
    }
    if ((DMA_IT & 0xF0) == 0x10)
    {
      DMA1->MaskErr = 0x100 << (DMA_IT & 0x0F);
    }
  }
}

/**
  * @name   DMA_GetFlagStatus
  * @brief  EN: Get the specified DMAy channel x interrupt status.
  *         CN: 获取指定的 DMAy 通道 x 中断状态。
  * @param  DMAy_FLAG: 
  *         EN: specifies the flag to get.
  *         CN: 指定要获取的标志。
  *             @arg DMA1_FLAG_TC0
  *             @arg DMA1_FLAG_TE0
  *             @arg DMA1_FLAG_TC1
  *             @arg DMA1_FLAG_TE1
  * @retval FlagStatus
  *         EN: The new state of DMA_FLAG (SET or RESET).
  *         CN: DMA_FLAG的新状态（SET或RESET）。
  */
FlagStatus DMA_GetFlagStatus(uint32_t DMAy_FLAG)
{
  /* Check the parameters */
  uint32_t tmp;
  assert_param(IS_DMA_GET_FLAG(DMAy_FLAG));
  if ((DMAy_FLAG & 0xF0) == 0x00)
  {
    tmp = (DMA1->RawBlock >> (((uint8_t)DMAy_FLAG) & 0x0F)) & 0x01;
  }
  if ((DMAy_FLAG & 0xF0) == 0x10)
  {
    tmp = (DMA1->RawErr >> (DMAy_FLAG & 0x0F)) & 0x01;
  }
  if (tmp)
    return SET;
  return RESET;
}

/**
  * @name   DMA_ClearFlag
  * @brief  EN: Clears the DMAy Channelx's pending flags.
  *         CN: 清除DMAy Channelx的挂起标志。
  * @param  DMAy_IT: 
  *         EN: specifies the flag to clear.
  *         CN: 指定要清除的标志。
  * @retval None
  */
void DMA_ClearFlag(uint32_t DMAy_FLAG)
{
  /* Check the parameters */
  assert_param(IS_DMA_CLEAR_FLAG(DMAy_FLAG));
  if ((DMAy_FLAG & 0xF0) == 0x00)
  {
    DMA1->ClearBlock |= 1 << (DMAy_FLAG & 0x0F);
  }
  if ((DMAy_FLAG & 0xF0) == 0x10)
  {
    DMA1->ClearErr |= 1 << (DMAy_FLAG & 0x0F);
  }
}

/**
  * @name   DMA_GetITStatus
  * @brief  EN: Checks whether the specified DMAy Channelx interrupt has occurred or not.
  *         CN: 检查指定的DMAy Channelx中断是否已发生。
  * @param  DMAy_IT: 
  *         EN: specifies the DMA interrupt pending bit to clear.
  *         CN: 指定要清除的DMA中断挂起位。
  * @retval ITStatus
  *         EN: The new state of DMA_IT (SET or RESET).
  *         CN: DMA_IT的新状态（SET或RESET）。
  */
ITStatus DMA_GetITStatus(uint32_t DMAy_IT)
{
  /* Check the parameters */
  uint32_t tmp;
  assert_param(IS_DMA_GET_FLAG(DMAy_IT));
  if ((DMAy_IT & 0xF0) == 0x00)
  {
    tmp = (DMA1->StatusBlock >> (DMAy_IT & 0x0F)) & 0x01;
  }
  if ((DMAy_IT & 0xF0) == 0x10)
  {
    tmp = (DMA1->StatusErr >> (DMAy_IT & 0x0F)) & 0x01;
  }
  if (tmp)
    return SET;
  return RESET;
}

/**
  * @name   DMA_ClearITPendingBit
  * @brief  EN: Clears the DMAy Channelx's interrupt pending bits.
  *         CN: 清除DMAy Channelx的中断挂起位。
  * @param  DMAy_IT: 
  *         EN: specifies the DMA interrupt pending bit to clear.
  *         CN: 指定要清除的DMA中断挂起位。
  * @note   Clearing the Global interrupt (DMAy_IT_GLx) results in clearing all other
  *         interrupts relative to the same channel (Transfer Complete, Half-transfer
  *         Complete and Transfer Error interrupts: DMAy_IT_TCx, DMAy_IT_HTx and
  *         DMAy_IT_TEx).
  * @retval None
  */
void DMA_ClearITPendingBit(uint32_t DMAy_IT)
{
  /* Check the parameters */
  assert_param(IS_DMA_CLEAR_FLAG(DMAy_IT));
  if ((DMAy_IT & 0xF0) == 0x00)
  {
    DMA1->ClearBlock = 1 << (DMAy_IT & 0x0F);
  }
  if ((DMAy_IT & 0xF0) == 0x10)
  {
    DMA1->ClearErr = 1 << (DMAy_IT & 0x0F);
  }
}

/**
  * @name   DMA_RemapConfig
  * @brief  EN: Map DMA request number to peripheral device.
  *         CN: DMA请求号映射到外设。
  * @param  DMAy_Channelx: 
  *         EN: where y is 1 to select DMA, where x can be 0 or 1 to select DMAy channel.
  *         CN: 其中 y 是 1 以选择 DMA，其中 x 可以是 0 或 1 以选择 DMAy 通道。
  * @param  DMA_ReqNum: 
  *         EN: Specify the request number to which DMA should be mapped.
  *         CN: 指定DMA要映射到的请求号。
  *             @arg DMA_ReqNum0
  *             @arg DMA_ReqNum1
  *             @arg DMA_ReqNum2
  *             @arg DMA_ReqNum3
  *             @arg DMA_ReqNum4
  *             @arg DMA_ReqNum5
  *             @arg DMA_ReqNum6
  *             @arg DMA_ReqNum7
  * @param  DMA_Request: 
  *         EN: Specify which peripheral to connect the mapping to.
  *         CN: 指定改映射连接到哪个外设。
  *             @arg DMA_REQ_TIM1_0
  *             @arg ...
  *             @arg DMA_REQ_SSP0_RX
  * @retval None
  */
void DMA_RemapConfig(DMA_Channel_TypeDef *DMAy_Channelx, uint32_t DMA_ReqNum, uint32_t DMA_Request)
{
  uint32_t tmpreg;
  assert_param(IS_REQ_NUM(DMA_ReqNum));
  assert_param(IS_DMA_REQ(DMA_Request));
  DMAy_Channelx->CFG_H_b.DEST_PER = DMA_ReqNum;
  DMAy_Channelx->CFG_H_b.SRC_PER = DMA_ReqNum;
  tmpreg = SYSCTRL->EDU_CFG0 & ~(0xF << (DMA_ReqNum * 4));
  tmpreg |= DMA_Request << (DMA_ReqNum * 4);
  sysctrl_access();
  SYSCTRL->EDU_CFG0 = tmpreg;
  __dekey();
}


/**
  * @name   DMA_ReEnable_Config
  * @brief  EN: DMA restart. After each DMA completion, the interface needs to be called in DMA non loop mode.
  *         CN: DMA 重新启动。每次DMA完成之后需要调用接口，DMA非循环模式。
  * @param  DMAy_Channelx: 
  *         EN: where y is 1 to select DMA, where x can be 0 or 1 to select DMAy channel.
  *         CN: 其中 y 是 1 以选择 DMA，其中 x 可以是 0 或 1 以选择 DMAy 通道。
  * @param  SAdress: 
  *         EN: DMA source address.
  *         CN: DMA 源地址。
  * @param  DAdress: 
  *         EN: DMA target address.
  *         CN: DMA 目标地址。
  * @param  NewState: 
  *         EN: Enable/Disable.
  *         CN: 使能或禁止。
  * @retval None
  */
void DMA_ReEnable_Config(DMA_Channel_TypeDef *DMAy_Channelx, uint32_t SAdress, uint32_t DAdress,FunctionalState NewState)
{
  uint32_t ch;
  uint32_t tmpreg;
  assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));
  assert_param(IS_FUNCTIONAL_STATE(NewState));
  
  DMAy_Channelx->DAR = SAdress;
  DMAy_Channelx->SAR = DAdress;
  if (DMAy_Channelx == DMA1_Channel0)
    ch = 0;
  else if (DMAy_Channelx == DMA1_Channel1)
    ch = 1;
  else
    ch = 2; // invaild
  tmpreg = DMA1->ChEnReg;
  if (NewState != DISABLE)
  {
    /* Enable the selected DMAy Channelx */
    tmpreg |= 0x101 << ch;
  }
  else
  {
    /* Disable the selected DMAy Channelx */
    tmpreg |= 0x100 << ch;
    tmpreg &= ~(1 << ch);
  }
  DMA1->ChEnReg = tmpreg;
}

/**
  * @name   DMA_One_Config
  * @brief  EN: DMA single transfer mode.
  *         CN: DMA单次传输模式。
  * @param  DMAy_Channelx: 
  *         EN: where y is 1 to select DMA, where x can be 0 or 1 to select DMAy channel.
  *         CN: 其中 y 是 1 以选择 DMA，其中 x 可以是 0 或 1 以选择 DMAy 通道。
  * @param  SAdress: 
  *         EN: DMA source address.
  *         CN: DMA 源地址。
  * @param  DAdress: 
  *         EN: DMA target address.
  *         CN: DMA 目标地址。
  * @param  Block_size: 
  *         EN: DMA block transfer size.
  *         CN: DMA 块传输大小。
  * @retval None
  */
void DMA_One_Config(DMA_Channel_TypeDef *DMAy_Channelx, uint32_t SAdress, uint32_t DAdress,uint32_t Block_size)
{
    assert_param(IS_DMA_ALL_PERIPH(DMAy_Channelx));

    
    DMAy_Channelx->SAR = SAdress;
    DMAy_Channelx->DAR = DAdress;

    DMAy_Channelx->CTL_H_b.BLOCK_TS = Block_size;
}
