[DemoCode下载] ISD9100系列的PDMA操作

[复制链接]
540|6
 楼主| 幸福小强 发表于 2020-1-31 20:47 | 显示全部楼层 |阅读模式
sd, DMA, pd, TE
  1. /**************************************************************************//**
  2. * [url=home.php?mod=space&uid=288409]@file[/url]     main.c
  3. * [url=home.php?mod=space&uid=895143]@version[/url]  V1.00
  4. * $Revision: 1 $
  5. * $Date: 14/07/15 2:52p $
  6. * [url=home.php?mod=space&uid=247401]@brief[/url]    ISD9100 Series PDMA Driver Sample Code
  7. *
  8. * @note
  9. * Copyright (C) 2014 Nuvoton Technology Corp. All rights reserved.
  10. *
  11. ******************************************************************************/
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include "ISD9100.h"

  15. /*---------------------------------------------------------------------------------------------------------*/
  16. /* Macro, type and constant definitions                                                                    */
  17. /*---------------------------------------------------------------------------------------------------------*/

  18. #define TEST_CH     3 // 0~3

  19. uint32_t PDMA_TEST_LENGTH = 64;
  20. uint8_t SrcArray[256];
  21. uint8_t DestArray[256];
  22. uint32_t volatile u32IsTestOver = 0xFF;

  23. void PDMA_IRQHandler(void)
  24. {
  25.     uint32_t status = PDMA_GET_INT_STATUS();

  26.     if(status & 0x1)    /* CH0 */
  27.     {
  28.         if(PDMA_GET_CH_INT_STS(0) & 0x2)
  29.             u32IsTestOver = 0;
  30.         PDMA_CLR_CH_INT_FLAG(0, PDMA_CHIF_TXOKIF_Msk);
  31.     }
  32.     else if(status & 0x2)      /* CH1 */
  33.     {
  34.         if(PDMA_GET_CH_INT_STS(1) & 0x2)
  35.             u32IsTestOver = 1;
  36.         PDMA_CLR_CH_INT_FLAG(1, PDMA_CHIF_TXOKIF_Msk);
  37.     }
  38.     else if(status & 0x4)      /* CH2 */
  39.     {
  40.         if(PDMA_GET_CH_INT_STS(2) & 0x2)
  41.             u32IsTestOver = 2;
  42.         PDMA_CLR_CH_INT_FLAG(2, PDMA_CHIF_TXOKIF_Msk);
  43.     }
  44.     else if(status & 0x8)      /* CH3 */
  45.     {
  46.         if(PDMA_GET_CH_INT_STS(3) & 0x2)
  47.             u32IsTestOver = 3;
  48.         PDMA_CLR_CH_INT_FLAG(3, PDMA_CHIF_TXOKIF_Msk);
  49.     }
  50.     else
  51.         printf("unknown interrupt !!\n");
  52. }

  53. void SYS_Init(void)
  54. {
  55.     /*---------------------------------------------------------------------------------------------------------*/
  56.     /* Init System Clock                                                                                       */
  57.     /*---------------------------------------------------------------------------------------------------------*/
  58.     /* Unlock protected registers */
  59.     SYS_UnlockReg();

  60.     /* Enable External XTL32K */
  61.     CLK_EnableXtalRC(CLK_PWRCTL_LXTEN_Msk);

  62.     /* Enable External OSC49M */
  63.     CLK_EnableXtalRC(CLK_PWRCTL_HIRCEN_Msk);
  64.        
  65.     /* Enable External OSC10K */
  66.     CLK_EnableXtalRC(CLK_PWRCTL_LIRCEN_Msk);
  67.        
  68.     /* Switch HCLK clock source to HXT */
  69.     CLK_SetHCLK(CLK_CLKSEL0_HCLKSEL_HIRC, CLK_CLKSEL0_HIRCFSEL_48M, CLK_CLKDIV0_HCLK(1));

  70.     /* Enable IP clock */
  71.     CLK_EnableModuleClock(UART_MODULE);
  72.                 CLK_EnableModuleClock(PDMA_MODULE);

  73.     /* Update System Core Clock */
  74.     /* User can use SystemCoreClockUpdate() to calculate SystemCoreClock. */
  75.     SystemCoreClockUpdate();

  76.     /* Update System Core Clock */
  77.     /* User can use SystemCoreClockUpdate() to calculate PllClock, SystemCoreClock and CycylesPerUs automatically. */
  78.     SystemCoreClockUpdate();

  79.     /*---------------------------------------------------------------------------------------------------------*/
  80.     /* Init I/O Multi-function                                                                                 */
  81.     /*---------------------------------------------------------------------------------------------------------*/
  82.     /* Set GPA multi-function pins for UART0 RXD and TXD */
  83.                 SYS->GPA_MFP  = (SYS->GPA_MFP & (~SYS_GPA_MFP_PA8MFP_Msk) ) | SYS_GPA_MFP_PA8MFP_UART_TX;
  84.                 SYS->GPA_MFP  = (SYS->GPA_MFP & (~SYS_GPA_MFP_PA9MFP_Msk) ) | SYS_GPA_MFP_PA9MFP_UART_RX;

  85.     /* Lock protected registers */
  86.     SYS_LockReg();
  87. }

  88. void UART_Init(void)
  89. {
  90.     /*---------------------------------------------------------------------------------------------------------*/
  91.     /* Init UR                                                                                               */
  92.     /*---------------------------------------------------------------------------------------------------------*/
  93.     /* Reset IP */
  94.     SYS_ResetModule(UART0_RST);

  95.     /* Configure UART0 and set UART0 Baudrate(115200) */
  96.     UART_Open( UART0,115200 );
  97. }

  98. /*---------------------------------------------------------------------------------------------------------*/
  99. /*  Main Function                                                                                          */
  100. /*---------------------------------------------------------------------------------------------------------*/
  101. int32_t main(void)
  102. {
  103.                 int32_t i;
  104.        
  105.     /* Init System, IP clock and multi-function I/O
  106.        In the end of SYS_Init() will issue SYS_LockReg()
  107.        to lock protected register. If user want to write
  108.        protected register, please issue SYS_UnlockReg()
  109.        to unlock protected register if necessary */

  110.     /* Init System, IP clock and multi-function I/O */
  111.     SYS_Init();

  112.     /* Init UART0 for printf */
  113.     UART_Init();

  114.     printf("\n\nCPU [url=home.php?mod=space&uid=72445]@[/url] %dHz <%d>\n", SystemCoreClock, TEST_CH);

  115.     printf("+--------------------------------------+ \n");
  116.     printf("|    ISD9100 PDMA Driver Sample Code   | \n");
  117.     printf("+--------------------------------------+ \n");
  118.        
  119.                 memset(SrcArray,0,256);
  120.                 memset(DestArray,0,256);
  121.                 for (i=0;i<256;i++) SrcArray[i]=i;

  122.     /* Open Channel TEST_CH */
  123.     PDMA_Open(1 << TEST_CH);
  124.     PDMA_SetTransferCnt(TEST_CH, PDMA_WIDTH_32, PDMA_TEST_LENGTH);
  125.     PDMA_SetTransferAddr(TEST_CH, (uint32_t)SrcArray, PDMA_SAR_INC, (uint32_t)DestArray, PDMA_DAR_INC);
  126.     PDMA_EnableInt(TEST_CH, PDMA_INTENCH_TXOKIEN_Msk);
  127.     NVIC_EnableIRQ(PDMA_IRQn);
  128.     u32IsTestOver = 0xFF;
  129.     PDMA_Trigger(TEST_CH);
  130.     while(u32IsTestOver == 0xFF);

  131.     if(u32IsTestOver == TEST_CH)
  132.                 {
  133.                         for (i=0;i<256;i++)
  134.                         {
  135.                                 if (SrcArray[i]!=DestArray[i])
  136.                                 {
  137.                                         printf("data compare error...\n");
  138.                                         while (1);
  139.                                 }
  140.                         }
  141.       printf("test done...\n");
  142.                         PDMA_Close();
  143.                         while (1);
  144.                 }

  145.                 while (1);
  146. }


 楼主| 幸福小强 发表于 2020-1-31 20:48 | 显示全部楼层
这个系列应该知道的人不多
 楼主| 幸福小强 发表于 2020-1-31 20:48 | 显示全部楼层
这个属于ARM Cortex-M 音频系统芯片
 楼主| 幸福小强 发表于 2020-1-31 20:49 | 显示全部楼层
这个系列目前没有中文手册。
小明的同学 发表于 2020-1-31 21:22 | 显示全部楼层
非常赞。
zhuomuniao110 发表于 2020-1-31 21:24 | 显示全部楼层
代码中使用了不少逻辑操作获取位的状态。
643757107 发表于 2020-1-31 22:32 | 显示全部楼层
分享的资料非常好。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

143

主题

1819

帖子

3

粉丝
快速回复 在线客服 返回列表 返回顶部