谁用过i2s3接wm8978录音的dma中断该怎么配置

2019-07-20 01:37发布




友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
2条回答
13372533333
1楼-- · 2019-07-20 03:29
void I2S3_TX_DMA_Init(u8* buf0,u8 *buf1,u16 num)
{
        NVIC_InitTypeDef   NVIC_InitStructure;
        DMA_InitTypeDef  DMA_InitStructure;
       

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1,ENABLE);//DMA1ê±Öóê1Äü
       
        DMA_DeInit(DMA1_Stream5);
        while (DMA_GetCmdStatus(DMA1_Stream5) != DISABLE){}//μè′yDMA1_Stream5¿éÅäÖÃ
               
        DMA_ClearITPendingBit(DMA1_Stream5,DMA_IT_FEIF5|DMA_IT_DMEIF5|DMA_IT_TEIF5|DMA_IT_HTIF5|DMA_IT_TCIF5);//Çå¿ÕDMA1_Stream5éÏËùóDÖD¶Ï±êÖ¾

  /* ÅäÖÃ DMA Stream */

  DMA_InitStructure.DMA_Channel = DMA_Channel_0;  //í¨μà
  DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&SPI3->DR;//íaéèμØÖ·Îau32)&SPI2->DR
  DMA_InitStructure.DMA_Memory0BaseAddr = (u32)buf0;//DMA ′æ′¢Æ÷0μØÖ·
  DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral;//′æ′¢Æ÷μ½íaéèÄ£ê½
  DMA_InitStructure.DMA_BufferSize = num;//êy¾Y′«êäá¿
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;//íaéè·ÇÔöá¿Ä£ê½
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;//′æ′¢Æ÷Ôöá¿Ä£ê½
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;//íaéèêy¾Y3¤¶è:16λ
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;//′æ′¢Æ÷êy¾Y3¤¶è£o16λ
  DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;// ê1óÃÑ-»·Ä£ê½
  DMA_InitStructure.DMA_Priority = DMA_Priority_High;//¸ßóÅÏ輶
  DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; //2»ê1óÃFIFOģ꽠       
  DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_1QuarterFull;
  DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;//íaéèí»·¢μ¥′Î′«êä
  DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;//′æ′¢Æ÷í»·¢μ¥′Î′«êä
  DMA_Init(DMA1_Stream5, &DMA_InitStructure);//3õê¼»ˉDMA Stream
       
        DMA_DoubleBufferModeConfig(DMA1_Stream5,(u32)buf1,DMA_Memory_0);//Ë«»o3åÄ£ê½ÅäÖÃ

  DMA_DoubleBufferModeCmd(DMA1_Stream5,ENABLE);//Ë«»o3åÄ£꽿aÆô

  DMA_ITConfig(DMA1_Stream5,DMA_IT_TC,ENABLE);//¿aÆô′«êäíê3éÖD¶Ï

        NVIC_InitStructure.NVIC_IRQChannel = DMA1_Stream5_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x00;//ÇàÕ¼óÅÏ輶0
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x00;//×óóÅÏ輶0
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//ê1Äüía2¿ÖD¶Ïí¨μà
  NVIC_Init(&NVIC_InitStructure);//ÅäÖà      
}

void I2S3ext_RX_DMA_Init(u8* buf0,u8 *buf1,u16 num)
{        
       
        NVIC_InitTypeDef   NVIC_InitStructure;
        DMA_InitTypeDef  DMA_InitStructure;
       

  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA1,ENABLE);//DMA1ê±Öóê1Äü
       
        DMA_DeInit(DMA1_Stream0);
        while (DMA_GetCmdStatus(DMA1_Stream0) != DISABLE){}//μè′yDMA1_Stream3¿éÅäÖÃ
               
        DMA_ClearITPendingBit(DMA1_Stream0,DMA_IT_FEIF0|DMA_IT_DMEIF0|DMA_IT_TEIF0|DMA_IT_HTIF0|DMA_IT_TCIF0);//Çå¿ÕDMA1_Stream3éÏËùóDÖD¶Ï±êÖ¾

  /* ÅäÖÃ DMA Stream */

  DMA_InitStructure.DMA_Channel = DMA_Channel_3;  //í¨μà3 I2S2ext_RXí¨μà
  DMA_InitStructure.DMA_PeripheralBaseAddr = (u32)&I2S3ext->DR;//íaéèμØÖ·Îau32)&I2S2ext->DR>DR
  DMA_InitStructure.DMA_Memory0BaseAddr = (u32)buf0;//DMA ′æ′¢Æ÷0μØÖ·
  DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;//íaéèμ½′æ′¢Æ÷Ä£ê½
  DMA_InitStructure.DMA_BufferSize = num;//êy¾Y′«êäá¿
  DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;//íaéè·ÇÔöá¿Ä£ê½
  DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;//′æ′¢Æ÷Ôöá¿Ä£ê½
  DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;//íaéèêy¾Y3¤¶è:16λ
  DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;//′æ′¢Æ÷êy¾Y3¤¶è£o16λ
  DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;// ê1óÃÑ-»·Ä£ê½
  DMA_InitStructure.DMA_Priority = DMA_Priority_Medium;//ÖDμèóÅÏ輶
  DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable; //2»ê1óÃFIFOģ꽠       
  DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_1QuarterFull;
  DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;//íaéèí»·¢μ¥′Î′«êä
  DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;//′æ′¢Æ÷í»·¢μ¥′Î′«êä
  DMA_Init(DMA1_Stream0, &DMA_InitStructure);//3õê¼»ˉDMA Stream
       
        DMA_DoubleBufferModeConfig(DMA1_Stream0,(u32)buf1,DMA_Memory_0);//Ë«»o3åÄ£ê½ÅäÖÃ

  DMA_DoubleBufferModeCmd(DMA1_Stream0,ENABLE);//Ë«»o3åÄ£꽿aÆô

  DMA_ITConfig(DMA1_Stream0,DMA_IT_TC,ENABLE);//¿aÆô′«êäíê3éÖD¶Ï
  
               
        NVIC_InitStructure.NVIC_IRQChannel = DMA1_Stream0_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority =0x00;//ÇàÕ¼óÅÏ輶0
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x00;//×óóÅÏ輶1
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//ê1Äüía2¿ÖD¶Ïí¨μà
  NVIC_Init(&NVIC_InitStructure);//ÅäÖÃ
       
         
}
正点原子
2楼-- · 2019-07-20 08:03
 精彩回答 2  元偷偷看……

一周热门 更多>