CC26xx Driver Library |

- Main Page
- Related Pages
- CC26xx APIs
- Register Descriptions
- Online Resources

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Functions | Variables
[i2s] Inter-IC Sound

## Data Structures
struct | I2SControlTable
| A structure that defines an audio control table. Note: Memory for this structure must be initialized by user application. See detailed description! More...

## Functions
void | I2SEnable (uint32_t ui32Base)
| Enables the I2S module for operation. More...
__STATIC_INLINE void | I2SDisable (uint32_t ui32Base)
| Disables the I2S module for operation. More...
void | I2SAudioFormatConfigure (uint32_t ui32Base, uint32_t ui32FmtCfg, uint32_t ui32BitClkDelay)
| Configures the I2S module. More...
void | I2SChannelConfigure (uint32_t ui32Base, uint32_t ui32Chan0Cfg, uint32_t ui32Chan1Cfg, uint32_t ui32Chan2Cfg)
| Setup the audio channel configuration. More...
__STATIC_INLINE void | I2SClockConfigure (uint32_t ui32Base, uint32_t ui32ClkConfig)
| Configure the I2S frame clock. More...
void | I2SBufferConfig (uint32_t ui32Base, uint32_t ui32InBufBase, uint32_t ui32OutBufBase, uint16_t ui16DMABufSize, uint16_t ui16ChanBufSize)
| Set the input buffer pointers. More...
void | I2SPointerUpdate (uint32_t ui32Base, bool bInput)
| Update the buffer pointers. More...
void | I2SPointerSet (uint32_t ui32Base, bool bInput, void *pNextPointer)
| Set a buffer pointer (input or output) directly. More...
__STATIC_INLINE void | I2SIntRegister (uint32_t ui32Base, void(*pfnHandler)(void))
| Registers an interrupt handler for an I2S interrupt. More...
__STATIC_INLINE void | I2SIntUnregister (uint32_t ui32Base)
| Unregisters an interrupt handler for a I2S interrupt. More...
__STATIC_INLINE void | I2SIntEnable (uint32_t ui32Base, uint32_t ui32IntFlags)
| Enables individual I2S interrupt sources. More...
__STATIC_INLINE void | I2SIntDisable (uint32_t ui32Base, uint32_t ui32IntFlags)
| Disables individual I2S interrupt sources. More...
__STATIC_INLINE uint32_t | I2SIntStatus (uint32_t ui32Base, bool bMasked)
| Gets the current interrupt status. More...
__STATIC_INLINE void | I2SIntClear (uint32_t ui32Base, uint32_t ui32IntFlags)
| Clears I2S interrupt sources. More...
__STATIC_INLINE void | I2SSampleStampEnable (uint32_t ui32Base)
| Enable the Sample Stamp generator. More...
__STATIC_INLINE void | I2SSampleStampDisable (uint32_t ui32Base)
| Disable the Sample Stamp generator. More...
void | I2SSampleStampConfigure (uint32_t ui32Base, bool bInput, bool bOutput)
| Configure the sample stamp generator. More...
uint32_t | I2SSampleStampGet (uint32_t ui32Base, uint32_t ui32Channel)
| Get the current value of a sample stamp counter. More...

## Variables
I2SControlTable * | g_pControlTable

## Detailed Description

## Function Documentation

void I2SAudioFormatConfigure | ( | uint32_t | ui32Base,
|  | uint32_t | ui32FmtCfg,
|  | uint32_t | ui32BitClkDelay
| ) |  |

Configures the I2S module.

The word length defines the size of the word transmitted on the data lines. For single phased formats `I2S_WORD_LENGTH_x` is the exact number of bits per word. In dual phased format this is the maximum number of bits per word. The size is set using I2S_WORD_LENGTH_8, I2S_WORD_LENGTH_16 or I2S_WORD_LENGTH_24.

Parameters

  ui32Base | is the I2S module base address.
  ui32FmtCfg | is the bitwise OR of several options: Sample size: I2S_MEM_LENGTH_16 I2S_MEM_LENGTH_24 Clock edge sampling: I2S_POS_EDGE I2S_NEG_EDGE Phase: I2S_DUAL_PHASE_FMT I2S_SINGLE_PHASE_FMT Word length: I2S_WORD_LENGTH_8 I2S_WORD_LENGTH_16 I2S_WORD_LENGTH_24
  ui32BitClkDelay | defines the bit clock delay by setting the number of bit clock periods between the positive word clock edge and the MSB of the first word in a phase. The bit clock delay is determined by the ratio between the bit clock and the frame clock and the chosen audio format. The bit clock delay must be configured depending on the chosen audio format: 0 : Left Justified Format (LJF). 1 : I2S and DSP format. 2-255 : Right Justified format (RJF).

Returns
  None

See also
  I2SChannelConfigure()

Definition at line 114 of file i2s.c.

void I2SBufferConfig | ( | uint32_t | ui32Base,
|  | uint32_t | ui32InBufBase,
|  | uint32_t | ui32OutBufBase,
|  | uint16_t | ui16DMABufSize,
|  | uint16_t | ui16ChanBufSize
| ) |  |

Set the input buffer pointers.

TBD - Consider using a fifth argument which is the channel delay size, and then calculate the address of the next pointer.

The next pointer should always be written while the DMA is using the previous written pointer. If not written in time an I2S_INT_PTR_ERR will occure and all outputs will be disabled.

Note
  At startup the next data pointer should be written just before and just after calling the I2SEnable().

Parameters

  ui32Base | is the base address of the I2S module.
  ui32InBufBase | is the address of the input buffer.
  ui32OutBufBase | is the address of the output buffer.
  ui16DMABufSize | is the size of the DMA buffers. Must be greater than 0!
  ui16ChanBufSize | is the size of the channel buffers.

Returns
  None

Definition at line 279 of file i2s.c.

void I2SChannelConfigure | ( | uint32_t | ui32Base,
|  | uint32_t | ui32Chan0Cfg,
|  | uint32_t | ui32Chan1Cfg,
|  | uint32_t | ui32Chan2Cfg
| ) |  |

Setup the audio channel configuration.

The channel configuration is a bitwise OR of the input/output mode of each data line and the active audio channels within a specific audio frame.

Setting up the input/output mode use one of:

- I2S_LINE_UNUSED
- I2S_LINE_INPUT
- I2S_LINE_OUTPUT

For dual phased audio (LJF,RJF,I2S) only mono and stereo modes are allowed. For single phased audio format (DSP) up to 8 active channels are allowed on a single data line. For setting up the active channels in a frame use:

- Single phased, use a bitwise OR'ed combination of:
  - I2S_CHAN0_ACT
  - I2S_CHAN1_ACT
  - I2S_CHAN2_ACT
  - I2S_CHAN3_ACT
  - I2S_CHAN4_ACT
  - I2S_CHAN5_ACT
  - I2S_CHAN6_ACT
  - I2S_CHAN7_ACT
- Dual phased, use one of:
  - I2S_MONO_MODE (same as I2S_CHAN0_ACT)
  - I2S_STEREO_MODE (same as I2S_CHAN0_ACT | I2S_CHAN1_ACT)

Note
  The audio format and the clock configuration should be set using I2SAudioFormatConfigure()

Parameters

  ui32Base | is base address of the I2S module.
  ui32Chan0Cfg | defines the channel configuration for data line 0.
  ui32Chan1Cfg | defines the channel configuration for data line 1.
  ui32Chan2Cfg | defines the channel configuration for data line 2.

Returns
  None

See also
  I2SAudioFormatConfigure()

Definition at line 140 of file i2s.c.

__STATIC_INLINE void I2SClockConfigure | ( | uint32_t | ui32Base,
|  | uint32_t | ui32ClkConfig
| ) |  |

Configure the I2S frame clock.

Configure I2S clock to be either internal or external and either normal or inverted.

Note
  The bit clock configuration is done externally, but the internal/ external setting must match what is chosen internally in the I2S module for the frame clock.

Parameters

  ui32Base | is the base address of the I2S module.
  ui32ClkConfig | is the clock configuration parameter. Bitwise OR'ed combination of clock source and clock polarity: Clock source: I2S_EXT_WCLK : External clock. I2S_INT_WCLK : Internal clock. Clock polarity: I2S_NORMAL_WCLK : Normal clock. I2S_INVERT_WCLK : Inverted clock.

Returns
  None

Definition at line 415 of file i2s.h.

__STATIC_INLINE void I2SDisable | ( | uint32_t | ui32Base | ) |

Disables the I2S module for operation.

This function will immediately disable the I2S module. To ensure that all buffer operations are completed before shutting down, the correct procedure is:

1. Do not update the data pointers using I2SPointerUpdate().
2. Await next interrupt resulting in I2S_INT_PTR_ERR.
3. Disable the I2S using I2SDisable() and clear the pointer error using I2SIntClear().
4. Disable bit clock source (done externally).

Parameters

  ui32Base | is the I2S module base address.

Returns
  None

Definition at line 291 of file i2s.h.

void I2SEnable | ( | uint32_t | ui32Base | ) |

Enables the I2S module for operation.

Note
  The module should only be enabled after configuration. When the module is disabled, no data or clocks will be generated on the I2S signals.
  Immediately after enabling the module the programmer should update the DMA data pointer registers using I2SPointerUpdate() to ensure a new pointer is written before the DMA transfer completes. Failure to update the pointer in time will result in an I2S_INT_PTR_ERR.

Parameters

  ui32Base | is the I2S module base address.

Returns
  None

Definition at line 79 of file i2s.c.

__STATIC_INLINE void I2SIntClear | ( | uint32_t | ui32Base,
|  | uint32_t | ui32IntFlags
| ) |  |

Clears I2S interrupt sources.

The specified I2S interrupt sources are cleared, so that they no longer assert. This function must be called in the interrupt handler to keep the interrupt from being recognized again immediately upon exit.

Note
  Because there is a write buffer in the Cortex-M3 processor, it may take several clock cycles before the interrupt source is actually cleared. Therefore, it is recommended that the interrupt source be cleared early in the interrupt handler (as opposed to the very last action) to avoid returning from the interrupt handler before the interrupt source is actually cleared. Failure to do so may result in the interrupt handler being immediately reentered (because the interrupt controller still sees the interrupt source asserted).

Parameters

  ui32Base | is the base address of the I2S port.
  ui32IntFlags | is a bit mask of the interrupt sources to be cleared. The parameter is the bitwise OR of any of the following: I2S_INT_DMA_IN I2S_INT_DMA_OUT I2S_INT_TIMEOUT I2S_INT_BUS_ERR I2S_INT_WCLK_ERR I2S_INT_PTR_ERR I2S_INT_ALL (covers all the above)

Returns
  None

Definition at line 735 of file i2s.h.

__STATIC_INLINE void I2SIntDisable | ( | uint32_t | ui32Base,
|  | uint32_t | ui32IntFlags
| ) |  |

Disables individual I2S interrupt sources.

This function disables the indicated I2S interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

Parameters

  ui32Base | is the base address of the I2S port.
  ui32IntFlags | is the bit mask of the interrupt sources to be disabled. The parameter is the bitwise OR of any of the following: I2S_INT_DMA_IN I2S_INT_DMA_OUT I2S_INT_TIMEOUT I2S_INT_BUS_ERR I2S_INT_WCLK_ERR I2S_INT_PTR_ERR I2S_INT_ALL (covers all the above)

Returns
  None.

Definition at line 643 of file i2s.h.

__STATIC_INLINE void I2SIntEnable | ( | uint32_t | ui32Base,
|  | uint32_t | ui32IntFlags
| ) |  |

Enables individual I2S interrupt sources.

This function enables the indicated I2S interrupt sources. Only the sources that are enabled can be reflected to the processor interrupt; disabled sources have no effect on the processor.

Parameters

  ui32Base | is the base address of the I2S port.
  ui32IntFlags | is the bit mask of the interrupt sources to be enabled. The parameter is the bitwise OR of any of the following: I2S_INT_DMA_IN I2S_INT_DMA_OUT I2S_INT_TIMEOUT I2S_INT_BUS_ERR I2S_INT_WCLK_ERR I2S_INT_PTR_ERR I2S_INT_ALL (covers all the above)

Returns
  None.

Definition at line 607 of file i2s.h.

__STATIC_INLINE void I2SIntRegister | ( | uint32_t | ui32Base,
|  | void(*)(void) | pfnHandler
| ) |  |

Registers an interrupt handler for an I2S interrupt.

This function does the actual registering of the interrupt handler. This function enables the global interrupt in the interrupt controller; specific I2S interrupts must be enabled via I2SIntEnable(). It is the interrupt handler's responsibility to clear the interrupt source.

Parameters

  ui32Base | is the base address of the I2S port.
  pfnHandler | is a pointer to the function to be called when the I2S interrupt occurs.

Returns
  None

See also
  IntRegister() for important information about registering interrupt handlers.

Definition at line 530 of file i2s.h.

__STATIC_INLINE uint32_t I2SIntStatus | ( | uint32_t | ui32Base,
|  | bool | bMasked
| ) |  |

Gets the current interrupt status.

This function returns the interrupt status for the specified I2S. Either the raw interrupt status or the status of interrupts that are allowed to reflect to the processor can be returned.

Parameters

  ui32Base | is the base address of the I2S port
  bMasked | selects between raw and masked interrupt status: `false` : Raw interrupt status is required. `true` : Masked interrupt status is required.

Returns
  Returns the current interrupt status as a vector of:
  - I2S_INT_DMA_IN
  - I2S_INT_DMA_OUT
  - I2S_INT_TIMEOUT
  - I2S_INT_BUS_ERR
  - I2S_INT_WCLK_ERR
  - I2S_INT_PTR_ERR

Definition at line 679 of file i2s.h.

__STATIC_INLINE void I2SIntUnregister | ( | uint32_t | ui32Base | ) |

Unregisters an interrupt handler for a I2S interrupt.

This function does the actual unregistering of the interrupt handler. It clears the handler to be called when an I2S interrupt occurs. This function also masks off the interrupt in the interrupt controller so that the interrupt handler no longer is called.

Parameters

  ui32Base | is the base address of the I2S port.

Returns
  None

See also
  IntRegister() for important information about registering interrupt handlers.

Definition at line 566 of file i2s.h.

void I2SPointerSet | ( | uint32_t | ui32Base,
|  | bool | bInput,
|  | void * | pNextPointer
| ) |  |

Set a buffer pointer (input or output) directly.

This function allows bypassing of the pointers in the global control table.

The next pointer should always be written while the DMA is using the previous written pointer. If not written in time an I2S_INT_PTR_ERR will occure and all outputs will be disabled. Nothing is preventing the pointers from being identical, but this function relies on both pointers (input or output pointers) are pointing to a valid address.

Note
  It is recommended that the pointer update is done in an interrupt context to ensure that the update is performed before the buffer is full.

Parameters

  ui32Base | is the base address of the I2S module.
  bInput | determines whether to update input or output pointer. `true` : Update input pointer. `false` : Update output pointer
  pNextPointer | is a void pointer to user defined buffer.

Returns
  None

See also
  I2SPointerUpdate()

Set a buffer pointer (input or output) directly.

Definition at line 304 of file i2s.c.

void I2SPointerUpdate | ( | uint32_t | ui32Base,
|  | bool | bInput
| ) |  |

Update the buffer pointers.

The next pointer should always be written while the DMA is using the previous written pointer. If not written in time an I2S_INT_PTR_ERR will occure and all outputs will be disabled. Nothing is preventing the pointers from being identical, but this function relies on both pointers (input or output pointers) are pointing to a valid address.

Note
  It is recommended that the pointer update is done in an interrupt context to ensure that the update is performed before the buffer is full.

Parameters

  ui32Base | is the base address of the I2S module.
  bInput | determines whether to update input or output pointer. `true` : Update input pointer. `false` : Update output pointer

Returns
  None

See also
  I2SPointerSet()

Definition at line 330 of file i2s.c.

void I2SSampleStampConfigure | ( | uint32_t | ui32Base,
|  | bool | bInput,
|  | bool | bOutput
| ) |  |

Configure the sample stamp generator.

Use this function to configure the sample stamp generator.

TBD - Expand function, not quite sure how this audio interface should be implemented.

Parameters

  ui32Base | is the base address of the I2S module.
  bInput | enables triggering of the sample stamp generator on input.
  bOutput | enables triggering of the sample stamp generator on output.

Returns
  None

Definition at line 373 of file i2s.c.

__STATIC_INLINE void I2SSampleStampDisable | ( | uint32_t | ui32Base | ) |

Disable the Sample Stamp generator.

Use this function to disable the sample stamp generators. When the sample stamp generator is disabled, the clock counters are automatically cleared.

Returns
  None

Definition at line 782 of file i2s.h.

__STATIC_INLINE void I2SSampleStampEnable | ( | uint32_t | ui32Base | ) |

Enable the Sample Stamp generator.

Use this function to enable the sample stamp generators.

Note
  It is the user's responsibility to ensure that the sample stamp generator is properly configured before it is enabled. It is the setting of the Input and Output triggers configured using I2SSampleStampConfigure() that triggers the start point of the audio streams.

Returns
  None

Definition at line 763 of file i2s.h.

uint32_t I2SSampleStampGet | ( | uint32_t | ui32Base,
|  | uint32_t | ui32Channel
| ) |  |

Get the current value of a sample stamp counter.

Parameters

  ui32Base | is the base address of the I2S module.
  ui32Channel | is the sample stamp counter to sample

Returns
  Returns the current value of the selected sample stamp channel.

Definition at line 409 of file i2s.c.

## Macro Definition Documentation

#define I2S_CHAN0_ACT 0x00000100

Definition at line 175 of file i2s.h.

#define I2S_CHAN1_ACT 0x00000200

Definition at line 176 of file i2s.h.

#define I2S_CHAN2_ACT 0x00000400

Definition at line 177 of file i2s.h.

#define I2S_CHAN3_ACT 0x00000800

Definition at line 178 of file i2s.h.

#define I2S_CHAN4_ACT 0x00001000

Definition at line 179 of file i2s.h.

#define I2S_CHAN5_ACT 0x00002000

Definition at line 180 of file i2s.h.

#define I2S_CHAN6_ACT 0x00004000

Definition at line 181 of file i2s.h.

#define I2S_CHAN7_ACT 0x00008000

Definition at line 182 of file i2s.h.

#define I2S_CHAN_CFG_MASK 0x0000FF00

Definition at line 185 of file i2s.h.

Referenced by I2SChannelConfigure().

#define I2S_DMA_BUF_SIZE_128 0x00000080

Definition at line 147 of file i2s.h.

#define I2S_DMA_BUF_SIZE_256 0x00000100

Definition at line 148 of file i2s.h.

#define I2S_DMA_BUF_SIZE_64 0x00000040

Definition at line 146 of file i2s.h.

#define I2S_DUAL_PHASE_FMT 0x00000020

Definition at line 196 of file i2s.h.

#define I2S_EXT_WCLK 0x00000001

Definition at line 155 of file i2s.h.

#define I2S_INT_ALL 0x0000003F

Definition at line 223 of file i2s.h.

#define I2S_INT_BUS_ERR 0x00000004

Definition at line 220 of file i2s.h.

#define I2S_INT_DMA_IN 0x00000020

Definition at line 217 of file i2s.h.

#define I2S_INT_DMA_OUT 0x00000010

Definition at line 218 of file i2s.h.

#define I2S_INT_PTR_ERR 0x00000001

Definition at line 222 of file i2s.h.

#define I2S_INT_TIMEOUT 0x00000008

Definition at line 219 of file i2s.h.

#define I2S_INT_WCLK 0x00000002

Definition at line 156 of file i2s.h.

#define I2S_INT_WCLK_ERR 0x00000002

Definition at line 221 of file i2s.h.

#define I2S_INVERT_WCLK 0x00000004

Definition at line 157 of file i2s.h.

#define I2S_LINE_INPUT 0x00000001

Definition at line 166 of file i2s.h.

Referenced by I2SChannelConfigure().

#define I2S_LINE_MASK 0x00000003

Definition at line 168 of file i2s.h.

Referenced by I2SChannelConfigure().

#define I2S_LINE_OUTPUT 0x00000002

Definition at line 167 of file i2s.h.

Referenced by I2SChannelConfigure().

#define I2S_LINE_UNUSED 0x00000000

Definition at line 165 of file i2s.h.

#define I2S_MEM_LENGTH_16 0x00000000

Definition at line 192 of file i2s.h.

#define I2S_MEM_LENGTH_24 0x00000080

Definition at line 193 of file i2s.h.

Referenced by I2SAudioFormatConfigure().

#define I2S_MONO_MODE 0x00000100

Definition at line 183 of file i2s.h.

#define I2S_NEG_EDGE 0x00000000

Definition at line 195 of file i2s.h.

#define I2S_NORMAL_WCLK 0x00000000

Definition at line 158 of file i2s.h.

#define I2S_POS_EDGE 0x00000040

Definition at line 194 of file i2s.h.

#define I2S_SINGLE_PHASE_FMT 0x00000000

Definition at line 197 of file i2s.h.

#define I2S_STEREO_MODE 0x00000300

Definition at line 184 of file i2s.h.

#define I2S_STMP0 0x00000001

Definition at line 207 of file i2s.h.

#define I2S_STMP1 0x00000002

Definition at line 208 of file i2s.h.

#define I2S_STMP_SATURATION 0x0000FFFF

Definition at line 209 of file i2s.h.

Referenced by I2SSampleStampGet().

#define I2S_WORD_LENGTH_16 0x00000010

Definition at line 199 of file i2s.h.

#define I2S_WORD_LENGTH_24 0x00000018

Definition at line 200 of file i2s.h.

#define I2S_WORD_LENGTH_8 0x00000008

Definition at line 198 of file i2s.h.

## Variable Documentation

I2SControlTable* g_pControlTable

Definition at line 71 of file i2s.c.