Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
i2s.h File Reference

Public APIs for the I2S (Inter-IC Sound) bus drivers. More...

#include <zephyr/types.h>
#include <zephyr/device.h>
#include <zephyr/syscalls/i2s.h>

Go to the source code of this file.

Data Structures

struct  i2s_config
 Interface configuration options. More...
 

Macros

#define I2S_FMT_DATA_FORMAT_SHIFT   0
 Data Format bit field position.
 
#define I2S_FMT_DATA_FORMAT_MASK   (0x7 << I2S_FMT_DATA_FORMAT_SHIFT)
 Data Format bit field mask.
 
#define I2S_FMT_DATA_FORMAT_I2S   (0 << I2S_FMT_DATA_FORMAT_SHIFT)
 Standard I2S Data Format.
 
#define I2S_FMT_DATA_FORMAT_PCM_SHORT   (1 << I2S_FMT_DATA_FORMAT_SHIFT)
 PCM Short Frame Sync Data Format.
 
#define I2S_FMT_DATA_FORMAT_PCM_LONG   (2 << I2S_FMT_DATA_FORMAT_SHIFT)
 PCM Long Frame Sync Data Format.
 
#define I2S_FMT_DATA_FORMAT_LEFT_JUSTIFIED   (3 << I2S_FMT_DATA_FORMAT_SHIFT)
 Left Justified Data Format.
 
#define I2S_FMT_DATA_FORMAT_RIGHT_JUSTIFIED   (4 << I2S_FMT_DATA_FORMAT_SHIFT)
 Right Justified Data Format.
 
#define I2S_FMT_DATA_ORDER_MSB   (0 << 3)
 Send MSB first.
 
#define I2S_FMT_DATA_ORDER_LSB   BIT(3)
 Send LSB first.
 
#define I2S_FMT_DATA_ORDER_INV   I2S_FMT_DATA_ORDER_LSB
 Invert bit ordering, send LSB first.
 
#define I2S_FMT_CLK_FORMAT_SHIFT   4
 Data Format bit field position.
 
#define I2S_FMT_CLK_FORMAT_MASK   (0x3 << I2S_FMT_CLK_FORMAT_SHIFT)
 Data Format bit field mask.
 
#define I2S_FMT_BIT_CLK_INV   BIT(4)
 Invert bit clock.
 
#define I2S_FMT_FRAME_CLK_INV   BIT(5)
 Invert frame clock.
 
#define I2S_FMT_CLK_NF_NB   (0 << I2S_FMT_CLK_FORMAT_SHIFT)
 Normal Frame, Normal Bit Clk.
 
#define I2S_FMT_CLK_NF_IB   (1 << I2S_FMT_CLK_FORMAT_SHIFT)
 Normal Frame, Inverted Bit Clk.
 
#define I2S_FMT_CLK_IF_NB   (2 << I2S_FMT_CLK_FORMAT_SHIFT)
 Inverted Frame, Normal Bit Clk.
 
#define I2S_FMT_CLK_IF_IB   (3 << I2S_FMT_CLK_FORMAT_SHIFT)
 Inverted Frame, Inverted Bit Clk.
 
#define I2S_OPT_BIT_CLK_CONT   (0 << 0)
 Run bit clock continuously.
 
#define I2S_OPT_BIT_CLK_GATED   BIT(0)
 Run bit clock when sending data only.
 
#define I2S_OPT_BIT_CLK_MASTER   (0 << 1)
 I2S driver is bit clock master.
 
#define I2S_OPT_BIT_CLK_SLAVE   BIT(1)
 I2S driver is bit clock slave.
 
#define I2S_OPT_FRAME_CLK_MASTER   (0 << 2)
 I2S driver is frame clock master.
 
#define I2S_OPT_FRAME_CLK_SLAVE   BIT(2)
 I2S driver is frame clock slave.
 
#define I2S_OPT_LOOPBACK   BIT(7)
 Loop back mode.
 
#define I2S_OPT_PINGPONG   BIT(6)
 Ping pong mode.
 

Typedefs

typedef uint8_t i2s_fmt_t
 I2S data stream format options.
 
typedef uint8_t i2s_opt_t
 I2S configuration options.
 

Enumerations

enum  i2s_dir { I2S_DIR_RX , I2S_DIR_TX , I2S_DIR_BOTH }
 I2C Direction. More...
 
enum  i2s_state {
  I2S_STATE_NOT_READY , I2S_STATE_READY , I2S_STATE_RUNNING , I2S_STATE_STOPPING ,
  I2S_STATE_ERROR
}
 Interface state. More...
 
enum  i2s_trigger_cmd {
  I2S_TRIGGER_START , I2S_TRIGGER_STOP , I2S_TRIGGER_DRAIN , I2S_TRIGGER_DROP ,
  I2S_TRIGGER_PREPARE
}
 Trigger command. More...
 

Functions

int i2s_configure (const struct device *dev, enum i2s_dir dir, const struct i2s_config *cfg)
 Configure operation of a host I2S controller.
 
static const struct i2s_configi2s_config_get (const struct device *dev, enum i2s_dir dir)
 Fetch configuration information of a host I2S controller.
 
static int i2s_read (const struct device *dev, void **mem_block, size_t *size)
 Read data from the RX queue.
 
int i2s_buf_read (const struct device *dev, void *buf, size_t *size)
 Read data from the RX queue into a provided buffer.
 
static int i2s_write (const struct device *dev, void *mem_block, size_t size)
 Write data to the TX queue.
 
int i2s_buf_write (const struct device *dev, void *buf, size_t size)
 Write data to the TX queue from a provided buffer.
 
int i2s_trigger (const struct device *dev, enum i2s_dir dir, enum i2s_trigger_cmd cmd)
 Send a trigger command.
 

Detailed Description

Public APIs for the I2S (Inter-IC Sound) bus drivers.