nRF5 SDK v17.1.0
Modules | Data Structures | Macros | Typedefs | Functions
I2S driver

Inter-IC Sound (I2S) peripheral driver. More...

Modules

 I2S peripheral driver configuration
 

Data Structures

struct  nrfx_i2s_config_t
 I2S driver configuration structure. More...
 
struct  nrfx_i2s_buffers_t
 I2S driver buffers structure. More...
 

Macros

#define NRFX_I2S_PIN_NOT_USED   0xFF
 This value can be provided instead of a pin number for the signals SDOUT, SDIN, and MCK to specify that a given signal is not used and therefore does not need to be connected to a pin.
 
#define NRFX_I2S_DEFAULT_CONFIG
 I2S driver default configuration. More...
 
#define NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED   (1UL << 0)
 

Typedefs

typedef void(* nrfx_i2s_data_handler_t )(nrfx_i2s_buffers_t const *p_released, uint32_t status)
 I2S driver data handler type. More...
 

Functions

nrfx_err_t nrfx_i2s_init (nrfx_i2s_config_t const *p_config, nrfx_i2s_data_handler_t handler)
 Function for initializing the I2S driver. More...
 
void nrfx_i2s_uninit (void)
 Function for uninitializing the I2S driver.
 
nrfx_err_t nrfx_i2s_start (nrfx_i2s_buffers_t const *p_initial_buffers, uint16_t buffer_size, uint8_t flags)
 Function for starting the continuous I2S transfer. More...
 
nrfx_err_t nrfx_i2s_next_buffers_set (nrfx_i2s_buffers_t const *p_buffers)
 Function for supplying the buffers to be used in the next part of the transfer. More...
 
void nrfx_i2s_stop (void)
 Function for stopping the I2S transfer.
 

Detailed Description

Inter-IC Sound (I2S) peripheral driver.

Macro Definition Documentation

#define NRFX_I2S_DEFAULT_CONFIG
#define NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED   (1UL << 0)

The application must provide buffers that are to be used in the next part of the transfer. A call to nrfx_i2s_next_buffers_set must be done before the currently used buffers are completely processed (that is, the time remaining for supplying the next buffers depends on the used size of the buffers).

Typedef Documentation

typedef void(* nrfx_i2s_data_handler_t)(nrfx_i2s_buffers_t const *p_released, uint32_t status)

I2S driver data handler type.

A data handling function of this type must be specified during the initialization of the driver. The driver will call this function when it finishes using buffers passed to it by the application, and when it needs to be provided with buffers for the next part of the transfer.

Note
The p_released pointer passed to this function is temporary and will be invalid after the function returns, hence it cannot be stored and used later. If needed, the pointed content (that is, buffers pointers) must be copied instead.
Parameters
[in]p_releasedPointer to a structure with pointers to buffers passed previously to the driver that will no longer be accessed by it (they can be now safely released or used for another purpose, in particular for a next part of the transfer). This pointer will be NULL if the application did not supply the buffers for the next part of the transfer (via a call to nrfx_i2s_next_buffers_set) since the previous time the data handler signaled such need. This means that data corruption occurred (the previous buffers are used for the second time) and no buffers can be released at the moment. Both pointers in this structure are NULL when the handler is called for the first time after a transfer is started, because no data has been transferred yet at this point. In all successive calls the pointers specify what has been sent (TX) and what has been received (RX) in the part of transfer that has just been completed (provided that a given direction is enabled, see nrfx_i2s_start).
[in]statusBit field describing the current status of the transfer. It can be 0 or a combination of the following flags:

Function Documentation

nrfx_err_t nrfx_i2s_init ( nrfx_i2s_config_t const *  p_config,
nrfx_i2s_data_handler_t  handler 
)

Function for initializing the I2S driver.

Parameters
[in]p_configPointer to the structure with the initial configuration.
[in]handlerData handler provided by the user. Must not be NULL.
Return values
NRFX_SUCCESSInitialization was successful.
NRFX_ERROR_INVALID_STATEThe driver was already initialized.
NRFX_ERROR_INVALID_PARAMThe requested combination of configuration options is not allowed by the I2S peripheral.
nrfx_err_t nrfx_i2s_next_buffers_set ( nrfx_i2s_buffers_t const *  p_buffers)

Function for supplying the buffers to be used in the next part of the transfer.

The application must call this function when the data handler receives NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED in the status parameter. The call can be done immediately from the data handler function or later, but it has to be done before the I2S peripheral finishes processing the buffers supplied previously. Otherwise, data corruption will occur.

See Also
nrfx_i2s_data_handler_t
Return values
NRFX_SUCCESSIf the operation was successful.
NRFX_ERROR_INVALID_STATEIf the buffers were already supplied or the peripheral is currently being stopped.
nrfx_err_t nrfx_i2s_start ( nrfx_i2s_buffers_t const *  p_initial_buffers,
uint16_t  buffer_size,
uint8_t  flags 
)

Function for starting the continuous I2S transfer.

The I2S data transfer can be performed in one of three modes: RX (reception) only, TX (transmission) only, or in both directions simultaneously. The mode is selected by specifying a proper buffer for a given direction in the call to this function or by passing NULL instead if this direction is to be disabled.

The length of the buffer (which is a common value for RX and TX if both directions are enabled) is specified in 32-bit words. One 32-bit memory word can either contain four 8-bit samples, two 16-bit samples, or one right-aligned 24-bit sample sign-extended to a 32-bit value. For a detailed memory mapping for different supported configurations, see the nRF52840 Product Specification or nRF52832 Product Specification.

Note
Peripherals using EasyDMA (including I2S) require the transfer buffers to be placed in the Data RAM region. If this condition is not met, this function will fail with the error code NRFX_ERROR_INVALID_ADDR.
Parameters
[in]p_initial_buffersPointer to a structure specifying the buffers to be used in the initial part of the transfer (buffers for all consecutive parts are provided through the data handler).
[in]buffer_sizeSize of the buffers (in 32-bit words). Must not be 0.
[in]flagsTransfer options (0 for default settings). Currently, no additional flags are available.
Return values
NRFX_SUCCESSThe operation was successful.
NRFX_ERROR_INVALID_STATETransfer was already started or the driver has not been initialized.
NRFX_ERROR_INVALID_ADDRThe provided buffers are not placed in the Data RAM region.

Documentation feedback | Developer Zone | Subscribe | Updated