Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SAM Inter-IC Sound Controller (I2S) Driver

This driver for Atmel® | SMART ARM®-based microcontrollers provides an interface for the configuration and management of the device's Inter-IC Sound Controller functionality.

The following driver API modes are covered by this manual:

The following peripheral is used by this module:

The following devices can use this module:

The outline of this documentation is as follows:

Prerequisites

There are no prerequisites for this module.

Module Overview

The I2S provides bidirectional, synchronous, digital audio link with external audio devices through these signal pins:

The I2S consists of two Clock Units and two Serializers, which can be separately configured and enabled, to provide varies functionalities as follow:

The I2S supports compact stereo data word, where left channel data bits are in lower half and right channel data bits are in upper half. It reduces the number of data words for stereo audio data and the DMA bandwidth.

In master mode, the frame is configured by number of slots and slot size, and allows range covering 16fs to 1024fs MCK, to provide oversampling clock to an external audio CODEC or digital signal processor (DSP).

A block diagram of the I2S can be seen in the figure below.

i2s_blocks.svg
I2S Block Diagram

This driver for I2S module provides an interface to:

Clocks

To use I2S module, the I2S bus interface clock (clk_i2s) must be enabled via Power Manager.

For each I2S Clock Unit, a generic clock (gclk_i2s_n) is connnected. When I2S works in master mode the generic clock is used. It should be prepared before clock unit is used. In master mode the input generic clock will be used as MCK for SCKn and FSn generation, in addition, the MCK could be devided and output to I2S MCKn pin, as oversampling clock to external audio device.

The I2S Serializer uses clock and control signal from Clock Unit to handle transfer. Select different clock unit with different configurations allows the I2S to work as master or slave, to work on non-related clocks.

When using the driver with ASF, enabling the register interface is normally done by the init function. The Generic Clock Controller (GCLK) source for the asynchronous domain is normally configured and set through the configuration struct / init function. If GCLK source != 0 is used, this source has to be configured and enabled through invoking the system_gclk driver function when needed, or modifying conf_clock.h to enable it at the beginning.

Audio Frame Generation

Audio sample data for all channels are sent in frames, one frame can consist 1 - 8 slots where each slot can be configured to a size 8-bit, 16-bit, 24-bit, or 32-bit. The audio frame synch clock is generated by the I2S Clock unit in the master/controller mode. The frame rate (or frame sync frequency) is calculated as follows:

FS = SCK / number_of_slots / number_of_bits_in_slot

The serial clock (SCK) source is either an external source (slave mode) or generated by the I2S clock unit (controller or master mode) using the MCK as source.

SCK = MCK / sck_div

Note
SCK generation division value is MCKDIV in register.

MCK is either an external source or generated using the GCLK input from a generic clock generator.

Master, Controller, and Slave Modes

The I2S module has three modes: master, controller, and slave.

Master

In master mode the module will control the data flow on the I2S bus and can be responsible for clock generation. The Serializers are enabled and will transmit/receive data. On a bus with only master and slave the SCK, and FS clock signal will be outputted on the SCK and FS pin on the master module. MCK can optionally be outputted on the MCK pin, if there is a controller module on the bus the SCK, FS, and optionally the MCK clock is sourced from the same pins. Serial data will be trancieved on the SD pin in both scenarios.

Controller

In controller mode the module will generate the clock signals, but the Serializers are disabled and no data will be transmitted/received by the module in this mode. The clock signals is outputted on the SCK, FS and optionally the MCK pin.

Slave

In slave mode the module will use the SCK and FS clock source from the master or the controller which is received on the SCK and FS pin. The MCK can optionally be sourced externally on the MCK pin. The Serializers are enabled and will tranceive data on the SD pin. All data flow is controlled by the master.

Switch Modes

The mode switching between master, controller, and slave modes are actually done by modifying the source mode of I2S pins. The source mode of I2S pins are selected by writing corresponding bits in CLKCTRLn. Since source mode switching changes the direction of pin, the mode must be changed when the I2S Clock Unit is stopped.

Data Stream Reception/Transmission

The I2S module support several data stream formats:

Basically the I2S module can send several words within each frame, it's more like TDM format. With adjust to the number of data words in a frame, the FS width, the FS to data bits delay, etc., the module is able to handle I2S compliant data stream.

Also the Serializer can receive PDM format data stream, which allows the I2S module receive 1 PDM data on each SCK edge.

I2S Stream Reception/Transmission

For 2-channel I2S compliant data stream format the I2S module uses the FS line as word select (WS) signal and will send left channel data word on low WS level and right channel data word on high WS level as specified in the I2S standard. The supported word sizes are 8-, 16-, 18-, 20-, 24-, and 32- bit.

Thus for I2S stream, the following settings should be applied to the module:

Following is an example for I2S application connections and waveforms. See the figure below.

i2s_example.svg
I2S Example Diagram

TDM Stream Reception/Transmission

In TDM format, the module sends several data words in each frame. For this data stream format most of the configurations could be adjusted:

The general TDM waveform generation is as follows:

tdm_wave.svg
TDM Waveform Generation

Some other settings could also be found to set up clock, data formatting and pin multiplexer (MUX). Refer to Clock Unit Configurations and Serializer Configurations for more details.

Following is examples for different application use cases.

See here for the Time Slot Application connection and waveform example.

tdm_timeslot_example.svg
Codec Example Diagram

See here for the Codec Application connection and waveform example.

tdm_codec_example.svg
Time Slot Example Diagram

PDM Reception

The I2S Serializer integrates PDM reception feature, to use this feature, simply select PDM2 mode in Serializer configuration. In PDM2 mode, it assumes two microphones are input for stereo stream. The left microphone bits will be stored in lower half and right microphone bits in upper half of the data word, like in compact stereo format.

See following figure for an example of PDM Microphones Application with both left and right channel microphone connected.

pdm_example.svg
Time PDM2 Example Diagram

MONO and Compact Data

The I2S Serializer can accept some pre-defined data format and generates the data stream in specified way.

When transmitting data, the Serializer can work in MONO mode: assum input is single channel mono data on left channel and copy it to right channel automatically.

Also the I2S Serializer can support compact stereo data word. The data word size of the Serializer can be set to 16-bit compact or 8-bit compact, with these option I2S Serializer will compact left channel data and right channel data together, the left channel data will take lower bytes and right channel data take higher bytes.

Loop-back Mode

The I2S can be configured to loop back the Transmitter to Receiver. In this mode Serializer's input will be connected to another Serializer's output internally.

Sleep Modes

The I2S will continue to operate in any sleep mode, where the selected source clocks are running.

Special Considerations

There is no special considerations for I2S module.

Extra Information

For extra information see Extra Information for I2S Driver. This includes:

Examples

For a list of examples related to this driver, see Examples for I2S Driver.

API Overview

Data Structures

struct  i2s_clock_config
 Configure for I2S clock (SCK). More...
 
struct  i2s_clock_unit_config
 Configure for I2S clock unit. More...
 
struct  i2s_frame_config
 Configure for I2S frame. More...
 
struct  i2s_frame_sync_config
 Configure for I2S frame sync (FS). More...
 
struct  i2s_module
 I2S Software Module instance struct. More...
 
struct  i2s_pin_config
 Configure for I2S pin. More...
 
struct  i2s_serializer_config
 Configure for I2S Serializer. More...
 
struct  i2s_serializer_module
 I2S Serializer instance struct. More...
 

Typedefs

typedef void(* i2s_serializer_callback_t )(struct i2s_module *const module)
 Type of the callback functions. More...
 

Enumerations

enum  i2s_bit_order {
  I2S_BIT_ORDER_MSB_FIRST,
  I2S_BIT_ORDER_LSB_FIRST
}
 I2S data bit order. More...
 
enum  i2s_bit_padding {
  I2S_BIT_PADDING_0,
  I2S_BIT_PADDING_1,
  I2S_BIT_PADDING_MSB,
  I2S_BIT_PADDING_LSB
}
 I2S data bit padding. More...
 
enum  i2s_clock_unit {
  I2S_CLOCK_UNIT_0,
  I2S_CLOCK_UNIT_1,
  I2S_CLOCK_UNIT_N
}
 I2S clock unit selection. More...
 
enum  i2s_data_adjust {
  I2S_DATA_ADJUST_RIGHT,
  I2S_DATA_ADJUST_LEFT
}
 I2S data word adjust. More...
 
enum  i2s_data_delay {
  I2S_DATA_DELAY_0,
  I2S_DATA_DELAY_1,
  I2S_DATA_DELAY_LEFT_JUSTIFIED = I2S_DATA_DELAY_0,
  I2S_DATA_DELAY_I2S = I2S_DATA_DELAY_1
}
 Data delay from Frame Sync (FS). More...
 
enum  i2s_data_format {
  I2S_DATA_FORMAT_STEREO,
  I2S_DATA_FORMAT_MONO
}
 I2S data format, to extend mono data to two channels. More...
 
enum  i2s_data_padding {
  I2S_DATA_PADDING_0,
  I2S_DATA_PADDING_SAME_AS_LAST,
  I2S_DATA_PADDING_LAST = I2S_DATA_PADDING_SAME_AS_LAST,
  I2S_DATA_PADDING_SAME = I2S_DATA_PADDING_SAME_AS_LAST
}
 I2S data padding. More...
 
enum  i2s_data_size {
  I2S_DATA_SIZE_32BIT,
  I2S_DATA_SIZE_24BIT,
  I2S_DATA_SIZE_20BIT,
  I2S_DATA_SIZE_18BIT,
  I2S_DATA_SIZE_16BIT,
  I2S_DATA_SIZE_16BIT_COMPACT,
  I2S_DATA_SIZE_8BIT,
  I2S_DATA_SIZE_8BIT_COMPACT
}
 I2S data word size. More...
 
enum  i2s_dma_usage {
  I2S_DMA_USE_SINGLE_CHANNEL_FOR_ALL,
  I2S_DMA_USE_ONE_CHANNEL_PER_DATA_CHANNEL
}
 DMA channels usage for I2S. More...
 
enum  i2s_frame_sync_source {
  I2S_FRAME_SYNC_SOURCE_SCKDIV,
  I2S_FRAME_SYNC_SOURCE_FSPIN
}
 Frame Sync (FS) source. More...
 
enum  i2s_frame_sync_width {
  I2S_FRAME_SYNC_WIDTH_SLOT,
  I2S_FRAME_SYNC_WIDTH_HALF_FRAME,
  I2S_FRAME_SYNC_WIDTH_BIT,
  I2S_FRAME_SYNC_WIDTH_BURST
}
 Frame Sync (FS) output pulse width. More...
 
enum  i2s_job_type {
  I2S_JOB_WRITE_BUFFER,
  I2S_JOB_READ_BUFFER
}
 Enum for the possible types of I2S asynchronous jobs that may be issued to the driver. More...
 
enum  i2s_line_default_state {
  I2S_LINE_DEFAULT_0,
  I2S_LINE_DEFAULT_1,
  I2S_LINE_DEFAULT_HIGH_IMPEDANCE = 3,
  I2S_LINE_DEFAULT_HIZ = I2S_LINE_DEFAULT_HIGH_IMPEDANCE
}
 I2S line default value when slot disabled. More...
 
enum  i2s_master_clock_source {
  I2S_MASTER_CLOCK_SOURCE_GCLK,
  I2S_MASTER_CLOCK_SOURCE_MCKPIN
}
 Master Clock (MCK) source selection. More...
 
enum  i2s_serial_clock_source {
  I2S_SERIAL_CLOCK_SOURCE_MCKDIV,
  I2S_SERIAL_CLOCK_SOURCE_SCKPIN
}
 Serial Clock (SCK) source selection. More...
 
enum  i2s_serializer {
  I2S_SERIALIZER_0,
  I2S_SERIALIZER_1,
  I2S_SERIALIZER_N
}
 I2S Serializer selection. More...
 
enum  i2s_serializer_callback {
  I2S_SERIALIZER_CALLBACK_BUFFER_DONE,
  I2S_SERIALIZER_CALLBACK_OVER_UNDER_RUN
}
 I2S Serializer Callback enum. More...
 
enum  i2s_serializer_mode {
  I2S_SERIALIZER_RECEIVE,
  I2S_SERIALIZER_TRANSMIT,
  I2S_SERIALIZER_PDM2
}
 I2S Serializer mode. More...
 
enum  i2s_slot_adjust {
  I2S_SLOT_ADJUST_RIGHT,
  I2S_SLOT_ADJUST_LEFT
}
 I2S data slot adjust. More...
 
enum  i2s_slot_size {
  I2S_SLOT_SIZE_8_BIT,
  I2S_SLOT_SIZE_16_BIT,
  I2S_SLOT_SIZE_24_BIT,
  I2S_SLOT_SIZE_32_BIT
}
 Time Slot Size in number of I2S serial clocks (bits). More...
 

Functions

static bool i2s_is_syncing (const struct i2s_module *const module_inst)
 Determines if the hardware module(s) are currently synchronizing to the bus. More...
 

Module Status Flags

I2S status flags, returned by i2s_get_status() and cleared by i2s_clear_status().

#define I2S_STATUS_TRANSMIT_UNDERRUN(x)   (1u << ((x)+0))
 Module Serializer x (0~1) Transmit Underrun. More...
 
#define I2S_STATUS_TRANSMIT_READY(x)   (1u << ((x)+2))
 Module Serializer x (0~1) is ready to accept new data to be transmitted. More...
 
#define I2S_STATUS_RECEIVE_OVERRUN(x)   (1u << ((x)+4))
 Module Serializer x (0~1) Receive Overrun. More...
 
#define I2S_STATUS_RECEIVE_READY(x)   (1u << ((x)+6))
 Module Serializer x (0~1) has received a new data. More...
 
#define I2S_STATUS_SYNC_BUSY   (1u << 8)
 Module is busy on synchronization. More...
 

Driver Initialization

enum status_code i2s_init (struct i2s_module *const module_inst, I2s *hw)
 Initializes a hardware I2S module instance. More...
 

Enable/Disable/Reset

static void i2s_enable (const struct i2s_module *const module_inst)
 Enable the I2S module. More...
 
static void i2s_disable (const struct i2s_module *const module_inst)
 Disables the I2S module. More...
 
static void i2s_reset (const struct i2s_module *const module_inst)
 Resets the I2S module. More...
 

Clock Unit Initialization and Configuration

static void i2s_clock_unit_get_config_defaults (struct i2s_clock_unit_config *const config)
 Initializes config with predefined default values for I2S clock unit. More...
 
enum status_code i2s_clock_unit_set_config (struct i2s_module *const module_inst, const enum i2s_clock_unit clock_unit, const struct i2s_clock_unit_config *config)
 Configure specified I2S clock unit. More...
 

Clock Unit Enable/Disable

static void i2s_clock_unit_enable (const struct i2s_module *const module_inst, const enum i2s_clock_unit clock_unit)
 Enable the Specified Clock Unit of I2S module. More...
 
static void i2s_clock_unit_disable (const struct i2s_module *const module_inst, const enum i2s_clock_unit clock_unit)
 Disable the Specified Clock Unit of I2S module. More...
 

Serializer Initialization and Configuration

static void i2s_serializer_get_config_defaults (struct i2s_serializer_config *const config)
 Initializes config with predefined default values for I2S Serializer. More...
 
enum status_code i2s_serializer_set_config (struct i2s_module *const module_inst, const enum i2s_serializer serializer, const struct i2s_serializer_config *config)
 Configure specified I2S serializer. More...
 

Serializer Enable/Disable

static void i2s_serializer_enable (const struct i2s_module *const module_inst, const enum i2s_serializer serializer)
 Enable the Specified Serializer of I2S module. More...
 
static void i2s_serializer_disable (const struct i2s_module *const module_inst, const enum i2s_serializer serializer)
 Disable the Specified Serializer of I2S module. More...
 

Status Management

uint32_t i2s_get_status (const struct i2s_module *const module_inst)
 Retrieves the current module status. More...
 
void i2s_clear_status (const struct i2s_module *const module_inst, uint32_t status)
 Clears a module status flags. More...
 
enum status_code i2s_enable_status_interrupt (struct i2s_module *const module_inst, uint32_t status)
 Enable interrupts on status set. More...
 
void i2s_disable_status_interrupt (struct i2s_module *const module_inst, uint32_t status)
 Disable interrupts on status set. More...
 

Data Read/Write

static void i2s_serializer_write_wait (const struct i2s_module *const module_inst, enum i2s_serializer serializer, uint32_t data)
 Write a data word to the specified Serializer of I2S module. More...
 
static uint32_t i2s_serializer_read_wait (const struct i2s_module *const module_inst, enum i2s_serializer serializer)
 Read a data word from the specified Serializer of I2S module. More...
 
enum status_code i2s_serializer_write_buffer_wait (const struct i2s_module *const module_inst, enum i2s_serializer serializer, void *buffer, uint32_t size)
 Write buffer to the specified Serializer of I2S module. More...
 
enum status_code i2s_serializer_read_buffer_wait (const struct i2s_module *const module_inst, enum i2s_serializer serializer, void *buffer, uint32_t size)
 Read from the specified Serializer of I2S module to a buffer. More...
 

Callback Management

static void i2s_serializer_register_callback (struct i2s_module *const module_inst, const enum i2s_serializer serializer, const i2s_serializer_callback_t callback_func, const enum i2s_serializer_callback callback_type)
 Registers a callback for serializer. More...
 
static void i2s_serializer_unregister_callback (struct i2s_module *const module_inst, const enum i2s_serializer serializer, const enum i2s_serializer_callback callback_type)
 Unregisters a callback for serializer. More...
 
static void i2s_serializer_enable_callback (struct i2s_module *const module_inst, const enum i2s_serializer serializer, const enum i2s_serializer_callback callback_type)
 Enables callback for serializer. More...
 
static void i2s_serializer_disable_callback (struct i2s_module *const module_inst, const enum i2s_serializer serializer, const enum i2s_serializer_callback callback_type)
 Disables callback for Serializer. More...
 

Job Management

enum status_code i2s_serializer_write_buffer_job (struct i2s_module *const module_inst, const enum i2s_serializer serializer, const void *buffer, const uint32_t size)
 Write buffer to the specified Serializer of I2S module. More...
 
enum status_code i2s_serializer_read_buffer_job (struct i2s_module *const module_inst, const enum i2s_serializer serializer, void *buffer, const uint32_t size)
 Read from the specified Serializer of I2S module to a buffer. More...
 
void i2s_serializer_abort_job (struct i2s_module *const module_inst, const enum i2s_serializer serializer, const enum i2s_job_type job_type)
 Aborts an ongoing job running on serializer. More...
 
enum status_code i2s_serializer_get_job_status (const struct i2s_module *const module_inst, const enum i2s_serializer serializer, const enum i2s_job_type job_type)
 Gets the status of a job running on serializer. More...
 

#define I2S_STATUS_RECEIVE_OVERRUN (   x)    (1u << ((x)+4))

Module Serializer x (0~1) Receive Overrun.

Referenced by i2s_clear_status(), i2s_disable_status_interrupt(), i2s_enable_status_interrupt(), and i2s_get_status().

#define I2S_STATUS_RECEIVE_READY (   x)    (1u << ((x)+6))

Module Serializer x (0~1) has received a new data.

Referenced by i2s_clear_status(), i2s_disable_status_interrupt(), i2s_enable_status_interrupt(), and i2s_get_status().

#define I2S_STATUS_SYNC_BUSY   (1u << 8)

Module is busy on synchronization.

Referenced by i2s_enable_status_interrupt(), and i2s_get_status().

#define I2S_STATUS_TRANSMIT_READY (   x)    (1u << ((x)+2))

Module Serializer x (0~1) is ready to accept new data to be transmitted.

Referenced by i2s_clear_status(), i2s_disable_status_interrupt(), i2s_enable_status_interrupt(), and i2s_get_status().

#define I2S_STATUS_TRANSMIT_UNDERRUN (   x)    (1u << ((x)+0))

Module Serializer x (0~1) Transmit Underrun.

Referenced by i2s_clear_status(), i2s_disable_status_interrupt(), i2s_enable_status_interrupt(), and i2s_get_status().

typedef void(* i2s_serializer_callback_t)(struct i2s_module *const module)

Type of the callback functions.

I2S data bit order.

Enumerator
I2S_BIT_ORDER_MSB_FIRST 

Transfer Data Most Significant Bit first (Default for I2S protocol)

I2S_BIT_ORDER_LSB_FIRST 

Transfer Data Least Significant Bit first.

I2S data bit padding.

Enumerator
I2S_BIT_PADDING_0 

Padding with 0.

I2S_BIT_PADDING_1 

Padding with 1.

I2S_BIT_PADDING_MSB 

Padding with MSBit.

I2S_BIT_PADDING_LSB 

Padding with LSBit.

I2S clock unit selection.

Enumerator
I2S_CLOCK_UNIT_0 

Clock Unit channel 0.

I2S_CLOCK_UNIT_1 

Clock Unit channel 1.

I2S_CLOCK_UNIT_N 

Number of Clock Unit channels.

I2S data word adjust.

Enumerator
I2S_DATA_ADJUST_RIGHT 

Data is right adjusted in word.

I2S_DATA_ADJUST_LEFT 

Data is left adjusted in word.

Data delay from Frame Sync (FS).

Enumerator
I2S_DATA_DELAY_0 

Left Justified (no delay)

I2S_DATA_DELAY_1 

I2S data delay (1-bit delay)

I2S_DATA_DELAY_LEFT_JUSTIFIED 

Left Justified (no delay)

I2S_DATA_DELAY_I2S 

I2S data delay (1-bit delay)

I2S data format, to extend mono data to two channels.

Enumerator
I2S_DATA_FORMAT_STEREO 

Normal mode, keep data to its right channel.

I2S_DATA_FORMAT_MONO 

Assume input is mono data for left channel, the data is duplicated to right channel.

I2S data padding.

Enumerator
I2S_DATA_PADDING_0 

Padding 0 in case of under-run.

I2S_DATA_PADDING_SAME_AS_LAST 

Padding last data in case of under-run.

I2S_DATA_PADDING_LAST 

Padding last data in case of under-run (abbr.

I2S_DATA_PADDING_SAME_AS_LAST)

I2S_DATA_PADDING_SAME 

Padding last data in case of under-run (abbr.

I2S_DATA_PADDING_SAME_AS_LAST)

I2S data word size.

Enumerator
I2S_DATA_SIZE_32BIT 

32-bit

I2S_DATA_SIZE_24BIT 

24-bit

I2S_DATA_SIZE_20BIT 

20-bit

I2S_DATA_SIZE_18BIT 

18-bit

I2S_DATA_SIZE_16BIT 

16-bit

I2S_DATA_SIZE_16BIT_COMPACT 

16-bit compact stereo

I2S_DATA_SIZE_8BIT 

8-bit

I2S_DATA_SIZE_8BIT_COMPACT 

8-bit compact stereo

DMA channels usage for I2S.

Enumerator
I2S_DMA_USE_SINGLE_CHANNEL_FOR_ALL 

Single DMA channel for all I2S channels.

I2S_DMA_USE_ONE_CHANNEL_PER_DATA_CHANNEL 

One DMA channel per data channel.

Frame Sync (FS) source.

Enumerator
I2S_FRAME_SYNC_SOURCE_SCKDIV 

Frame Sync (FS) is divided from I2S Serial Clock.

I2S_FRAME_SYNC_SOURCE_FSPIN 

Frame Sync (FS) is input from FS input pin.

Frame Sync (FS) output pulse width.

Enumerator
I2S_FRAME_SYNC_WIDTH_SLOT 

Frame Sync (FS) Pulse is one slot width.

I2S_FRAME_SYNC_WIDTH_HALF_FRAME 

Frame Sync (FS) Pulse is half a frame width.

I2S_FRAME_SYNC_WIDTH_BIT 

Frame Sync (FS) Pulse is one bit width.

I2S_FRAME_SYNC_WIDTH_BURST 

1-bit wide Frame Sync (FS) per Data sample, only used when Data transfer is requested

Enum for the possible types of I2S asynchronous jobs that may be issued to the driver.

Enumerator
I2S_JOB_WRITE_BUFFER 

Asynchronous I2S write from a user provided buffer.

I2S_JOB_READ_BUFFER 

Asynchronous I2S read into a user provided buffer.

I2S line default value when slot disabled.

Enumerator
I2S_LINE_DEFAULT_0 

Output default value is 0.

I2S_LINE_DEFAULT_1 

Output default value is 1.

I2S_LINE_DEFAULT_HIGH_IMPEDANCE 

Output default value is high impedance.

I2S_LINE_DEFAULT_HIZ 

Output default value is high impedance (abbr.

I2S_LINE_DEFAULT_HIGH_IMPEDANCE)

Master Clock (MCK) source selection.

Enumerator
I2S_MASTER_CLOCK_SOURCE_GCLK 

Master Clock (MCK) is from general clock.

I2S_MASTER_CLOCK_SOURCE_MCKPIN 

Master Clock (MCK) is from MCK input pin.

Serial Clock (SCK) source selection.

Enumerator
I2S_SERIAL_CLOCK_SOURCE_MCKDIV 

Serial Clock (SCK) is divided from Master Clock.

I2S_SERIAL_CLOCK_SOURCE_SCKPIN 

Serial Clock (SCK) is input from SCK input pin.

I2S Serializer selection.

Enumerator
I2S_SERIALIZER_0 

Serializer channel 0.

I2S_SERIALIZER_1 

Serializer channel 1.

I2S_SERIALIZER_N 

Number of Serializer channels.

I2S Serializer Callback enum.

Enumerator
I2S_SERIALIZER_CALLBACK_BUFFER_DONE 

Callback for buffer read/write finished.

I2S_SERIALIZER_CALLBACK_OVER_UNDER_RUN 

Callback for Serializer overrun/underrun.

I2S Serializer mode.

Enumerator
I2S_SERIALIZER_RECEIVE 

Serializer is used to receive data.

I2S_SERIALIZER_TRANSMIT 

Serializer is used to transmit data.

I2S_SERIALIZER_PDM2 

Serializer is used to receive PDM data on each clock edge.

I2S data slot adjust.

Enumerator
I2S_SLOT_ADJUST_RIGHT 

Data is right adjusted in slot.

I2S_SLOT_ADJUST_LEFT 

Data is left adjusted in slot.

Time Slot Size in number of I2S serial clocks (bits).

Enumerator
I2S_SLOT_SIZE_8_BIT 

8-bit slot

I2S_SLOT_SIZE_16_BIT 

16-bit slot

I2S_SLOT_SIZE_24_BIT 

24-bit slot

I2S_SLOT_SIZE_32_BIT 

32-bit slot

void i2s_clear_status ( const struct i2s_module *const  module_inst,
uint32_t  status 
)

Clears a module status flags.

Clears the given status flags of the module.

Parameters
[in]module_instPointer to the I2S software instance struct
[in]statusBitmask of I2S_STATUS_* flags to clear

References Assert, i2s_module::hw, I2S_STATUS_RECEIVE_OVERRUN, I2S_STATUS_RECEIVE_READY, I2S_STATUS_TRANSMIT_READY, and I2S_STATUS_TRANSMIT_UNDERRUN.

static void i2s_clock_unit_disable ( const struct i2s_module *const  module_inst,
const enum i2s_clock_unit  clock_unit 
)
inlinestatic

Disable the Specified Clock Unit of I2S module.

Disables a Clock Unit in I2S module that has been previously initialized.

Parameters
[in]module_instPointer to the software module instance struct
[in]clock_unitI2S Clock Unit to disable

References Assert, and i2s_module::hw.

static void i2s_clock_unit_enable ( const struct i2s_module *const  module_inst,
const enum i2s_clock_unit  clock_unit 
)
inlinestatic

Enable the Specified Clock Unit of I2S module.

Enables a Clock Unit in I2S module that has been previously initialized.

Parameters
[in]module_instPointer to the software module instance struct
[in]clock_unitI2S Clock Unit to enable

References Assert, and i2s_module::hw.

static void i2s_clock_unit_get_config_defaults ( struct i2s_clock_unit_config *const  config)
inlinestatic

Initializes config with predefined default values for I2S clock unit.

This function will initialize a given I2S Clock Unit configuration structure to a set of known default values. This function should be called on any new instance of the configuration structures before being modified by the user application.

The default configuration is as follows:

  • The clock unit does not generate output clocks (MCK, SCK, and FS)
  • The pins (MCK, SCK, and FS) and MUX configurations are not set
Parameters
[out]configPointer to a I2S module clock unit configuration struct to set

References Assert, i2s_clock_unit_config::clock, i2s_frame_config::data_delay, i2s_pin_config::enable, i2s_clock_unit_config::frame, i2s_frame_config::frame_sync, i2s_clock_unit_config::fs_pin, GCLK_GENERATOR_0, i2s_clock_config::gclk_src, i2s_pin_config::gpio, I2S_DATA_DELAY_I2S, I2S_FRAME_SYNC_SOURCE_SCKDIV, I2S_FRAME_SYNC_WIDTH_HALF_FRAME, I2S_MASTER_CLOCK_SOURCE_GCLK, I2S_SERIAL_CLOCK_SOURCE_MCKDIV, I2S_SLOT_SIZE_32_BIT, i2s_frame_sync_config::invert_out, i2s_frame_sync_config::invert_use, i2s_clock_config::mck_out_div, i2s_clock_config::mck_out_enable, i2s_clock_config::mck_out_invert, i2s_clock_unit_config::mck_pin, i2s_clock_config::mck_src, i2s_pin_config::mux, i2s_frame_config::number_slots, i2s_clock_config::sck_div, i2s_clock_config::sck_out_invert, i2s_clock_unit_config::sck_pin, i2s_clock_config::sck_src, i2s_frame_config::slot_size, i2s_frame_sync_config::source, and i2s_frame_sync_config::width.

enum status_code i2s_clock_unit_set_config ( struct i2s_module *const  module_inst,
const enum i2s_clock_unit  clock_unit,
const struct i2s_clock_unit_config config 
)

Configure specified I2S clock unit.

Enables the clock and initialize the clock unit, based on the given configurations.

Parameters
[in,out]module_instPointer to the software module instance struct
[in]clock_unitI2S clock unit to initialize and configure
[in]configPointer to the I2S clock unit configuration options struct
Returns
Status of the configuration procedure.
Return values
STATUS_OKThe module was initialized successfully
STATUS_BUSYHardware module was busy when the configuration procedure was attempted
STATUS_ERR_DENIEDHardware module was already enabled
STATUS_ERR_INVALID_ARGInvalid divider value or MCK direction setting conflict

References Assert, i2s_clock_unit_config::clock, i2s_frame_config::data_delay, i2s_pin_config::enable, i2s_clock_unit_config::frame, i2s_frame_config::frame_sync, i2s_clock_unit_config::fs_pin, i2s_clock_config::gclk_src, i2s_pin_config::gpio, i2s_module::hw, I2S_CLOCK_UNIT_N, i2s_frame_sync_config::invert_out, i2s_frame_sync_config::invert_use, i2s_clock_config::mck_out_div, i2s_clock_config::mck_out_enable, i2s_clock_config::mck_out_invert, i2s_clock_unit_config::mck_pin, i2s_clock_config::mck_src, i2s_pin_config::mux, system_pinmux_config::mux_position, i2s_frame_config::number_slots, i2s_clock_config::sck_div, i2s_clock_config::sck_out_invert, i2s_clock_unit_config::sck_pin, i2s_clock_config::sck_src, i2s_frame_config::slot_size, i2s_frame_sync_config::source, system_gclk_chan_config::source_generator, STATUS_BUSY, STATUS_ERR_DENIED, STATUS_ERR_INVALID_ARG, STATUS_OK, system_gclk_chan_enable(), system_gclk_chan_get_config_defaults(), system_gclk_chan_set_config(), system_pinmux_get_config_defaults(), system_pinmux_pin_set_config(), and i2s_frame_sync_config::width.

static void i2s_disable ( const struct i2s_module *const  module_inst)
inlinestatic

Disables the I2S module.

Disables a I2S module.

Parameters
[in]module_instPointer to the software module instance struct

References Assert, and i2s_module::hw.

Referenced by i2s_reset().

void i2s_disable_status_interrupt ( struct i2s_module *const  module_inst,
uint32_t  status 
)

Disable interrupts on status set.

Disable the given status interrupt request from the I2S module.

Parameters
[in]module_instPointer to the I2S software instance struct
[in]statusStatus interrupts to disable

References Assert, i2s_module::hw, I2S_STATUS_RECEIVE_OVERRUN, I2S_STATUS_RECEIVE_READY, I2S_STATUS_TRANSMIT_READY, and I2S_STATUS_TRANSMIT_UNDERRUN.

static void i2s_enable ( const struct i2s_module *const  module_inst)
inlinestatic

Enable the I2S module.

Enables a I2S module that has been previously initialized.

Parameters
[in]module_instPointer to the software module instance struct

References Assert, and i2s_module::hw.

enum status_code i2s_enable_status_interrupt ( struct i2s_module *const  module_inst,
uint32_t  status 
)

Enable interrupts on status set.

Enable the given status interrupt request from the I2S module.

Parameters
[in]module_instPointer to the I2S software instance struct
[in]statusStatus interrupts to enable
Returns
Status of enable procedure.
Return values
STATUS_OKInterrupt is enabled successfully
STATUS_ERR_INVALID_ARGStatus with no interrupt is passed

References Assert, i2s_module::hw, I2S_STATUS_RECEIVE_OVERRUN, I2S_STATUS_RECEIVE_READY, I2S_STATUS_SYNC_BUSY, I2S_STATUS_TRANSMIT_READY, I2S_STATUS_TRANSMIT_UNDERRUN, STATUS_ERR_INVALID_ARG, and STATUS_OK.

uint32_t i2s_get_status ( const struct i2s_module *const  module_inst)

Retrieves the current module status.

Retrieves the status of the module, giving overall state information.

Parameters
[in]module_instPointer to the I2S software instance struct
Returns
Bitmask of I2S_STATUS_* flags.
Return values
I2S_STATUS_SYNC_BUSYModule is busy synchronization
I2S_STATUS_TRANSMIT_UNDERRUN(x)Serializer x (0~1) is underrun
I2S_STATUS_TRANSMIT_READY(x)Serializer x (0~1) is ready to transmit new data word
I2S_STATUS_RECEIVE_OVERRUN(x)Serializer x (0~1) is overrun
I2S_STATUS_RECEIVE_READY(x)Serializer x (0~1) has data ready to read

References Assert, i2s_module::hw, I2S_STATUS_RECEIVE_OVERRUN, I2S_STATUS_RECEIVE_READY, I2S_STATUS_SYNC_BUSY, I2S_STATUS_TRANSMIT_READY, and I2S_STATUS_TRANSMIT_UNDERRUN.

enum status_code i2s_init ( struct i2s_module *const  module_inst,
I2s *  hw 
)

Initializes a hardware I2S module instance.

Enables the clock and initialize the I2S module.

Parameters
[in,out]module_instPointer to the software module instance struct
[in]hwPointer to the TCC hardware module
Returns
Status of the initialization procedure.
Return values
STATUS_OKThe module was initialized successfully
STATUS_BUSYHardware module was busy when the initialization procedure was attempted
STATUS_ERR_DENIEDHardware module was already enabled

References _i2s_instances, Assert, i2s_serializer_module::callback, i2s_serializer_module::data_size, i2s_serializer_module::enabled_callback_mask, i2s_module::hw, I2S_DATA_SIZE_32BIT, I2S_SERIALIZER_RECEIVE, i2s_serializer_module::job_buffer, i2s_serializer_module::job_status, i2s_serializer_module::mode, i2s_serializer_module::registered_callback_mask, i2s_serializer_module::requested_words, i2s_module::serializer, STATUS_BUSY, STATUS_ERR_DENIED, STATUS_OK, system_apb_clock_set_mask(), SYSTEM_CLOCK_APB_APBC, system_interrupt_enable(), SYSTEM_INTERRUPT_MODULE_I2S, and i2s_serializer_module::transferred_words.

static bool i2s_is_syncing ( const struct i2s_module *const  module_inst)
inlinestatic

Determines if the hardware module(s) are currently synchronizing to the bus.

Checks to see if the underlying hardware peripheral module(s) are currently synchronizing across multiple clock domains to the hardware bus, This function can be used to delay further operations on a module until such time that it is ready, to prevent blocking delays for synchronization in the user application.

Parameters
[in]module_instPointer to the software module instance struct
Returns
Synchronization status of the underlying hardware module(s).
Return values
falseIf the module has completed synchronization
trueIf the module synchronization is ongoing

References Assert, and i2s_module::hw.

Referenced by i2s_reset().

static void i2s_reset ( const struct i2s_module *const  module_inst)
inlinestatic

Resets the I2S module.

Resets the I2S module, restoring all hardware module registers to their default values and disabling the module. The I2S module will not be accessible while the reset is being performed.

Parameters
[in]module_instPointer to the software module instance struct

References Assert, i2s_module::hw, i2s_disable(), and i2s_is_syncing().

void i2s_serializer_abort_job ( struct i2s_module *const  module_inst,
const enum i2s_serializer  serializer,
const enum i2s_job_type  job_type 
)

Aborts an ongoing job running on serializer.

Aborts an ongoing job.

Parameters
[in]module_instPointer to the software module instance struct
[in]serializerThe serializer which runs the job
[in]job_typeType of job to abort

References Assert, i2s_module::hw, I2S_JOB_READ_BUFFER, I2S_JOB_WRITE_BUFFER, I2S_SERIALIZER_N, i2s_serializer_module::job_status, i2s_module::serializer, and STATUS_ABORTED.

static void i2s_serializer_disable ( const struct i2s_module *const  module_inst,
const enum i2s_serializer  serializer 
)
inlinestatic

Disable the Specified Serializer of I2S module.

Disables a Serializer in I2S module that has been previously initialized.

Parameters
[in]module_instPointer to the software module instance struct
[in]serializerI2S Serializer to disable

References Assert, and i2s_module::hw.

static void i2s_serializer_disable_callback ( struct i2s_module *const  module_inst,
const enum i2s_serializer  serializer,
const enum i2s_serializer_callback  callback_type 
)
inlinestatic

Disables callback for Serializer.

Disables the callback function registered by the i2s_serializer_register_callback.

Parameters
[in]modulePointer to ADC software instance struct
[in]serializerThe serializer that generates callback
[in]callback_typeCallback type given by an enum

References Assert, i2s_serializer_module::enabled_callback_mask, i2s_module::hw, I2S_SERIALIZER_CALLBACK_OVER_UNDER_RUN, I2S_SERIALIZER_N, I2S_SERIALIZER_TRANSMIT, i2s_serializer_module::mode, and i2s_module::serializer.

static void i2s_serializer_enable ( const struct i2s_module *const  module_inst,
const enum i2s_serializer  serializer 
)
inlinestatic

Enable the Specified Serializer of I2S module.

Enables a Serializer in I2S module that has been previously initialized.

Parameters
[in]module_instPointer to the software module instance struct
[in]serializerI2S Serializer to enable

References Assert, and i2s_module::hw.

static void i2s_serializer_enable_callback ( struct i2s_module *const  module_inst,
const enum i2s_serializer  serializer,
const enum i2s_serializer_callback  callback_type 
)
inlinestatic

Enables callback for serializer.

Enables the callback function registered by i2s_serializer_register_callback. The callback function will be called from the interrupt handler when the conditions for the callback type are met.

Parameters
[in]modulePointer to ADC software instance struct
[in]serializerThe serializer that generates callback
[in]callback_typeCallback type given by an enum

References Assert, i2s_serializer_module::enabled_callback_mask, i2s_module::hw, I2S_SERIALIZER_CALLBACK_OVER_UNDER_RUN, I2S_SERIALIZER_N, I2S_SERIALIZER_TRANSMIT, i2s_serializer_module::mode, and i2s_module::serializer.

static void i2s_serializer_get_config_defaults ( struct i2s_serializer_config *const  config)
inlinestatic

Initializes config with predefined default values for I2S Serializer.

This function will initialize a given I2S Clock Unit configuration structure to a set of known default values. This function should be called on any new instance of the configuration structures before being modified by the user application.

The default configuration is as follows:

  • Output data does not internally loopback to input line
  • Does not extend mono data (left channel) to right channel
  • None of the data slot is disabled
  • MSB of I2S data is transferred first
  • In data word data is adjusted right
  • In slot data word is adjusted left
  • The data size is 16-bit width
  • I2S will padd 0 to not defined bits
  • I2S will padd 0 to not defined words
  • I2S will use single DMA channel for all data channels
  • I2S will use clock unit 0 to serve as clock
  • The default data line state is 0, when there is no data
  • I2S will transmit data to output line
  • The data pin and MUX configuration are not set
Parameters
[out]configPointer to a I2S module Serializer configuration struct to set

References i2s_serializer_config::bit_padding, i2s_serializer_config::clock_unit, i2s_serializer_config::data_adjust_left_in_slot, i2s_serializer_config::data_adjust_left_in_word, i2s_serializer_config::data_padding, i2s_serializer_config::data_pin, i2s_serializer_config::data_size, i2s_serializer_config::disable_data_slot, i2s_serializer_config::dma_usage, i2s_pin_config::enable, i2s_pin_config::gpio, I2S_BIT_PADDING_0, I2S_CLOCK_UNIT_0, I2S_DATA_PADDING_0, I2S_DATA_SIZE_16BIT, I2S_DMA_USE_SINGLE_CHANNEL_FOR_ALL, I2S_LINE_DEFAULT_0, I2S_SERIALIZER_TRANSMIT, i2s_serializer_config::line_default_state, i2s_serializer_config::loop_back, i2s_serializer_config::mode, i2s_serializer_config::mono_mode, i2s_pin_config::mux, and i2s_serializer_config::transfer_lsb_first.

enum status_code i2s_serializer_get_job_status ( const struct i2s_module *const  module_inst,
const enum i2s_serializer  serializer,
const enum i2s_job_type  job_type 
)

Gets the status of a job running on serializer.

Gets the status of an ongoing or the last job.

Parameters
[in]module_instPointer to the software module instance struct
[in]serializerThe serializer which runs the job
[in]job_typeType of job to abort
Returns
Status of the job.

References Assert, I2S_JOB_READ_BUFFER, I2S_JOB_WRITE_BUFFER, I2S_SERIALIZER_N, i2s_serializer_module::job_status, i2s_module::serializer, and STATUS_ERR_INVALID_ARG.

enum status_code i2s_serializer_read_buffer_job ( struct i2s_module *const  module_inst,
const enum i2s_serializer  serializer,
void *  buffer,
const uint32_t  size 
)

Read from the specified Serializer of I2S module to a buffer.

Parameters
[in]module_instPointer to the software module instance struct
[in]serializerThe serializer to write to
[out]bufferThe buffer to fill read data
[in]sizeNumber of data words to read
Returns
Status of the initialization procedure.
Return values
STATUS_OKThe data was sent successfully
STATUS_ERR_DENIEDThe serializer is not in receive mode
STATUS_ERR_INVALID_ARGAn invalid buffer pointer was supplied

References Assert, i2s_serializer_module::data_size, i2s_module::hw, I2S_DATA_SIZE_16BIT, I2S_DATA_SIZE_16BIT_COMPACT, I2S_DATA_SIZE_18BIT, I2S_DATA_SIZE_20BIT, I2S_DATA_SIZE_24BIT, I2S_DATA_SIZE_32BIT, I2S_SERIALIZER_N, I2S_SERIALIZER_TRANSMIT, i2s_serializer_module::job_buffer, i2s_serializer_module::job_status, i2s_serializer_module::mode, i2s_serializer_module::requested_words, i2s_module::serializer, STATUS_BUSY, STATUS_ERR_DENIED, STATUS_ERR_INVALID_ARG, STATUS_OK, and i2s_serializer_module::transferred_words.

enum status_code i2s_serializer_read_buffer_wait ( const struct i2s_module *const  module_inst,
enum i2s_serializer  serializer,
void *  buffer,
uint32_t  size 
)

Read from the specified Serializer of I2S module to a buffer.

Parameters
[in]module_instPointer to the software module instance struct
[in]serializerThe serializer to write to
[in]bufferThe buffer to fill read data (NULL to discard)
[in]sizeNumber of data words to read
Returns
Status of the initialization procedure.
Return values
STATUS_OKThe data was sent successfully
STATUS_ERR_DENIEDThe module or serializer is disabled
STATUS_ERR_INVALID_ARGAn invalid buffer pointer was supplied

References Assert, i2s_serializer_module::data_size, i2s_module::hw, I2S_DATA_SIZE_16BIT, I2S_DATA_SIZE_16BIT_COMPACT, I2S_DATA_SIZE_18BIT, I2S_DATA_SIZE_20BIT, I2S_DATA_SIZE_24BIT, I2S_DATA_SIZE_32BIT, i2s_module::serializer, STATUS_ERR_DENIED, STATUS_ERR_INVALID_ARG, and STATUS_OK.

static uint32_t i2s_serializer_read_wait ( const struct i2s_module *const  module_inst,
enum i2s_serializer  serializer 
)
inlinestatic

Read a data word from the specified Serializer of I2S module.

Parameters
[in]module_instPointer to the software module instance struct
[in]serializerThe Serializer to read

References Assert, and i2s_module::hw.

static void i2s_serializer_register_callback ( struct i2s_module *const  module_inst,
const enum i2s_serializer  serializer,
const i2s_serializer_callback_t  callback_func,
const enum i2s_serializer_callback  callback_type 
)
inlinestatic

Registers a callback for serializer.

Registers a callback function which is implemented by the user.

Note
The callback must be enabled by for the interrupt handler to call it when the condition for the callback is met.
Parameters
[in]modulePointer to ADC software instance struct
[in]serializerThe serializer that generates callback
[in]callback_funcPointer to callback function
[in]callback_typeCallback type given by an enum

References Assert, i2s_serializer_module::callback, I2S_SERIALIZER_N, i2s_serializer_module::registered_callback_mask, and i2s_module::serializer.

enum status_code i2s_serializer_set_config ( struct i2s_module *const  module_inst,
const enum i2s_serializer  serializer,
const struct i2s_serializer_config config 
)

Configure specified I2S serializer.

Enables the clock and initialize the serializer, based on the given configurations.

Parameters
[in,out]module_instPointer to the software module instance struct
[in]serializerI2S serializer to initialize and configure
[in]configPointer to the I2S serializer configuration options struct
Returns
Status of the configuration procedure.
Return values
STATUS_OKThe module was initialized successfully
STATUS_BUSYHardware module was busy when the configuration procedure was attempted
STATUS_ERR_DENIEDHardware module was already enabled

References Assert, i2s_serializer_config::bit_padding, i2s_serializer_config::clock_unit, i2s_serializer_config::data_adjust_left_in_slot, i2s_serializer_config::data_adjust_left_in_word, i2s_serializer_config::data_padding, i2s_serializer_config::data_pin, i2s_serializer_config::data_size, i2s_serializer_module::data_size, i2s_serializer_config::disable_data_slot, i2s_serializer_config::dma_usage, i2s_pin_config::enable, i2s_pin_config::gpio, i2s_module::hw, I2S_CLOCK_UNIT_N, I2S_SERIALIZER_N, i2s_serializer_config::line_default_state, i2s_serializer_config::loop_back, i2s_serializer_config::mode, i2s_serializer_module::mode, i2s_serializer_config::mono_mode, i2s_pin_config::mux, system_pinmux_config::mux_position, i2s_module::serializer, STATUS_BUSY, STATUS_ERR_DENIED, STATUS_ERR_INVALID_ARG, STATUS_OK, system_pinmux_get_config_defaults(), system_pinmux_pin_set_config(), and i2s_serializer_config::transfer_lsb_first.

static void i2s_serializer_unregister_callback ( struct i2s_module *const  module_inst,
const enum i2s_serializer  serializer,
const enum i2s_serializer_callback  callback_type 
)
inlinestatic

Unregisters a callback for serializer.

Unregisters a callback function which is implemented by the user.

Parameters
[in]modulePointer to ADC software instance struct
[in]serializerThe serializer that generates callback
[in]callback_typeCallback type given by an enum

References Assert, i2s_serializer_module::callback, I2S_SERIALIZER_N, i2s_serializer_module::registered_callback_mask, and i2s_module::serializer.

enum status_code i2s_serializer_write_buffer_job ( struct i2s_module *const  module_inst,
const enum i2s_serializer  serializer,
const void *  buffer,
const uint32_t  size 
)

Write buffer to the specified Serializer of I2S module.

Parameters
[in]module_instPointer to the software module instance struct
[in]serializerThe serializer to write to
[in]bufferThe data buffer to write
[in]sizeNumber of data words to write
Returns
Status of the initialization procedure.
Return values
STATUS_OKThe data was sent successfully
STATUS_ERR_DENIEDThe serializer is not in transmit mode
STATUS_ERR_INVALID_ARGAn invalid buffer pointer was supplied

References Assert, i2s_serializer_module::data_size, i2s_module::hw, I2S_DATA_SIZE_16BIT, I2S_DATA_SIZE_16BIT_COMPACT, I2S_DATA_SIZE_18BIT, I2S_DATA_SIZE_20BIT, I2S_DATA_SIZE_24BIT, I2S_DATA_SIZE_32BIT, I2S_SERIALIZER_N, I2S_SERIALIZER_TRANSMIT, i2s_serializer_module::job_buffer, i2s_serializer_module::job_status, i2s_serializer_module::mode, i2s_serializer_module::requested_words, i2s_module::serializer, STATUS_BUSY, STATUS_ERR_DENIED, STATUS_ERR_INVALID_ARG, STATUS_OK, and i2s_serializer_module::transferred_words.

enum status_code i2s_serializer_write_buffer_wait ( const struct i2s_module *const  module_inst,
enum i2s_serializer  serializer,
void *  buffer,
uint32_t  size 
)

Write buffer to the specified Serializer of I2S module.

Parameters
[in]module_instPointer to the software module instance struct
[in]serializerThe serializer to write to
[in]bufferThe data buffer to write
[in]sizeNumber of data words to write
Returns
Status of the initialization procedure.
Return values
STATUS_OKThe data was sent successfully
STATUS_ERR_DENIEDThe module or serializer is disabled
STATUS_ERR_INVALID_ARGAn invalid buffer pointer was supplied

References Assert, i2s_serializer_module::data_size, i2s_module::hw, I2S_DATA_SIZE_16BIT, I2S_DATA_SIZE_16BIT_COMPACT, I2S_DATA_SIZE_18BIT, I2S_DATA_SIZE_20BIT, I2S_DATA_SIZE_24BIT, I2S_DATA_SIZE_32BIT, I2S_SERIALIZER_N, i2s_module::serializer, STATUS_ERR_DENIED, STATUS_ERR_INVALID_ARG, and STATUS_OK.

static void i2s_serializer_write_wait ( const struct i2s_module *const  module_inst,
enum i2s_serializer  serializer,
uint32_t  data 
)
inlinestatic

Write a data word to the specified Serializer of I2S module.

Parameters
[in]module_instPointer to the software module instance struct
[in]serializerThe Serializer to write to
[in]dataThe data to write

References Assert, and i2s_module::hw.