Not well confirmed

Dependencies:   mbed shimabara unzen_quickstart_lpc4088

Committer:
shorie
Date:
Sat Jun 11 05:42:07 2016 +0000
Revision:
0:2bfb84d07f90
First version;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shorie 0:2bfb84d07f90 1 #include "unzen.h" // audio framework include file
shorie 0:2bfb84d07f90 2 #include "umb_adau1361a.h" // audio codec contoler include file
shorie 0:2bfb84d07f90 3 #include "mbed.h"
shorie 0:2bfb84d07f90 4
shorie 0:2bfb84d07f90 5 #define CODEC_I2C_ADDR 0x38
shorie 0:2bfb84d07f90 6
shorie 0:2bfb84d07f90 7 // for debug
shorie 0:2bfb84d07f90 8 DigitalOut myled1(LED1);
shorie 0:2bfb84d07f90 9
shorie 0:2bfb84d07f90 10
shorie 0:2bfb84d07f90 11
shorie 0:2bfb84d07f90 12 // customer signal processing initialization call back.
shorie 0:2bfb84d07f90 13 void init_callback(
shorie 0:2bfb84d07f90 14 unsigned int block_size // block size [sample]
shorie 0:2bfb84d07f90 15 )
shorie 0:2bfb84d07f90 16 {
shorie 0:2bfb84d07f90 17 // place initialization code here
shorie 0:2bfb84d07f90 18 }
shorie 0:2bfb84d07f90 19
shorie 0:2bfb84d07f90 20
shorie 0:2bfb84d07f90 21 // customer signal processing call back.
shorie 0:2bfb84d07f90 22 void process_callback(
shorie 0:2bfb84d07f90 23 float rx_left_buffer[], // array of the left input samples
shorie 0:2bfb84d07f90 24 float rx_right_buffer[], // array of the right input samples
shorie 0:2bfb84d07f90 25 float tx_left_buffer[], // place to write the left output samples
shorie 0:2bfb84d07f90 26 float tx_right_buffer[], // place to write the left output samples
shorie 0:2bfb84d07f90 27 unsigned int block_size // block size [sample]
shorie 0:2bfb84d07f90 28 )
shorie 0:2bfb84d07f90 29 {
shorie 0:2bfb84d07f90 30 // Sample processing
shorie 0:2bfb84d07f90 31 for ( int i=0; i<block_size; i++) // for all sample
shorie 0:2bfb84d07f90 32 {
shorie 0:2bfb84d07f90 33 tx_left_buffer[i] = rx_left_buffer[i]; // copy from input to output
shorie 0:2bfb84d07f90 34 tx_right_buffer[i] = rx_right_buffer[i];
shorie 0:2bfb84d07f90 35
shorie 0:2bfb84d07f90 36 }
shorie 0:2bfb84d07f90 37 }
shorie 0:2bfb84d07f90 38
shorie 0:2bfb84d07f90 39
shorie 0:2bfb84d07f90 40 int main()
shorie 0:2bfb84d07f90 41 {
shorie 0:2bfb84d07f90 42 // I2C is essential to talk with ADAU1361
shorie 0:2bfb84d07f90 43 I2C i2c(p32, p31); // SDA, SDC of LPC4088 I2C0
shorie 0:2bfb84d07f90 44
shorie 0:2bfb84d07f90 45 // create an audio codec contoler
shorie 0:2bfb84d07f90 46 shimabara::UMB_ADAU1361A codec(shimabara::Fs_32, i2c, CODEC_I2C_ADDR ); //
shorie 0:2bfb84d07f90 47 // shimabara::UMB_ADAU1361A codec(shimabara::Fs_441, i2c, CODEC_I2C_ADDR );
shorie 0:2bfb84d07f90 48 // shimabara::UMB_ADAU1361A codec(shimabara::Fs_48, i2c, CODEC_I2C_ADDR );
shorie 0:2bfb84d07f90 49 // shimabara::UMB_ADAU1361A codec(shimabara::Fs_96, i2c, CODEC_I2C_ADDR );
shorie 0:2bfb84d07f90 50
shorie 0:2bfb84d07f90 51 // create an audio framework by singlton pattern
shorie 0:2bfb84d07f90 52 unzen::Framework audio;
shorie 0:2bfb84d07f90 53
shorie 0:2bfb84d07f90 54 /* Set I3C clock to 100kHz*/
shorie 0:2bfb84d07f90 55 i2c.frequency( 100000 );
shorie 0:2bfb84d07f90 56
shorie 0:2bfb84d07f90 57
shorie 0:2bfb84d07f90 58 /* Configure the optional block size of signal processing. By default, it is 1[Sample] */
shorie 0:2bfb84d07f90 59 // audio.set_block_size(4);
shorie 0:2bfb84d07f90 60
shorie 0:2bfb84d07f90 61 /* for debug. Optional pre/post call backs. This block can be removed in the real application */
shorie 0:2bfb84d07f90 62
shorie 0:2bfb84d07f90 63 // audio.set_pre_interrupt_callback(pre_int);
shorie 0:2bfb84d07f90 64 // audio.set_post_interrupt_callback(post_int);
shorie 0:2bfb84d07f90 65 // audio.set_pre_process_callback(pre_proc);
shorie 0:2bfb84d07f90 66 // audio.set_post_process_callback(post_proc);
shorie 0:2bfb84d07f90 67
shorie 0:2bfb84d07f90 68
shorie 0:2bfb84d07f90 69
shorie 0:2bfb84d07f90 70 /* Start the ADAU1361. Audio codec starts to generate the I2C signals */
shorie 0:2bfb84d07f90 71 codec.start();
shorie 0:2bfb84d07f90 72
shorie 0:2bfb84d07f90 73 /* Start the audio framework on ARM processor. */
shorie 0:2bfb84d07f90 74 audio.start( init_callback, process_callback); // path the initializaiton and process call back to framework
shorie 0:2bfb84d07f90 75
shorie 0:2bfb84d07f90 76
shorie 0:2bfb84d07f90 77
shorie 0:2bfb84d07f90 78 codec.set_hp_output_gain( 0, 0 );
shorie 0:2bfb84d07f90 79
shorie 0:2bfb84d07f90 80 while(1)
shorie 0:2bfb84d07f90 81 {
shorie 0:2bfb84d07f90 82 for ( int i=-15; i<4; i++ )
shorie 0:2bfb84d07f90 83 {
shorie 0:2bfb84d07f90 84 codec.set_hp_output_gain( i, i );
shorie 0:2bfb84d07f90 85 codec.set_line_output_gain( i, i );
shorie 0:2bfb84d07f90 86 myled1 = 1;
shorie 0:2bfb84d07f90 87 wait(0.25);
shorie 0:2bfb84d07f90 88 myled1 = 0;
shorie 0:2bfb84d07f90 89 wait(0.25);
shorie 0:2bfb84d07f90 90 }
shorie 0:2bfb84d07f90 91 }
shorie 0:2bfb84d07f90 92 }
shorie 0:2bfb84d07f90 93
shorie 0:2bfb84d07f90 94
shorie 0:2bfb84d07f90 95
shorie 0:2bfb84d07f90 96 //*************** debug functions ******************
shorie 0:2bfb84d07f90 97