Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: amakusa mbed-dsp mbed shimabara ukifune unzen_nucleo_f746
Fork of skeleton_unzen_nucleo_f746 by
main.cpp
- Committer:
- shorie
- Date:
- 2017-01-27
- Revision:
- 7:e86c645231ff
- Parent:
- 6:486b1cb03e61
- Child:
- 8:d8d1776e865b
File content as of revision 7:e86c645231ff:
#include "mbed.h"
// Note : Do not touch the "unzen dependent" part.
// Configure the "project dependent" part.
/************************** unzen dependent constants. ************************/
#define CODEC_I2C_ADDR 0x38 // Address of the ADAU-1361A
/*========================= Project Dependent Constants ======================*/
#define BLOCKSIZE 16 // number of the sample to be processed at once.
#define FS shimabara::Fs_48 // Fs can be Fs_32, Fs_441, Fs_48, Fs_96
/************************** unzen dependent include. **************************/
#include "unzen.h" // audio framework include file
#include "umb_adau1361a.h" // audio codec contoler include file
#include "amakusa.h" // audio signal processing class library.
#include "ukifune.h" // UI board support routines
/*========================= project dependent include. =======================*/
#include "signal_processing.h"
/************************* Unzen Dependent Global Variables *******************/
// I2C is essential to talk with ADAU1361
I2C i2c(D14, D15);
// create an audio codec contoler
shimabara::UMB_ADAU1361A codec(FS, i2c, CODEC_I2C_ADDR );
// create an audio framework by singlton pattern
unzen::Framework audio;
/*========================= project dependent Global Variable. ===============*/
// create a pointer to the signal processing object.
SignalProcessing * process;
/************************* Unzen Dependent Function Prototype *****************/
// for system usage. Do not care.
void initialize_system(void);
/*========================= Main program. ====================================*/
int main()
{
// start audio. Do not touch
initialize_system();
// main loop. Signal processing is done in background.
while(1)
{ // place your foreground program here.
process->set_volume( ukifune::get_volume(0) );
// you have to call tick() every 20mS-50mS if you need get_volume()
wait(0.05);
ukifune::tick();
}
} // End of main
/*========================= project dependent Signal Processing. ============*/
// customer signal processing initialization call back.
void init_callback(
unsigned int block_size // block size [sample]
)
{
// place initialization code here
process = new SignalProcessing( block_size );
} // end of init_callback
// customer signal processing call back.
void process_callback(
float rx_left_buffer[], // array of the left input samples
float rx_right_buffer[], // array of the right input samples
float tx_left_buffer[], // place to write the left output samples
float tx_right_buffer[], // place to write the left output samples
unsigned int block_size // block size [sample]
)
{
// place signal processing code here
process->run( rx_left_buffer, rx_right_buffer, tx_left_buffer, tx_right_buffer, block_size );
} // End of process_callback
/************************* Unzen Dependent Function implementation ************/
void initialize_system(void)
{
// Set I3C clock to 100kHz
i2c.frequency( 100000 );
// Configure the optional block size of signal processing. By default, it is 1[Sample]
audio.set_block_size(BLOCKSIZE);
// Start UI module.
ukifune::init( & audio );
// Start the ADAU1361. Audio codec starts to generate the I2C signals
codec.start();
// Start the audio framework on ARM processor.
audio.start( init_callback, process_callback); // path the initializaiton and process call back to framework
// Setup initial analog gain
codec.set_hp_output_gain( 0, 0 );
codec.set_line_output_gain( 0, 0 );
}
