| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Macros | Enumerations | Functions
I2S HAL
I2S HAL and driver

nRF52 only: Hardware access layer for managing the Inter-IC Sound (I2S) peripheral. More...

## Macros
#define | NRF_I2S_PIN_NOT_CONNECTED 0xFFFFFFFF
| This value can be provided as a parameter for the nrf_i2s_pins_set function call to specify that a given I2S signal (SDOUT, SDIN, or MCK) shall not be connected to a physical pin.

## Enumerations
enum | nrf_i2s_task_t { NRF_I2S_TASK_START = offsetof(NRF_I2S_Type, TASKS_START), NRF_I2S_TASK_STOP = offsetof(NRF_I2S_Type, TASKS_STOP) }
| I2S tasks. More...
enum | nrf_i2s_event_t { NRF_I2S_EVENT_RXPTRUPD = offsetof(NRF_I2S_Type, EVENTS_RXPTRUPD), NRF_I2S_EVENT_TXPTRUPD = offsetof(NRF_I2S_Type, EVENTS_TXPTRUPD), NRF_I2S_EVENT_STOPPED = offsetof(NRF_I2S_Type, EVENTS_STOPPED) }
| I2S events. More...
enum | nrf_i2s_int_mask_t { NRF_I2S_INT_RXPTRUPD_MASK = I2S_INTENSET_RXPTRUPD_Msk, NRF_I2S_INT_TXPTRUPD_MASK = I2S_INTENSET_TXPTRUPD_Msk, NRF_I2S_INT_STOPPED_MASK = I2S_INTENSET_STOPPED_Msk }
| I2S interrupts. More...
enum | nrf_i2s_mode_t { NRF_I2S_MODE_MASTER = I2S_CONFIG_MODE_MODE_Master, NRF_I2S_MODE_SLAVE = I2S_CONFIG_MODE_MODE_Slave }
| I2S modes of operation. More...
enum | nrf_i2s_mck_t { NRF_I2S_MCK_DISABLED = 0, NRF_I2S_MCK_32MDIV2 = (int)I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV2, NRF_I2S_MCK_32MDIV3 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV3, NRF_I2S_MCK_32MDIV4 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV4, NRF_I2S_MCK_32MDIV5 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV5, NRF_I2S_MCK_32MDIV6 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV6, NRF_I2S_MCK_32MDIV8 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV8, NRF_I2S_MCK_32MDIV10 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV10, NRF_I2S_MCK_32MDIV11 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV11, NRF_I2S_MCK_32MDIV15 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV15, NRF_I2S_MCK_32MDIV16 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV16, NRF_I2S_MCK_32MDIV21 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV21, NRF_I2S_MCK_32MDIV23 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV23, NRF_I2S_MCK_32MDIV31 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV31, NRF_I2S_MCK_32MDIV42 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV42, NRF_I2S_MCK_32MDIV63 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV63, NRF_I2S_MCK_32MDIV125 = I2S_CONFIG_MCKFREQ_MCKFREQ_32MDIV125 }
| I2S master clock generator settings. More...
enum | nrf_i2s_ratio_t { NRF_I2S_RATIO_32X = I2S_CONFIG_RATIO_RATIO_32X, NRF_I2S_RATIO_48X = I2S_CONFIG_RATIO_RATIO_48X, NRF_I2S_RATIO_64X = I2S_CONFIG_RATIO_RATIO_64X, NRF_I2S_RATIO_96X = I2S_CONFIG_RATIO_RATIO_96X, NRF_I2S_RATIO_128X = I2S_CONFIG_RATIO_RATIO_128X, NRF_I2S_RATIO_192X = I2S_CONFIG_RATIO_RATIO_192X, NRF_I2S_RATIO_256X = I2S_CONFIG_RATIO_RATIO_256X, NRF_I2S_RATIO_384X = I2S_CONFIG_RATIO_RATIO_384X, NRF_I2S_RATIO_512X = I2S_CONFIG_RATIO_RATIO_512X }
| I2S MCK/LRCK ratios. More...
enum | nrf_i2s_swidth_t { NRF_I2S_SWIDTH_8BIT = I2S_CONFIG_SWIDTH_SWIDTH_8Bit, NRF_I2S_SWIDTH_16BIT = I2S_CONFIG_SWIDTH_SWIDTH_16Bit, NRF_I2S_SWIDTH_24BIT = I2S_CONFIG_SWIDTH_SWIDTH_24Bit }
| I2S sample widths. More...
enum | nrf_i2s_align_t { NRF_I2S_ALIGN_LEFT = I2S_CONFIG_ALIGN_ALIGN_Left, NRF_I2S_ALIGN_RIGHT = I2S_CONFIG_ALIGN_ALIGN_Right }
| I2S alignments of sample within a frame. More...
enum | nrf_i2s_format_t { NRF_I2S_FORMAT_I2S = I2S_CONFIG_FORMAT_FORMAT_I2S, NRF_I2S_FORMAT_ALIGNED = I2S_CONFIG_FORMAT_FORMAT_Aligned }
| I2S frame formats. More...
enum | nrf_i2s_channels_t { NRF_I2S_CHANNELS_STEREO = I2S_CONFIG_CHANNELS_CHANNELS_Stereo, NRF_I2S_CHANNELS_LEFT = I2S_CONFIG_CHANNELS_CHANNELS_Left, NRF_I2S_CHANNELS_RIGHT = I2S_CONFIG_CHANNELS_CHANNELS_Right }
| I2S enabled channels. More...

## Functions
__STATIC_INLINE void | nrf_i2s_task_trigger (NRF_I2S_Type *p_i2s, nrf_i2s_task_t task)
| Function for activating a specific I2S task. More...
__STATIC_INLINE uint32_t | nrf_i2s_task_address_get (NRF_I2S_Type const *p_i2s, nrf_i2s_task_t task)
| Function for getting the address of a specific I2S task register. More...
__STATIC_INLINE void | nrf_i2s_event_clear (NRF_I2S_Type *p_i2s, nrf_i2s_event_t event)
| Function for clearing a specific I2S event. More...
__STATIC_INLINE bool | nrf_i2s_event_check (NRF_I2S_Type const *p_i2s, nrf_i2s_event_t event)
| Function for checking the state of a specific I2S event. More...
__STATIC_INLINE uint32_t | nrf_i2s_event_address_get (NRF_I2S_Type const *p_i2s, nrf_i2s_event_t event)
| Function for getting the address of a specific I2S event register. More...
__STATIC_INLINE void | nrf_i2s_int_enable (NRF_I2S_Type *p_i2s, uint32_t mask)
| Function for enabling specified interrupts. More...
__STATIC_INLINE void | nrf_i2s_int_disable (NRF_I2S_Type *p_i2s, uint32_t mask)
| Function for disabling specified interrupts. More...
__STATIC_INLINE bool | nrf_i2s_int_enable_check (NRF_I2S_Type const *p_i2s, nrf_i2s_int_mask_t i2s_int)
| Function for retrieving the state of a given interrupt. More...
__STATIC_INLINE void | nrf_i2s_enable (NRF_I2S_Type *p_i2s)
| Function for enabling the I2S peripheral. More...
__STATIC_INLINE void | nrf_i2s_disable (NRF_I2S_Type *p_i2s)
| Function for disabling the I2S peripheral. More...
__STATIC_INLINE void | nrf_i2s_pins_set (NRF_I2S_Type *p_i2s, uint32_t sck_pin, uint32_t lrck_pin, uint32_t mck_pin, uint32_t sdout_pin, uint32_t sdin_pin)
| Function for configuring I2S pins. More...
__STATIC_INLINE bool | nrf_i2s_configure (NRF_I2S_Type *p_i2s, nrf_i2s_mode_t mode, nrf_i2s_format_t format, nrf_i2s_align_t alignment, nrf_i2s_swidth_t sample_width, nrf_i2s_channels_t channels, nrf_i2s_mck_t mck_setup, nrf_i2s_ratio_t ratio)
| Function for setting the I2S peripheral configuration. More...
__STATIC_INLINE void | nrf_i2s_transfer_set (NRF_I2S_Type *p_i2s, uint16_t size, uint32_t *p_rx_buffer, uint32_t const *p_tx_buffer)
| Function for setting up the I2S transfer. More...
__STATIC_INLINE void | nrf_i2s_rx_buffer_set (NRF_I2S_Type *p_i2s, uint32_t *p_buffer)
| Function for setting the pointer to the receive buffer. More...
__STATIC_INLINE uint32_t * | nrf_i2s_rx_buffer_get (NRF_I2S_Type const *p_i2s)
| Function for getting the pointer to the receive buffer. More...
__STATIC_INLINE void | nrf_i2s_tx_buffer_set (NRF_I2S_Type *p_i2s, uint32_t const *p_buffer)
| Function for setting the pointer to the transmit buffer. More...
__STATIC_INLINE uint32_t * | nrf_i2s_tx_buffer_get (NRF_I2S_Type const *p_i2s)
| Function for getting the pointer to the transmit buffer. More...

## Detailed Description

nRF52 only: Hardware access layer for managing the Inter-IC Sound (I2S) peripheral.

## Enumeration Type Documentation

enum nrf_i2s_align_t

I2S alignments of sample within a frame.

Enumerator
NRF_I2S_ALIGN_LEFT | Left-aligned.
NRF_I2S_ALIGN_RIGHT | Right-aligned.

enum nrf_i2s_channels_t

I2S enabled channels.

Enumerator
NRF_I2S_CHANNELS_STEREO | Stereo.
NRF_I2S_CHANNELS_LEFT | Left only.
NRF_I2S_CHANNELS_RIGHT | Right only.

enum nrf_i2s_event_t

I2S events.

Enumerator
NRF_I2S_EVENT_RXPTRUPD | The RXD.PTR register has been copied to internal double-buffers.
NRF_I2S_EVENT_TXPTRUPD | The TXD.PTR register has been copied to internal double-buffers.
NRF_I2S_EVENT_STOPPED | I2S transfer stopped.

enum nrf_i2s_format_t

I2S frame formats.

Enumerator
NRF_I2S_FORMAT_I2S | Original I2S format.
NRF_I2S_FORMAT_ALIGNED | Alternate (left- or right-aligned) format.

enum nrf_i2s_int_mask_t

I2S interrupts.

Enumerator
NRF_I2S_INT_RXPTRUPD_MASK | Interrupt on RXPTRUPD event.
NRF_I2S_INT_TXPTRUPD_MASK | Interrupt on TXPTRUPD event.
NRF_I2S_INT_STOPPED_MASK | Interrupt on STOPPED event.

enum nrf_i2s_mck_t

I2S master clock generator settings.

Enumerator
NRF_I2S_MCK_DISABLED | MCK disabled.
NRF_I2S_MCK_32MDIV2 | 32 MHz / 2 = 16.0 MHz.
NRF_I2S_MCK_32MDIV3 | 32 MHz / 3 = 10.6666667 MHz.
NRF_I2S_MCK_32MDIV4 | 32 MHz / 4 = 8.0 MHz.
NRF_I2S_MCK_32MDIV5 | 32 MHz / 5 = 6.4 MHz.
NRF_I2S_MCK_32MDIV6 | 32 MHz / 6 = 5.3333333 MHz.
NRF_I2S_MCK_32MDIV8 | 32 MHz / 8 = 4.0 MHz.
NRF_I2S_MCK_32MDIV10 | 32 MHz / 10 = 3.2 MHz.
NRF_I2S_MCK_32MDIV11 | 32 MHz / 11 = 2.9090909 MHz.
NRF_I2S_MCK_32MDIV15 | 32 MHz / 15 = 2.1333333 MHz.
NRF_I2S_MCK_32MDIV16 | 32 MHz / 16 = 2.0 MHz.
NRF_I2S_MCK_32MDIV21 | 32 MHz / 21 = 1.5238095 MHz.
NRF_I2S_MCK_32MDIV23 | 32 MHz / 23 = 1.3913043 MHz.
NRF_I2S_MCK_32MDIV31 | 32 MHz / 31 = 1.0322581 MHz.
NRF_I2S_MCK_32MDIV42 | 32 MHz / 42 = 0.7619048 MHz.
NRF_I2S_MCK_32MDIV63 | 32 MHz / 63 = 0.5079365 MHz.
NRF_I2S_MCK_32MDIV125 | 32 MHz / 125 = 0.256 MHz.

enum nrf_i2s_mode_t

I2S modes of operation.

Enumerator
NRF_I2S_MODE_MASTER | Master mode.
NRF_I2S_MODE_SLAVE | Slave mode.

enum nrf_i2s_ratio_t

I2S MCK/LRCK ratios.

Enumerator
NRF_I2S_RATIO_32X | LRCK = MCK / 32.
NRF_I2S_RATIO_48X | LRCK = MCK / 48.
NRF_I2S_RATIO_64X | LRCK = MCK / 64.
NRF_I2S_RATIO_96X | LRCK = MCK / 96.
NRF_I2S_RATIO_128X | LRCK = MCK / 128.
NRF_I2S_RATIO_192X | LRCK = MCK / 192.
NRF_I2S_RATIO_256X | LRCK = MCK / 256.
NRF_I2S_RATIO_384X | LRCK = MCK / 384.
NRF_I2S_RATIO_512X | LRCK = MCK / 512.

enum nrf_i2s_swidth_t

I2S sample widths.

Enumerator
NRF_I2S_SWIDTH_8BIT | 8 bit.
NRF_I2S_SWIDTH_16BIT | 16 bit.
NRF_I2S_SWIDTH_24BIT | 24 bit.

enum nrf_i2s_task_t

I2S tasks.

Enumerator
NRF_I2S_TASK_START | Starts continuous I2S transfer. Also starts the MCK generator if this is enabled.
NRF_I2S_TASK_STOP | Stops I2S transfer. Also stops the MCK generator.

## Function Documentation

__STATIC_INLINE bool nrf_i2s_configure | ( | NRF_I2S_Type * | p_i2s,
|  | nrf_i2s_mode_t | mode,
|  | nrf_i2s_format_t | format,
|  | nrf_i2s_align_t | alignment,
|  | nrf_i2s_swidth_t | sample_width,
|  | nrf_i2s_channels_t | channels,
|  | nrf_i2s_mck_t | mck_setup,
|  | nrf_i2s_ratio_t | ratio
| ) |  |

Function for setting the I2S peripheral configuration.

Parameters

  [in] | p_i2s | I2S instance.
  [in] | mode | Mode of operation (master or slave).
  [in] | format | I2S frame format.
  [in] | alignment | Alignment of sample within a frame.
  [in] | sample_width | Sample width.
  [in] | channels | Enabled channels.
  [in] | mck_setup | Master clock generator setup.
  [in] | ratio | MCK/LRCK ratio.

Return values

  true | If the configuration has been set successfully.
  false | If the requested configuration is not allowed.

__STATIC_INLINE void nrf_i2s_disable | ( | NRF_I2S_Type * | p_i2s | ) |

Function for disabling the I2S peripheral.

Parameters

  [in] | p_i2s | I2S instance.

__STATIC_INLINE void nrf_i2s_enable | ( | NRF_I2S_Type * | p_i2s | ) |

Function for enabling the I2S peripheral.

Parameters

  [in] | p_i2s | I2S instance.

__STATIC_INLINE uint32_t nrf_i2s_event_address_get | ( | NRF_I2S_Type const * | p_i2s,
|  | nrf_i2s_event_t | event
| ) |  |

Function for getting the address of a specific I2S event register.

Parameters

  [in] | p_i2s | I2S instance.
  [in] | event | Requested event.

Returns
  Address of the specified event register.

__STATIC_INLINE bool nrf_i2s_event_check | ( | NRF_I2S_Type const * | p_i2s,
|  | nrf_i2s_event_t | event
| ) |  |

Function for checking the state of a specific I2S event.

Parameters

  [in] | p_i2s | I2S instance.
  [in] | event | Event to check.

Return values

  true | If the event is set.
  false | If the event is not set.

__STATIC_INLINE void nrf_i2s_event_clear | ( | NRF_I2S_Type * | p_i2s,
|  | nrf_i2s_event_t | event
| ) |  |

Function for clearing a specific I2S event.

Parameters

  [in] | p_i2s | I2S instance.
  [in] | event | Event to clear.

__STATIC_INLINE void nrf_i2s_int_disable | ( | NRF_I2S_Type * | p_i2s,
|  | uint32_t | mask
| ) |  |

Function for disabling specified interrupts.

Parameters

  [in] | p_i2s | I2S instance.
  [in] | mask | Interrupts to disable.

__STATIC_INLINE void nrf_i2s_int_enable | ( | NRF_I2S_Type * | p_i2s,
|  | uint32_t | mask
| ) |  |

Function for enabling specified interrupts.

Parameters

  [in] | p_i2s | I2S instance.
  [in] | mask | Interrupts to enable.

__STATIC_INLINE bool nrf_i2s_int_enable_check | ( | NRF_I2S_Type const * | p_i2s,
|  | nrf_i2s_int_mask_t | i2s_int
| ) |  |

Function for retrieving the state of a given interrupt.

Parameters

  [in] | p_i2s | I2S instance.
  [in] | i2s_int | Interrupt to check.

Return values

  true | If the interrupt is enabled.
  false | If the interrupt is not enabled.

__STATIC_INLINE void nrf_i2s_pins_set | ( | NRF_I2S_Type * | p_i2s,
|  | uint32_t | sck_pin,
|  | uint32_t | lrck_pin,
|  | uint32_t | mck_pin,
|  | uint32_t | sdout_pin,
|  | uint32_t | sdin_pin
| ) |  |

Function for configuring I2S pins.

Usage of the SDOUT, SDIN, and MCK signals is optional. If a given signal is not needed, pass the NRF_I2S_PIN_NOT_CONNECTED value instead of its pin number.

Parameters

  [in] | p_i2s | I2S instance.
  [in] | sck_pin | SCK pin number.
  [in] | lrck_pin | LRCK pin number.
  [in] | mck_pin | MCK pin number.
  [in] | sdout_pin | SDOUT pin number.
  [in] | sdin_pin | SDIN pin number.

__STATIC_INLINE uint32_t* nrf_i2s_rx_buffer_get | ( | NRF_I2S_Type const * | p_i2s | ) |

Function for getting the pointer to the receive buffer.

Parameters

  [in] | p_i2s | I2S instance.

Returns
  Pointer to the receive buffer.

__STATIC_INLINE void nrf_i2s_rx_buffer_set | ( | NRF_I2S_Type * | p_i2s,
|  | uint32_t * | p_buffer
| ) |  |

Function for setting the pointer to the receive buffer.

Note
  The size of the buffer can be set only by calling nrf_i2s_transfer_set.

Parameters

  [in] | p_i2s | I2S instance.
  [in] | p_buffer | Pointer to the receive buffer.

__STATIC_INLINE uint32_t nrf_i2s_task_address_get | ( | NRF_I2S_Type const * | p_i2s,
|  | nrf_i2s_task_t | task
| ) |  |

Function for getting the address of a specific I2S task register.

Parameters

  [in] | p_i2s | I2S instance.
  [in] | task | Requested task.

Returns
  Address of the specified task register.

__STATIC_INLINE void nrf_i2s_task_trigger | ( | NRF_I2S_Type * | p_i2s,
|  | nrf_i2s_task_t | task
| ) |  |

Function for activating a specific I2S task.

Parameters

  [in] | p_i2s | I2S instance.
  [in] | task | Task to activate.

__STATIC_INLINE void nrf_i2s_transfer_set | ( | NRF_I2S_Type * | p_i2s,
|  | uint16_t | size,
|  | uint32_t * | p_rx_buffer,
|  | uint32_t const * | p_tx_buffer
| ) |  |

Function for setting up the I2S transfer.

This function sets up the RX and TX buffers and enables reception and/or transmission accordingly. If the transfer in a given direction is not required, pass NULL instead of the pointer to the corresponding buffer.

Parameters

  [in] | p_i2s | I2S instance.
  [in] | size | Size of the buffers (in 32-bit words).
  [in] | p_rx_buffer | Pointer to the receive buffer. Pass NULL to disable reception.
  [in] | p_tx_buffer | Pointer to the transmit buffer. Pass NULL to disable transmission.

__STATIC_INLINE uint32_t* nrf_i2s_tx_buffer_get | ( | NRF_I2S_Type const * | p_i2s | ) |

Function for getting the pointer to the transmit buffer.

Parameters

  [in] | p_i2s | I2S instance.

Returns
  Pointer to the transmit buffer.

__STATIC_INLINE void nrf_i2s_tx_buffer_set | ( | NRF_I2S_Type * | p_i2s,
|  | uint32_t const * | p_buffer
| ) |  |

Function for setting the pointer to the transmit buffer.

Note
  The size of the buffer can be set only by calling nrf_i2s_transfer_set.

Parameters

  [in] | p_i2s | I2S instance.
  [in] | p_buffer | Pointer to the transmit buffer.