Core/i2s.h File Reference
#include <driver/i2s.h>
#include <stdint.h>
#include <stdbool.h>
Include dependency graph for Core/i2s.h:

Go to the source code of this file.

Macros

#define I2S_BLOCKING_TIMEOUT   100
 

Functions

bool i2s_rxtx_begin (bool enableRx, bool enableTx)
 
bool i2s_begin ()
 Enable TX only, for compatibility. More...
 
void i2s_end ()
 
bool i2s_set_rate (uint32_t rate)
 
bool i2s_is_full ()
 
bool i2s_rx_is_full ()
 
bool i2s_is_empty ()
 
bool i2s_rx_is_empty ()
 
uint16_t i2s_available ()
 
uint16_t i2s_rx_available ()
 
bool i2s_write_sample (uint32_t sample)
 32bit sample with channels being upper and lower 16 bits (blocking when DMA is full) More...
 
bool i2s_write_sample_nb (uint32_t sample)
 Same as above but does not block when DMA is full and returns false instead. More...
 
bool i2s_write_lr (int16_t left, int16_t right)
 
bool i2s_read_sample (int16_t *left, int16_t *right, bool blocking)
 
void i2s_set_callback (void(*callback)(void))
 
void i2s_rx_set_callback (void(*callback)(void))
 
uint16_t i2s_write_buffer_mono (int16_t *frames, uint16_t frame_count)
 Writes a buffer of frames into the DMA memory, returns the amount of frames written. More...
 
uint16_t i2s_write_buffer_mono_nb (int16_t *frames, uint16_t frame_count)
 
uint16_t i2s_write_buffer (int16_t *frames, uint16_t frame_count)
 
uint16_t i2s_write_buffer_nb (int16_t *frames, uint16_t frame_count)
 

Macro Definition Documentation

◆ I2S_BLOCKING_TIMEOUT

#define I2S_BLOCKING_TIMEOUT   100

Function Documentation

◆ i2s_available()

uint16_t i2s_available ( )
Return values
uint16_tNumber of samples than can be written before blocking

◆ i2s_begin()

bool i2s_begin ( )
inline

Enable TX only, for compatibility.

◆ i2s_end()

void i2s_end ( )
inline

◆ i2s_is_empty()

bool i2s_is_empty ( )
Return values
booltrue if DMA is empty (underflow)

◆ i2s_is_full()

bool i2s_is_full ( )
Return values
booltrue if DMA is full and can not take more bytes (overflow)

◆ i2s_read_sample()

bool i2s_read_sample ( int16_t *  left,
int16_t *  right,
bool  blocking 
)
Note
RX data returned in both 16-bit outputs.

◆ i2s_rx_available()

uint16_t i2s_rx_available ( )
Return values
uint16_tNumber of samples that can be read before blocking

◆ i2s_rx_is_empty()

bool i2s_rx_is_empty ( )

◆ i2s_rx_is_full()

bool i2s_rx_is_full ( )

◆ i2s_rx_set_callback()

void i2s_rx_set_callback ( void(*)(void)  callback)

◆ i2s_rxtx_begin()

bool i2s_rxtx_begin ( bool  enableRx,
bool  enableTx 
)

◆ i2s_set_callback()

void i2s_set_callback ( void(*)(void)  callback)

◆ i2s_set_rate()

bool i2s_set_rate ( uint32_t  rate)
inline
Parameters
rateSample rate in Hz (ex 44100, 48000) for TX/RX

◆ i2s_write_buffer()

uint16_t i2s_write_buffer ( int16_t *  frames,
uint16_t  frame_count 
)

◆ i2s_write_buffer_mono()

uint16_t i2s_write_buffer_mono ( int16_t *  frames,
uint16_t  frame_count 
)

Writes a buffer of frames into the DMA memory, returns the amount of frames written.

Note
A frame is just a int16_t for mono, for stereo a frame is two int16_t, one for each channel.

◆ i2s_write_buffer_mono_nb()

uint16_t i2s_write_buffer_mono_nb ( int16_t *  frames,
uint16_t  frame_count 
)

◆ i2s_write_buffer_nb()

uint16_t i2s_write_buffer_nb ( int16_t *  frames,
uint16_t  frame_count 
)

◆ i2s_write_lr()

bool i2s_write_lr ( int16_t  left,
int16_t  right 
)
Note
Combines both channels and calls i2s_write_sample with the result

◆ i2s_write_sample()

bool i2s_write_sample ( uint32_t  sample)
inline

32bit sample with channels being upper and lower 16 bits (blocking when DMA is full)

◆ i2s_write_sample_nb()

bool i2s_write_sample_nb ( uint32_t  sample)
inline

Same as above but does not block when DMA is full and returns false instead.