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

📄 voice_task.lst

📁 基于AT89C51SND1的MP3的程序设计(包括播放mp3和录音功能)
💻 LST
📖 第 1 页 / 共 3 页
字号:
C51 COMPILER V7.06   VOICE_TASK                                                            05/05/2005 12:12:04 PAGE 1   


C51 COMPILER V7.06, COMPILATION OF MODULE VOICE_TASK
OBJECT MODULE PLACED IN voice_task.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE modules\voice\voice_task.c OPTIMIZE(7,SPEED) BROWSE INCDIR(.\modules\system
                    -;.\;.\;.\lib_refd) DEFINE(KEIL) DEBUG OBJECTEXTEND PRINT(.\voice_task.lst) OBJECT(voice_task.obj)

stmt level    source

   1          /*C**************************************************************************
   2          * NAME:         voice_task.c
   3          *----------------------------------------------------------------------------
   4          * Copyright (c) 2003 Atmel.
   5          *----------------------------------------------------------------------------
   6          * RELEASE:      snd1c-refd-nf-4_0_3      
   7          * REVISION:     1.13     
   8          *----------------------------------------------------------------------------
   9          * PURPOSE:
  10          * This file contains the voice task and attached routines
  11          *
  12          * NOTES:
  13          * Global Variables:
  14          *   - gl_key_press:   bit in bdata space
  15          *   - gl_key:         byte in idata space
  16          *   - voice_buffer:      array of bytes in pdata space
  17          *   - gl_pointer:     byte in data space
  18          *   - gl_wav_header:  wave structure in code
  19          *****************************************************************************/
  20          
  21          /*_____ I N C L U D E S ____________________________________________________*/
  22          
  23          #include "config.h"                         /* system configuration */
  24          #include "board.h"                          /* board definition */
  25          #include "modules\display\disp.h"           /* display definition */
  26          #include "modules\file\file.h"              /* file definition */
  27          #include "lib_mcu\clock\clock.h"            /* clock definition */
  28          #include "modules\mode\mode_task.h"         /* mode task definition */
  29          #include "modules\display\disp_task.h"      /* display definition */
  30          #include "modules\mem\mem_task.h"           /* memory task definition */
  31          #include "voice_drv.h"                      /* voice definition */
  32          #include "voice_task.h"                     /* voice task definition */
  33          #include "modules\file\wav.h"               /* wav file definition */
  34          
  35          
  36          /*_____ M A C R O S ________________________________________________________*/
  37          
  38          
  39          /*_____ D E F I N I T I O N ________________________________________________*/
  40          
  41          extern  bdata   bit     gl_key_press;       /* TRUE when a key is decoded */
  42          extern  idata   Byte    gl_key;             /* value of the key pressed */
  43          extern  bdata   bit     gl_mem_failure;     /* memory hardware failure */
  44          
  45          extern  data    Byte    gl_pointer;
  46          extern  code    wav_struct  gl_wav_header;
  47          
  48          static  idata   Byte    voice_state;        /* task state */
  49          
  50          xdata   Byte    voice_buffer[256];
  51          
  52          /*_____ D E C L A R A T I O N ______________________________________________*/
  53          
  54          
C51 COMPILER V7.06   VOICE_TASK                                                            05/05/2005 12:12:04 PAGE 2   

  55          /*F**************************************************************************
  56          * NAME: voice_task_init
  57          *----------------------------------------------------------------------------
  58          * PARAMS:
  59          *
  60          * return:
  61          *----------------------------------------------------------------------------
  62          * PURPOSE: 
  63          *   Voice task initialization
  64          *----------------------------------------------------------------------------
  65          * EXAMPLE:
  66          *----------------------------------------------------------------------------
  67          * NOTE:
  68          *----------------------------------------------------------------------------
  69          * REQUIREMENTS:
  70          *****************************************************************************/
  71          void voice_task_init (void)
  72          {
  73   1        voice_state = VOICE_START;
  74   1        Voc_init_volume();                            /* mid-range volume */
  75   1      }
  76          
  77          
  78          /*F**************************************************************************
  79          * NAME: voice_task
  80          *----------------------------------------------------------------------------
  81          * PARAMS:
  82          *
  83          * return:
  84          *----------------------------------------------------------------------------
  85          * PURPOSE: 
  86          *   Voice playing / recording task
  87          *----------------------------------------------------------------------------
  88          * EXAMPLE:
  89          *----------------------------------------------------------------------------
  90          * NOTE:
  91          *   STATES:
  92          *   VOICE_START      start task
  93          *   VOICE_INSTALL     voice installation
  94          *   VOICE_IDLE        idle state of this task
  95          *   VOICE_PLAY_INIT   initialisation of audio interface
  96          *   VOICE_PLAY        voice under playing
  97          *   VOICE_PLAY_PAUSE  voice playing halted
  98          *   VOICE_NEW         previous or next song handler
  99          *   VOICE_PLAY_STOP   stop playing
 100          *   VOICE_NO_MESSAGE  file system empty
 101          *   VOICE_REC_INIT    initialisation of A to D converter
 102          *   VOICE_RECORD      voice under recording
 103          *   VOICE_REC_PAUSE   voice recording halted
 104          *   VOICE_REC_STOP    stop recording
 105          *   VOICE_ERROR       error in playing or recording
 106          *----------------------------------------------------------------------------
 107          * REQUIREMENTS:
 108          *****************************************************************************/
 109          void voice_task (void)
 110          {
 111   1      Byte    i;
 112   1      static  Uint32  voc_cpt;
 113   1      xdata   char * file_name;
 114   1      xdata   char buff[12];
 115   1      
 116   1        switch (voice_state)
C51 COMPILER V7.06   VOICE_TASK                                                            05/05/2005 12:12:04 PAGE 3   

 117   1        {
 118   2          case VOICE_START:
 119   2          {
 120   3            print_mode_voice();                   /* select voice icon */
 121   3            print_state_blank();                  /* select blank icon */
 122   3            print_screen(VOICE_SCREEN);           /* display voice screen */
 123   3            print_voice_vol(Voc_get_volume());    /* display volume level */
 124   3            voice_state = VOICE_INSTALL;
 125   3            break;
 126   3          }
 127   2      
 128   2          case VOICE_INSTALL:
 129   2          {
 130   3            if (mem_status() != MEM_BUSY)         /* wait end of memory install */
 131   3            {
 132   4              if (mem_status() == MEM_READY)
 133   4              {
 134   5                if (File_entry_root(FILE_WAV) == OK)/* WAV file in root dir? */
 135   5                {
 136   6                  print_file_name();              /* display file name */
 137   6                  voice_state = VOICE_IDLE;
 138   6                }
 139   5                else
 140   5                { /* no *.wav file in root */
 141   6                  voice_state = VOICE_NO_MSG;
 142   6                }
 143   5              }
 144   4              else
 145   4              { /* disk not formated */
 146   5                print_state_error();              /* error icon when not formated */
 147   5                if (gl_key_press)                 /* a key is pressed? */
 148   5                {
 149   6                  switch (gl_key)
 150   6                  {
 151   7                    case KEY_MEM:
 152   7                      mem_select_next();          /* select next memory */
 153   7                      voice_state = VOICE_START;
 154   7                      break;
 155   7      
 156   7                    case KEY_MODE:
 157   7                      mode_set_init();            /* exit from song task */
 158   7                      voice_state = VOICE_START;
 159   7                      break;
 160   7                    }
 161   6                  gl_key_press = FALSE;           /* ack key usage */
 162   6                }
 163   5                else
 164   5                { /* check card presence */
 165   6                  if (mem_check_card() == KO)
 166   6                  {
 167   7                    mem_select_next();
 168   7                    voice_state = VOICE_START;    /* card has been unplugged */
 169   7                  }
 170   6                }
 171   5              }
 172   4            }
 173   3            break;
 174   3          }
 175   2      
 176   2      
 177   2          case VOICE_IDLE:                        /* no file openned */
 178   2          {
C51 COMPILER V7.06   VOICE_TASK                                                            05/05/2005 12:12:04 PAGE 4   

 179   3            if (gl_key_press)                     /* a key is pressed? */
 180   3            {
 181   4              switch (gl_key)
 182   4              {
 183   5                case KEY_PLAY:
 184   5                  voice_state = VOICE_PLAY_INIT;
 185   5                  break;
 186   5      
 187   5                case KEY_NEXT:
 188   5                  file_seek_next(FILE_WAV, TRUE); /* select next message with loop */
 189   5                  print_file_name();              /* display file name */
 190   5                  break;
 191   5      
 192   5                case KEY_PREV:
 193   5                  file_seek_prev(FILE_WAV, TRUE);       /* select previous message */
 194   5                  print_file_name();              /* display file name */
 195   5                  break;
 196   5      
 197   5                case KEY_REC:
 198   5                  voice_state = VOICE_REC_INIT;
 199   5                  break;
 200   5      
 201   5                case KEY_INC:
 202   5                  voc_inc_volume();               /* increment volume */
 203   5                  print_voice_vol(Voc_get_volume());  /* display new level */
 204   5                  break;
 205   5      
 206   5                case KEY_DEC:
 207   5                  voc_dec_volume();               /* decrement volume */
 208   5                  print_voice_vol(Voc_get_volume());  /* display new level */
 209   5                  break;
 210   5      
 211   5                case KEY_MODE:
 212   5                  mode_set_init();                /* exit from voice task */
 213   5                  disp_name_stop();
 214   5                  voice_state = VOICE_START;
 215   5                  break;
 216   5      
 217   5                case KEY_MEM:
 218   5                  mem_select_next();              /* select next memory */
 219   5                  disp_name_stop();
 220   5                  voice_state = VOICE_START;
 221   5                  break;
 222   5      
 223   5                default:
 224   5                  break;
 225   5              }
 226   4              gl_key_press = FALSE;               /* ack key usage */
 227   4            }

⌨️ 快捷键说明

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