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

📄 usefunction.asm

📁 使用GPTC6604做的一个录放音DEMO
💻 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,FlashAddrHi,F_ReadFmFlash,F_StopFlash,F_ReadFlashBuf
.external F_WriteOneByte,F_ReadOneByte,F_FlashTest,FlashAddr,FlashData
.external SW_Buff


.include var.inc
.include spt6604a.inc
.ram
.public R_ADC_Channel;
.var    R_ADC_Channel = 0;


.const	RW_Bank1	= 0x400
//======================
.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. 
//--------------------------------------------------------------------
// ffc0
// 0ffc
F_SACM_DVR1600_GetADC: .PROC
		R1=[P_Adc];	
		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:
   	[P_Ch0Envelope] = R4
    	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_RampUpDAC1: .PROC
F_SACM_RampUpDAC2:
		push R1 to [SP]; 
    	R1 = [P_Ch0Envelope]; 
    	R1 &= 0xff00; 
    	jz ?_Branch_0; 
    
?_Loop_0:  
    	call F_SACM_Delay;
    	R1 -= 0x0100; 
    	[P_Ch0Envelope] = 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_RampDnDAC2: .PROC
F_SACM_RampDnDAC1:
		push R1 to [SP]; 
  		R1 = [P_Ch0Envelope]; 
    	R1 &= 0xff00; 
    	cmp R1, 0x8000;
    	jb ?_Loop_0;
       
    	je ?_Branch_0; 
				                
?_Loop_1:
    	call F_SACM_Delay;
    	R1 -= 0x0100; 
    	[P_Ch0Envelope] = R1; 
    	cmp R1, 0x8000; 
    	jne ?_Loop_1; 
      
    	jmp ?_Branch_0; 

?_Loop_0:
		call F_SACM_Delay; 
    	R1 += 0x0100; 
    	[P_Ch0Envelope] = R1; 
    	cmp R1, 0x8000; 
    	jne ?_Loop_0; 
    
?_Branch_0:
   		pop R1 from [SP]; 
.ENDP
		RETF
F_SACM_Delay:
		push R1 TO [SP]
		R1 = 0x7F
?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]
L_LoopSaveData:
        R3 =  [R1++]
        [FlashAddr] = bp
		[FlashData] = R3
        Call	F_WriteOneByte   //1
		R3 = R3 LSR	4
		R3 = R3 LSR	4
		bp+=1
		JNZ		?L_NotOver
		R4 = 1
		[FlashAddrHi] = R4
?L_NotOver:
        [FlashAddr] = bp
		[FlashData] = R3
        Call	F_WriteOneByte     //2
		bp+=1
		JNZ		?L_NotOver1
		R4 = 1
		[FlashAddrHi] = R4
?L_NotOver1:
		R4 = [RW_Length]
		R4 +=1
		[RW_Length] = R4
        R2 -=1
        jnz	L_LoopSaveData
        [RW_Address] = bp
		RETF
//============================
//  Input Parameter
//   R1:Length Low
//   R2:Length High
//      save two word 4 byte
F_USER_DVR1600_EndRecord: 
		R3 = 0
		[FlashAddrHi] = R3
	    R4 = 0x10  
        [FlashAddr] = R4
		[FlashData] = R1
        Call	F_WriteOneByte	//1
		R1 = R1 LSR	4
		R1 = R1 LSR	4
		R4+=1
        [FlashAddr] = R4
		[FlashData] = R1
        Call	F_WriteOneByte	//2
		R4+=1
        [FlashAddr] = R4
		[FlashData] = R2
        Call	F_WriteOneByte	//3
		R2 = R2 LSR	4
		R2 = R2 LSR	4
		R4+=1
        [FlashAddr] = R4
		[FlashData] = R2
        Call	F_WriteOneByte	//4
        nop
		R1 = C_RecEndFlag
		[RW_Flag] = R1
		RETF

//======================

//======================
F_USER_DVR1600_GetData:
//	input Parameter:
//          Buffer Start Adr:R1; Buffer Length:R2 
//  Get Data Length
	    R4 = [RW_Address]
	    [FlashAddr] = R4
	    Call	F_ReadFmFlash
L_LoopGetData:
        CALL    F_ReadOneByte;
        R3 = R5;
        R4 +=1
		JNZ		?L_NotOver
		R5 = 1
		[FlashAddrHi] = R5
?L_NotOver:
        CALL    F_ReadOneByte;
        R5 = R5 LSL 4;
        R5 = R5 LSL 4;
        R3 |=R5
        [R1++] =R3
        R4 +=1
		JNZ		?L_NotOver1
		R5 = 1
		[FlashAddrHi] = R5
?L_NotOver1:
		R5 = [RW_Length]
		R5 -=1
		JZ		exit
		[RW_Length] = R5
        R2 -=1
        JNZ	L_LoopGetData
L_ExitLoopGetData:
        [RW_Address] = R4
        CALL    F_StopFlash;
        RETF
exit:
		R1 = C_EndAddrFlag
		[RW_Flag] = R1
        CALL    F_StopFlash;
		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
			

⌨️ 快捷键说明

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