
Dialog DA7212 evaluating project DEVELOP branch
Dependencies: FXAS21002 TLV320 mbed sinelookup C12832 FXOS8700
main.cpp
- Committer:
- k4zuki
- Date:
- 2016-03-24
- Revision:
- 7:6b4ca547cb88
- Parent:
- 5:f1907e4d1147
- Child:
- 8:42093f0e5d9e
File content as of revision 7:6b4ca547cb88:
/** original: p07gbar/code/TLV320_Write_test/ * modify by k4zuki * to control Dialog DA7212 codec */ #include "mbed.h" #include "sinelookup.h" // #include "TLV320.h" // #include "DA7212.h" // #include "I2S.h" // #include "C12832.h" // C12832 lcd(D11, D13, D12, D7, D10); // C12832 lcd(PTD2, PTD1, PTD3, PTC3, PTD0); // AnalogIn pot1 (A0); // AnalogIn pot2 (A1); // AnalogIn pot1 (PTB2); // AnalogIn pot2 (PTB3); #define SAMPLERATE 32000 /* //DA7212 codec(I2C_SDA, I2C_SCL); TLV320 codec(I2C_SDA, I2C_SCL); I2S i2s(I2S_TRANSMIT, PTC1, PTB19, PTB18); AnalogIn aIn(p19); AnalogIn vol(p20); float phase_l; float phase_r; int minibuf[16]; float skipper; float volume; float phase_kill; extern "C" void HardFault_Handler() { error("Hard Fault!\n"); } void play(void) { int to_write = i2s.max_fifo_points() - (i2s.fifo_points()); for(int i = 0; i < to_write; i+=2) { minibuf[i] = int(float(sine16lookup[int(phase_l)])*volume); //minibuf[i] = int(sine16lookup[int(phase_l)]); minibuf[i+1] = int(float(sine16lookup[int(phase_r)])*volume); phase_l+=skipper; phase_r = phase_l + phase_kill; while(phase_l >= SINE16LENGTH) { phase_l -= SINE16LENGTH; } while(phase_r >= SINE16LENGTH) { phase_r -= SINE16LENGTH; } while(phase_r< 0) phase_r += SINE16LENGTH; } i2s.write(minibuf, to_write); } */ /* main */ int main() { I2S0_TCSR |= 1u<<31; /* skipper = (aIn*49)+1; codec.power(true); codec.frequency(SAMPLERATE); codec.wordsize(16); codec.master(false); codec.headphone_volume(0.5); codec.start(); i2s.frequency(SAMPLERATE); i2s.wordsize(16); i2s.stereomono(I2S_STEREO); i2s.masterslave(I2S_MASTER); i2s.attach(&play); i2s.start(); */ while(1) {; /* skipper = (aIn*30)+1; volume = 1; phase_kill = (vol-0.5)*400; //printf("Skipper:%f, %i, %i\n\r",skipper, to_write,i2s.fifo_level()); */ /*if(flag) { printf("."); flag = false; }*/ } } // #include "C12832.h" // // C12832 lcd(D11, D13, D12, D7, D10); // // AnalogIn pot1 (A0); // AnalogIn pot2 (A1); // // int main() // { // while(1) { // lcd.cls(); // lcd.locate(0,3); // lcd.printf("Pot 1 = %.2f", (float)pot1); // lcd.locate(0,14); // lcd.printf("Pot 2 = %.2f", (float)pot2); // wait(0.1); // } // }