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

📄 test4at303.dsp

📁 基于ADSP的G.729语音编解码程序
💻 DSP
📖 第 1 页 / 共 3 页
字号:
                  |||||+------- IRQE_n
                  ||||+-------- SPORT0 Rx
                  |||+--------- SPORT0 Tx
                  ||+---------- IRQL0_n
                  |+----------- IRQL1_n
                  +------------ IRQ2_n
*/


// Interrup BSB IRQ to 8051
		RegWrite(0x707, b#1000000000000001, ax1);
/*                        ^^^^^^^^xxxxxx||
                              |         |+--- DSP BSB interrupt to 8051
                              |         |
		                      |         +---- DSP AUX interrupt to 8051
		                      |
		                      +-------------- DSP interrupt length
*/


/////////////////////////////////////////////////////////////////////////
//                                                                     //
// Enable Audio-Buffer                                                 //
//                                                                     //
/////////////////////////////////////////////////////////////////////////
DECODER_ENABLE_AUB :

        RegWrite(0x704, b#1000100000000000, ax1);
/*                        ||||||xxxxxxxx||
                          ||||||        |+--- Rx FIFO empty
                          ||||||        +---- Tx FIFO full
                          ||||||
                          |||||+------------- Rx FIFO mute
                          ||||+-------------- Tx FIFO mute   //Anna changed it to enable Tx FIFO mute 
                          |||+--------------- Rx FIFO pointer reset
                          ||+---------------- Tx FIFO pointer reset
                          |+----------------- Enable Rx FIFO
                          +------------------ Enable Tx FIFO
*/

        RegWrite(0x704, b#1000000000000000, ax1);  //Anna+
        imask = b#0000000100;		
/*                ||||||||||
                  |||||||||+--- Timer
                  ||||||||+---- SPORT1 Rx or IRQ0_n
                  |||||||+----- SPORT1 Tx or IRQ1_n
                  ||||||+------ BDMA
                  |||||+------- IRQE_n
                  ||||+-------- SPORT0 Rx
                  |||+--------- SPORT0 Tx
                  ||+---------- IRQL0_n
                  |+----------- IRQL1_n
                  +------------ IRQ2_n
*/


IDLE_LOOP :

	    	 idle;

		     nop;

//---------------------------------------------+<Anna+
	           imask = b#0010000000;

			   ar=dm(EndPlay);
               none=pass ar;
               if ne jump Idle_loop1;
               
               ar=dm(PausePlay);
               none=pass ar;
               if eq jump Normal_idle;
               RegWrite(0x70D,0x0000,ax1);
               RegWrite(0x707,b#1000000000000010,ax1);
          
               
Idle_loop2:   
               ax1=dm(ResumePlay);
               ay1=dm(StartPlay);
               none=ax1 or ay1;
               if eq jump Idle_loop2;
               RegWrite(0x70D,0x0000,ax1);
               RegWrite(0x707,b#1000000000000010,ax1);
        
               jump Normal_idle;
               
Idle_loop1:    
               RegWrite(0x70D,0x0000,ax1);
               RegWrite(0x707,b#1000000000000010,ax1);
              
               idle(128);
			   ax0=dm(WmodeChange);
			   none=pass ax0;
			   if ne jump WorkModeChange;

Normal_restart:

               RegWrite(0x70D,0x0000,ax1);
               RegWrite(0x707,b#1000000000000010,ax1);
         
               ar=dm(StartPlay);
               none=pass ar;
               if ne jump Normal_idle;
               jump Idle_loop1;
               
Normal_idle:
			   imask = b#0010000100;
			    
			
	          
			   jump IDLE_LOOP;


IDLE_LOOP_ENC:
                  idle;
                  nop;
           
             imask = b#0010000000;
	
               ar=dm(EndEncode);
               none=pass ar;
               if ne jump Idle_loop_enc1;
               
               ar=dm(PauseEncode);
               none=pass ar;
               if eq jump Normal_idle_enc;
              RegWrite(0x70D,0x0000,ax1);
              RegWrite(0x707,b#1000000000000010,ax1);
               

Idle_loop_enc2: 
               ax1=dm(ResumeEncode);
               ay1=dm(StartEncode);
               none=ax1 or ay1;
               if eq jump Idle_loop_enc2;
               RegWrite(0x70D,0x0000,ax1);
               RegWrite(0x707,b#1000000000000010,ax1);
               

               RegWrite(0x704, b#0001000000000000, ax1);

               RegWrite(0x704, b#1100000000000000, ax1);
               
               jump Normal_idle_enc;
               
Idle_loop_enc1: 
               RegWrite(0x70D,0x0000,ax1);
               RegWrite(0x707,b#1000000000000010,ax1);

                idle(128);
			    ax0=dm(WmodeChange);
			    none=pass ax0;
			    if ne jump WorkModeChange;

Normal_restart_enc:
               
                RegWrite(0x70D,0x0000,ax1);
                RegWrite(0x707,b#1000000000000010,ax1);
               ar=dm(StartEncode);
               none=pass ar;
               if eq jump Normal_restart_enc;
               RegWrite(0x704, b#0001000000000000, ax1);

               RegWrite(0x704, b#1100000000000000, ax1);
               
               
Normal_idle_enc:
                 imask = b#0010000010;
                 
                 
                  jump IDLE_LOOP_ENC;	
//--------------------------------------------------+>Anna
              
/////////////////////////////////////////////////////////////////////////
//                                                                     //
// IRQ8 : ISR for Audio Buffer Tx Water-Mark (Almost Empty)            //
//                                                                     //
/////////////////////////////////////////////////////////////////////////
ISR_AUBTxWmk :

		ena sec_reg;
			
		// Read Tx FIFO data count
		ax1  = io(0x701);

		ay1  = AUBTxWmk;

		none = ax1 - ay1;

		if gt jump LEAVE_AUBTX_ISR;		// - sunny

//-----------------------------+< sunny
		CALL read_seag;   
		CALL decode_seag;

//------------------------------+<Anna	
#ifdef AB_PLAY			
		ar=dm(Frame_Numbers);  //calculate frame numbers that had been decoded
		ar=ar+1;
		dm(Frame_Numbers)=ar;
		CALL FILEPOS_CAL;      //calculate filepos
#endif
//----------------------------- +>Anna		
 
/* remove the following after debugging.
				I0 = DM(stream_current_sample_position);
				L0 = %tmp_bit_stream;
			   CNTR=41;
			   DO read_sample_put_speech UNTIL CE;			   
			   SI=DM(I0,M1);
    			IO(speech_port)=SI;   // two channels
read_sample_put_speech:	   IO(speech_port)=SI;
	
				DM(stream_current_sample_position) = I0;	// sunny+
				L0 = 0;										// sunny+
*/// remove the above after debugging.			

		AR = DM(available_stream_samples);
		AY0 = 41;
		AR = AR - AY0;
		DM(available_stream_samples) = AR;
		
		AR = AR - AY0;
		if ge jump LEAVE_AUBTX_ISR;		// if there is less than 41 samples, fetch data from for BSB

//-----------------------------+<Anna
#ifdef AB_PLAY
		ar=dm(BSB_Number);    //calculate BSB numbers
		ar=ar+1;
		dm(BSB_Number)=ar;
#endif
//----------------------------+>Anna		

        I0 = DM(stream_last_sample_position);
		L0 = %tmp_bit_stream;
			
		cntr = 0x0100;
			
		DO bsb2dm UNTIL CE; 
			AX0 = IO(stream_port);
bsb2dm:
			DM(I0, M1) = AX0; 
			
	    DM(stream_last_sample_position)=I0;
		L0 = 0;
			
		AR = DM(available_stream_samples);
		AR = AR + 0x100;
		DM(available_stream_samples) = AR;
//----------------------------->+ sunny
       

// LEAVE_AUBTX_ISR :	// sunny-

		dis sec_reg;

		// Interrup BSB IRQ to 8051
		RegWrite(0x707, b#1000000000000001, ax1);
/*                        ^^^^^^^^xxxxxx||
                              |         |+--- DSP BSB interrupt to 8051
                              |         |
		                      |         +---- DSP AUX interrupt to 8051
		                      |
		                      +-------------- DSP interrupt length
*/
		rti;

LEAVE_AUBTX_ISR :
		dis sec_reg;
		rti;

////////////////////////////////////
//          AB_PLAY               ///----------+<Anna
////////////////////////////////////
#ifdef AB_PLAY
FILEPOS_CAL:
     
      dis ar_sat;
      ar=dm(Frame_Numbers);
      my0=82;
      mr=ar*my0(uu);
      ay0=dm(Filepos_Low);
      ar=mr0+ay0;
      dm(Filepos_Low)=ar;
      ar=dm(Filepos_High);
      ar=ar+c;
      dm(Filepos_High)=ar;
      ena ar_sat;
      rts;
#endif
//---------------------------------------------+>Anna				
/////////////////////////////////////////////////////////////////////////
//                                                                     //
// IRQ7 : ISR for Audio Buffer Rx Water-Mark (Almost Full)             //
//                                                                     //
/////////////////////////////////////////////////////////////////////////
ISR_AUBRxWmk :

		ena sec_reg;

//----------------------------+<Anna		
	/*	ax1=dm(data_throw);
        ar=ax1-2;
        none=pass ar;
        if eq jump encode_next;
        
        ar=io(0x706);
        cntr=ar;
        do throw_data until ce;
        ax0=io(0x705);
throw_data:
       io(0x700)=ax0;               
       ar=ax1+1;
       dm(data_throw)=ar;
       jump EXIT_AUBRX_ISR;*/
//-----------------------------+>Anna
		
encode_next:
                    
#ifndef DEBUG
		// Read Rx FIFO count
		ax1 = io(0x706);
		
//		ay1 = AUBRxWmk;		// sunny -
		ay1 = 320;			// sunny +
		
		none = ax1 - ay1;
		
		if lt jump EXIT_AUBRX_ISR;	// - sunny	temporarily disabled
#endif
//			AR=DM(count_frame);	// -sunny
// 	 		AR=AR+1;				// -sunny
// sunny +
			   AX0=32767;			
			   AY0=DM(count_frame);
			   AR=AY0+1;
			   NONE=AX0-AY0;
			   IF EQ AR=PASS 0;
// + sunny
			   DM(count_frame)=AR;
			   io(0x555) = AR;// to LED
			   
			   CALL encode_frame;
               
               AR=DM(count_frame);
               CALL out_speech;
               
               AR = DM(available_stream_samples);	// no of the encoded bitstream
				AY0 = 256;
				AR = AR - AY0;

				if lt jump encode_next;		// if there are less than 256 samples, encode next frame
				DM(available_stream_samples) = AR;	// + sunny
//---------------------------------->+ sunny

		// Reset BSB
		RegWrite(0x703, 0x8000, ax1);
		
//-------------------------------------------------+< sunny
		I0 = DM(stream_last_sample_position);
		L0 = %tmp_bit_stream;
//--------------------------------------------------+> sunny
		cntr = 256;
		
		do ISR_PUT_BSB until ce;
		
//			ax0 = io(0x705);	// - sunny
//			io(0x700) = ax0;	// - sunny
			ax0 = DM(I0, M1);	// + sunny

			io(0x702) = ax0;
			
ISR_PUT_BSB :
			nop;

		DM(stream_last_sample_position) = I0;	// sunny+
		L0 = 0;									// sunny+

		
LEAVE_AUBRX_ISR :	// notify BSB before exit

		dis sec_reg;
		
		// Interrupt BSB IRQ to 8051
		RegWrite(0x707, b#1000000000000001, ax1);
/*                        ^^^^^^^^xxxxxx||
                              |         |+--- DSP BSB interrupt to 8051
                              |         |
		                      |         +---- DSP AUX interrupt to 8051
		                      |
		                      +-------------- DSP interrupt length
*/

		rti;

EXIT_AUBRX_ISR :	// exit without notifying BSB

		dis sec_reg;
		rti;

/////////////////////////////////////////////////////////////////////////
//                                                                     //
// IRQ4 : ISR for Bit-Stream Buffer (from pin "IRQE")                  //
//                                                                     //
/////////////////////////////////////////////////////////////////////////
ISR_AccessBSB :

//----------------------------+< sunny

				I0 = ^tmp_bit_stream;
				L0 = %tmp_bit_stream;
			    DM(stream_current_sample_position) = I0;
			
				cntr = 0x0100;
			
				DO bsb2dm1 UNTIL CE; 
					AX0 = IO(stream_port);
				bsb2dm1:
					DM(I0, M1) = AX0; 
			
			    DM(stream_last_sample_position)=I0;
				L0 = 0;

				AY0 = 256;				// 256 samples to be decoded
				DM(available_stream_samples) = AY0;
			    
//-----------------------------+> sunny 

		ena sec_reg;
////////////////////////////
#ifdef AB_PLAY		
		ar=dm(BSB_Number);    //calculate BSB number
		ar=ar+1;
		dm(BSB_Number)=ar;
#endif
////////////////////////////        
		ax1 = 0x0001;

		dm(BSBWrRdReq) = ax1;
		
		dis sec_reg;


		rti;

/*------Wait for command------------*/
/*-----------------------------------------<Anna-
                I0 = ^tmp_bit_stream;
			    DM(stream_last_sample_position) = I0;
			    DM(stream_current_sample_position) = I0;


   				IMASK = 0x0010;        /*enable BSB to receive IRQ*/
			//	IDLE;
			//	IMASK = 0x0000;        /*disable BSB to receive IRQ*/
			
				// fill output buffer with 1280 samples

			//	CALL read_seag;   		// input 40 + 1 stream samples
			//	CALL decode_seag;		// output 640 * 2 (channels) speech samples
			
			//	AY0 = 215;				// (256-41) samples left to be decoded
			//	DM(available_stream_samples) = AY0;
			
			//	AY0 = 0x08;
			//	IO(0x72E) = AY0;		// start audio operation

⌨️ 快捷键说明

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