You are viewing an older revision! See the latest version
RS Audio Codec
This page provides information and some examples for the use of the RS Audio Codec sub board, based on TI's TLV320 chip. This chip provides a high quality audio link out and in to the mbed with IO including: an amplified stereo headphone out, an stereo line out, a stereo line in and an pre-amped mono microphone input. Such a capable chip opens up a lot of options for high quality audio on mbed. 
The easiest way to get something working is to load a test wave file (such as this one or this one) onto a flash drive, plug it into the Lab Board and load up this program:
Import programWavPlayer_test
A test program for the WavPlayer class, works on the RS Animatronic Lab Board
or just this one:
Import programTLV320_Write_test
A test program for the TLV320, Generates some sine waves.
Both programs use the TLV320 library and the I2S library:
Import library
Public Member Functions |
|
| I2S (bool rxtx, PinName sd, PinName ws, PinName clk) | |
|
Create a
I2S
instance.
|
|
| I2S (bool rxtx, PinName sd) | |
|
Create a
I2S
instance: Only with the serial data line set.
|
|
| I2S (bool rxtx, PinName sd, PinName ws) | |
|
Create a
I2S
instance: Only with serial data line and word select.
|
|
| I2S (bool rxtx, PinName sd, bool fourwiremode) | |
|
Create a
I2S
instance: Only with serial data line.
|
|
| I2S (bool rxtx, PinName sd, PinName ws, bool fourwiremode) | |
|
Create a
I2S
instance: Only with serial data line and word select line.
|
|
| ~I2S () | |
|
Destroy the
I2S
instance.
|
|
| void | write (char buf[], int len) |
|
Write to the FIFO.
|
|
| void | write (int buf[], int len) |
|
Write to the FIFO.
|
|
| int | read () |
|
Read the FIFOs contents.
|
|
| void | read (char buf[], int len) |
|
Read from the FIFO.
|
|
| void | read (int buf[], int len) |
|
Read from the FIFO.
|
|
| int | max_fifo_points () |
|
Get the maximum number of points of data the FIFO could store.
|
|
| void | power (bool pwr) |
|
Switch the peripheral on and off.
|
|
| void | masterslave (bool mastermode) |
|
Switch the peripheral between master and slave.
|
|
| void | wordsize (int words) |
|
Switch the peripheral between different wordsizes.
|
|
| void | mclk_freq (int freq) |
|
Define the mclk frequency.
|
|
| void | frequency (int freq) |
|
Define the sample rate.
|
|
| void | set_interrupt_fifo_level (int level) |
|
Set the level that the fifo interrupts at.
|
|
| int | fifo_level () |
|
Get the current FIFO level.
|
|
| int | fifo_points () |
|
Get the current number of samples in the FIFO.
|
|
| void | stereomono (bool stereomode) |
|
Set whether the peripheral is in stereo or mono mode: in mono the perifpheral sends out the same data twice.
|
|
| void | mute () |
|
Mute the peripheral.
|
|
| void | mute (bool mute_en) |
|
Set the mute status of the peripheral.
|
|
| void | stop () |
|
Stop the peripheral.
|
|
| void | start () |
|
Start the peripheral.
|
|
| bool | setup_ok () |
|
Check the Clock and Pin setup went according to plan.
|
|
| void | attach (void(*fptr)(void)) |
|
Attach a function to be called when the FIFO triggers.
|
|
| template<typename T > | |
| void | attach (T *tptr, void(T::*mptr)(void)) |
|
Attach a member function to be called when the FIFO triggers.
|
|
Import library
Public Member Functions |
|
| TLV320 (PinName i2c_sda, PinName i2c_scl) | |
|
Create an instance of the
TLV320
class.
|
|
| TLV320 (PinName i2c_sda, PinName i2c_scl, bool cs_level) | |
|
Create an instance of the
TLV320
class.
|
|
| void | power (bool on_off) |
|
Control the power of the device.
|
|
| void | input_select (int input) |
|
Control the input source of the device.
|
|
| void | headphone_volume (float h_volume) |
|
Set the headphone volume.
|
|
| void | linein_volume (float li_volume) |
|
Set the line in pre-amp volume.
|
|
| void | microphone_boost (bool mic_boost) |
|
Turn on/off the microphone pre-amp boost.
|
|
| void | input_mute (bool mute) |
|
Mute the input.
|
|
| void | output_mute (bool mute) |
|
Mute the output.
|
|
| void | input_power (bool on_off) |
|
Turn on/off the input stage.
|
|
| void | output_power (bool on_off) |
|
Turn on/off the output stage.
|
|
| void | wordsize (int words) |
|
Select the word size.
|
|
| void | master (bool master) |
|
Select interface mode: Master or Slave.
|
|
| void | frequency (int freq) |
|
Select the sample rate.
|
|
| void | input_highpass (bool enabled) |
|
Enable the input highpass filter.
|
|
| void | output_softmute (bool enabled) |
|
Enable the output soft mute.
|
|
| void | interface_switch (bool on_off) |
|
Turn on and off the I2S.
|
|
| void | reset () |
|
Reset the device and settings.
|
|
| void | sidetone (float sidetone_vol) |
|
Set the microphone sidetone volume.
|
|
| void | bypass (bool bypass_en) |
|
Set the analog bypass.
|
|
| void | deemphasis (char code) |
|
Set the deemphasis frequency.
|
|
| void | adc_highpass (bool enable) |
|
Enable the input highpass filter.
|
|
| void | start () |
|
Start the device sending/recieving etc.
|
|
| void | stop () |
|
Stop the device sending/recieving etc.
|
|
