예제 #1
0
파일: main.c 프로젝트: yfang1644/DSP55X
void main(void)
{
	Uint16 key;

	ICR = 0xff2e;	/* IDLE Control Register */
	/* mem port, io port and cpu idle active */

	/* Peripheral_Reset  */
	CSL_SYSCTRL_REGS->PSRCR = 0x0020;

	CSL_SYSCTRL_REGS->PCGCR1 = 0x0000;
	CSL_SYSCTRL_REGS->PCGCR2 = 0x0000;
	CSL_SYSCTRL_REGS->PRCR = 0x00bf;

/* VERY IMPORTANT !!! */
/* PPMODE1 (SPI, GPIO, UART, and I2S2):
	7 signals of the SPI module,
	6 GPIO signals(GP[17:12]),
	4 signals of the UART module,
	4 signals of the I2S2 module

   SP1MODE2 (GP[11:6]). 6 GPIO signals (GP[11:6])
   SP0MODE0 (MMC/SD0). All 6 signals of the MMC/SD0
*/
	CSL_SYSCTRL_REGS->EBSR = (CSL_SYS_EBSR_PPMODE_MODE1 << 12)
							|(CSL_SYS_EBSR_SP1MODE_MODE2 << 10)
							|(CSL_SYS_EBSR_SP0MODE_MODE0 << 8);

	asm("	bit(ST1, #ST1_INTM) = #1");

	INTR_init();
	PLL_init(160*1000000L);
	TIMER_init();

	EZDSP5535_I2C_init();
	EZDSP5535_LCD_init();
	aic3204_init(2, 0);
	EZDSP5535_GPIO_init();
	EZDSP5535_I2S_init(1);			// interrupt mode
	EZDSP5535_SAR_init();
	asm("	bit(ST1, #ST1_INTM) = #0");

	displayPeriod();
	while(1) {
		key = EZDSP5535_SAR_getKey();
		if(key == SW1) {
			if(period > 10)
				period--;
			CSL_GPIO_REGS->IOOUTDATA2 ^= 2;
			displayPeriod();
		}
		if(key == SW2) {
			if(period < 900)
				period++;
			CSL_GPIO_REGS->IOOUTDATA2 ^= 1;
			displayPeriod();
		}
		asm("   idle");
	}
}
예제 #2
0
파일: main.c 프로젝트: yfang1644/DSP55X
void main()
{
	int key = 0;
	int freqShift = 0;

	ICR = 0xff2e;	/* IDLE Control Register */
					/* mem port, io port and cpu idle active */

	/* Peripheral_Reset  */
	CSL_SYSCTRL_REGS->PSRCR = 0x0020;

	CSL_SYSCTRL_REGS->PCGCR1 = 0x0000;
	CSL_SYSCTRL_REGS->PCGCR2 = 0x0000;
	CSL_SYSCTRL_REGS->PRCR = 0x00bf;

/* VERY IMPORTANT !!! */
/* PPMODE1 (SPI, GPIO, UART, and I2S2):
	7 signals of the SPI module,
	6 GPIO signals(GP[17:12]),
	4 signals of the UART module,
	4 signals of the I2S2 module

   SP1MODE2 (GP[11:6]). 6 GPIO signals (GP[11:6])
   SP0MODE0 (MMC/SD0). All 6 signals of the MMC/SD0
*/
	CSL_SYSCTRL_REGS->EBSR = (CSL_SYS_EBSR_PPMODE_MODE1 << 12)
							|(CSL_SYS_EBSR_SP1MODE_MODE2 << 10)
							|(CSL_SYS_EBSR_SP0MODE_MODE0 << 8);

	asm("	bit(ST1, #ST1_INTM) = #1");
	PLL_init(80000000);				/* CPU clock = 10MHz */
	INTR_init();				/* set Interrupt vector and clean all IRs */
	EZDSP5535_GPIO_init();
	EZDSP5535_I2C_init();		/* Initialize I2C */
	aic3204_init(2, 0);		/* Initialize codec, sampling rate = 32kHz */
    DMA_audio_init(4 * FFT_L);
	EZDSP5535_I2S_init(0);		/* Initialize I2S */

	EZDSP5535_SAR_init();

	asm("	bit(ST1, #ST1_INTM) = #0");

	while(1) {
		audioProcessing(freqShift);

		key = EZDSP5535_SAR_getKey();
		if(key == SW1) {
			freqShift = 1;
			CSL_GPIO_REGS->IOOUTDATA2 &= ~0x0002;
		}
		if(key == SW2) {
			freqShift = 0;
			CSL_GPIO_REGS->IOOUTDATA2 |= 0x0002;
		}

		asm("   idle");
	}
}
예제 #3
0
파일: main.c 프로젝트: daniw/dsvb
void main( void ) 
{
    /* Initialize BSL */
    USBSTK5505_init( );

	/* Initialize Phase Locked Loop (PLL) */
    pll_frequency_setup(100);

    /* Initialise hardware interface and I2C for code */
    aic3204_hardware_init();
    
    /* Initialise the AIC3204 codec */
    aic3204_init(); 

    printf("\n\nRunning Project DTMF Generator\n");
    printf( "Generates DTMF frequencies for telephone number --> to Headphones/Lineout\n\n" );

   /* Setup sampling frequency */

    set_sampling_frequency_and_gain(SAMPLES_PER_SECOND, 0);
  
    asm(" bclr XF");                // Turn off XF LED
   
    while(1)
    {
     aic3204_codec_read(&left_input, &right_input); // Configured for one interrupt per two channels.
     
     left_output = right_output = dial_phone_number(&telephone_number[0]);

     if ( left_output > 0)
      {
       asm(" bset XF");
      }
     else
      {
       asm(" bclr XF");
      }
 
     aic3204_codec_write(left_output/2, right_output/2);
    }
}
예제 #4
0
파일: main.c 프로젝트: yfang1644/DSP55X
void main(void)
{
	Int16  *samples;
	HANDLE FHandle = Not_Open_FILE;
	Int16  *out_words = &rawOutWords[1];
	Uint8  *byte16 = &RfByte[2];	
	Int16  mlt_coefs[DCT_LENGTH];
	Int16  mag_shift[2];
	Int16  old_mag_shift[2];
	Uint16 number_of_bits_per_frame;
	Uint16 number_of_bytes_per_frame;
	Uint16 number_of_16bit_words_per_frame;
	Int16  offset;
	Int16  key;
	Uint16 chn;		// left and right channel, 0 or 1
	Int16  sent_buffer_cnt = 0;
	Uint8  *sent_buffer;
	
	ICR = 0xff2e;	/* IDLE Control Register */
					/* mem port, io port and cpu idle active */

	DSP_zero(xmt_l, DCT_LENGTH);
	DSP_zero(xmt_r, DCT_LENGTH);
	/* Peripheral_Reset  */
	CSL_SYSCTRL_REGS->PSRCR = 0x0020;

	CSL_SYSCTRL_REGS->PCGCR1 = 0x0000;
	CSL_SYSCTRL_REGS->PCGCR2 = 0x0000;
	CSL_SYSCTRL_REGS->PRCR = 0x00bf;

	CSL_SYSCTRL_REGS->EBSR = (CSL_SYS_EBSR_PPMODE_MODE1 << 12)
							| (0 << 8) | (2 << 10);//GPIO(11-6)
	asm("	bit(ST1, #ST1_INTM) = #1");

	number_of_bits_per_frame = (Uint16)(BITRATE * 20);	// BITRATE in kbps
	number_of_bytes_per_frame = (Uint16)(number_of_bits_per_frame>>3);
	number_of_16bit_words_per_frame = (Uint16)(number_of_bits_per_frame>>4);

	INTR_init();
	PLL_init();
	TIMER_init();
	EZDSP5535_GPIO_init();
	DMA_audio_init(DCT_LENGTH);

	EZDSP5535_I2C_init();		/* Initialize I2C */
	aic3204_init(6);			/* Initialize codec */
	EZDSP5535_LCD_init();
	EZDSP5535_I2S_init();		/* Initialize I2S */
	LCD_print("G722.1 Send       ", 17, 0);
	LCD_print("16kbps  ", 8, 1);
	EZDSP5535_SPI_init();
	Si446x_Init();
	EZDSP5535_SAR_init();
	DiskInit();
	FileInit();
	AddFileDriver(SDCammand, NULL);

	sam2coef_init();
	coef2sam_init();
	rawOutWords[0] = 0x6b21;
	RfByte[0] = 0x21; RfByte[1] = 0x6b;		// little-endian

	old_mag_shift[0] = 0;
	old_mag_shift[1] = 0;
	asm("	bit(ST1, #ST1_INTM) = #0");

	SpiWriteByte(CMD_GET_INT_STATUS, 0);	// clear interrupt pending
	while(1) {
		if(pingpong >= 0) {
			offset = (pingpong>>1) * DCT_LENGTH;
/*******************************************************************
 * LEFT LEFT LEFT LEFT LEFT LEFT LEFT LEFT LEFT LEFT LEFT LEFT
 *******************************************************************/
			chn = LEFT;
			samples = &rcv_l[offset];		// Read frame of samples from mem.
			// Convert input samples to rmlt coefs
			mag_shift[chn] = samples_to_rmlt_coefs(samples, mlt_coefs, chn);
			// Encode the mlt coefs
			encoder(number_of_bits_per_frame, mlt_coefs, mag_shift[chn], out_words);
			byte16 = &RfByte[2];
			byte16[-2] = 0x6b; byte16[-1] = 0x20;
			DSP_word2byte(byte16, out_words, number_of_16bit_words_per_frame);
			
			// process the out_words into decoder_mlt_coefs
			decoder(out_words, mlt_coefs, &mag_shift[chn], &old_mag_shift[chn]);

			samples = &xmt_l[offset];		// Write frame of output samples
			// convert the decoder_mlt_coefs to samples
			rmlt_coefs_to_samples(mlt_coefs, samples, mag_shift[chn], chn);

/*******************************************************************
 * RIGHT RIGHT RIGHT RIGHT RIGHT RIGHT RIGHT RIGHT RIGHT RIGHT 
 *******************************************************************/
			chn = RIGHT;
			samples = &rcv_r[offset];		// Read frame of samples from mem.
			// Convert input samples to rmlt coefs
			mag_shift[chn] = samples_to_rmlt_coefs(samples, mlt_coefs, chn);
			// Encode the mlt coefs
			encoder(number_of_bits_per_frame, mlt_coefs, mag_shift[chn], out_words);

			byte16 = &RfByte[number_of_bytes_per_frame + 4];
			byte16[-2] = 0x6b; byte16[-1] = 0x21;
			DSP_word2byte(byte16, out_words, number_of_16bit_words_per_frame);

			// process the out_words into decoder_mlt_coefs
			decoder(out_words, mlt_coefs, &mag_shift[chn], &old_mag_shift[chn]);

			samples = &xmt_r[offset];		// Write frame of output samples
			// convert the decoder_mlt_coefs to samples
			rmlt_coefs_to_samples(mlt_coefs, samples, mag_shift[chn], chn);

			if (FHandle != Not_Open_FILE)	// Write output bitstream
				FileWrite(RfByte, 2*number_of_bytes_per_frame+4, FHandle);

			pingpong = -1;
			sent_buffer = RfByte;
			sent_buffer_cnt = 0;
		}
		if(spiIsrStatus == 1) {
			bApi_Set_Send(43);
			spiIsrStatus = 0;
		}
		if(sent_buffer_cnt < 2) {
			if(gpioIsrStatus == 1) {
				SPI_sendData(sent_buffer, number_of_bytes_per_frame+2);
				sent_buffer += number_of_bytes_per_frame+2;
				sent_buffer_cnt++;
				gpioIsrStatus = 0;
				CSL_GPIO_REGS->IOINTFLG1 = 0x0800;
			}
		}

//		key = EZDSP5535_SAR_getKey();
		key = -1;
		if(key == SW1)
		if(FHandle == Not_Open_FILE)
		{
			LCD_print("RECORDING......", 15, 0);
			FHandle = FileOpen("A:\\VOICE000.TXT", FILE_FLAGS_WRITE);
		}
		if(key == SW2)
		if(FHandle != Not_Open_FILE)
		{
			LCD_print("SAVE VOICE000.DAT", 17, 0); 
			FileClose(FHandle);
			AllCacheWriteBack();
			FHandle = Not_Open_FILE;
		}
		asm("	idle");
	}