void dsp_process_init(int cpu_hz, int hsb_hz, int pba_hz, int pbb_hz) { // Initialize TPA6130 tpa6130_init(); // Initialize DAC that send audio to TPA6130 tpa6130_dac_start(DAC_SAMPLING_RATE, DAC_NUM_CHANNELS, DAC_BITS_PER_SAMPLE, DAC_SWAP_CHANNELS, audio_callback, AUDIO_DAC_RELOAD_CB, FOSC0); tpa6130_set_volume(0x20); tpa6130_get_volume(); signal_source_init(&signal1_generator, 433, 20000); signal_source_init(&signal2_generator, 2000, 10000); current_stereo_out_buf = stereo_out_buf1; signal_in_buf = signal_pre_filter_buf + FIR_NUM_COEF; filter_restore_default(); /* Fill the initial buffer for the hamming window with ones. This buffer * will then be multiplied by the hamming window. */ dsp16_gen_step(fft_window, BUFFER_LENGTH, DSP16_Q(1.), DSP16_Q(1.), 0); dsp16_win_hamm(fft_window, fft_window, BUFFER_LENGTH); /* Run the interrupt handler manually once to start the ABDAC */ dac_reload_callback(); }
/*! main function */ int main(void) { init_sys_clocks(); // Initialize RS232 debug text output. init_dbg_rs232(FOSC0); print_dbg(MSG_WELCOME); // Enable LED0 and LED1 gpio_enable_gpio_pin(LED0_GPIO); gpio_enable_gpio_pin(LED1_GPIO); // Configure TWI as master twi_init(); // Initialize TPA6130 tpa6130_init(); // Initialize DAC that send audio to TPA6130 tpa6130_dac_start(DEFAULT_DAC_SAMPLE_RATE_HZ, DEFAULT_DAC_NUM_CHANNELS, DEFAULT_DAC_BITS_PER_SAMPLE, DEFAULT_DAC_SWAP_CHANNELS, master_callback, AUDIO_DAC_OUT_OF_SAMPLE_CB | AUDIO_DAC_RELOAD_CB, FOSC0); tpa6130_set_volume(0x2F); tpa6130_get_volume(); int count = 0; int i=0; while(true) { count = 0; // Store sample from the sound_table array while(count < (SOUND_SAMPLES)){ samples[count++] = ((uint8_t)sound_table[i]+0x80) << 8; samples[count++] = ((uint8_t)sound_table[i]+0x80) << 8; i++; if (i >= sizeof(sound_table)) i = 0; } gpio_set_gpio_pin(LED0_GPIO); gpio_clr_gpio_pin(LED1_GPIO); // Play buffer tpa6130_dac_output((void *) samples,SOUND_SAMPLES/2); gpio_clr_gpio_pin(LED0_GPIO); gpio_set_gpio_pin(LED1_GPIO); /* Wait until the reload register is empty. * This means that one transmission is still ongoing * but we are already able to set up the next transmission */ while(!tpa6130_dac_output(NULL, 0)); } }