BeRTOS
|
I2S driver functions. More...
Go to the source code of this file.
Defines | |
#define | I2S_FIRST_BUF 0 |
First buffer. | |
#define | I2S_SECOND_BUF 1 |
Second buffer. | |
Functions | |
void | i2s_init (void) |
Initializes the module and sets current buffer to I2S_FIRST_BUF. | |
uint8_t * | i2s_getBuffer (unsigned buf_num) |
Returns one of the two buffers or NULL if none is available. | |
uint8_t * | i2s_getFreeBuffer (void) |
Returns a buffer that will be played after the current one. | |
bool | i2s_start (void) |
Starts playing from I2S_FIRST_BUFFER. |
I2S driver functions.
This driver uses a double buffering technique to keep i2s bus busy. First fill in the two buffers using i2s_getBuffer(), then start audio playing with i2s_start(). Then call i2s_getFreeBuffer() until you have finished your samples. The reproduction will automatically stop if you don't call i2s_getFreeBuffer() frequently enough.
Example:
// fill in the buffers before start buf = i2s_getBuffer(I2S_FIRST_BUF); // ... buf = i2s_getBuffer(I2S_SECOND_BUF); // ... // here the driver will play only the first two buffers... i2s_start(); // ...call getFreeBuffer() to continue playing. while (!(buf = i2s_getFreeBuffer())) ; // now fill the buffer again
Definition in file i2s_at91.h.
uint8_t* i2s_getBuffer | ( | unsigned | buf_num | ) |
Returns one of the two buffers or NULL if none is available.
You can't call this function if you have already started the player.
buf_num | The number of the buffer, ie I2S_FIRST_BUF or I2S_SECOND_BUF. |
Definition at line 69 of file i2s_at91.c.
uint8_t* i2s_getFreeBuffer | ( | void | ) |
Returns a buffer that will be played after the current one.
You should fill it faster than your reproduction time. You can't call this function if the player is not running
Definition at line 87 of file i2s_at91.c.
bool i2s_start | ( | void | ) |
Starts playing from I2S_FIRST_BUFFER.
You must have filled both buffers before calling this function. Does nothing if already playing.
Definition at line 121 of file i2s_at91.c.