Ejemplo n.º 1
0
/*****************************************************************************
 *	\brief		test main function to run in main.c
 *	\parameters	None
 *	\return		None
 *****************************************************************************/
void test_main(){
	unsigned int n, m;
	// Initializes rx and mic buffers to zeros
	memset(audioRx, 0, N_RX*BUFLEN_8KHZ*sizeof(short));
	memset(audioMic, 0, N_MIC*BUFLEN_8KHZ*sizeof(short));
	memset(audioTx, 0, N_TX*BUFLEN_8KHZ*sizeof(short));
	memset(audioLs, 0, N_LS*BUFLEN_8KHZ*sizeof(short));

	USTIMER_init();
	I2C_init(I2C0, I2C_CLK_400K);

	// Init and config of TrueVoice
	config_true_voice_test();

	// Setup of pointers to audio buffers
	init_audio_signals_test();

	if(USE_DEBUG_PLOT) {
		// DEBUG of mixer. Run TrueVoice for TV_PLOT_LENGTH samples and dump output to files
		test_mixer();
		// DEBUG of DTMF.
		//test_dtmf();
		//DEBUG of noise reduction
		//test_noise_reduction();
		//test_fileInput();
		//DEBUG of subband functions
		//test_subband();
		//DEBUG of LEC
		//test_lec();
		//DEBUG of mute
		//test_mute();

		//Line In/Out
		//test_audio_loop();
//		TEST_audio();
//		mitt_test();
//		for(m=0;m<666;m++){ //Infinite loop
//			//Update inputBuffer
//			for(n=0; n<BUFLEN_8KHZ; n++){
//				audioMic[1][n] = n;
//			}
//
//			//Run true voice
//			true_voice(rx, mic, tx, ls);
//		}
	} else {
		// Run TrueVoice once
		//while(1){
			//simulate_capture_audio();
			//true_voice(rx, mic, tx, ls);
			//simulate_send_audio();
		//}

	}
}
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------
// Function:	Initialize the general-purpose I/O
//
// Parameters:  none
//
// Returns:     none
//
//-----------------------------------------------------------------------------
int main(void)
{
	float yc_new, yc_old;   		// Cosine Samples
	float ys_new, ys_old;   		// Sine Sample
	float cosw, sinw;				// Sin/Cos Fractions

   EVMOMAPL138_init();				// Initialize the board
   EVMOMAPL138_initRAM();			// Set up the RAM
   EVMOMAPL138_enableDsp();			// Wake up the DSP

	// init the i2c for all to use.
	USTIMER_init();					// General use timers
	I2C_init(I2C0, I2C_CLK_400K);	// I2C initialization

	// set gpio output
	SetGpio();						// Configure the General Purpose I/O
	McASP_Init();					// Initialize McASP
	AIC3106_Init();					// Initialize AIC3106
	McASP_Start();					// Start McASP

	// Initialize oscillators
	ys_new = AMPLITUDE;
	yc_new = 0.0f;
	cosw = cos(THETA_INC);
	sinw = sin(THETA_INC);

	// Infinite loop:  	Each loop reads/writes one sample to the left and right channels.
	while (1){

		// Save old samples
		yc_old = yc_new;
		ys_old = ys_new;

		// Generate new samples
		yc_new = cosw*yc_old - sinw*ys_old;
		ys_new = cosw*ys_old + sinw*yc_old;

        // wait for xmit ready and send a sample to the left channel.
        while (!CHKBIT(MCASP->SRCTL11, XRDY)) {}
        MCASP->XBUF11 = (int16_t)yc_old;

        // wait for xmit ready and send a sample to the right channel.
        while (!CHKBIT(MCASP->SRCTL11, XRDY)) {}
        MCASP->XBUF11 = (int16_t)ys_old;
            	
     }   
}
Ejemplo n.º 3
0
//-----------------------------------------------------------------------------
// Function:	Initialize the general-purpose I/O
//
// Parameters:  none
//
// Returns:     none
//
//-----------------------------------------------------------------------------
int main(void)
{
	int16_t sample = 0;				// Sample index into the buffer array
	int16_t dataInput;       		// Sine Sample
	int16_t oldDataInput;       	// Sine Sample delayed
	float theta = 0;				// Argument of the sine wave
	int16_t buffer[BUFF_SIZE] = {0};// Buffer to hold the sine samples
	float amplitude = AMPLITUDE;	// Amplitude of the generated sin wave

   EVMOMAPL138_init();				// Initialize the board
   EVMOMAPL138_initRAM();			// Set up the RAM
   EVMOMAPL138_enableDsp();			// Wake up the DSP


	// init the i2c for all to use.
	USTIMER_init();					// General use timers
	I2C_init(I2C0, I2C_CLK_400K);	// I2C initialization

	// set gpio output
	SetGpio();						// Configure the General Purpose I/O
	
	McASP_Init();					// Initialize McASP

	AIC3106_Init();					// Initialize AIC3106

	McASP_Start();					// Start McASP

	// Infinite loop:  	Each loop reads/writes one sample to the left and right channels.
	while (1){

/* The following code is here to allow a test signal to be generated. THIS IS
NOT HOW LAB 1 IS TO BE DONE!  Remove the code up to the indicated spot and insert
your own code.
*/

		// Store the last sample because of the one sample delay between channels.
		oldDataInput = dataInput;

		// Calculate the next sine wave sample...
        dataInput = ((int16_t) amplitude*sin(theta));
			
		// Increment the argument...
		theta += THETA_INC;
        if (theta > 2*PI) theta -= 2*PI;  	// Wrap around 2pi
			
		// Store the new sample in the buffer, for viewing...
        buffer[sample] = dataInput;
        sample = (sample+1)%BUFF_SIZE;      // Update the sample indx
			
/* Before writing the 16-bit samples, you must insert your own processing here. */

        // wait for xmit ready and send a sample to the left channel.
        while (!CHKBIT(MCASP->SRCTL11, XRDY)) {}
        MCASP->XBUF11 = oldDataInput;
//        oldDataInput = MCASP->XBUF12;	// Read the left channel input samples.

        // wait for xmit ready and send a sample to the right channel.
        while (!CHKBIT(MCASP->SRCTL11, XRDY)) {}
        MCASP->XBUF11 = dataInput;
//        dataInput = MCASP->XBUF12;	// Read the right channel input samples.
            	
     }   
}
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------
// Function:	Initialize the general-purpose I/O
//
// Parameters:  none
//
// Returns:     none
//
//-----------------------------------------------------------------------------
int main(void)
{
	int i, k;
	float out;
	int circ_idx = FILTER_LEN-1;
	float coeffs[FILTER_LEN] = { FIR_FILT_32 };
	float z[FILTER_LEN];

	int16_t dataInput;       		// Sine Sample
	int16_t oldDataInput;       	// Sine Sample delayed

   EVMOMAPL138_init();				// Initialize the board
   EVMOMAPL138_initRAM();			// Set up the RAM
   EVMOMAPL138_enableDsp();			// Wake up the DSP


	// init the i2c for all to use.
	USTIMER_init();					// General use timers
	I2C_init(I2C0, I2C_CLK_400K);	// I2C initialization

	// set gpio output
	SetGpio();						// Configure the General Purpose I/O
	
	McASP_Init();					// Initialize McASP

	AIC3106_Init();					// Initialize AIC3106

	McASP_Start();					// Start McASP

	// Infinite loop:  	Each loop reads/writes one sample to the left and right channels.
	while (1){

/* The following code is here to allow a test signal to be generated. THIS IS
NOT HOW LAB 1 IS TO BE DONE!  Remove the code up to the indicated spot and insert
your own code.
*/

		// Store the last sample because of the one sample delay between channels.
		oldDataInput = dataInput;

		//
		// Update the circular buffer index and insert the latest sample
		//
		circ_idx++;
		z[circ_idx & 0x1F] = (float)dataInput;

		//
		// Compute next filter output
		//
		out = 0.0f;                     // Zero the accumulator
		for( i=0; i<FILTER_LEN; i++ )
		{
			k = (circ_idx - i) & 0x1F;  // Index into circular buffer
			out += coeffs[i]*z[k];		// Multiply by coefficient
		}

		dataInput = (int16_t) out;

        // wait for xmit ready and send a sample to the left channel.
        while (!CHKBIT(MCASP->SRCTL11, XRDY)) {}
        MCASP->XBUF11 = oldDataInput;
		oldDataInput = MCASP->XBUF12;	// Read the left channel input samples.

        // wait for xmit ready and send a sample to the right channel.
        while (!CHKBIT(MCASP->SRCTL11, XRDY)) {}
        MCASP->XBUF11 = dataInput;
		dataInput = MCASP->XBUF12;	// Read the right channel input samples.
            	
     }   
}
Void main()
{

	int i = 0;

	// unlock the system config registers.
	SYSCONFIG->KICKR[0] = KICK0R_UNLOCK;
	SYSCONFIG->KICKR[1] = KICK1R_UNLOCK;

	SYSCONFIG1->PUPD_SEL |= 0x10000000;  // change pin group 28 to pullup for GP7[12/13] (LCD switches)

	// Initially set McBSP1 pins as GPIO ins
	CLRBIT(SYSCONFIG->PINMUX[1], 0xFFFFFFFF);
	SETBIT(SYSCONFIG->PINMUX[1], 0x88888880);  // This is enabling the McBSP1 pins

	CLRBIT(SYSCONFIG->PINMUX[16], 0xFFFF0000);
	SETBIT(SYSCONFIG->PINMUX[16], 0x88880000);  // setup GP7.8 through GP7.13 
	CLRBIT(SYSCONFIG->PINMUX[17], 0x000000FF);
	SETBIT(SYSCONFIG->PINMUX[17], 0x00000088);  // setup GP7.8 through GP7.13


	//Rick added for LCD DMA flagging test
	GPIO_setDir(GPIO_BANK0, GPIO_PIN8, GPIO_OUTPUT);
	GPIO_setOutput(GPIO_BANK0, GPIO_PIN8, OUTPUT_HIGH);

	GPIO_setDir(GPIO_BANK0, GPIO_PIN0, GPIO_INPUT);
	GPIO_setDir(GPIO_BANK0, GPIO_PIN1, GPIO_INPUT);
	GPIO_setDir(GPIO_BANK0, GPIO_PIN2, GPIO_INPUT);
	GPIO_setDir(GPIO_BANK0, GPIO_PIN3, GPIO_INPUT);
	GPIO_setDir(GPIO_BANK0, GPIO_PIN4, GPIO_INPUT);
	GPIO_setDir(GPIO_BANK0, GPIO_PIN5, GPIO_INPUT);  
	GPIO_setDir(GPIO_BANK0, GPIO_PIN6, GPIO_INPUT);

	GPIO_setDir(GPIO_BANK7, GPIO_PIN8, GPIO_OUTPUT);
	GPIO_setDir(GPIO_BANK7, GPIO_PIN9, GPIO_OUTPUT);
	GPIO_setDir(GPIO_BANK7, GPIO_PIN10, GPIO_OUTPUT);
	GPIO_setDir(GPIO_BANK7, GPIO_PIN11, GPIO_OUTPUT);
	GPIO_setDir(GPIO_BANK7, GPIO_PIN12, GPIO_INPUT);
	GPIO_setDir(GPIO_BANK7, GPIO_PIN13, GPIO_INPUT); 

	GPIO_setOutput(GPIO_BANK7, GPIO_PIN8, OUTPUT_HIGH);  
	GPIO_setOutput(GPIO_BANK7, GPIO_PIN9, OUTPUT_HIGH);
	GPIO_setOutput(GPIO_BANK7, GPIO_PIN10, OUTPUT_HIGH);
	GPIO_setOutput(GPIO_BANK7, GPIO_PIN11, OUTPUT_HIGH);  

	CLRBIT(SYSCONFIG->PINMUX[13], 0xFFFFFFFF);
	SETBIT(SYSCONFIG->PINMUX[13], 0x88888811); //Set GPIO 6.8-13 to GPIOs and IMPORTANT Sets GP6[15] to /RESETOUT used by PHY, GP6[14] CLKOUT appears unconnected

	#warn GP6.15 is also connected to CAMERA RESET This is a Bug in my board design Need to change Camera Reset to different IO.

	GPIO_setDir(GPIO_BANK6, GPIO_PIN8, GPIO_OUTPUT);
	GPIO_setDir(GPIO_BANK6, GPIO_PIN9, GPIO_OUTPUT);
	GPIO_setDir(GPIO_BANK6, GPIO_PIN10, GPIO_OUTPUT);
	GPIO_setDir(GPIO_BANK6, GPIO_PIN11, GPIO_OUTPUT);
	GPIO_setDir(GPIO_BANK6, GPIO_PIN12, GPIO_OUTPUT);
	GPIO_setDir(GPIO_BANK6, GPIO_PIN13, GPIO_INPUT);   


   // on power up wait until Linux has initialized Timer1
	while ((T1_TGCR & 0x7) != 0x7) {
	  for (index=0;index<50000;index++) {}  // small delay before checking again

	}

	USTIMER_init();
	
	// Turn on McBSP1
	EVMOMAPL138_lpscTransition(PSC1, DOMAIN0, LPSC_MCBSP1, PSC_ENABLE);

    // If Linux has already booted It sets a flag so no need to delay
    if ( GET_ISLINUX_BOOTED == 0) {
    	USTIMER_delay(4*DELAY_1_SEC);  // delay allowing Linux to partially boot before continuing with DSP code
    }
	   
	// init the us timer and i2c for all to use.
	I2C_init(I2C0, I2C_CLK_100K);
	init_ColorVision();	
	init_LCD_mem(); // added rick

	EVTCLR0 = 0xFFFFFFFF;
	EVTCLR1 = 0xFFFFFFFF;
	EVTCLR2 = 0xFFFFFFFF;
	EVTCLR3 = 0xFFFFFFFF;	

	init_DMA();
	init_McBSP();

	init_LADAR();

	CLRBIT(SYSCONFIG->PINMUX[1], 0xFFFFFFFF);
	SETBIT(SYSCONFIG->PINMUX[1], 0x22222220);  // This is enabling the McBSP1 pins

	CLRBIT(SYSCONFIG->PINMUX[5], 0x00FF0FFF);
	SETBIT(SYSCONFIG->PINMUX[5], 0x00110111);  // This is enabling SPI pins

	CLRBIT(SYSCONFIG->PINMUX[16], 0xFFFF0000);
	SETBIT(SYSCONFIG->PINMUX[16], 0x88880000);  // setup GP7.8 through GP7.13 
	CLRBIT(SYSCONFIG->PINMUX[17], 0x000000FF);
	SETBIT(SYSCONFIG->PINMUX[17], 0x00000088);  // setup GP7.8 through GP7.13

	init_LCD();
    
	LADARps.x = 3.5/12; // 3.5/12 for front mounting
	LADARps.y = 0;
	LADARps.theta = 1;  // not inverted

	OPTITRACKps.x = 0;
	OPTITRACKps.y = 0;
	OPTITRACKps.theta = 0;

	for(i = 0;i<LADAR_MAX_DATA_SIZE;i++)
	{ LADARdistance[i] = LADAR_MAX_READING; } //initialize all readings to max value.

	// ROBOTps will be updated by Optitrack during gyro calibration
	// TODO: specify the starting position of the robot
	ROBOTps.x = 0;			//the estimate in array form (useful for matrix operations)
	ROBOTps.y = 0;
	ROBOTps.theta = 0;  // was -PI: need to flip OT ground plane to fix this

	// flag pins
	GPIO_setDir(IMAGE_TO_LINUX_BANK, IMAGE_TO_LINUX_FLAG, GPIO_OUTPUT);
	GPIO_setDir(OPTITRACKDATA_FROM_LINUX_BANK, OPTITRACKDATA_FROM_LINUX_FLAG, GPIO_OUTPUT);
	GPIO_setDir(DATA_TO_LINUX_BANK, DATA_TO_LINUX_FLAG, GPIO_OUTPUT);
	GPIO_setDir(DATA_FROM_LINUX_BANK, DATA_FROM_LINUX_FLAG, GPIO_OUTPUT);
	GPIO_setDir(DATAFORFILE_TO_LINUX_BANK, DATAFORFILE_TO_LINUX_FLAG, GPIO_OUTPUT);
	GPIO_setDir(LVDATA_FROM_LINUX_BANK, LVDATA_FROM_LINUX_FLAG, GPIO_OUTPUT);
	GPIO_setDir(LVDATA_TO_LINUX_BANK, LVDATA_TO_LINUX_FLAG, GPIO_OUTPUT);


	CLR_OPTITRACKDATA_FROM_LINUX;  // Clear = tell linux DSP is ready for new Opitrack data
	CLR_DATA_FROM_LINUX;  // Clear = tell linux that DSP is ready for new data
	CLR_DATAFORFILE_TO_LINUX;  // Clear = linux not requesting data
	SET_DATA_TO_LINUX;  // Set = put float array data into shared memory for linux
	SET_IMAGE_TO_LINUX;  // Set = put image into shared memory for linux
	CLR_LVDATA_FROM_LINUX;  // Clear = tell linux that DSP is ready for new LV data
	SET_LVDATA_TO_LINUX;  // Set = put LV char data into shared memory for linux

    // clear all possible EDMA 
	EDMA3_0_Regs->SHADOW[1].ICR = 0xFFFFFFFF;
	
    // Add your init code here
}
Ejemplo n.º 6
0
//-----------------------------------------------------------------------------
// Function:	Initialize the general-purpose I/O
//
// Parameters:  none
//
// Returns:     none
//
//-----------------------------------------------------------------------------
int main(void)
{
	int i;
	float fir_coeffs[FILTER_LEN] = { FIR_FILT_32 };
	float lat_coeffs[FILTER_LEN] = {0.0f};
	float f_prev=0.0f, g_new=0.0f, g_prev=0.0f;
	float g[FILTER_LEN+1]={0.0f};

	int16_t dataInput;       		// Sine Sample
	int16_t oldDataInput;       	// Sine Sample delayed

	//
	// Compute reflection coefficients for lattice filter
	//
	MakeLatticeCoeffs(fir_coeffs, lat_coeffs);

   EVMOMAPL138_init();				// Initialize the board
   EVMOMAPL138_initRAM();			// Set up the RAM
   EVMOMAPL138_enableDsp();			// Wake up the DSP


	// init the i2c for all to use.
	USTIMER_init();					// General use timers
	I2C_init(I2C0, I2C_CLK_400K);	// I2C initialization

	// set gpio output
	SetGpio();						// Configure the General Purpose I/O
	
	McASP_Init();					// Initialize McASP

	AIC3106_Init();					// Initialize AIC3106

	McASP_Start();					// Start McASP

	// Infinite loop:  	Each loop reads/writes one sample to the left and right channels.
	while (1){

/* The following code is here to allow a test signal to be generated. THIS IS
NOT HOW LAB 1 IS TO BE DONE!  Remove the code up to the indicated spot and insert
your own code.
*/

		// Store the last sample because of the one sample delay between channels.
		oldDataInput = dataInput;

		//
		// Update the first stage of the lattice filter
		//
		f_prev = dataInput;			// Set f_0 equal to the input sample
		g_prev = g[0];			// Save the value stored in g[0]
		g[0] = dataInput;				// Update g[0]

		//
		// Iteratively compute next filter output for remaining stages
		//
		for( i=1; i<=FILTER_LEN; i++ )
		{
			// Save the value currently stored in the i-th delay element
			g_new = g[i];
			// Compute g, and store it in the i-th delay element
			g[i] = g_prev + f_prev*lat_coeffs[i-1];
			// Compute f
			f_prev += g_prev*lat_coeffs[i-1];
			// Pass the saved value from the delay element to the next stage
			g_prev = g_new;
		}

		//
		// Subtract the current input sample (Due to FIR to Lattice conversion)
		//
		dataInput = (int16_t) f_prev - dataInput;


        // wait for xmit ready and send a sample to the left channel.
        while (!CHKBIT(MCASP->SRCTL11, XRDY)) {}
        MCASP->XBUF11 = oldDataInput;
		oldDataInput = MCASP->XBUF12;	// Read the left channel input samples.

        // wait for xmit ready and send a sample to the right channel.
        while (!CHKBIT(MCASP->SRCTL11, XRDY)) {}
        MCASP->XBUF11 = dataInput;
		dataInput = MCASP->XBUF12;	// Read the right channel input samples.
            	
     }   
}