Plays USB Audio packets through external DAC (Cirrus Logic CS4344). Simple demo code, don't expect a sophisticated I2S library. HW setup: mbed DIP 5 (I2STX_SDA) -> DAC SDIN (Serial Audio Data Input) mbed DIP 6 (I2STX_WS) -> DAC LRCK (Left Right Clock) mbed DIP 7 (I2STX_CLK) -> DAC SCLK (External Serial Clock Input) mbed DIP 30 (I2SRX_CLK) -> DAC MCLK (Master Clock) also needed an extra USB connector wired to mbed. Does not work with built-in USB. Code needs a bit of clean up.
main.cpp
- Committer:
- csorbag
- Date:
- 2012-04-16
- Revision:
- 0:bf9e7b99dda5
- Child:
- 1:12e8ee1b7ea2
File content as of revision 0:bf9e7b99dda5:
#include "mbed.h" #include "USBAudio.h" #include "I2S.h" Serial pc(USBTX, USBRX); // frequency: 48 kHz #define FREQ 48000 // 1 channel: mono #define NB_CHA 2 // length of an audio packet: each ms, we receive 48 * 16bits ->48 * 2 bytes per channel. For stereo multiply by 2 #define AUDIO_LENGTH_PACKET 48 * 2 * 2 // USBAudio USBAudio audio(FREQ, NB_CHA,FREQ, NB_CHA,0x7bb8, 0x1112); int main() { int16_t buf[AUDIO_LENGTH_PACKET/2]; setup(&pc); pc.printf("Begin new\n"); while (1) { // read an audio packet audio.read((uint8_t *)buf); // send to DAC play(buf,AUDIO_LENGTH_PACKET/2); } }