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:
There are no prerequisites for this module.
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.
This driver for I2S module provides an interface to:
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 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
MCK is either an external source or generated using the GCLK input from a generic clock generator.
The I2S module has three modes: master, controller, and slave.
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.
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.
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.
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.
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.
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.
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:
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.
See here for the Codec Application connection and waveform example.
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.
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.
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.
The I2S will continue to operate in any sleep mode, where the selected source clocks are running.
There is no special considerations for I2S module.
For extra information see Extra Information for I2S Driver. This includes:
For a list of examples related to this driver, see Examples for I2S Driver.
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... | |
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.
enum i2s_bit_order |
enum i2s_bit_padding |
enum i2s_clock_unit |
enum i2s_data_adjust |
enum i2s_data_delay |
enum i2s_data_format |
enum i2s_data_padding |
I2S data padding.
enum i2s_data_size |
enum i2s_dma_usage |
enum i2s_frame_sync_width |
Frame Sync (FS) output pulse width.
enum i2s_job_type |
I2S line default value when slot disabled.
enum i2s_serializer |
enum i2s_serializer_mode |
enum i2s_slot_adjust |
enum i2s_slot_size |
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.
[in] | module_inst | Pointer to the I2S software instance struct |
[in] | status | Bitmask 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.
|
inlinestatic |
Disable the Specified Clock Unit of I2S module.
Disables a Clock Unit in I2S module that has been previously initialized.
[in] | module_inst | Pointer to the software module instance struct |
[in] | clock_unit | I2S Clock Unit to disable |
References Assert, and i2s_module::hw.
|
inlinestatic |
Enable the Specified Clock Unit of I2S module.
Enables a Clock Unit in I2S module that has been previously initialized.
[in] | module_inst | Pointer to the software module instance struct |
[in] | clock_unit | I2S Clock Unit to enable |
References Assert, and i2s_module::hw.
|
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:
[out] | config | Pointer 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.
[in,out] | module_inst | Pointer to the software module instance struct |
[in] | clock_unit | I2S clock unit to initialize and configure |
[in] | config | Pointer to the I2S clock unit configuration options struct |
STATUS_OK | The module was initialized successfully |
STATUS_BUSY | Hardware module was busy when the configuration procedure was attempted |
STATUS_ERR_DENIED | Hardware module was already enabled |
STATUS_ERR_INVALID_ARG | Invalid 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.
|
inlinestatic |
Disables the I2S module.
Disables a I2S module.
[in] | module_inst | Pointer 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.
[in] | module_inst | Pointer to the I2S software instance struct |
[in] | status | Status 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.
|
inlinestatic |
Enable the I2S module.
Enables a I2S module that has been previously initialized.
[in] | module_inst | Pointer 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.
[in] | module_inst | Pointer to the I2S software instance struct |
[in] | status | Status interrupts to enable |
STATUS_OK | Interrupt is enabled successfully |
STATUS_ERR_INVALID_ARG | Status 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.
[in] | module_inst | Pointer to the I2S software instance struct |
I2S_STATUS_*
flags.I2S_STATUS_SYNC_BUSY | Module 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.
[in,out] | module_inst | Pointer to the software module instance struct |
[in] | hw | Pointer to the TCC hardware module |
STATUS_OK | The module was initialized successfully |
STATUS_BUSY | Hardware module was busy when the initialization procedure was attempted |
STATUS_ERR_DENIED | Hardware 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.
|
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.
[in] | module_inst | Pointer to the software module instance struct |
false | If the module has completed synchronization |
true | If the module synchronization is ongoing |
References Assert, and i2s_module::hw.
Referenced by i2s_reset().
|
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.
[in] | module_inst | Pointer 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.
[in] | module_inst | Pointer to the software module instance struct |
[in] | serializer | The serializer which runs the job |
[in] | job_type | Type 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.
|
inlinestatic |
Disable the Specified Serializer of I2S module.
Disables a Serializer in I2S module that has been previously initialized.
[in] | module_inst | Pointer to the software module instance struct |
[in] | serializer | I2S Serializer to disable |
References Assert, and i2s_module::hw.
|
inlinestatic |
Disables callback for Serializer.
Disables the callback function registered by the i2s_serializer_register_callback.
[in] | module | Pointer to ADC software instance struct |
[in] | serializer | The serializer that generates callback |
[in] | callback_type | Callback 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.
|
inlinestatic |
Enable the Specified Serializer of I2S module.
Enables a Serializer in I2S module that has been previously initialized.
[in] | module_inst | Pointer to the software module instance struct |
[in] | serializer | I2S Serializer to enable |
References Assert, and i2s_module::hw.
|
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.
[in] | module | Pointer to ADC software instance struct |
[in] | serializer | The serializer that generates callback |
[in] | callback_type | Callback 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.
|
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:
[out] | config | Pointer 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.
[in] | module_inst | Pointer to the software module instance struct |
[in] | serializer | The serializer which runs the job |
[in] | job_type | Type of job to abort |
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.
[in] | module_inst | Pointer to the software module instance struct |
[in] | serializer | The serializer to write to |
[out] | buffer | The buffer to fill read data |
[in] | size | Number of data words to read |
STATUS_OK | The data was sent successfully |
STATUS_ERR_DENIED | The serializer is not in receive mode |
STATUS_ERR_INVALID_ARG | An 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.
[in] | module_inst | Pointer to the software module instance struct |
[in] | serializer | The serializer to write to |
[in] | buffer | The buffer to fill read data (NULL to discard) |
[in] | size | Number of data words to read |
STATUS_OK | The data was sent successfully |
STATUS_ERR_DENIED | The module or serializer is disabled |
STATUS_ERR_INVALID_ARG | An 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.
|
inlinestatic |
Read a data word from the specified Serializer of I2S module.
[in] | module_inst | Pointer to the software module instance struct |
[in] | serializer | The Serializer to read |
References Assert, and i2s_module::hw.
|
inlinestatic |
Registers a callback for serializer.
Registers a callback function which is implemented by the user.
[in] | module | Pointer to ADC software instance struct |
[in] | serializer | The serializer that generates callback |
[in] | callback_func | Pointer to callback function |
[in] | callback_type | Callback 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.
[in,out] | module_inst | Pointer to the software module instance struct |
[in] | serializer | I2S serializer to initialize and configure |
[in] | config | Pointer to the I2S serializer configuration options struct |
STATUS_OK | The module was initialized successfully |
STATUS_BUSY | Hardware module was busy when the configuration procedure was attempted |
STATUS_ERR_DENIED | Hardware 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.
|
inlinestatic |
Unregisters a callback for serializer.
Unregisters a callback function which is implemented by the user.
[in] | module | Pointer to ADC software instance struct |
[in] | serializer | The serializer that generates callback |
[in] | callback_type | Callback 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.
[in] | module_inst | Pointer to the software module instance struct |
[in] | serializer | The serializer to write to |
[in] | buffer | The data buffer to write |
[in] | size | Number of data words to write |
STATUS_OK | The data was sent successfully |
STATUS_ERR_DENIED | The serializer is not in transmit mode |
STATUS_ERR_INVALID_ARG | An 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.
[in] | module_inst | Pointer to the software module instance struct |
[in] | serializer | The serializer to write to |
[in] | buffer | The data buffer to write |
[in] | size | Number of data words to write |
STATUS_OK | The data was sent successfully |
STATUS_ERR_DENIED | The module or serializer is disabled |
STATUS_ERR_INVALID_ARG | An 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.
|
inlinestatic |
Write a data word to the specified Serializer of I2S module.
[in] | module_inst | Pointer to the software module instance struct |
[in] | serializer | The Serializer to write to |
[in] | data | The data to write |
References Assert, and i2s_module::hw.