📄 song_task.lst
字号:
C51 COMPILER V7.50 SONG_TASK 02/16/2009 09:59:55 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE SONG_TASK
OBJECT MODULE PLACED IN song_task.obj
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE modules\song\song_task.c LARGE OPTIMIZE(0,SPEED) BROWSE DEBUG OBJECTEXTEND
-PRINT(.\song_task.lst) OBJECT(song_task.obj)
line level source
1
2 #include "config.h" /* system configuration */
3 #include "lib_mcu\lcd\lcd_drv.h"
4 #include "modules\file\file.h" /* file definition */
5 #include "lib_mcu\clock\clock.h" /* clock definition */
6 #include "lib_mcu\kbd\key_drv.h"
7 #include "lib_mcu\aud\aud_drv.h" /* audio driver definition */
8 #include "lib_mcu\mp3\mp3_drv.h" /* mp3 driver definition */
9 #include "song_drv.h" /* song driver definition */
10 #include "song_task.h" /* song task definition */
11 #include "lib_mcu\remote\remote_drv.h"
12 #include "modules\display\disp_task.h"
13
14
15 extern bdata bit gl_key_press; /* TRUE when a key is decoded */
16 extern Byte gl_key; /* value of the key pressed */
17 extern bit led_flush;
18 Byte song_state; /* task state */
19 static bit song_loop; /* auto replay */
20 extern Byte mp3_volume;
21
22 sbit LED_RED = P1 ^ 4;
23 sbit LED_GREEN = P1 ^ 5;
24
25
26
27 /////////////////////////////////////////////////////////////////////////////////
28 void song_task_init (void)
29 {
30 1 key_song_task_init();
31 1 song_loop = PLAYER_PLAY_LOOP; /* default loop playing */
32 1 song_snd_init(); /* init sound control */
33 1 song_state = SONG_START;
34 1 }
35
36 /////////////////////////////////////////////////////////////////////////////////
37 void song_request_data(void)
38 {
39 1 Byte cpt_data;
40 1
41 1 if (Mp3_frame_request())
42 1 {
43 2 cpt_data = 0;
44 2 do
45 2 {
46 3 Mp3_load(Fgetc()); //send data while requested
47 3 cpt_data++;
48 3 // workaround for 320Kbs frame support
49 3 if ((cpt_data & 0x40) == 0x40)
50 3 {
51 4 Mp3_set_full();
52 4 Mp3_reset_full(); // ack 64 Bytes write
53 4 break;
54 4 }
C51 COMPILER V7.50 SONG_TASK 02/16/2009 09:59:55 PAGE 2
55 3 }
56 2 while (Mp3_frame_request()); // until frame request
57 2
58 2 while (Mp3_frame_request()) // frame request ?
59 2 {
60 3 Mp3_load(Fgetc()); // send data while requested
61 3 }
62 2 }
63 1
64 1 }
65
66
67
68 /////////////////////////////////////////////////////////////////////////////////
69 void song_task (void)
70 {
71 1 bit loop;
72 1
73 1 song_request_data();
74 1
75 1 switch (song_state)
76 1 {
77 2 case SONG_START:
78 2 {
79 3 print_sound_level(); /* display volume level */
80 3 song_state = SONG_INSTALL;
81 3 break;
82 3 }
83 2
84 2 case SONG_INSTALL:
85 2 {
86 3 if (File_entry_root(FILE_MP3 | FILE_DIR) == OK) /* goto root directory */
87 3 {
88 4 print_file_name(); /* display file name */
89 4
90 4 #if PLAYER_PLAY_START == START_STOP
//------------------------------------------------------------------<<<<<<<<
song_state = SONG_IDLE;
//------------------------------------------------------------------<<<<<<<<
#else
95 4 //------------------------------------------------------------------<<<<<<<<
96 4 if (File_type() == FILE_DIR)
97 4 { /* file_type is dir */
98 5 #if PLAYER_PLAY_MODE == PLAY_DISK
99 5 song_state = SONG_NEW; /* enter dir and play */
100 5 #else
song_state = SONG_NEXT; /* stay in root dir */
#endif
103 5 }
104 4 else
105 4 { /* file_type is MP3 */
106 5 song_state = SONG_INIT;
107 5 }
108 4 //------------------------------------------------------------------<<<<<<<<
109 4 #endif
110 4 }
111 3 else
112 3 { /* root is empty of song & diretory */
113 4 song_state = SONG_NO_SONG;
114 4 }
115 3
116 3 break;
C51 COMPILER V7.50 SONG_TASK 02/16/2009 09:59:55 PAGE 3
117 3 }
118 2
119 2
120 2 case SONG_IDLE: /* no file openned */
121 2 {
122 3 if (gl_key_press) /* a key is pressed? */
123 3 {
124 4 switch (gl_key)
125 4 {
126 5 case KEY_PLAY:
127 5 if (File_type() == FILE_DIR)
128 5 {
129 6 file_entry_dir(FILE_MP3 | FILE_DIR); /* goto sub-directory */
130 6 print_file_name(); /* display directory name */
131 6 }
132 5 else
133 5 { /* file_type is MP3 */
134 6 song_state = SONG_INIT;
135 6 }
136 5 break;
137 5
138 5 case KEY_NEXT:
139 5 file_seek_next(FILE_MP3 | FILE_DIR, TRUE); /* select next song with loop */
140 5 print_file_name(); /* display file name */
141 5 break;
142 5
143 5 case KEY_PREV:
144 5 file_seek_prev(FILE_MP3 | FILE_DIR, TRUE); /* select previous song */
145 5 print_file_name(); /* display file name */
146 5 break;
147 5
148 5 case KEY_INC:
149 5 song_snd_inc(); /* increment selected control */
150 5 print_sound_level(); /* display new level */
151 5 break;
152 5
153 5 case KEY_DEC:
154 5 song_snd_dec(); /* decrement selected control */
155 5 print_sound_level(); /* display new level */
156 5 break;
157 5
158 5 // case KEY_SOUND:
159 5 // song_snd_select(); /* select next sound control */
160 5 // print_sound(); /* display selected sound icon */
161 5 // print_sound_level(); /* display new level */
162 5 // break;
163 5
164 5 case KEY_PARENT:
165 5 File_goto_parent(FILE_MP3 | FILE_DIR); /* goto parent directory */
166 5 print_file_name(); /* display first file name */
167 5 break;
168 5
169 5 default:
170 5 break;
171 5 }
172 4 gl_key_press = FALSE; /* ack key usage */
173 4 }
174 3 break;
175 3 }
176 2
177 2
178 2 case SONG_INIT:
C51 COMPILER V7.50 SONG_TASK 02/16/2009 09:59:55 PAGE 4
179 2 {
180 3 disp_clock_reset(); /* reset clock timer */
181 3 if (Fopen(READ) == OK)
182 3 {
183 4 if (song_init() != SONG_NO_ERR) /* init song playing */
184 4 {
185 5 song_stop(); /* stop playing song */
186 5 Fclose();
187 5 loop = song_loop;
188 5 song_state = SONG_NEXT;
189 5 }
190 4 else
191 4 {
192 5 song_audio_init(); /* init audio interface */
193 5 // clock_song_init();
194 5 song_state = SONG_PLL;
195 5 }
196 4 }
197 3 else
198 3 {
199 4 song_state = SONG_ERROR;
200 4 }
201 3 break;
202 3 }
203 2
204 2
205 2 case SONG_PLL:
206 2 {
207 3 if (Pll_get_lock()) /* pll locked? */
208 3 {
209 4 song_start(); /* start playing song */
210 4 disp_clock_start(); /* start clock timer */
211 4 print_state_play(); /* display play icon */
212 4 song_state = SONG_PLAY;
213 4 }
214 3 break;
215 3 }
216 2
217 2 case SONG_PLAY:
218 2 {
219 3 if(led_flush)
220 3 {
221 4 LED_RED = 1;
222 4 LED_GREEN = ~LED_GREEN;
223 4 led_flush = 0;
224 4 }
225 3
226 3 if (Feof() == TRUE)
227 3 {
228 4 song_stop(); /* stop playing song */
229 4 Fclose();
230 4 loop = song_loop;
231 4 song_state = SONG_NEXT;
232 4 gl_key_press = FALSE; /* no key usage */
233 4 }
234 3
235 3 if (gl_key_press) /* a key is pressed? */
236 3 {
237 4 gl_key_press = FALSE;
238 4 switch (gl_key)
239 4 {
240 5 case KEY_PLAY:
C51 COMPILER V7.50 SONG_TASK 02/16/2009 09:59:55 PAGE 5
241 5 Aud_song_pause(); /* suspend sample request */
242 5 disp_clock_stop(); /* suspend clock timer */
243 5 print_state_pause(); /* display pause icon */
244 5 song_state = SONG_PAUSE;
245 5 break;
246 5
247 5 case KEY_NEXT:
248 5 song_pause(); /* pause playing song */
249 5 disp_clock_stop(); /* suspend clock timer */
250 5 Fclose();
251 5 loop = TRUE; /* keypad action so loop */
252 5 song_state = SONG_NEXT;
253 5 break;
254 5
255 5 case KEY_PREV:
256 5 song_pause(); /* pause playing song */
257 5 disp_clock_stop(); /* suspend clock timer */
258 5 Fclose();
259 5 loop = TRUE;
260 5 song_state = SONG_PREV;
261 5 break;
262 5
263 5 case KEY_INC:
264 5 song_snd_inc(); /* increment selected control */
265 5 print_sound_level(); /* display new level */
266 5 break;
267 5
268 5 case KEY_DEC:
269 5 song_snd_dec(); /* decrement selected control */
270 5 print_sound_level(); /* display new level */
271 5 break;
272 5
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -