aic23.c

来自「在开发FPGA上比较有用」· C语言 代码 · 共 875 行 · 第 1/3 页

C
875
字号
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3123){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/buxingmoshi1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3124){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/qianfangyouren1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3125){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/fasongjieshou1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3126){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/meiyouzhangaiwu1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3127){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/diantai_menu1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x52000;
           }else if(num == 3128){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/4road1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3129){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/3road1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3130){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/2road1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3131){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/1road1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3132){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/change_mode1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3133){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/notchange_mode1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3134){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/east1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3135){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/west1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3136){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/north1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3137){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/south1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3138){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/diantai_chose_destanation1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x22500;
           }else if(num == 3139){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/queding_fasong1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3140){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/qingxuanzecaozuo1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3141){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/45road1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3142){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/408road1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3143){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/mudidixuanze1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }else if(num == 3144){
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/fasongshezhi1.dat", "r");
            // AUDIO_BUFF_SIZE2 = 0x20000;
            AUDIO_BUFF_SIZE2 = 0x6000;
           }
}





/*************************************************
*函数名:aic23_station_play
*参数:文件名
*功能:播放站名
/************************************************/
void aic23_station_play(int num)
{
     // char filename[]="/dev/sd_controller_inst/Input_Files/welcomeinit.dat";
           AUDIO_BUFF_SIZE2 = 0x6000;
           if(num == 2001)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/DaChaiShi.dat", "r");
            //  hostfile = fopen("filename", "r");
           else if(num == 2002)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/DongMen.dat", "r");
           else if(num == 2003)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/DongNanChengJiao.dat", "r");
           else if(num == 2004)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/DuanLvMen.dat", "r");
           else if(num == 2005)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/HePingMen.dat", "r");
           else if(num == 2006)
              hostfile = fopen("/dev/sd_controller_inst/Input_Files/JiaoDaDianNaoCheng.dat", "r");
           else if(num == 2007)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/JiaoDaShangChang.dat", "r");
           else if(num == 2008)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/LiJiaCun.dat", "r");
           else if(num == 2009)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/LuJiaCun.dat", "r");
           else if(num == 2010)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/NanGuoMen.dat", "r");
           else if(num == 2011)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/NanMen.dat", "r");
           else if(num == 2012)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/NanShaoMen.dat", "r");
           else if(num == 2013)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/SaiGeDianNaoCheng.dat", "r");
           
           else if(num == 2014)//
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/ShaPoCun.dat", "r");//
           else if(num == 2015)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/ShaPo.dat", "r");
           else if(num == 2016)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/XingQingGongYuan.dat", "r");
           else if(num == 2017)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/ZhongLou.dat", "r");
           else if(num == 2018)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/WuJingYiYuan.dat", "r");
           else if(num == 2019)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/TieYiJvYiYuan.dat", "r");
           else if(num == 2020)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/TaiYiLu.dat", "r");
           else if(num == 2021)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/WaYaoXiaoQv.dat", "r");
           else if(num == 2022)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/WenYiLu.dat", "r");
           else if(num == 2023)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/ahead.dat", "r");
           else if(num == 2024)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/right.dat", "r");
           else if(num == 2025)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/left.dat", "r");
           else if(num == 2026)
             hostfile = fopen("/dev/sd_controller_inst/Input_Files/stop.dat", "r");
}
/*************************************************
*函数名:aic23_play
*参数:文件名
*功能:播放
/************************************************/
void aic23_play(int num)
{
    int i;
 //   FILE * hostfile;
    unsigned int v1;
    int flag=1;
    char ch;
    /*hostfile = fopen("/dev/sd_controller_inst/Input_Files/silence_init.dat", "r");
        for(i=0;i<0x56000;)
              {
                  IOWR(FREEDEV_AIC23_0_BASE,0x07,audioBuff[i]);
                  i++;
               }*/
        if(num<2000)
         {
           if(num == 1001)
           {
              for(i=0;i<AUDIO_BUFF_SIZE;)
              {
                //读音频外设状态
                v1=IORD(FREEDEV_AIC23_0_BASE,0x03);
                // 输出FIFO不为满
                if(!(v1 & 0x01))
               {
                  IOWR(FREEDEV_AIC23_0_BASE,0x07,audioBuff[i]);
                  i++;
               }
       //    hostfile = fopen("/dev/sd_controller_inst/Input_Files/ahead16.dat", "r");
              }
           }else if(num == 1002)
             {
               for(i=0;i<AUDIO_BUFF_SIZE;)
              {
              //读音频外设状态
               v1=IORD(FREEDEV_AIC23_0_BASE,0x03);
              // 输出FIFO不为满
               if(!(v1 & 0x01))
               {
                 IOWR(FREEDEV_AIC23_0_BASE,0x07,audioBuff1[i]);
                  i++;
               }
             //  hostfile = fopen("/dev/sd_controller_inst/Input_Files/left16.dat", "r");
             }
          }else if(num == 1003){
             for(i=0;i<AUDIO_BUFF_SIZE;)
            {
              //读音频外设状态
             v1=IORD(FREEDEV_AIC23_0_BASE,0x03);
              // 输出FIFO不为满
             if(!(v1 & 0x01))
             {
               IOWR(FREEDEV_AIC23_0_BASE,0x07,audioBuff2[i]);
               i++;
             }
         //  hostfile = fopen("/dev/sd_controller_inst/Input_Files/right16.dat", "r");
           }
             }else if(num == 1004){
             for(i=0;i<AUDIO_BUFF_SIZE;)
           {
              //读音频外设状态
             v1=IORD(FREEDEV_AIC23_0_BASE,0x03);
              // 输出FIFO不为满
             if(!(v1 & 0x01))
             {
               IOWR(FREEDEV_AIC23_0_BASE,0x07,audioBuff3[i]);
               i++;
             }
           }
         }else if(num == 1005){
             for(i=0;i<0x35000;)
             {
              //读音频外设状态
               v1=IORD(FREEDEV_AIC23_0_BASE,0x03);
              // 输出FIFO不为满
               if(!(v1 & 0x01))
               {
                 IOWR(FREEDEV_AIC23_0_BASE,0x07,audioBuff4[i]);
                 i++;
               }
             }
         }else if(num == 1006){
             for(i=0;i<0x52000;)
           {
              //读音频外设状态
             v1=IORD(FREEDEV_AIC23_0_BASE,0x03);
              // 输出FIFO不为满
             if(!(v1 & 0x01))
             {
               IOWR(FREEDEV_AIC23_0_BASE,0x07,audioBuff5[i]);
               i++;
             }
           }
         }
        }
        else{
            if(num < 3000)
              aic23_station_play(num);
            else if(num < 4000)
              aic23_warning_play(num);
         
           // 读音频数据到内存
            for(i=0;i<AUDIO_BUFF_SIZE2;i++)
            {
              fread(&audioBuff6[i],4,1,hostfile);     //change
              // IOWR(FREEDEV_AIC23_0_BASE,0x07,audioBuff[i]);
            }  
        
          //     关闭文件
            fclose(hostfile);
               
             //播放内存音频数据
           for(i=0;i<AUDIO_BUFF_SIZE2;)
           {
              //读音频外设状态
             v1=IORD(FREEDEV_AIC23_0_BASE,0x03);
              // 输出FIFO不为满
             if(!(v1 & 0x01))
             {
               IOWR(FREEDEV_AIC23_0_BASE,0x07,audioBuff6[i]);
               i++;
             }
           }
        }
                
 }
/*************************************************

⌨️ 快捷键说明

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