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

📄 sta013.s

📁 LED条屏显示程序,但是对初学者
💻 S
📖 第 1 页 / 共 5 页
字号:
; 0x26, 0x80, 0x27, 0x10, 0x28, 0xd4, 0x21, 0x10, 0x23, 0x63, 
; 0x26, 0x2a, 0x27, 0x00, 0x28, 0xd5, 0x21, 0x00, 0x23, 0x60, 
; 0x26, 0xa8, 0x27, 0x12, 0x28, 0xd6, 0x21, 0xaf, 0x22, 0x4c, 
; 0x23, 0x00, 0x26, 0xc8, 0x27, 0x0c, 0x28, 0xd7, 0x21, 0x00, 
; 0x22, 0x00, 0x26, 0x80, 0x27, 0x05, 0x28, 0xd8, 0x23, 0x80, 
; 0x24, 0x86, 0x25, 0x3b, 0x26, 0x1e, 0x27, 0x00, 0x28, 0xd9, 
; 0x20, 0x42, 0x21, 0x1c, 0x22, 0x0e, 0x23, 0x00, 0x24, 0x80, 
; 0x25, 0x07, 0x28, 0xda, 0x20, 0x00, 0x21, 0x35, 0x22, 0x29, 
; 0x26, 0xc4, 0x27, 0x0c, 0x28, 0xdb, 0x20, 0x02, 0x21, 0x1d, 
; 0x22, 0x0e, 0x26, 0x1e, 0x27, 0x00, 0x28, 0xdc, 0x20, 0x00, 
; 0x21, 0x7f, 0x22, 0x34, 0x26, 0xc4, 0x27, 0x0c, 0x28, 0xdd, 
; 0x21, 0x00, 0x22, 0x00, 0x23, 0x90, 0x24, 0x9f, 0x25, 0x04, 
; 0x26, 0x10, 0x27, 0x0a, 0x28, 0xde, 0x23, 0x00, 0x24, 0x84, 
; 0x25, 0x00, 0x26, 0x80, 0x27, 0x10, 0x28, 0xdf, 0x21, 0x06, 
; 0x23, 0x63, 0x24, 0x80, 0x25, 0x07, 0x26, 0x2a, 0x27, 0x00, 
; 0x28, 0xe0, 0x21, 0x00, 0x23, 0x80, 0x24, 0x89, 0x26, 0xaa, 
; 0x27, 0x0a, 0x28, 0xe1, 0x20, 0x05, 0x23, 0x84, 0x26, 0xb4, 
; 0x27, 0x09, 0x28, 0xe2, 0x20, 0x70, 0x21, 0x61, 0x22, 0xb8, 
; 0x23, 0x95, 0x26, 0x12, 0x27, 0x08, 0x28, 0xe3, 0x20, 0x00, 
; 0x21, 0x01, 0x22, 0x00, 0x23, 0x80, 0x24, 0x86, 0x25, 0xc3, 
; 0x26, 0xab, 0x27, 0x0a, 0x28, 0xe4, 0x20, 0x42, 0x21, 0xce, 
; 0x22, 0x0f, 0x24, 0x89, 0x25, 0x07, 0x26, 0xaa, 0x28, 0xe5, 
; 0x20, 0x70, 0x21, 0x50, 0x22, 0xb8, 0x23, 0x95, 0x26, 0x12, 
; 0x27, 0x08, 0x28, 0xe6, 0x20, 0x05, 0x21, 0x00, 0x22, 0x00, 
; 0x23, 0x84, 0x26, 0xb4, 0x27, 0x09, 0x28, 0xe7, 0x20, 0x70, 
; 0x21, 0x64, 0x22, 0xb8, 0x23, 0x95, 0x26, 0x12, 0x27, 0x08, 
; 0x28, 0xe8, 0x20, 0x00, 0x21, 0x01, 0x22, 0x00, 0x23, 0x80, 
; 0x24, 0x86, 0x25, 0xc3, 0x26, 0xab, 0x27, 0x0a, 0x28, 0xe9, 
; 0x20, 0x42, 0x21, 0xd3, 0x22, 0x0f, 0x24, 0x89, 0x25, 0x07, 
; 0x26, 0xaa, 0x28, 0xea, 0x20, 0x70, 0x21, 0x51, 0x22, 0xb8, 
; 0x23, 0x95, 0x26, 0x12, 0x27, 0x08, 0x28, 0xeb, 0x20, 0x05, 
; 0x21, 0x00, 0x22, 0x00, 0x23, 0x84, 0x26, 0xb4, 0x27, 0x09, 
; 0x28, 0xec, 0x20, 0x70, 0x21, 0x65, 0x22, 0xb8, 0x23, 0x95, 
; 0x26, 0x12, 0x27, 0x08, 0x28, 0xed, 0x20, 0x00, 0x21, 0x01, 
; 0x22, 0x00, 0x23, 0x80, 0x24, 0x86, 0x25, 0xc3, 0x26, 0xab, 
; 0x27, 0x0a, 0x28, 0xee, 0x20, 0x42, 0x21, 0xd8, 0x22, 0x0f, 
; 0x24, 0x89, 0x25, 0x07, 0x26, 0xaa, 0x28, 0xef, 0x20, 0x70, 
; 0x21, 0x52, 0x22, 0xb8, 0x23, 0x95, 0x26, 0x12, 0x27, 0x08, 
; 0x28, 0xf0, 0x20, 0x05, 0x21, 0x00, 0x22, 0x00, 0x23, 0x84, 
; 0x26, 0xb4, 0x27, 0x09, 0x28, 0xf1, 0x20, 0x70, 0x21, 0x61, 
; 0x22, 0xb8, 0x23, 0x95, 0x26, 0x02, 0x27, 0x08, 0x28, 0xf2, 
; 0x20, 0x00, 0x21, 0x01, 0x22, 0x00, 0x23, 0x80, 0x24, 0x86, 
; 0x25, 0xc3, 0x26, 0xab, 0x27, 0x0a, 0x28, 0xf3, 0x20, 0x42, 
; 0x21, 0xdd, 0x22, 0x0f, 0x24, 0x89, 0x25, 0x07, 0x26, 0xaa, 
; 0x28, 0xf4, 0x20, 0x70, 0x21, 0x50, 0x22, 0xb8, 0x23, 0x95, 
; 0x26, 0x02, 0x27, 0x08, 0x28, 0xf5, 0x20, 0x05, 0x21, 0x00, 
; 0x22, 0x00, 0x23, 0x84, 0x26, 0xb4, 0x27, 0x09, 0x28, 0xf6, 
; 0x20, 0x00, 0x21, 0x01, 0x23, 0x80, 0x24, 0x86, 0x25, 0xcb, 
; 0x26, 0xab, 0x27, 0x0a, 0x28, 0xf7, 0x20, 0x42, 0x21, 0xe1, 
; 0x22, 0x0f, 0x24, 0x89, 0x25, 0x07, 0x26, 0xaa, 0x28, 0xf8, 
; 0x20, 0x00, 0x21, 0x02, 0x22, 0x00, 0x23, 0x00, 0x24, 0x81, 
; 0x25, 0xc4, 0x26, 0xab, 0x28, 0xf9, 0x21, 0x00, 0x23, 0x80, 
; 0x24, 0x89, 0x25, 0x48, 0x26, 0xaa, 0x28, 0xfa, 0x20, 0x05, 
; 0x23, 0x84, 0x25, 0x07, 0x26, 0xb4, 0x27, 0x09, 0x28, 0xfb, 
; 0x20, 0x70, 0x21, 0x4e, 0x22, 0xb8, 0x23, 0x95, 0x26, 0x10, 
; 0x27, 0x08, 0x28, 0xfc, 0x20, 0x00, 0x21, 0x00, 0x22, 0x00, 
; 0x23, 0x80, 0x24, 0x86, 0x25, 0xc3, 0x26, 0xab, 0x27, 0x0a, 
; 0x28, 0xfd, 0x20, 0x42, 0x21, 0xe7, 0x22, 0x0f, 0x24, 0x89, 
; 0x25, 0x07, 0x26, 0xaa, 0x28, 0xfe, 0x20, 0x00, 0x21, 0xbb, 
; 0x22, 0x00, 0x23, 0x95, 0x26, 0x20, 0x27, 0x00, 0x28, 0xff, 
; 0x20, 0x05, 0x21, 0x00, 0x23, 0x84, 0x26, 0xb4, 0x27, 0x09, 
; 0x2a, 0x08, 0x10, 0x01, 0x3a, 0x00, 0x64, 0x3a, 0x65, 0xbb, 
; 0x08, 0x3a, 0x09, 0xbb, 0x50, 0x10, 0x52, 0x67, 0x51, 0x77, 
; 0x05, 0xa1, 0x18, 0x04, 0xff, 0xff
;    };
; /*
; const uint8 BassTrebleTable[8][6]= 
; {  // TRLow   TRHigh   BSLow   BSHigh   TEhnc   BSEnhc          
;       {0x40, 0x1F,   70,   0,      0x00,   0x00},  // Normal 
;       {0x58, 0x1B,   100,  0,      0x06,   0x0C}, // HiBS, HiTrbl 
;       {0xE8, 0x03,   0x58, 0x02,   0x06,   0x09}, // HiVocal 
;       {0x58, 0x1B,   100,  0,      0xF7,   0xF7}, // LowBS, LowTrbl, LowVocal 
;       {0x58, 0x1B,   70,   0,      0xF7,   0x0C}, // HiBs, LowTrbl 
;       {0x58, 0x1B,   70,   0,      0x06,   0xF7}, // LowBs, HiTrbl 
;       {0xE8, 0x03,   0x58, 0x02,   0x06,   0xF7}, // LowMidBS, HiMidTrbl 
;       {0xE8, 0x03,   0x58, 0x02,   0xF7,   0x06}, // HiMidBS, LowMidTrbl 
; };  
; */                      
; 
; 
; 
; //初始化端口
; void STA013_Ini(void)
; {
	.dbline 437
; 	DDRA|=(1<<RST);			                //RST为输出
	sbi 0x1a,1
	.dbline 438
; 	DDRA|=(1<<STA013_Chip_Select);		    //STA013_Chip_Select为输出
	sbi 0x1a,3
	.dbline 440
; 	
;     STA013_Disable();
	cbi 0x1b,3
	.dbline 440
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e sta_Init _sta_Init fc
	.even
_sta_Init::
	.dbline -1
	.dbline 446
; 
; }   
;    
; //STA013初始化
; uint8 sta_Init(void)
; {   
	.dbline 448
; 	//复位
; 	sta_Reset();
	xcall _sta_Reset
	.dbline 451
; 
; 	//识别STA013
; 	if(sta_ReadDevice(STA_REG_IDENT,device1) != STA_IDENT)
	ldi R18,134
	ldi R16,1
	xcall _sta_ReadDevice
	cpi R16,172
	breq L3
	.dbline 452
; 	{   
	.dbline 453
; 		return 1;
	ldi R16,1
	xjmp L2
L3:
	.dbline 457
; 	}
;     
; 	//配置STA013
; 	sta_DownloadUpdate();
	xcall _sta_DownloadUpdate
	.dbline 459
; 	
; 	sta_StartDecoder();
	xcall _sta_StartDecoder
	.dbline 460
; 	return 0;
	clr R16
	.dbline -2
L2:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e sta_Reset _sta_Reset fV
	.even
_sta_Reset::
	.dbline -1
	.dbline 467
; } 
; 
; 
; //=======================================================================
; //STA013复位
; void sta_Reset(void)
; {
	.dbline 468
; 	PORTA|=1<<RST;        	//RST低为复位
	sbi 0x1b,1
	.dbline 469
; 	PORTA&=~(1<<RST);
	cbi 0x1b,1
	.dbline 470
; 	Delay_us(1200);
	ldi R16,1200
	ldi R17,4
	xcall _Delay_us
	.dbline 471
; 	PORTA|=1<<RST;  
	sbi 0x1b,1
	.dbline -2
L5:
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e sta_DownloadUpdate _sta_DownloadUpdate fV
;              i -> R20,R21
	.even
_sta_DownloadUpdate::
	xcall push_gset1
	sbiw R28,1
	.dbline -1
	.dbline 477
; }
; //=======================================================================
; 
; //写配置文件
; void sta_DownloadUpdate(void)
; {   
	.dbline 479
; 	unsigned int i;
; 	i = 0; 
	clr R20
	clr R21
L7:
	.dbline 481
;     do 
;      {
	.dbline 482
; 	  i2c_Write(STA013_UpdateData[i],device1, STA013_UpdateData[i+1]);
	ldi R24,<_STA013_UpdateData
	ldi R25,>_STA013_UpdateData
	movw R30,R20
	adiw R30,1
	add R30,R24
	adc R31,R25
	lpm R30,Z
	std y+0,R30
	ldi R18,134
	movw R30,R20
	add R30,R24
	adc R31,R25
	lpm R16,Z
	xcall _i2c_Write
	.dbline 484
; 	  
;       i+=2;
	subi R20,254  ; offset = 2
	sbci R21,255
	.dbline 485
; 	 }
L8:
	.dbline 486
; 	while(STA013_UpdateData[i] != 0xff); 
	ldi R24,<_STA013_UpdateData
	ldi R25,>_STA013_UpdateData
	movw R30,R20
	add R30,R24
	adc R31,R25
	lpm R30,Z
	cpi R30,255
	brne L7
	.dbline -2
L6:
	adiw R28,1
	xcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 i
	.dbend
	.dbfunc e sta_StartDecoder _sta_StartDecoder fV
	.even
_sta_StartDecoder::
	sbiw R28,1
	.dbline -1
	.dbline 516
; }
; /*
; //=======================================================================
; //设置音调
; void sta_SetTone(uint8 bassEnh,uint16 bassFreq, uint8 trebleEnh, uint16 trebleFreq)
; {
; 	//设置低音增益
; 	i2c_Write(STA_REG_BASS_FREQUENCY_LOW,device1,  (bassFreq   ) & 0xFF );
; 	i2c_Write(STA_REG_BASS_FREQUENCY_HIGH,device1, (bassFreq>>8) & 0xFF );
; 	//注意界限
; 	bassEnh = MIN(bassEnh,MAX_BASS_ENHANCE);
; 	bassEnh = MAX(bassEnh,MIN_BASS_ENHANCE);
; 	i2c_Write(STA_REG_BASS_ENHANCE,device1, bassEnh);
; 
; 	//设置高音增益
; 	i2c_Write(STA_REG_TREBLE_FREQUENCY_LOW,device1,  (trebleFreq   ) & 0xFF );
; 	i2c_Write(STA_REG_TREBLE_FREQUENCY_HIGH,device1, (trebleFreq>>8) & 0xFF );
; 	//注意界限
; 	trebleEnh = MIN(trebleEnh,MAX_TREBLE_ENHANCE);
; 	trebleEnh = MAX(trebleEnh,MIN_TREBLE_ENHANCE);
; 	i2c_Write(STA_REG_TREBLE_ENHANCE,device1, trebleEnh);
; 
; 	//
; 	i2c_Write( STA_REG_TONE_ATTEN,device1, MAX(bassEnh,trebleEnh) );
; }
; */
; //=======================================================================
; //配置STA013并开始解压
; void sta_StartDecoder(void)
; {
	.dbline 518
; 	//静音
; 	i2c_Write(STA_REG_MUTE,device1,				0x01);
	ldi R24,1
	std y+0,R24
	ldi R18,134
	ldi R16,20
	xcall _i2c_Write
	.dbline 521
; 	
; 	//软件复位
; 	i2c_Write(STA_REG_SOFT_RESET,device1,		0x01);
	ldi R24,1
	std y+0,R24
	ldi R18,134
	ldi R16,16
	xcall _i2c_Write
	.dbline 524
; 	
; 	// 配置DAC输出--Configure PLL for MP3 rates
; 	i2c_Write(STA_REG_PCMDIVIDER,device1,		0x02);	// 32-bit mode, O_FAC = 384
	ldi R24,2
	std y+0,R24
	ldi R18,134
	ldi R16,84
	xcall _i2c_Write
	.dbline 525
; 	i2c_Write(STA_REG_PCMCONF,device1,			0x33);	// 24-bit mode 
	ldi R24,51
	std y+0,R24
	ldi R18,134
	ldi R16,85
	xcall _i2c_Write
	.dbline 528
; 
; 	//配置PLL
; 	i2c_Write(STA_REG_PLLFRAC_441_H,device1,		124); 
	ldi R24,124
	std y+0,R24
	ldi R18,134
	ldi R16,82
	xcall _i2c_Write
	.dbline 529
; 	i2c_Write(STA_REG_PLLFRAC_441_L,device1,		0);
	clr R2
	std y+0,R2
	ldi R18,134
	ldi R16,81
	xcall _i2c_Write
	.dbline 530
; 	i2c_Write(STA_REG_PLLFRAC_H,device1,			64);
	ldi R24,64
	std y+0,R24
	ldi R18,134
	ldi R16,101
	xcall _i2c_Write
	.dbline 531
; 	i2c_Write(STA_REG_PLLFRAC_L,device1,			0);
	clr R2
	std y+0,R2
	ldi R18,134
	ldi R16,100
	xcall _i2c_Write
	.dbline 532
; 	i2c_Write(STA_REG_MFSDF_441,device1,			9);
	ldi R24,9
	std y+0,R24
	ldi R18,134
	ldi R16,80
	xcall _i2c_Write
	.dbline 533
; 	i2c_Write(STA_REG_MFSDF,device1,				8);
	ldi R24,8
	std y+0,R24
	ldi R18,134
	ldi R16,97
	xcall _i2c_Write
	.dbline 536
;     
; 	//配置界面等
; 	i2c_Write(STA_REG_PLLCTL_2,device1,			0x0C);
	ldi R24,12
	std y+0,R24
	ldi R18,134
	ldi R16,6
	xcall _i2c_Write
	.dbline 537
;     i2c_Write(STA_REG_PLLCTL_3,device1,			0x00);
	clr R2
	std y+0,R2
	ldi R18,134
	ldi R16,7
	xcall _i2c_Write
	.dbline 539
; 	//i2c_Write(STA_REG_PLLCTL_1,device1,         0x01);
; 	i2c_Write(STA_REG_SCLK_POL,device1,			0x00);	// data sampled on rising edge
	clr R2
	std y+0,R2
	ldi R18,134
	ldi R16,13
	xcall _i2c_Write
	.dbline 540
; 	i2c_Write(STA_REG_REQ_POL,device1,			0x01);	// REQ line active high
	ldi R24,1
	std y+0,R24
	ldi R18,134
	ldi R16,12
	xcall _i2c_Write
	.dbline 541
; 	i2c_Write(STA_REG_DATA_REQ_ENABLE,device1,	0x04);
	ldi R24,4
	std y+0,R24
	ldi R18,134
	ldi R16,24
	xcall _i2c_Write
	.dbline 542
; 	i2c_Write(STA_REG_PLLCTL_1,device1,			0xA1);
	ldi R24,161
	std y+0,R24
	ldi R18,134
	ldi R16,5
	xcall _i2c_Write
	.dbline 545
; 
; 	//STA013开始运行
; 	i2c_Write(STA_REG_RUN,device1,  0x01);
	ldi R24,1
	std y+0,R24
	ldi R18,134
	ldi R16,114
	xcall _i2c_Write
	.dbline 546
; 	i2c_Write(STA_REG_PLAY,device1, 0x01);
	ldi R24,1
	std y+0,R24
	ldi R18,134
	ldi R16,19
	xcall _i2c_Write
	.dbline 547
; 	i2c_Write(STA_REG_MUTE,device1, 0x00);
	clr R2
	std y+0,R2
	ldi R18,134
	ldi R16,20
	xcall _i2c_Write
	.dbline -2
L10:
	adiw R28,1
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e sta_PauseDecoder _sta_PauseDecoder fV
	.even
_sta_PauseDecoder::
	sbiw R28,1
	.dbline -1
	.dbline 566
; } 
; 
; /*
; //=======================================================================
; //停止解压
; void sta_StopDecoder(void)
; {
; 	//静音
; 	i2c_Write(STA_REG_MUTE,device1, 0x01);
; 	//软件复位
; 	i2c_Write(STA_REG_SOFT_RESET,device1, 0x01);
; 	i2c_Write(STA_REG_SOFT_RESET,device1, 0x00);
; }
; */
; 
; //=======================================================================
; //暂停解压
; void sta_PauseDecoder(void)
; {
	.dbline 570
; 	//静音
; 	//i2c_Write(STA_REG_MUTE,device1, 0x01);
; 	//停止
; 	i2c_Write(STA_REG_PLAY,device1, 0x00);
	clr R2
	std y+0,R2
	ldi R18,134
	ldi R16,19
	xcall _i2c_Write
	.dbline -2
L11:
	adiw R28,1
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e sta_ResumeDecoder _sta_ResumeDecoder fV
	.even
_sta_ResumeDecoder::
	sbiw R28,1
	.dbline -1
	.dbline 576
; }
; 
; //=======================================================================
; //恢复解压
; void sta_ResumeDecoder(void)
; {
	.dbline 578
; 	//开始解压
; 	i2c_Write(STA_REG_PLAY,device1, 0x01);
	ldi R24,1
	std y+0,R24
	ldi R18,134
	ldi R16,19
	xcall _i2c_Write
	.dbline -2
L12:
	adiw R28,1
	.dbline 0 ; func end
	ret
	.dbend
	.dbfunc e sta_SetVolume _sta_SetVolume fV
;         attenR -> R20
;         attenL -> R22
;        balance -> R22
;         volume -> R20
	.even
_sta_SetVolume::
	xcall push_gset3
	mov R22,R18
	mov R20,R16
	sbiw R28,1
	.dbline -1
	.dbline 586
; 	//放音
; 	//i2c_Write(STA_REG_MUTE,device1, 0x00);
; }
; 
; //=======================================================================
; //设置音量
; void sta_SetVolume(uint8 volume, uint8 balance)
; {
	.dbline 606
; 	char attenL, attenR;
; /*
; 	// volume is expected as 0-100 value
; 	// Note:
; 	//	#define MIN_VOLUME_ATTENUATION     0
; 	//	#define MAX_VOLUME_ATTENUATION     96
; 
; 	if( balance > 0)
; 	{	// balance to the left, attenuate right
; 		attenL = (100 - volume);
; 		attenR = (100 - volume) - (balance);
; 	}
; 	else
; 	{	// balance to the right, attenuate left
; 		attenL = (100 - volume) + (balance);
; 		attenR = (100 - volume);
; 	}
; */
; 
;     attenL = (100 - volume);
	ldi R22,100
	sub R22,R20
	.dbline 607
; 	attenR = (100 - volume);
	ldi R24,100
	sub R24,R20
	mov R20,R24
	.dbline 609
; 	// respect limits
; 	attenL = MIN(attenL,MAX_VOLUME_ATTENUATION);
	cpi R22,96
	brsh L14
	mov R10,R22
	clr R11
	xjmp L15
L14:
	ldi R24,96
	ldi R25,0
	movw R10,R24
L15:
	mov R22,R10
	.dbline 610
; 	attenL = MAX(attenL,MIN_VOLUME_ATTENUATION);
	clr R2
	cp R2,R10
	brsh L16
	clr R11
	xjmp L17
L16:
	clr R10
	clr R11
L17:
	mov R22,R10
	.dbline 611
; 	attenR = MIN(attenR,MAX_VOLUME_ATTENUATION);
	cpi R20,96
	brsh L18
	mov R10,R20
	clr R11
	xjmp L19
L18:
	ldi R24,96
	ldi R25,0
	movw R10,R24
L19:
	mov R20,R10
	.dbline 612
; 	attenR = MAX(attenR,MIN_VOLUME_ATTENUA

⌨️ 快捷键说明

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