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

📄 usefunction.asm

📁 SPT6608平台软件
💻 ASM
字号:
.public F_USER_DVR1600_EndRecord
.public F_USER_DVR1600_GetData,F_USER_DVR1600_WriteData

.public F_SACM_DVR1600_GetADC
.public F_SACM_DVR1600_SendDAC1
.public F_SACM_DVR1600_SendDAC2
.public F_SACM_DVR1600_EndPlay
//.public F_SACM_DVR1600_ISR_On
//.public F_SACM_DVR1600_ISR_Off
.PUBLIC F_SP_SwitchChannel

.public F_SACM_RampUpDAC1
.public F_SACM_RampDnDAC1
.public F_SACM_RampUpDAC2
.public F_SACM_RampDnDAC2

.public F_SP_SACM_DVR1600_DAC_Timer_Init
.public F_SP_SACM_DVR1600_ADC_Timer_Init
.external R_Resouce_DS

.include var.inc
.include spt6608.inc
.public   R_DAC;
.ram
.public R_ADC_Channel;
.public R_Test_Counter
.var    R_ADC_Channel = 0;
.var    R_Test_Counter;
.var    R_DAC;

//======================
.code
////////////////////////////////////////////////////////
// Function: _SP_SACM_DAC_Timer_Init_
// Description: Select A1600_Play DAC Sampling Rate, 
//              called by library
//              
// Destory: R1
// Parameter : None
// Return    : None
////////////////////////////////////////////////////////
F_SP_SACM_DVR1600_DAC_Timer_Init:
    push r1 to [sp];
    
//    R1 = C_DVR1600_DAC_Timer_Setting;  	
//	[P_TimerA_Data] = R1;
	
	pop r1 from [sp];
	retf;

////////////////////////////////////////////////////////
// Function: _SP_SACM_ADC_Timer_Init_
// Description: Select A1600_Rec ADC Sampling Rate
//              called by library
//              
// Destory: R1
// Parameter : None
// Return    : None
////////////////////////////////////////////////////////

F_SP_SACM_DVR1600_ADC_Timer_Init:
    push r1 to [sp];
 
//    R1 = C_DVR1600_ADC_Timer_Setting;  	
//	[P_TimerA_Data] = R1;
	
	pop r1 from [sp];
	retf;

//---------------------------------------------------------------
//Function : F_SP_SwitchChannel
//Description: This function switches the A/D channel based on 
//             the parameter. 
//Used register: r1
//Return: none
//---------------------------------------------------------------
F_SP_SwitchChannel: .proc
   	push BP to [SP];
//   	BP = SP + 1;
 //  	R1 = [BP + 3]; //RceMonitorOff
    	
	pop BP from [SP];
retf
.ENDP
	

////////////////////////////////////////////////////////
// Function: F_SACM_DVR1600_EndPlay
// Description: call back from kernel when bit stream 
//              decoding is done 
//              
// Syntax  : F_SACM_DVR1600_EndPlay
// Destory: R1
// Parameter : None
// Return    : N/A
////////////////////////////////////////////////////////
F_SACM_DVR1600_EndPlay: .PROC
	push R1 to [SP]; 
    // implemented by designer and SA
    // User can also handle concatenation , Ramp down ant etc.
    nop
    nop
    pop R1 from [SP]; 
    retf; 
.ENDP

//--------------------------------------------------------------------
//-- Function: F_SACM_DVR1600_GetADC
//-- Parameter: N/A   
//-- Return: R1 = ADC data
//-- Description: This function called by library to get  
//                ADC data for recording. It can be from either Microphone
//                or line-in.
//                User would have to modified the function body 
//                based on the need to fulfill this request from 
//                library. 
//                User should store the value in register(R2-R5)if use them. 
//--------------------------------------------------------------------

F_SACM_DVR1600_GetADC: .PROC
		R1=[P_ADC];	
//		R1 = R1 LSR 4		//  modify for  SPT6608_a1600_040814.lib or later
//		R1 = R1 LSR 2	    //  modify for  SPT6608_a1600_040814.lib or later
		R1 &=0xFFC0			//  modify for  SPT6608_a1600_040814.lib or later
		nop
        retf
.ENDP

////////////////////////////////////////////////////////
// Function: F_SACM_DVR1600_SendDAC1
// Description: send data to DAC1 from library 
//              
// Syntax  : F_SACM_DVR1600_SendDAC
// Destory: R4   (Suggest to be R1 by Arthur) 
// Parameter : R4: 16-bit unsign PCM
// Return    :None
////////////////////////////////////////////////////////
F_SACM_DVR1600_SendDAC1: .PROC
F_SACM_DVR1600_SendDAC2:
	//push R4 to [SP]; 
    // implemented by designer and SA
//    R4 = R4 LSL 4		 //  modify for  SPT6608_a1600_040814.lib or later
//    R4 = R4 LSL 2		 //  modify for  SPT6608_a1600_040814.lib or later
    R4 &=0xFFC0
//    [P_Ch0Envelope] = R4;
    [P_DAC] = R4;
    [R_DAC] = R4;
//Store to Buffer    
	R3 = [R_Test_Counter]
	CMP R3,0x87FF
	JE ?Skip
    R4 |= 0x8000;
    [R3++] = R4;
//    R3 = [R_Test_Counter];
//    R3 += 0x0001;
    [R_Test_Counter]=R3;
    nop;
    retf;
    
?Skip:
	R3 = 0x8000
	[R_Test_Counter] = R3;
  	nop;  
    retf; 
.ENDP

////////////////////////////////////////////////////////
// Function: F_SACM_RampDnDAC1
// Description: Ramp down after using DAC to avoid "bow" sound
//              from speaker 
// Syntax  : F_SACM_RampDnDAC1
// Destory: R1
////////////////////////////////////////////////////////
F_SACM_RampDnDAC1: .PROC
F_SACM_RampDnDAC2:
		push R1 to [SP];
		r1 = [P_Int];
		R1& = 0xFFFF-B_TmrAInt;
		[P_Int]=R1; 
				
//    	R1 = [P_DAC]; 
		R1 = [R_DAC]; 
    	R1 &= 0xffC0; 
    	jz ?_Branch_0; 
    
?_Loop_0:  
    	call F_SACM_Delay;
    	R1 -= 0x0040; 
    	[P_DAC] = R1;   
    	[R_DAC] = R1;  
    	jnz ?_Loop_0; 
    
?_Branch_0:       
    	pop R1 from [SP]; 
    	retf; 
.ENDP

////////////////////////////////////////////////////////
// Function: F_SACM_RampUpDAC
// Description: Ramp Up before using DAC to avoid "bow" sound
//              from speaker 
// Syntax  : F_SACM_RampUpDAC1()
// Destory: R1
////////////////////////////////////////////////////////
F_SACM_RampUpDAC2: .PROC
F_SACM_RampUpDAC1:
		push R1 to [SP]; 
//  		R1 = [P_DAC];
		R1 = [R_DAC]; 
    	R1 &= 0xffC0; 
    	cmp R1, 0x8000;
    	jb ?_Loop_0;
       
    	je ?_Branch_0; 
				                
?_Loop_1:
    	call F_SACM_Delay;
    	R1 -= 0x0040; 
    	[P_DAC] = R1; 
    	[R_DAC] = R1; 
    	cmp R1, 0x8000; 
    	jne ?_Loop_1; 
      
    	jmp ?_Branch_0; 

?_Loop_0:
		call F_SACM_Delay; 
    	R1 += 0x0040; 
    	[P_DAC] = R1;
    	[R_DAC] = R1;  
    	cmp R1, 0x8000; 
    	jne ?_Loop_0; 
    
?_Branch_0:
   		pop R1 from [SP]; 
		RETF
.ENDP		
		
		
F_SACM_Delay:
	push R1 TO [SP]
	R1 = 0x3F;
?loop:

	R1 -=1
	JNZ  ?loop
	pop	R1 From [sp]
	RETF
	
F_SACM_Delay2:
	push R1 TO [SP]
	R1 = 0x0F;
?loop:

	R1 -=1
	JNZ  ?loop
	pop	R1 From [sp]
	RETF	
	
//======================
//
//======================
F_USER_DVR1600_WriteData:
//	input Parameter:
//              Buffer Start Adr:R1; Buffer Length:R2 
//	retf;
	    Bp = [RW_Address]
    	nop
L_LoopSaveData:
        R3 =[R1++]
        [bp++] = R3      //Save into SRAM at odd 
        R4 = [RW_Length]
        R4+=1
		[RW_Length] = R4
L_AddressInc:        
        CMP		R5,C_EndAddrBuf
        JE		L_Exit
        JA		L_Exit
        R2 -=1
        jnz	L_LoopSaveData
        [RW_Address] = bp
		RETF
L_Exit:
		R1 = C_EndAddrFlag
		[RW_Flag] = R1
        [RW_Address] = bp
		RETF
//============================
//  Input Parameter
//   R1:Length Low
//   R2:Length High
F_USER_DVR1600_EndRecord:  
	    Bp = C_UserBuffer  
	    R3 = [RW_Length]
    	[bp++] = R3
		[BP++] = R1       // save length for total
		[BP++] = R2       // save length for total
		R1 = C_RecEndFlag
		[RW_Flag] = R1
		RETF
//======================

//======================
F_USER_DVR1600_GetData:
//	input Parameter:
//          Buffer Start Adr:R1; Buffer Length:R2 
//  Get Data Length
		
	    Bp = [RW_Address]
L_LoopGetData:
        CMP		R5,C_EndAddrBuf
        JE		L_ExitGetData
        R3 =[bp++]
        [R1++] =R3
	    R3 = [RW_Length]
	    R3 -=1
	    [RW_Length] = R3
		TEST  R3,0xFFFF
		JZ	  L_ExitGetData
        R2 -=1
        JNZ	L_LoopGetData
L_ExitLoopGetData:
        [RW_Address] = bp
        RETF
L_ExitGetData:
		R1 = C_EndAddrFlag
		[RW_Flag] = R1
		RETF
////////////////////////////////////////////////////////
.external R_Resouce_BS
.public	F_GetInternalROMData;
F_GetInternalROMData:
   	push R1, R3 to [SP];  // add by adamcar 
	SR &= 0x3FF
	r3 = [R_Resouce_BS]
	R4 =[R3++];
	cmp R3, 0;
	jnz ?L_End;
	SR &= 0x3FF
	[R_Resouce_DS] = SR;

?L_End:
	[R_Resouce_BS] = R3; 
	 
	pop R1, R3 from [SP];
	//-----------------------
	// end of user define area
    //-----------------------
	retf;

// Function: F_SP_SACM_DVR1600_Init_
// Description: Hardware initilazation, System Clock, DAC, INT
//              
// Syntax  : F_SP_SACM_Init_
// Destory: R1
// Parameter : None
// Return    : None
////////////////////////////////////////////////////////
// call by decode.asm to initilaize the hardware for decode  // by Arthur
.public F_SP_SACM_DVR1600_Init_
F_SP_SACM_DVR1600_Init_:
		FIQ on;
		IRQ on;
		retf;

//Function: F_OutputADC
//Description: The function is called each 8192Hz only when A1600(DVR) is active 
//             and recording. Because it is called from A1600 library, all used Register 
//             must be push to stack first, then 
//				pop from stack before leave the function. 
//input : R1 (ADC data)			

.public	F_OutputADC;	
F_OutputADC:	
		push R1, R1 to [SP];
//		r1 = [0x7006];
//		r1 ^= 0x0001;
//		[0x7005] = r1;
		pop R1, R1 from [SP];
		retf;	
			

⌨️ 快捷键说明

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