A library which allows the playing of Wav files using the TLV320

Dependents:   RSALB_hbridge_helloworld RSALB_lobster WavPlayer_test AudioCODEC_HelloWorld

Embed: (wiki syntax)

« Back to documentation index

I2S Class Reference

I2S Class Reference

A class to play give access to the I2S library. More...

#include <I2S.h>

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.

Detailed Description

A class to play give access to the I2S library.

Definition at line 55 of file I2S.h.


Constructor & Destructor Documentation

I2S ( bool  rxtx,
PinName  sd,
PinName  ws,
PinName  clk 
)

Create a I2S instance.

Parameters:
rxtxSet the I2S instance to be transmit or recieve (I2S_TRANSMIT/I2S_RECEIVE)
sdThe serial data pin
wsThe word select pin
clkThe clock pin

Definition at line 22 of file I2S.cpp.

I2S ( bool  rxtx,
PinName  sd 
)

Create a I2S instance: Only with the serial data line set.

Won't really do much.

Parameters:
rxtxSet the I2S instance to be transmit or recieve (I2S_TRANSMIT/I2S_RECEIVE)
sdThe serial data pin

Definition at line 48 of file I2S.cpp.

I2S ( bool  rxtx,
PinName  sd,
PinName  ws 
)

Create a I2S instance: Only with serial data line and word select.

Parameters:
rxtxSet the I2S instance to be transmit or recieve (I2S_TRANSMIT/I2S_RECEIVE)
sdThe serial data pin
wsThe word select pin

Definition at line 121 of file I2S.cpp.

I2S ( bool  rxtx,
PinName  sd,
bool  fourwiremode 
)

Create a I2S instance: Only with serial data line.

Four wire mode means this is functional

Parameters:
rxtxSet the I2S instance to be transmit or recieve (I2S_TRANSMIT/I2S_RECEIVE)
sdThe serial data pin
fourwiremodeTrue means the peripheral is in 4-wire mode. It borrows WS and CLK from the other half

Definition at line 72 of file I2S.cpp.

I2S ( bool  rxtx,
PinName  sd,
PinName  ws,
bool  fourwiremode 
)

Create a I2S instance: Only with serial data line and word select line.

Four wire mode means this is functional

Parameters:
rxtxSet the I2S instance to be transmit or recieve (I2S_TRANSMIT/I2S_RECEIVE)
sdThe serial data pin
wsThe word select pin
fourwiremodeTrue means the peripheral is in 4-wire mode. It borrows WS and CLK from the other half

Definition at line 96 of file I2S.cpp.

~I2S (  )

Destroy the I2S instance.

Definition at line 146 of file I2S.cpp.


Member Function Documentation

void attach ( void(*)(void)  fptr )

Attach a function to be called when the FIFO triggers.

Parameters:
fptrA pointer to the function to be called

Definition at line 232 of file I2S.h.

void attach ( T *  tptr,
void(T::*)(void)  mptr 
)

Attach a member function to be called when the FIFO triggers.

Parameters:
tptrA pointer to the instance of the class
mptrA pointer to the member function

Definition at line 252 of file I2S.h.

int fifo_level (  )

Get the current FIFO level.

Returns:
A number between 0 and 7 the FIFO is currently at

Definition at line 375 of file I2S.cpp.

int fifo_points (  )

Get the current number of samples in the FIFO.

Returns:
A number showing how many samples are in the FIFO

Definition at line 323 of file I2S.cpp.

void frequency ( int  freq )

Define the sample rate.

Parameters:
freqThe desired sample rate frequency

Definition at line 369 of file I2S.cpp.

void masterslave ( bool  mastermode )

Switch the peripheral between master and slave.

Parameters:
mastermodeThe peripherals master/slave status (I2S_MASTER/I2S_SLAVE)

Definition at line 347 of file I2S.cpp.

int max_fifo_points (  )

Get the maximum number of points of data the FIFO could store.

Returns:
The number of points

Definition at line 309 of file I2S.cpp.

void mclk_freq ( int  freq )

Define the mclk frequency.

Parameters:
freqThe frequency desired for the mclk

Definition at line 363 of file I2S.cpp.

void mute (  )

Mute the peripheral.

Definition at line 399 of file I2S.cpp.

void mute ( bool  mute_en )

Set the mute status of the peripheral.

Parameters:
mute_enSet whether the mute is enabled

Definition at line 405 of file I2S.cpp.

void power ( bool  pwr )

Switch the peripheral on and off.

Parameters:
pwrPower status

Definition at line 337 of file I2S.cpp.

void read ( char  buf[],
int  len 
)

Read from the FIFO.

Parameters:
buf[]The buffer of values to read: raw bit shifted
lenThe number of chars to read

Definition at line 254 of file I2S.cpp.

void read ( int  buf[],
int  len 
)

Read from the FIFO.

Parameters:
buf[]The buffer of values to read: sorted to just values
lenThe number of chars to read

Definition at line 279 of file I2S.cpp.

int read (  )

Read the FIFOs contents.

Returns:
The buffers value.

Definition at line 249 of file I2S.cpp.

void set_interrupt_fifo_level ( int  level )

Set the level that the fifo interrupts at.

Parameters:
levelA number between 0 and 7 at which the fifo interrupts

Definition at line 417 of file I2S.cpp.

bool setup_ok (  )

Check the Clock and Pin setup went according to plan.

Returns:
Setup okay?

Definition at line 430 of file I2S.cpp.

void start (  )

Start the peripheral.

Definition at line 423 of file I2S.cpp.

void stereomono ( bool  stereomode )

Set whether the peripheral is in stereo or mono mode: in mono the perifpheral sends out the same data twice.

Parameters:
stereomodeWhether the peripheral is in stereo or mono: I2S_STEREO/I2S_MONO

Definition at line 390 of file I2S.cpp.

void stop (  )

Stop the peripheral.

Definition at line 411 of file I2S.cpp.

void wordsize ( int  words )

Switch the peripheral between different wordsizes.

Parameters:
wordsThe number of bits per word: 8,16,32

Definition at line 357 of file I2S.cpp.

void write ( char  buf[],
int  len 
)

Write to the FIFO.

Parameters:
buf[]The buffer of values to write: are bit stuffed in fours
lenThe number of chars to write

Definition at line 173 of file I2S.cpp.

void write ( int  buf[],
int  len 
)

Write to the FIFO.

Parameters:
buf[]The buffer of values to write: are bit stuffed automatically
lenThe number of chars to write

Definition at line 192 of file I2S.cpp.