SimpleLink Audio Plugin
Data Structures | Typedefs | Variables
AudioHAL Codec

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
 

Detailed Description

This module implements communication with codec devices that support I2C control interfaces and I2S audio interfaces.

Driver include

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.

Overview

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

General Behavior

Before using the AudioHALCodec:

I2C codec configuration

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
Note
The codec may operate in master or slave mode at multiple sample rates. Additionally multiple bit depths may be supported by the codec. These settings are initialized in the 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.

Make I2C optional

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.

const AudioHALCodec_HWAttrsV1 AudioHALCodecHWAttrs[] = {
{
.i2cIdx = CC26X2R1_LAUNCHXL_I2C0,
.i2sIdx = CC26X2R1_LAUNCHXL_I2S0,
.i2cPageSelAddr = TI3254_PAGE_SEL_REG,
.openScript = NULL,
.closeScript = NULL,
.startScript = NULL,
.stopScript = NULL,
.clkCfg = NULL,
.clkCfgSize = 0,
.intfCfg = NULL,
.intfCfgSize = 0,
.mclkOpenFxn = NULL,
.mclkStartFxn = NULL,
.mclkStopFxn = NULL,
.mclkCloseFxn = NULL
}
};

Choosing Driver Indicies

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.

Setting Page Select Address

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.

Setting I2C Address

The AudioHALCodec operates as an I2C master, the codec's slave address can be set with i2cAddr.

Master Clock (MCLK) Generation

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.

.mclkOpenFxn = MCLKCC26XX_open,
.mclkStartFxn = MCLKCC26XX_start,
.mclkStopFxn = MCLKCC26XX_stop,
.mclkCloseFxn = MCLKCC26XX_close

MCLK APIs

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

Disabling MCLK generation.

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.

Supported Functions

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
Note
All calls should go through the generic API

Typedef Documentation

§ MclkCloseFxn

typedef void(* MclkCloseFxn) (void)

specifies the function signature for closing MCLK

§ MclkOpenFxn

typedef bool(* MclkOpenFxn) (void)

specifies the function signature for opening MCLK

§ MclkStartFxn

typedef void(* MclkStartFxn) (void)

specifies the function signature for starting MCLK signal generation

§ MclkStopFxn

typedef void(* MclkStopFxn) (void)

specifies the function signature for stopping MCLK signal generation

Variable Documentation

§ AudioHALCodec_fxnTable

const AudioHAL_FxnTable AudioHALCodec_fxnTable

AudioHAL function table pointer, points to codec specific HAL implementations

© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale