![]() |
![]() |
|
SimpleLink Audio Plugin
|
This module implements communication with codec devices that support I2C control interfaces and I2S audio interfaces. More...
Data Structures | |
| struct | AudioHALCodec_HWAttrsV1 |
| AudioHALCodec Hardware1attributes. More... | |
| struct | AudioHALCodec_Object |
| AudioHALCodec Object. More... | |
Typedefs | |
| typedef void(* | MclkCloseFxn) (void) |
| typedef bool(* | MclkOpenFxn) (void) |
| typedef void(* | MclkStartFxn) (void) |
| typedef void(* | MclkStopFxn) (void) |
Variables | |
| const AudioHAL_FxnTable | AudioHALCodec_fxnTable |
This module implements communication with codec devices that support I2C control interfaces and I2S audio interfaces.
The AudioHAL header file should be included in an application as follows:
Refer to AudioHAL.h for a complete description of APIs. In general it is intended to use the highest level of abstraction (e.g. AudioHAL.h). It shouldn't be necessary to use the codec layer directly in the application.
The general AudioHAL API should used in application code, i.e. AudioHAL_open() is used instead of AudioHALCodec_open(). The board file will define the HAL specific config, and casting in the general API will ensure that the correct HAL specific functions are called.
The AudioHALCodec is designed to interface to codecs that operate via I2S as a data interface and I2C as a control interface. AudioHALCodec is comprised of three components
Before using the AudioHALCodec:
AudioHALCodec is intended to interface to Codec devices that have an I2C based control interface. These devices contain I2C registers that control things such as sampling rate, serial format, and clock configuration.
AudioHALCodec will use the functions in AudioHAL_I2C to run a string of I2C register operations defined as a script. See AudioHAL_I2CScript.
I2C scripts are passed into the HAL via entries in the AudioHALCodec_HWAttrsV1 struct that is defined in the board file. The various scripts and their mapping to the variables in the HWAttrs are described below
| HWAttrs Parameter | Executed During | Description |
|---|---|---|
| AudioHALCodec_HWAttrsV1.clkCfg | AudioHALCodec_open() | Array of AudioHAL_I2CScript that sets up the codecs clocking based on Fs and role |
| AudioHALCodec_HWAttrsV1.intfCfg | AudioHALCodec_open() | Array of AudioHAL_I2CScript that sets up the codecs interface settings. (e.g. bit depth) |
| AudioHALCodec_HWAttrsV1.openScript | AudioHALCodec_open() | AudioHAL_I2CScript that configures codec settings such as mini DSP settings, output path |
| AudioHALCodec_HWAttrsV1.closeScript | AudioHALCodec_close() | AudioHAL_I2CScript that shuts down codec |
| AudioHALCodec_HWAttrsV1.startScript | AudioHALCodec_startStream() | AudioHAL_I2CScript that prepares the codec to stream I2S data |
| AudioHALCodec_HWAttrsV1.startScript | AudioHALCodec_stopStream() | AudioHAL_I2CScript that stops the stream of data |
clkCfg and intfCfg arrays of scripts respectively. In order to support the use case where the codec supports multiple sample rates and bit depths, an array of scripts must be used. On open, the AudioHALCodec will search for the clk and intf config that setup the codec based on the user provided parameters to the HAL. The fields intfCfgSize and clkCfgSize should be populated with the number of entries in the script array.If the I2C configuration is not needed by the codec, or an external device does the configuration, the I2C communication may be made entirely optional. In this case, the AudioHALCodec will not open the I2C or attempt to execute any scripts. To do so, change the AudioHALCodecHWAttrs to null out the I2C entries. Note that if I2C is to be used then at least one clkCfg and intfCfg must be provided. Other scripts (open, close, start, stop) are optional.
The AudioHALCodec requires the I2S and optionally the I2C driver to run. If the target device supports more than one instance of either of these interfaces, the index to open can be specified using the i2sIdx and i2cIdx field of the HWAttrs struct in the board file.
The AudioHALCodec's I2C support is intended to configure the control settings of the codec. It assumes that that the codec has a paged architecture consisting of multiple register banks that can be switched between with a write to a page select register. This register's address can be set with i2cPageSelAddr.
The AudioHALCodec operates as an I2C master, the codec's slave address can be set with i2cAddr.
Some devices such as CC13xx/CC26xx cannot generate a master clock signal when operating as an I2S slave. However, it may be advantageous to have the CCxxxx device operate in slave mode while generating a MCLK. In this case, the MCLK signal must be generated in SW using a timer or similar mechanism. If this functionality is desired, the HAL may open, close, start, and stop the MCLK signal. The MCLK functions are specified via the HW attrs structure in the board file.
| HWAttrs Parameter | Executed During | Description |
|---|---|---|
| AudioHALCodec_HWAttrsV1.mclkOpenFxn | AudioHALCodec_open() | Opens any H/W or SW necessary to generate an MCLK signal |
| AudioHALCodec_HWAttrsV1.mclkStartFxn | AudioHALCodec_startStream() | Starts generation of MCLK signal |
| AudioHALCodec_HWAttrsV1.mclkStopFxn | AudioHALCodec_stopStream() | Stops generation of MCLK signal |
| AudioHALCodec_HWAttrsV1.mclkCloseFxn | AudioHALCodec_open() | Closes MCLK, releases resources |
As with I2C, if the MCLK functons are specified to be NULL, then no signal will be generated. See the I2C example above for info on how to NULL these signals.
| Generic API function | API function | Description |
|---|---|---|
| AudioHAL_init() | AudioHALCodec_init() | Initialize member variables and I2C, I2S drivers |
| AudioHAL_close() | AudioHALCodec_close() | Deallocate resources, stop clocks, close drivers |
| AudioHAL_control() | AudioHALCodec_control() | RFU |
| AudioHAL_readBufGet() | AudioHALCodec_readBufGet() | Copy a read buffer into user specified memory |
| AudioHAL_writeBufPut() | AudioHALCodec_writeBufPut() | Copy a write buffer from user specified memory |
| AudioHAL_startStream() | AudioHALCodec_startStream() | Begin TX,RX using ring list |
| AudioHAL_stopStream() | AudioHALCodec_stopStream() | Stop TX, RX, shutdown clocks |
| typedef void(* MclkCloseFxn) (void) |
specifies the function signature for closing MCLK
| typedef bool(* MclkOpenFxn) (void) |
specifies the function signature for opening MCLK
| typedef void(* MclkStartFxn) (void) |
specifies the function signature for starting MCLK signal generation
| typedef void(* MclkStopFxn) (void) |
specifies the function signature for stopping MCLK signal generation
| const AudioHAL_FxnTable AudioHALCodec_fxnTable |
AudioHAL function table pointer, points to codec specific HAL implementations