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

📄 song_task.lst

📁 基于uCOS/II制作的MP3
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V7.50   SONG_TASK                                                             06/03/2006 10:32:53 PAGE 1   


C51 COMPILER V7.50, COMPILATION OF MODULE SONG_TASK
OBJECT MODULE PLACED IN song_task.obj
COMPILER INVOKED BY: C:\Program Files\keil\C51\BIN\C51.EXE modules\song\song_task.c LARGE BROWSE DEBUG OBJECTEXTEND PRIN
                    -T(.\song_task.lst) OBJECT(song_task.obj)

line level    source

   1          /*C**************************************************************************
   2          * NAME:         song_task.c
   3          *----------------------------------------------------------------------------
   4          * Copyright (c) 2003 Atmel.
   5          *----------------------------------------------------------------------------
   6          * RELEASE:      snd1c-refd-nf-4_0_3      
   7          * REVISION:     1.16     
   8          *----------------------------------------------------------------------------
   9          * PURPOSE:          
  10          * This file contains the song task and attached routines
  11          *
  12          * CONFIGURATION
  13          * Three #define must be set in config.h:
  14          *   - PLAYER_PLAY_MODE
  15          *       PLAY_DIR      play selected dir
  16          *       PLAY_DISK     play whole disk including sub-directory
  17          *   - PLAYER_PLAY_START
  18          *       START_PLAY    start playing after power-up
  19          *       START_STOP    do not play after power-up
  20          *   - PLAYER_PLAY_LOOP
  21          *       PLAY_LOOP     loop after last file of dir or disk has been played
  22          *       PLAY_NO_LOOP  no loop after last file of dir or disk has been played
  23          * NOTES:
  24          * Global Variables:
  25          *   - gl_key_press:   bit in bdata space
  26          *   - gl_key:         byte in idata space
  27          *   - gl_mem_failure: bit in bdata space
  28          *****************************************************************************/
  29          
  30          /*_____ I N C L U D E S ____________________________________________________*/
  31          
  32          #include "config.h"                         /* system configuration */
  33          #include "lib_mcu\lcd\lcd_drv.h"  
  34          #include "modules\file\file.h"              /* file definition */
  35          #include "lib_mcu\clock\clock.h"            /* clock definition */
  36          #include "lib_mcu\kbd\key_drv.h"
  37          #include "lib_mcu\aud\aud_drv.h"            /* audio driver definition */
  38          #include "lib_mcu\mp3\mp3_drv.h"            /* mp3 driver definition */
  39          #include "song_drv.h"                       /* song driver definition */
  40          #include "song_task.h"                      /* song task definition */ 
  41          
  42          /*_____ M A C R O S ________________________________________________________*/
  43          
  44          
  45          /*_____ D E F I N I T I O N ________________________________________________*/
  46          
  47          extern  bdata   bit     gl_key_press;       /* TRUE when a key is decoded */
  48          extern  idata   Byte    gl_key;             /* value of the key pressed */
  49          extern  bdata   bit     gl_mem_failure;     /* memory hardware failure */
  50          
  51          Byte    song_state;                         /* task state */
  52          static  bit     song_loop;                  /* auto replay */
  53          extern  Byte    mp3_volume;
  54          
C51 COMPILER V7.50   SONG_TASK                                                             06/03/2006 10:32:53 PAGE 2   

  55          /*_____ D E C L A R A T I O N ______________________________________________*/
  56          
  57          
  58          /*F**************************************************************************
  59          * NAME: song_task_init
  60          *----------------------------------------------------------------------------
  61          * PARAMS:
  62          *
  63          * return:
  64          *----------------------------------------------------------------------------
  65          * PURPOSE: 
  66          *   Song playing task initialization
  67          *----------------------------------------------------------------------------
  68          * EXAMPLE:
  69          *----------------------------------------------------------------------------
  70          * NOTE:
  71          *----------------------------------------------------------------------------
  72          * REQUIREMENTS:
  73          *****************************************************************************/
  74          void song_task_init (void)
  75          {
  76   1        song_loop = PLAYER_PLAY_LOOP;             /* default loop playing */
  77   1        song_snd_init();                          /* init sound control */
  78   1        song_state = SONG_START;
  79   1      }
  80          
  81          
  82          /*F**************************************************************************
  83          * NAME: song_task
  84          *----------------------------------------------------------------------------
  85          * PARAMS:
  86          *
  87          * return:
  88          *----------------------------------------------------------------------------
  89          * PURPOSE: 
  90          *   Song playing task
  91          *----------------------------------------------------------------------------
  92          * EXAMPLE:
  93          *----------------------------------------------------------------------------
  94          * NOTE:
  95          *----------------------------------------------------------------------------
  96          * REQUIREMENTS:
  97          *****************************************************************************/
  98          void song_task (void)
  99          {
 100   1      // Byte  cpt_data;
 101   1      bit     loop;
 102   1      
 103   1        /*if (Mp3_frame_request())
 104   1        { 
 105   1         // printch(0x96,"请求  ");
 106   1          cpt_data = 0;
 107   1          do
 108   1          {
 109   1            Mp3_load(Fgetc());                     //send data while requested 
 110   1            cpt_data++;
 111   1            // workaround for 320Kbs frame support 
 112   1            if ((cpt_data & 0x40) == 0x40)
 113   1            {
 114   1              Mp3_set_full();
 115   1              Mp3_reset_full();                   // ack 64 Bytes write 
 116   1              break;
C51 COMPILER V7.50   SONG_TASK                                                             06/03/2006 10:32:53 PAGE 3   

 117   1            }
 118   1          }
 119   1          while (Mp3_frame_request());           //  until frame request */
 120   1      
 121   1          while (Mp3_frame_request())             /* frame request ? */
 122   1          {
 123   2            Mp3_load(Fgetc());                    /* send data while requested */
 124   2          }
 125   1      //}
 126   1      
 127   1        switch (song_state)
 128   1        {
 129   2          case SONG_START:
 130   2          { 
 131   3                printch(0x93,"标准  ");
 132   3                Mp3_set_right_vol(0);
 133   3            Mp3_set_left_vol(0);
 134   3            song_state = SONG_INSTALL;
 135   3            break;
 136   3          }
 137   2      
 138   2      
 139   2          case SONG_INSTALL:
 140   2          {
 141   3            if (File_entry_root(FILE_MP3 | FILE_DIR) == OK) /* goto root directory */
 142   3                {     
 143   4                          Mp3_set_right_vol(0);
 144   4                  Mp3_set_left_vol(0);
 145   4                  print_file_name();              /* display file name */
 146   4                  //#if PLAYER_PLAY_START == START_STOP
 147   4                  //  song_state = SONG_IDLE;
 148   4                  //#else
 149   4                    if (File_type() == FILE_DIR)
 150   4                    { /* file_type is dir */
 151   5                    #if PLAYER_PLAY_MODE == PLAY_DISK
 152   5                      song_state = SONG_NEW;      /* enter dir and play */
 153   5                    #else
                              song_state = SONG_NEXT;     /* stay in root dir */
                            #endif
 156   5                    }
 157   4                    else
 158   4                    { /* file_type is MP3 */
 159   5                      song_state = SONG_INIT;
 160   5                    }
 161   4      //            #endif
 162   4                 }
 163   3                else
 164   3                { /* root is empty of song & diretory */
 165   4                  song_state = SONG_NO_SONG;
 166   4                }
 167   3      
 168   3            break;
 169   3          }
 170   2      
 171   2      
 172   2          case SONG_IDLE:                         /* no file openned */
 173   2          { 
 174   3           printch(0x90,"挂起  ");
 175   3           
 176   3            if (gl_key_press)                     /* a key is pressed? */
 177   3            {
 178   4              switch (gl_key)
C51 COMPILER V7.50   SONG_TASK                                                             06/03/2006 10:32:53 PAGE 4   

 179   4              {
 180   5                case KEY_PLAY:
 181   5                  if (File_type() == FILE_DIR)
 182   5                  {
 183   6                    file_entry_dir(FILE_MP3 | FILE_DIR);  /* goto sub-directory */ 
 184   6                    print_file_name();            /* display directory name */
 185   6                  }
 186   5                  else
 187   5                  { /* file_type is MP3 */
 188   6                    song_state = SONG_INIT;
 189   6                  }
 190   5                  break;
 191   5      
 192   5                case KEY_NEXT:
 193   5                  file_seek_next(FILE_MP3 | FILE_DIR, TRUE);  /* select next song with loop */
 194   5                  print_file_name();              /* display file name */
 195   5                  break;
 196   5      
 197   5                case KEY_PREV:
 198   5                  file_seek_prev(FILE_MP3 | FILE_DIR, TRUE);  /* select previous song */
 199   5                  print_file_name();              /* display file name */
 200   5                  break;
 201   5      
 202   5                case KEY_INC:
 203   5                  song_snd_inc();                 /* increment selected control */
 204   5                  print_sound_level();            /* display new level */
 205   5                  break;
 206   5      
 207   5                case KEY_DEC:
 208   5                  song_snd_dec();                 /* decrement selected control */
 209   5                  print_sound_level();            /* display new level */
 210   5                  break;
 211   5      
 212   5               // case KEY_SOUND:
 213   5               //   song_snd_select();              /* select next sound control */
 214   5               //   print_sound();                  /* display selected sound icon */
 215   5               //   print_sound_level();            /* display new level */
 216   5               //   break;
 217   5      
 218   5                case KEY_PARENT:
 219   5                  File_goto_parent(FILE_MP3 | FILE_DIR); /* goto parent directory */ 
 220   5                  print_file_name();              /* display first file name */
 221   5                  break;
 222   5      
 223   5                default:
 224   5                  break;
 225   5              }
 226   4              gl_key_press = FALSE;               /* ack key usage */
 227   4            }
 228   3            break;
 229   3          }
 230   2      
 231   2      
 232   2          case SONG_INIT:
 233   2          { 
 234   3          //  printch(0x90,"就绪  ");
 235   3          //  disp_clock_reset();                   /* reset clock timer */
 236   3            if (Fopen(READ) == OK)
 237   3            {
 238   4               //if (song_init() != SONG_NO_ERR)     /* init song playing */
 239   4               //{
 240   4                // song_stop();                      /* stop playing song */
C51 COMPILER V7.50   SONG_TASK                                                             06/03/2006 10:32:53 PAGE 5   

 241   4                // Fclose();
 242   4               //  loop = song_loop;
 243   4               //  song_state = SONG_NEXT;
 244   4              // }
 245   4               //else
 246   4              {  
 247   5                song_audio_init();                /* init audio interface */
 248   5                clock_song_init();  
 249   5                song_state = SONG_PLL;
 250   5      
 251   5                Mp3_set_right_vol(mp3_volume);
 252   5                Mp3_set_left_vol(mp3_volume);
 253   5              }
 254   4            }
 255   3            else
 256   3            {
 257   4              song_state = SONG_ERROR;
 258   4            }
 259   3            break;
 260   3          }
 261   2      
 262   2      
 263   2          case SONG_PLL:
 264   2          { 
 265   3            if (Pll_get_lock())                   /* pll locked? */
 266   3            {
 267   4              song_start();                       /* start playing song */
 268   4              //disp_clock_start();                 /* start clock timer */
 269   4              print_state_play();                 /* display play icon */
 270   4              song_state = SONG_PLAY;
 271   4            }
 272   3            break;
 273   3          }
 274   2      
 275   2          case SONG_PLAY:
 276   2          {
 277   3           // printch(0x94,"播放  ");
 278   3            if (Feof() == TRUE)
 279   3            { 
 280   4                  Mp3_set_right_vol(0);
 281   4              Mp3_set_left_vol(0);
 282   4                  //printch(0x90,"结束  ");/* end of file reached */
 283   4              song_stop();                        /* stop playing song */
 284   4              //Fclose();
 285   4              loop = song_loop;
 286   4              song_state = SONG_NEXT;
 287   4                gl_key_press = FALSE;             /* no key usage */
 288   4              }
 289   3      
 290   3            if (gl_key_press)                     /* a key is pressed? */                                                                                               
 291   3            {
 292   4                  gl_key_press = FALSE;
 293   4              switch (gl_key)
 294   4              {
 295   5                case KEY_PAUSE:
 296   5                  Aud_song_pause();               /* suspend sample request */
 297   5                  disp_clock_stop();              /* suspend clock timer */

⌨️ 快捷键说明

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