📄 main.s
字号:
tst R20
breq L216
X81:
.dbline 511
ldi R24,16
std y+2,R24
ldi R24,<_ScreenStr12+416
ldi R25,>_ScreenStr12+416
std y+1,R25
std y+0,R24
clr R18
ldi R16,1
xcall _PrintConstAscStr
xjmp L217
L216:
.dbline 511
ldi R24,16
std y+2,R24
ldi R24,<_ScreenStr12+432
ldi R25,>_ScreenStr12+432
std y+1,R25
std y+0,R24
clr R18
ldi R16,1
xcall _PrintConstAscStr
L217:
.dbline 512
; Delay(800);
ldi R16,800
ldi R17,3
xcall _Delay
.dbline 513
; }
xjmp L213
L212:
.dbline 514
; else if(UsrSel==5) //快速歌曲定位
lds R24,_UsrSel
cpi R24,5
brne L220
X82:
.dbline 515
; {
.dbline 516
; ChangePlayPosition(pdata);
movw R16,R10
xcall _ChangePlayPosition
.dbline 517
; }
L220:
L213:
L211:
L209:
L201:
L193:
.dbline 518
; if(CurStatus==1) //播放器当前正在播放
lds R24,_CurStatus
cpi R24,1
brne L222
X83:
.dbline 519
; {
.dbline 520
; ClearLCD();
xcall _ClearLCD
.dbline 521
; DisplayNumInt(1,0,*pdata,3);PrintOneASCII(1,24,'/');
ldi R24,3
std y+2,R24
movw R30,R10
ldd R2,z+0
ldd R3,z+1
std y+1,R3
std y+0,R2
clr R18
ldi R16,1
xcall _DisplayNumInt
.dbline 521
ldi R24,47
std y+0,R24
ldi R18,24
ldi R16,1
xcall _PrintOneASCII
.dbline 522
; DisplayNumInt(1,32,DEF_MAX_SONGS,3);
ldi R24,3
std y+2,R24
lds R2,_DEF_MAX_SONGS
lds R3,_DEF_MAX_SONGS+1
std y+1,R3
std y+0,R2
ldi R18,32
ldi R16,1
xcall _DisplayNumInt
.dbline 523
; PrintConstAscStr(0,0,ScreenStr12[7],16); //显示"正在播放Mp3文件:"
ldi R24,16
std y+2,R24
ldi R24,<_ScreenStr12+112
ldi R25,>_ScreenStr12+112
std y+1,R25
std y+0,R24
clr R18
clr R16
xcall _PrintConstAscStr
.dbline 524
; PrintHZ16(Mp3FileName,buff,2,16,8);
ldi R24,8
std y+4,R24
ldi R24,16
std y+2,R24
ldi R24,2
std y+0,R24
ldi R18,<_buff
ldi R19,>_buff
ldi R16,<_Mp3FileName
ldi R17,>_Mp3FileName
xcall _PrintHZ16
.dbline 525
; }
L222:
.dbline 526
; ADC_Init(); //进行一次AD转换,测量电池电量,并且显示出来
xcall _ADC_Init
.dbline 527
; retry=ADC_Convert();
xcall _ADC_Convert
mov R10,R16
.dbline 528
; Display_BattVol(BattVolPic,retry);
mov R18,R10
ldi R16,<_BattVolPic
ldi R17,>_BattVolPic
xcall _Display_BattVol
xjmp L226
L225:
.dbline 530
; while(retry==0 && KeySt01!=0) //电量空,提醒用户充电
; {
.dbline 531
; PrintConstAscStr(7,16,Menustr6[6],13);
ldi R24,13
std y+2,R24
ldi R24,<_Menustr6+78
ldi R25,>_Menustr6+78
std y+1,R25
std y+0,R24
ldi R18,16
ldi R16,7
xcall _PrintConstAscStr
.dbline 532
; Delay(500);
ldi R16,500
ldi R17,1
xcall _Delay
.dbline 533
; ADC_Init(); //进行一次AD转换,测量电池电量,并且显示出来
xcall _ADC_Init
.dbline 534
; retry=ADC_Convert();
xcall _ADC_Convert
mov R12,R16
mov R10,R12
.dbline 535
; }
L226:
.dbline 529
tst R10
brne L229
X84:
in R20,0x16
andi R20,1
out 0x16,R20
tst R20
brne L225
X85:
L229:
.dbline 536
; SEI();//开中断
sei
.dbline -2
L155:
.dbline 0 ; func end
adiw R28,5
xjmp pop_xgset303C
.dbsym r retry 10 c
.dbsym r pdata 10 pi
.dbend
.dbfunc e main _main fV
; i -> R10
; i -> R10
; funret -> R10
; old_tmp -> R10,R11
; Dir_Attrib -> y+22
; Clustervar -> y+18
; flgover -> R10
; Lcdak -> R12
; tmp -> y+16
; Size -> y+12
; a -> y+8
; b -> R14,R15
; retry -> y+23
.even
_main::
sbiw R28,24
.dbline -1
.dbline 540
; }
;
; void main()
; {
.dbline 541
; unsigned char Dir_Attrib = 0,retry=0;
clr R2
std y+22,R2
.dbline 541
clr R0
std y+23,R0
.dbline 542
; unsigned long Size = 0;
ldi R20,0
ldi R21,0
ldi R22,0
ldi R23,0
std y+12,R20
std y+13,R21
std y+14,R22
std y+15,R23
.dbline 547
; unsigned long a;
; unsigned int b;
; unsigned int tmp,old_tmp;
; unsigned char flgover;
; unsigned char Lcdak=1;
clr R12
inc R12
.dbline 550
; unsigned long Clustervar; //找到字库文件的起始簇号
;
; MCUMode(10); //MCU不进入休眠模式
ldi R16,10
xcall _MCUMode
.dbline 551
; IniData_From_EEPROM(); //先读取一下E2Prom信息
xcall _IniData_From_EEPROM
.dbline 552
; LCD_AK_Control(Lcdak); //打开背光
mov R16,R12
xcall _LCD_AK_Control
.dbline 553
; LCD_Ini();
xcall _LCD_Ini
.dbline 554
; KeyIni();KeyInput(); //LCD,键盘初始化
in R24,0x18
ori R24,15
out 0x18,R24
.dbline 554
in R24,0x17
andi R24,240
out 0x17,R24
.dbline 555
; Delay(30);
ldi R16,30
ldi R17,0
xcall _Delay
.dbline 556
; ClearLCD();
xcall _ClearLCD
.dbline 557
; send_cmd(LCD_DISPLAY_NORMAL);
ldi R16,166
ldi R17,0
xcall _send_cmd
.dbline 558
; Display_Picture(MainUIPic); //显示开机画面
ldi R16,<_MainUIPic
ldi R17,>_MainUIPic
xcall _Display_Picture
.dbline 559
; Delay(1500);
ldi R16,1500
ldi R17,5
xcall _Delay
.dbline 561
;
; ClearLCD();
xcall _ClearLCD
.dbline 562
; ADC_Init(); //进行一次AD转换,测量电池电量,并且显示出来
xcall _ADC_Init
.dbline 563
; retry=ADC_Convert();
xcall _ADC_Convert
std y+23,R16
.dbline 564
; Display_BattVol(BattVolPic,retry);//显示ADC电量
mov R18,R16
ldi R16,<_BattVolPic
ldi R17,>_BattVolPic
xcall _Display_BattVol
xjmp L232
L231:
.dbline 566
; while(retry==0 && KeySt01!=0) //电量空,提醒用户充电
; {
.dbline 567
; CLI();
cli
.dbline 568
; PrintConstAscStr(7,16,Menustr6[6],13);
ldi R24,13
std y+2,R24
ldi R24,<_Menustr6+78
ldi R25,>_Menustr6+78
std y+1,R25
std y+0,R24
ldi R18,16
ldi R16,7
xcall _PrintConstAscStr
.dbline 569
; Delay(500);
ldi R16,500
ldi R17,1
xcall _Delay
.dbline 570
; ADC_Init(); //进行一次AD转换,测量电池电量,并且显示出来
xcall _ADC_Init
.dbline 571
; retry=ADC_Convert();
xcall _ADC_Convert
std y+23,R16
.dbline 572
; SEI();
sei
.dbline 573
; }
L232:
.dbline 565
ldd R0,y+23
tst R0
brne L235
X88:
in R24,0x16
andi R24,1
mov R10,R24
out 0x16,R24
tst R24
brne L231
X89:
L235:
.dbline 575
; //初始化VS1011B,准备播放
; SPI_CS_Deassert(); //PB2=1,释放MMC/SD卡
sbi 0x18,4
.dbline 576
; VS1011B_XRESET_H();//使能芯片 //chip select
sbi 0x1b,6
.dbline 577
; {
.dbline 579
; unsigned char funret;
; funret=VS1011B_Init();
xcall _VS1011B_Init
mov R10,R16
.dbline 580
; Delay(10);
ldi R16,10
ldi R17,0
xcall _Delay
.dbline 581
; if(funret>0) //初始化VS1011B,失败
ldi R24,0
cp R24,R10
brsh L236
X90:
.dbline 582
; {
.dbline 583
; ClearLCD();
xcall _ClearLCD
.dbline 584
; PrintConstAscStr(3,0,ScreenStr12[8],16);
ldi R24,16
std y+2,R24
ldi R24,<_ScreenStr12+128
ldi R25,>_ScreenStr12+128
std y+1,R25
std y+0,R24
clr R18
ldi R16,3
xcall _PrintConstAscStr
.dbline 585
; DisplayNumChar(1,2,funret,3);
ldi R24,3
std y+2,R24
std y+0,R10
ldi R18,2
ldi R16,1
xcall _DisplayNumChar
L239:
.dbline 586
; while(1) ;
L240:
.dbline 586
xjmp L239
L236:
.dbline 588
; }
; }
.dbline 590
; //显示正在读取MMC卡
; PrintConstAscStr(3,0,ScreenStr12[1],16);
ldi R24,16
std y+2,R24
ldi R24,<_ScreenStr12+16
ldi R25,>_ScreenStr12+16
std y+1,R25
std y+0,R24
clr R18
ldi R16,3
xcall _PrintConstAscStr
.dbline 592
; //打开LM4906_Speaker:
; DDRA&=~BIT(4);//端口A的第4位设置为输出
cbi 0x1a,4
.dbline 593
; PORTA|=BIT(4);//端口A的第4位输出高电平
sbi 0x1b,4
.dbline 595
; //关闭Vs1011b,返回到MMC_SD_SPI模式
; VS1011B_DDR |= BIT(VS1011B_XCS)|BIT(VS1011B_XRESET); //XCS,XDCS=1
in R24,0x1a
ori R24,66
out 0x1a,R24
.dbline 596
; VS1011B_DISABLE();
in R24,0x1b
ori R24,3
out 0x1b,R24
.dbline 597
; MMC_SD_Init();//初始化MMC_SD_spi口
xcall _MMC_SD_Init
.dbline 598
; Delay(1500);
ldi R16,1500
ldi R17,5
xcall _Delay
xjmp L244
L243:
.dbline 600
; while(MMC_SD_Reset())//复位SD卡,失败会retry++;
; {
.dbline 601
; retry++;
ldd R0,y+23
inc R0
std y+23,R0
.dbline 602
; if(retry>20) //超时,显示失败
ldi R24,20
cp R24,R0
brsh L246
X91:
.dbline 603
; {
.dbline 604
; ClearLCD();
xcall _ClearLCD
.dbline 605
; PrintConstAscStr(3,0,ScreenStr12[0],16);
ldi R24,16
std y+2,R24
ldi R24,<_ScreenStr12
ldi R25,>_ScreenStr12
std y+1,R25
std y+0,R24
clr R18
ldi R16,3
xcall _PrintConstAscStr
.dbline 606
; Delay(500);
ldi R16,500
ldi R17,1
xcall _Delay
L248:
.dbline 607
; while(MMC_SD_Reset()==1) ; //直到插入SD卡为止.
L249:
.dbline 607
xcall _MMC_SD_Reset
mov R10,R16
cpi R16,1
breq L248
X92:
.dbline 608
; }
L246:
.dbline 609
; }
L244:
.dbline 599
xcall _MMC_SD_Reset
mov R10,R16
tst R16
brne L243
X93:
.dbline 611
;
; Clustervar=fat_root_dir_addr(buff); //获取FDT.
ldi R16,<_buff
ldi R17,>_buff
xcall _fat_root_dir_addr
std y+18,R16
std y+19,R17
std y+20,R18
std y+21,R19
.dbline 614
;
; //获取字库文件的第一个簇,第二个0参数,表明要寻找字库文件
; FONT_ClusterVar = fat_read_dir_ent(0,0,&Size,&Dir_Attrib,buff);
ldi R24,<_buff
ldi R25,>_buff
std y+7,R25
std y+6,R24
movw R24,R28
adiw R24,22
std y+5,R25
std y+4,R24
movw R24,R28
adiw R24,12
std y+3,R25
std y+2,R24
clr R2
clr R3
std y+1,R3
std y+0,R2
ldi R16,0
ldi R17,0
ldi R18,0
ldi R19,0
xcall _fat_read_dir_ent
sts _FONT_ClusterVar+1,R17
sts _FONT_ClusterVar,R16
sts _FONT_ClusterVar+2+1,R19
sts _FONT_ClusterVar+2,R18
.dbline 615
; if (FONT_ClusterVar == 0xFFFFFFFF) //出错,退出返回
ldi R20,255
ldi R21,255
ldi R22,255
ldi R23,255
cp R16,R20
cpc R17,R21
cpc R18,R22
cpc R19,R23
brne L251
X94:
.dbline 616
; {
.dbline 618
; //测试用代码:
; ClearLCD();
xcall _ClearLCD
.dbline 619
; Display_BattVol(BattVolPic,retry);//显示ADC电量
ldd R18,y+23
ldi R16,<_BattVolPic
ldi R17,>_BattVolPic
xcall _Display_BattVol
.dbline 620
; PrintConstAscStr(3,0,ScreenStr12[2],16);
ldi R24,16
std y+2,R24
ldi R24,<_ScreenStr12+32
ldi R25,>_ScreenStr12+32
std y+1,R25
std y+0,R24
clr R18
ldi R16,3
xcall _PrintConstAscStr
.dbline 621
; Delay(1000);
ldi R16,1000
ldi R17,3
xcall _Delay
.dbline 622
; return ;
xjmp L230
L251:
.dbline 623
; }else if(FONT_ClusterVar == 0xFFFFFFFE) //根目录下的文件已经搜索完,返回
ldi R20,254
ldi R21,255
ldi R22,255
ldi R23,255
lds R4,_FONT_ClusterVar+2
lds R5,_FONT_ClusterVar+2+1
lds R2,_FONT_ClusterVar
lds R3,_FONT_ClusterVar+1
cp R2,R20
cpc R3,R21
cpc R4,R22
cpc R5,R23
brne L254
X95:
.dbline 624
; {
.dbline 626
; //测试用代码:
; ClearLCD();
xcall _ClearLCD
.dbline 627
; Display_BattVol(BattVolPic,retry);//显示ADC电量
ldd R18,y+23
ldi R16,<_BattVolPic
ldi R17,>_BattVolPic
xcall _Display_BattVol
.dbline 628
; PrintConstAscStr(3,0,ScreenStr12[3],16);
ldi R24,16
std y+2,R24
ldi R24,<_ScreenStr12+48
ldi R25,>_ScreenStr12+48
std y+1,R25
std y+0,R24
clr R18
ldi R16,3
xcall _PrintConstAscStr
.dbline 629
; Delay(1000);
ldi R16,1000
ldi R17,3
xcall _Delay
.dbline 630
; return ;
xjmp L230
L254:
.dbline 642
; }
;
; //以后就可以使用该汉字字库了,下面是一个测试
; //ClearLCD();
; //PrintConstHZ16(ScreenStr12[10],buff,3,0,16);
; //Delay(1500);
; //显示主菜单,并选择
; //MainMenu();
;
; ////////////////////////////////////////
; //开始进行Mp3文件的搜索与读取:
; fat_root_dir_addr(buff); //获取FDT.
ldi R16,<_buff
ldi R17,>_buff
xcall _fat_root_dir_addr
xjmp L258
L257:
.dbline 645
; //////第一次将根目录下的所有Mp3文件都扫描一遍,获取歌曲的数目:
; while(1)
; {
.dbline 646
; for (tmp = 1;tmp < 999;tmp++)
ldi R24,1
ldi R25,0
std y+17,R25
std y+16,R24
xjmp L263
L260:
.dbline 647
; {
.dbline 648
; Clustervar = fat_read_dir_ent(0,tmp,&Size,&Dir_Attrib,buff);
ldi R24,<_buff
ldi R25,>_buff
std y+7,R25
std y+6,R24
movw R24,R28
adiw R24,22
std y+5,R25
std y+4,R24
movw R24,R28
adiw R24,12
std y+3,R25
std y+2,R24
ldd R2,y+16
ldd R3,y+17
std y+1,R3
std y+0,R2
ldi R16,0
ldi R17,0
ldi R18,0
ldi R19,0
xcall _fat_read_dir_ent
std y+18,R16
std y+19,R17
std y+20,R18
std y+21,R19
.dbline 652
; ////测试使用:
; //DisplayLong(Clustervar,1);
; //
; if (Clustervar == 0xFFFFFFFF) //出错,退出返回
ldi R20,255
ldi R21,255
ldi R22,255
ldi R23,255
ldd R2,y+18
ldd R3,y+19
ldd R4,y+20
ldd R5,y+21
cp R2,R20
cpc R3,R21
cpc R4,R22
cpc R5,R23
brne L264
X96:
.dbline 653
; {
.dbline 654
; DEF_MAX_SONGS=0;
clr R2
clr R3
sts _DEF_MAX_SONGS+1,R3
sts _DEF_MAX_SONGS,R2
.dbline 655
;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -