i2s_at91.h File Reference
I2S driver functions. More...
#include <cfg/compiler.h>#include <cfg/macros.h>#include <io/arm.h>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. | |
Detailed Description
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.
Function Documentation
| 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.
- Parameters:
-
buf_num The number of the buffer, ie I2S_FIRST_BUF or I2S_SECOND_BUF.
- Returns:
- A pointer to the buffer if the buffer is available (not full), 0 on errors
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
- Returns:
- The next buffer to be played, 0 if both are busy.
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.
- Returns:
- false on errors, true otherwise.
Definition at line 121 of file i2s_at91.c.
