⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 91x_dma.c

📁 a set or ARM9 examples by STM
💻 C
📖 第 1 页 / 共 3 页
字号:
FlagStatus DMA_GetLSReq(u16 SRCReq)

{ /* Check for a specific source if it request a Last Single transfer . */
 if ( (DMA->SLSRR & SRCReq)!= RESET  )
 {
   return SET;
 }

 else
 {
  return RESET;
 }
}

/********************************************************************************
* Function Name  : DMA_GetBReq
* Description    : Check for a specific source if it request a Burst transfer .
* Input          :
*                 -SRCReq:specifies the DMA Request Source.
*                  This parameter can be:
*                     -DMA_USB_RX_Mask	           
*                     -DMA_USB_TX_Mask	           
*                     -DMA_TIM0_Mask	               
*                     -DMA_TIM1_Mask	              
*                     -DMA_UART0_RX_Mask             
*                     -DMA_UART0_TX_Mask             
*                     -DMA_UART1_RX_Mask           
*                     -DMA_UART1_TX_Mask            
*                     -DMA_External_Req0_Mask        
*                     -DMA_External_Req1_Mask	    
*                     -DMA_I2C0_Mask	                
*                     -DMA_I2C1_Mask	               
*                     -DMA_SSP0_RX_Mask	            
*                     -DMA_SSP0_TX_Mask	            
*                     -DMA_SSP1_RX_Mask	            
*                     -DMA_SSP1_TX_Mask	            
* Output         : None.
* Return         : SET or RESET.
*******************************************************************************/


FlagStatus DMA_GetBReq(u16 SRCReq)

{ /* Check for a specific source if it request a Burst transfer . */
 if (( DMA->SBRR & SRCReq ) != RESET )
 {
   return SET;
 }

 else
 {
  return RESET;
 }
}

/********************************************************************************
* Function Name  : DMA_GetLSReq
* Description    : Check for a specific source if it request a Last Burst transfer .
* Input          :
* Input          :
*                 - SRCReq:specifies the DMA Request Source.
*                  This parameter can be:
*                     -DMA_USB_RX_Mask	           
*                     -DMA_USB_TX_Mask	           
*                     -DMA_TIM0_Mask	               
*                     -DMA_TIM1_Mask	              
*                     -DMA_UART0_RX_Mask             
*                     -DMA_UART0_TX_Mask             
*                     -DMA_UART1_RX_Mask           
*                     -DMA_UART1_TX_Mask            
*                     -DMA_External_Req0_Mask        
*                     -DMA_External_Req1_Mask	    
*                     -DMA_I2C0_Mask	                
*                     -DMA_I2C1_Mask	               
*                     -DMA_SSP0_RX_Mask	            
*                     -DMA_SSP0_TX_Mask	            
*                     -DMA_SSP1_RX_Mask	            
*                     -DMA_SSP1_TX_Mask	            
* Output         : None.
* Return         : SET or RESET.
*******************************************************************************/


FlagStatus DMA_GetLBReq(u16 SRCReq)

{ /* Check for a specific source if it request a Last Burst transfer . */
 if ( ( DMA->SLBRR & SRCReq ) != RESET )
 {
   return SET;
 }

 else
 {
  return RESET;
 }
}



/*******************************************************************************
* Function Name  : DMA_ChannelHalt
* Description    : Enables DMA requests or ignore extra source DMA requests for
                   the specified channel.
* Input          :
                  -DMA_Channelx: where x can be 0,1,2,3,4,5,6,or 7 to select the DMA Channel.
                  -NewState: new state of the specified DMA_Channelx mask interrupt.
                             This parameter can be: ENABLE or DISABLE.
* Output         : None.
* Return         : None.
*******************************************************************************/


void DMA_ChannelHalt(DMA_Channel_TypeDef * DMA_Channelx, FunctionalState NewState)

{
  if (NewState==ENABLE) /* Enables DMA requests */

  {
    DMA_Channelx->CCNF |= DMA_HaltChannel ;
  }

  else /* Ignore extra source DMA request */
  {
    DMA_Channelx->CCNF &= ~ DMA_HaltChannel ;
  }
}


/*******************************************************************************
* Function Name  : DMA_ChannelLockTrsf
* Description    : Enables or disables the Locked Transfers Feature for the specified DMA_Channelx
* Input          :
*                  -DMA_Channelx: where x can be 0,1,2,3,4,5,6,or 7 to select the DMA Channel.
*                  -NewState: new state of the specified DMA_Channelx mask interrupt.
*                             This parameter can be: ENABLE or DISABLE.
* Output         : None.
* Return         : None.
*******************************************************************************/


void DMA_ChannelLockTrsf(DMA_Channel_TypeDef * DMA_Channelx, FunctionalState NewState)

{
  if (NewState==ENABLE) /* Locked transfers enabled on channel x */

  {
    DMA_Channelx->CCNF |= DMA_LockChannel ;
  }

  else /* Locked transfers disabled on channel xt */
  {
    DMA_Channelx->CCNF &= ~ DMA_LockChannel;
  }
}


/*******************************************************************************
* Function Name  : DMA_ChannelCache
* Description    : Enables or disables the cacheability Feature for the specified DMA_Channelx
* Input          :
*                  -DMA_Channelx: where x can be 0,1,2,3,4,5,6,or 7 to select the DMA Channel.
*                  -NewState: new state of the specified DMA_Channelx mask interrupt.
*                             This parameter can be: ENABLE or DISABLE.
* Output         : None.
* Return         : None.
*******************************************************************************/


void DMA_ChannelCache (DMA_Channel_TypeDef * DMA_Channelx, FunctionalState NewState)

{
  if (NewState==ENABLE) /* Cacheability Feature enabled on channelx */

  {
    DMA_Channelx->CC |= DMA_CacheChannel ;
  }

  else /* Cacheability Feature disabled on channelx */
  {
    DMA_Channelx->CC &= ~ DMA_CacheChannel ;
  }
}


/*******************************************************************************
* Function Name  : DMA_ChannelBuffering
* Description    : Enables or disables the Buffering Feature for the specified DMA_Channelx
* Input          :
*                  -DMA_Channelx: where x can be 0,1,2,3,4,5,6,or 7 to select the DMA Channel.
*                  -NewState: new state of the specified DMA_Channelx mask interrupt.
*                             This parameter can be: ENABLE or DISABLE.
* Output         : None.
* Return         : None.
*******************************************************************************/


void DMA_ChannelBuffering (DMA_Channel_TypeDef * DMA_Channelx, FunctionalState NewState)

{
  if (NewState==ENABLE) /* Cacheability Feature enabled on channel x */

  {
    DMA_Channelx->CC |= DMA_BufferChannel ;
  }

  else /* Cacheability Feature disabled on channel xt */
  {
    DMA_Channelx->CC &= ~ DMA_BufferChannel ;
  }
}

/*******************************************************************************
* Function Name  : MA_ChannelProt0Mod
* Description    : Sets The User or Privileged mode for the specified DMA_Channelx
* Input          :
*                  -DMA_Channelx: where x can be 0,1,2,3,4,5,6,or 7 to select the DMA Channel.
*                  -Prot0Mode: Specifies the Privileged mode Or the User mode.
*                                This parameter can be:
*                      - DMA_PrevilegedMode
*                      - DMA_UserMode
*
*
* Output         : None.
* Return         : None.
*******************************************************************************/


void DMA_ChannelProt0Mode (DMA_Channel_TypeDef * DMA_Channelx, u32 Prot0Mode)

{
  if (Prot0Mode==DMA_PrevilegedMode) /* Privileged mode */
  {
    DMA_Channelx->CC |= DMA_PrevilegedMode ;
  }

  else /* User mode */
  {
    DMA_Channelx->CC &= DMA_UserMode ;
  }
}





/*******************************************************************************
* Function Name  : DMA_ChannelSRCIncConfig
* Description    : Enables or disables the Source address incrementation after each transfer for
*                   the specified DMA_Channelx
* Input          :
*                  -DMA_Channelx: where x can be 0,1,2,3,4,5,6,or 7 to select the DMA Channel.
*                  -NewState: new state of the specified DMA_Channelx mask interrupt.
*                             This parameter can be: ENABLE or DISABLE.
* Output         : None.
* Return         : None.
*******************************************************************************/


void DMA_ChannelSRCIncConfig (DMA_Channel_TypeDef * DMA_Channelx, FunctionalState NewState)

{
  if (NewState==ENABLE) /* The Source address is incremented after each transfer */

  {
    DMA_Channelx->CC |= DMA_ChannelSRCInc ;
  }

  else /* The Source address is not incremented after each Transfer */
  {
    DMA_Channelx->CC &= ~ DMA_ChannelSRCInc  ;
  }
}


/*******************************************************************************
* Function Name  : DMA_ChannelDESIncConfig
* Description    : Enables or disables the Destination address incrementation after each transfer for
*                   the specified DMA_Channelx
* Input          :
*                  -DMA_Channelx: where x can be 0,1,2,3,4,5,6,or 7 to select the DMA Channel.
*                  -NewState: new state of the specified DMA_Channelx mask interrupt.
*                             This parameter can be: ENABLE or DISABLE.
* Output         : None.
* Return         : None.
*******************************************************************************/


void DMA_ChannelDESIncConfig (DMA_Channel_TypeDef * DMA_Channelx, FunctionalState NewState)

{
  if (NewState==ENABLE) /* The Destination address is incremented after each transfer */

  {
    DMA_Channelx->CC |= DMA_ChannelDESInc ;
  }

  else /* The Destination address is not incremented after each Transfer */
  {
    DMA_Channelx->CC &= ~ DMA_ChannelDESInc  ;
  }
}



/********************************************************************************
* Function Name  : DMA_GetChannelStatus
* Description    : Checks the status of DMA channelx ( Enabled or Disabled).
*                  - ChannelIndx:specifies the DMA Channel to be checked.
*                   This parameter can be:
*				      - Channel0
*					  - Channel1
*					  - Channel2
*					  - Channel3
*					  - Channel4
*					  - Channel5
*				      - Channel6
*					  - Channel7
* Output         : None.
*
* Return         : SET or RESET.
*******************************************************************************/


FlagStatus  DMA_GetChannelStatus(u8 ChannelIndx )

{

 if ( ( DMA->ENCSR & (1 <<  ChannelIndx )) != RESET )
 {
   return SET; /*  Channelx Enabled */
 }

 else

 {

  return RESET; /*  Channelx Disabled */

 }

}



/********************************************************************************
* Function Name  : DMA_GetITStatus
* Description    : Checks the status of Terminal Count and  Error interrupts request after and before Masking.
* Input          :
*                  - ChannelIndx:specifies the DMA Channel to be checked.
*                   This parameter can be:
*				      - Channel0
*					  - Channel1
*					  - Channel2
*					  - Channel3
*					  - Channel4
*					  - Channel5
*				      - Channel6
*					  - Channel7
*
*.                 - DMA_ITReq: specifies the DMA interrupt request status to be checked.
*                   This parameter can be:
*
*					  - DMA_IS 
*					  - DMA_TCS 
*					  - DMA_ES
*					  - DMA_TCRS
*					  - DMA_ERS.
*
* Output         : None.
*
* Return         : SET or RESET.
*******************************************************************************/


ITStatus DMA_GetITStatus(u8 ChannelIndx,u8 DMA_ITReq)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -