tlv320aic23b.h File Reference


Detailed Description

TLV320AIC23B stereo audio CODEC driver for AVR32.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file tlv320aic23b.h.

#include <limits.h>
#include <stddef.h>
#include "compiler.h"
#include "conf_tlv320aic23b.h"

Go to the source code of this file.

Data Structures

union  aic23b_aapc_t
 Register structure. More...
struct  aic23b_ctrl_t
 Register structure. More...
union  aic23b_daif_t
 Register structure. More...
union  aic23b_dapc_t
 Register structure. More...
union  aic23b_dia_t
 Register structure. More...
union  aic23b_lchvc_t
 Register structure. More...
union  aic23b_llicvc_t
 Register structure. More...
union  aic23b_pdc_t
 Register structure. More...
union  aic23b_rchvc_t
 Register structure. More...
union  aic23b_rlicvc_t
 Register structure. More...
union  aic23b_rr_t
 Register structure. More...
union  aic23b_src_t
 Register structure. More...

Defines

Analog Audio Path Control
#define AIC23B_AAPC   0x04
 Register index.
#define AIC23B_AAPC_ADDRESS   0x04
 Register address.
#define AIC23B_AAPC_BYP_OFFSET   3
 Bypass bit-field offset.
#define AIC23B_AAPC_BYP_SIZE   1
 Bypass bit-field size.
#define AIC23B_AAPC_DAC_OFFSET   4
 DAC select bit-field offset.
#define AIC23B_AAPC_DAC_SIZE   1
 DAC select bit-field size.
#define AIC23B_AAPC_DEFAULT   0x000A
 Register default value.
#define AIC23B_AAPC_INSEL_LINE   0x0000
 Input selected for ADC: line.
#define AIC23B_AAPC_INSEL_MIC   0x0001
 Input selected for ADC: microphone.
#define AIC23B_AAPC_INSEL_OFFSET   2
 Input select for ADC bit-field offset.
#define AIC23B_AAPC_INSEL_SIZE   1
 Input select for ADC bit-field size.
#define AIC23B_AAPC_MICB_OFFSET   0
 Microphone boost (+20 dB) bit-field offset.
#define AIC23B_AAPC_MICB_SIZE   1
 Microphone boost (+20 dB) bit-field size.
#define AIC23B_AAPC_MICM_OFFSET   1
 Microphone mute bit-field offset.
#define AIC23B_AAPC_MICM_SIZE   1
 Microphone mute bit-field size.
#define AIC23B_AAPC_STA_0DB   0x0004
 Added sidetone: 0 dB.
#define AIC23B_AAPC_STA_M12DB   0x0002
 Added sidetone: -12 dB.
#define AIC23B_AAPC_STA_M18DB   0x0003
 Added sidetone: -18 dB.
#define AIC23B_AAPC_STA_M6DB   0x0000
 Added sidetone: -6 dB.
#define AIC23B_AAPC_STA_M9DB   0x0001
 Added sidetone: -9 dB.
#define AIC23B_AAPC_STA_OFFSET   6
 Sidetone addition bit-field offset.
#define AIC23B_AAPC_STA_SIZE   3
 Sidetone addition bit-field size.
#define AIC23B_AAPC_STE_OFFSET   5
 Sidetone enable bit-field offset.
#define AIC23B_AAPC_STE_SIZE   1
 Sidetone enable bit-field size.
Register Structure
#define AIC23B_ADDRESS(REG)   REG##_ADDRESS
 Returns the address of the REG register (e.g. AIC23B_LLICVC).
#define AIC23B_DEFAULT(REG)   REG##_DEFAULT
 Returns the default value of the REG register (e.g. AIC23B_LLICVC).
#define AIC23B_MASK(REG, BITFIELD)   (((1 << REG##_##BITFIELD##_SIZE) - 1) << REG##_##BITFIELD##_OFFSET)
 Returns the mask of the BITFIELD bit-field (e.g.
#define AIC23B_OFFSET(REG, BITFIELD)   REG##_##BITFIELD##_OFFSET
 Returns the offset of the BITFIELD bit-field (e.g.
#define AIC23B_SIZE(REG, BITFIELD)   REG##_##BITFIELD##_SIZE
 Returns the size of the BITFIELD bit-field (e.g.
Control Word
#define AIC23B_CTRL_ADDR_OFFSET   9
 Control address bit-field offset.
#define AIC23B_CTRL_ADDR_SIZE   7
 Control address bit-field size.
#define AIC23B_CTRL_DATA_OFFSET   0
 Control data bit-field offset.
#define AIC23B_CTRL_DATA_SIZE   9
 Control data bit-field size.
#define AIC23B_CTRL_SIZE   (AIC23B_CTRL_ADDR_SIZE + AIC23B_CTRL_DATA_SIZE)
Control Interface
#define AIC23B_CTRL_INTERFACE_SPI   2
 Control interface: Serial Peripheral Interface.
#define AIC23B_CTRL_INTERFACE_TWI   1
 Control interface: Two-Wire Interface.
Digital Audio Interface Format
#define AIC23B_DAIF   0x07
 Register index.
#define AIC23B_DAIF_ADDRESS   0x07
 Register address.
#define AIC23B_DAIF_DEFAULT   0x0001
 Register default value.
#define AIC23B_DAIF_FMT_DSP   0x0003
 Data format: DSP format, frame sync followed by two data words.
#define AIC23B_DAIF_FMT_I2S   0x0002
 Data format: I²S format, MSB first, left - 1 aligned.
#define AIC23B_DAIF_FMT_LA   0x0001
 Data format: MSB first, left aligned.
#define AIC23B_DAIF_FMT_OFFSET   0
 Data format bit-field offset.
#define AIC23B_DAIF_FMT_RA   0x0000
 Data format: MSB first, right aligned.
#define AIC23B_DAIF_FMT_SIZE   2
 Data format bit-field size.
#define AIC23B_DAIF_IWL_16   0x0000
 Input bit length: 16.
#define AIC23B_DAIF_IWL_20   0x0001
 Input bit length: 20.
#define AIC23B_DAIF_IWL_24   0x0002
 Input bit length: 24.
#define AIC23B_DAIF_IWL_32   0x0003
 Input bit length: 32.
#define AIC23B_DAIF_IWL_OFFSET   2
 Input bit length bit-field offset.
#define AIC23B_DAIF_IWL_SIZE   2
 Input bit length bit-field size.
#define AIC23B_DAIF_LRP_OFFSET   4
 DAC left/right phase bit-field offset.
#define AIC23B_DAIF_LRP_SIZE   1
 DAC left/right phase bit-field size.
#define AIC23B_DAIF_LRSWAP_OFFSET   5
 DAC left/right swap bit-field offset.
#define AIC23B_DAIF_LRSWAP_SIZE   1
 DAC left/right swap bit-field size.
#define AIC23B_DAIF_MS_MASTER   0x0001
 Master mode.
#define AIC23B_DAIF_MS_OFFSET   6
 Master/slave mode bit-field offset.
#define AIC23B_DAIF_MS_SIZE   1
 Master/slave mode bit-field size.
#define AIC23B_DAIF_MS_SLAVE   0x0000
 Slave mode.
Digital Audio Path Control
#define AIC23B_DAPC   0x05
 Register index.
#define AIC23B_DAPC_ADCHP_OFFSET   0
 ADC high-pass filter bit-field offset.
#define AIC23B_DAPC_ADCHP_SIZE   1
 ADC high-pass filter bit-field size.
#define AIC23B_DAPC_ADDRESS   0x05
 Register address.
#define AIC23B_DAPC_DACM_OFFSET   3
 DAC soft mute bit-field offset.
#define AIC23B_DAPC_DACM_SIZE   1
 DAC soft mute bit-field size.
#define AIC23B_DAPC_DEEMP_32KHZ   0x0001
 De-emphasis: 32 kHz.
#define AIC23B_DAPC_DEEMP_44_1KHZ   0x0002
 De-emphasis: 44.1 kHz.
#define AIC23B_DAPC_DEEMP_48KHZ   0x0003
 De-emphasis: 48 kHz.
#define AIC23B_DAPC_DEEMP_NONE   0x0000
 De-emphasis: none.
#define AIC23B_DAPC_DEEMP_OFFSET   1
 De-emphasis control bit-field offset.
#define AIC23B_DAPC_DEEMP_SIZE   2
 De-emphasis control bit-field size.
#define AIC23B_DAPC_DEFAULT   0x0008
 Register default value.
Digital Interface Activation
#define AIC23B_DIA   0x09
 Register index.
#define AIC23B_DIA_ACT_OFFSET   0
 Activate interface bit-field offset.
#define AIC23B_DIA_ACT_SIZE   1
 Activate interface bit-field size.
#define AIC23B_DIA_ADDRESS   0x09
 Register address.
#define AIC23B_DIA_DEFAULT   0x0000
 Register default value.
Volume Control
#define AIC23B_HP_VOL_MAX   ((S8)(+ 6))
#define AIC23B_HP_VOL_MIN   ((S8)(-72))
#define AIC23B_HP_VOL_OFFSET   0x79
#define AIC23B_LIN_VOL_MAX   ((S8)(+12 * 2 / 3))
#define AIC23B_LIN_VOL_MIN   ((S8)(-34.5 * 2 / 3))
#define AIC23B_LIN_VOL_OFFSET   0x17
#define AIC23B_MUTED   SCHAR_MIN
Input Selected
#define AIC23B_INPUT_LINE   0
 Input Selected: LINE IN.
#define AIC23B_INPUT_MIC   1
 Input Selected: MIC.
Left Channel Headphone Volume Control
#define AIC23B_LCHVC   0x02
 Register index.
#define AIC23B_LCHVC_ADDRESS   0x02
 Register address.
#define AIC23B_LCHVC_DEFAULT   0x00F9
 Register default value.
#define AIC23B_LCHVC_LHV_OFFSET   0
 Left headphone volume control bit-field offset.
#define AIC23B_LCHVC_LHV_SIZE   7
 Left headphone volume control bit-field size.
#define AIC23B_LCHVC_LRS_OFFSET   8
 Left/right headphone channel simultaneous volume/mute update bit-field offset.
#define AIC23B_LCHVC_LRS_SIZE   1
 Left/right headphone channel simultaneous volume/mute update bit-field size.
#define AIC23B_LCHVC_LZC_OFFSET   7
 Left-channel zero-cross detect bit-field offset.
#define AIC23B_LCHVC_LZC_SIZE   1
 Left-channel zero-cross detect bit-field size.
Audio Channels
#define AIC23B_LEFT_CHANNEL   0x01
#define AIC23B_RIGHT_CHANNEL   0x02
Left Line Input Channel Volume Control
#define AIC23B_LLICVC   0x00
 Register index.
#define AIC23B_LLICVC_ADDRESS   0x00
 Register address.
#define AIC23B_LLICVC_DEFAULT   0x0097
 Register default value.
#define AIC23B_LLICVC_LIM_OFFSET   7
 Left line input mute bit-field offset.
#define AIC23B_LLICVC_LIM_SIZE   1
 Left line input mute bit-field size.
#define AIC23B_LLICVC_LIV_OFFSET   0
 Left line input volume control bit-field offset.
#define AIC23B_LLICVC_LIV_SIZE   5
 Left line input volume control bit-field size.
#define AIC23B_LLICVC_LRS_OFFSET   8
 Left/right line simultaneous volume/mute update bit-field offset.
#define AIC23B_LLICVC_LRS_SIZE   1
 Left/right line simultaneous volume/mute update bit-field size.
Mode Supported
#define AIC23B_MODE_ADC   1
 Mode supported: ADC.
#define AIC23B_MODE_CODEC   3
 Mode supported: CODEC.
#define AIC23B_MODE_DAC   0
 Mode supported: DAC.
Power Down Control
#define AIC23B_PDC   0x06
 Register index.
#define AIC23B_PDC_ADC_OFFSET   2
 ADC bit-field offset.
#define AIC23B_PDC_ADC_SIZE   1
 ADC bit-field size.
#define AIC23B_PDC_ADDRESS   0x06
 Register address.
#define AIC23B_PDC_CLK_OFFSET   6
 Clock bit-field offset.
#define AIC23B_PDC_CLK_SIZE   1
 Clock bit-field size.
#define AIC23B_PDC_DAC_OFFSET   3
 DAC bit-field offset.
#define AIC23B_PDC_DAC_SIZE   1
 DAC bit-field size.
#define AIC23B_PDC_DEFAULT   0x0007
 Register default value.
#define AIC23B_PDC_LINE_OFFSET   0
 Line input bit-field offset.
#define AIC23B_PDC_LINE_SIZE   1
 Line input bit-field size.
#define AIC23B_PDC_MIC_OFFSET   1
 Microphone input bit-field offset.
#define AIC23B_PDC_MIC_SIZE   1
 Microphone input bit-field size.
#define AIC23B_PDC_OFF_OFFSET   7
 Device power bit-field offset.
#define AIC23B_PDC_OFF_SIZE   1
 Device power bit-field size.
#define AIC23B_PDC_OSC_OFFSET   5
 Oscillator bit-field offset.
#define AIC23B_PDC_OSC_SIZE   1
 Oscillator bit-field size.
#define AIC23B_PDC_OUT_OFFSET   4
 Outputs bit-field offset.
#define AIC23B_PDC_OUT_SIZE   1
 Outputs bit-field size.
Right Channel Headphone Volume Control
#define AIC23B_RCHVC   0x03
 Register index.
#define AIC23B_RCHVC_ADDRESS   0x03
 Register address.
#define AIC23B_RCHVC_DEFAULT   0x00F9
 Register default value.
#define AIC23B_RCHVC_RHV_OFFSET   0
 Right headphone volume control bit-field offset.
#define AIC23B_RCHVC_RHV_SIZE   7
 Right headphone volume control bit-field size.
#define AIC23B_RCHVC_RLS_OFFSET   8
 Right/left headphone channel simultaneous volume/mute update bit-field offset.
#define AIC23B_RCHVC_RLS_SIZE   1
 Right/left headphone channel simultaneous volume/mute update bit-field size.
#define AIC23B_RCHVC_RZC_OFFSET   7
 Right-channel zero-cross detect bit-field offset.
#define AIC23B_RCHVC_RZC_SIZE   1
 Right-channel zero-cross detect bit-field size.
Right Line Input Channel Volume Control
#define AIC23B_RLICVC   0x01
 Register index.
#define AIC23B_RLICVC_ADDRESS   0x01
 Register address.
#define AIC23B_RLICVC_DEFAULT   0x0097
 Register default value.
#define AIC23B_RLICVC_RIM_OFFSET   7
 Right line input mute bit-field offset.
#define AIC23B_RLICVC_RIM_SIZE   1
 Right line input mute bit-field size.
#define AIC23B_RLICVC_RIV_OFFSET   0
 Right line input volume control bit-field offset.
#define AIC23B_RLICVC_RIV_SIZE   5
 Right line input volume control bit-field size.
#define AIC23B_RLICVC_RLS_OFFSET   8
 Right/left line simultaneous volume/mute update bit-field offset.
#define AIC23B_RLICVC_RLS_SIZE   1
 Right/left line simultaneous volume/mute update bit-field size.
Reset Register
#define AIC23B_RR   0x0A
 Register index.
#define AIC23B_RR_ADDRESS   0x0F
 Register address.
#define AIC23B_RR_DEFAULT   0x0000
 Register default value.
#define AIC23B_RR_RES_OFFSET   0
 Reset bit-field offset.
#define AIC23B_RR_RES_SIZE   9
 Reset bit-field size.
Sample Rate Control
#define AIC23B_SRC   0x08
 Register index.
#define AIC23B_SRC_ADDRESS   0x08
 Register address.
#define AIC23B_SRC_BOSR_OFFSET   1
 Base oversampling rate bit-field offset.
#define AIC23B_SRC_BOSR_SIZE   1
 Base oversampling rate bit-field size.
#define AIC23B_SRC_CLKIN_OFFSET   6
 Clock input divider bit-field offset.
#define AIC23B_SRC_CLKIN_SIZE   1
 Clock input divider bit-field size.
#define AIC23B_SRC_CLKOUT_OFFSET   7
 Clock output divider bit-field offset.
#define AIC23B_SRC_CLKOUT_SIZE   1
 Clock output divider bit-field size.
#define AIC23B_SRC_DEFAULT   0x0020
 Register default value.
#define AIC23B_SRC_SR_OFFSET   2
 Sampling rate control bit-field offset.
#define AIC23B_SRC_SR_SIZE   4
 Sampling rate control bit-field size.
#define AIC23B_SRC_USB_OFFSET   0
 USB clock mode select bit-field offset.
#define AIC23B_SRC_USB_SIZE   1
 USB clock mode select bit-field size.

Functions

Mid-Level Interface
void aic23b_activate_dig_audio (Bool act)
 Activates or deactivates the digital audio interface according to act.
void aic23b_configure_freq (int master_clock_hz, int sample_rate_hz)
 Used to configure the codec frequency.
U8 aic23b_dac_get_average_headphone_volume (void)
 Gets the average headphone volume.
Bool aic23b_dac_is_headphone_volume_boosted (void)
 Returns the state of the boost mode of the DAC.
Bool aic23b_dac_is_headphone_volume_muted (void)
 Returns the state of the mute mode of the DAC.
void aic23b_dac_set_average_headphone_volume (U8 volume)
 Sets the average headphone volume.
aic23b_aapc_t aic23b_get_analog_audio_path (void)
 Gets the analog audio path.
aic23b_dapc_t aic23b_get_digital_audio_path (void)
 Gets the digital audio path.
S8 aic23b_get_headphone_volume (U8 ch)
 Gets the ch channel headphone volume.
S8 aic23b_get_line_in_volume (U8 ch)
 Gets the ch line input channel volume.
aic23b_pdc_t aic23b_get_power_down_state (void)
 Gets the power down state.
Bool aic23b_is_dig_audio_activated (void)
 Tells whether the digital audio interface is activated.
void aic23b_reset (void)
 Resets the CODEC.
void aic23b_set_analog_audio_path (aic23b_aapc_t aapc)
 Sets the analog audio path to aapc.
void aic23b_set_digital_audio_path (aic23b_dapc_t dapc)
 Sets the digital audio path to dapc.
void aic23b_set_headphone_volume (U8 ch_mask, S8 vol, Bool z_cross)
 Sets the ch_mask channels headphone volume to vol, with zero-cross detect if z_cross is TRUE.
void aic23b_set_line_in_volume (U8 ch_mask, S8 vol)
 Sets the ch_mask line input channels volume to vol.
void aic23b_set_power_down_state (aic23b_pdc_t pdc)
 Sets the power down state to pdc.
High-Level Interface
void aic23b_adc_flush (void)
 Flushes the sample buffer being input from the ADC.
Bool aic23b_adc_input (void *sample_buffer, size_t sample_length)
 Input a sample buffer from the ADC.
void aic23b_adc_setup (U32 sample_rate_hz, U8 num_channels, U8 bits_per_sample, Bool swap_channels, void(*callback)(U32 arg), U32 callback_opt, U32 pba_hz)
 Sets the ADC up with new settings.
void aic23b_adc_start (U32 sample_rate_hz, U8 num_channels, U8 bits_per_sample, Bool swap_channels, void(*callback)(U32 arg), U32 callback_opt, U32 pba_hz)
 Starts the ADC.
void aic23b_adc_stop (void)
 Stops the ADC.
void aic23b_codec_flush (void)
 Flushes the sample buffers being input from the ADC and output to the DAC.
void aic23b_codec_setup (U32 sample_rate_hz, U8 num_channels, U8 bits_per_sample, Bool swap_channels, void(*callback)(U32 arg), U32 callback_opt, U32 pba_hz)
 Sets the CODEC up with new settings.
void aic23b_codec_start (U32 sample_rate_hz, U8 num_channels, U8 bits_per_sample, Bool swap_channels, void(*callback)(U32 arg), U32 callback_opt, U32 pba_hz)
 Starts the CODEC.
void aic23b_codec_stop (void)
 Stops the CODEC.
void aic23b_dac_decrease_volume (void)
 Decreases the output volume of the DAC.
void aic23b_dac_flush (void)
 Flushes the sample buffer being output to the DAC.
void aic23b_dac_increase_volume (void)
 Increases the output volume of the DAC.
void aic23b_dac_mute (Bool mute)
 Mute audio if mute is set to true.
Bool aic23b_dac_output (void *sample_buffer, size_t sample_length)
 Outputs a sample buffer to the DAC.
void aic23b_dac_setup (U32 sample_rate_hz, U8 num_channels, U8 bits_per_sample, Bool swap_channels, void(*callback)(U32 arg), U32 callback_opt, U32 pba_hz)
 Sets the DAC up with new settings.
void aic23b_dac_start (U32 sample_rate_hz, U8 num_channels, U8 bits_per_sample, Bool swap_channels, void(*callback)(U32 arg), U32 callback_opt, U32 pba_hz)
 Starts the DAC.
void aic23b_dac_stop (void)
 Stops the DAC.
Low-Level Interface
U16 aic23b_read_reg (U8 reg)
 Reads the reg register.
void aic23b_write_reg (U8 reg, U16 val)
 Writes val to the reg register.


Define Documentation

#define AIC23B_AAPC   0x04

Register index.

Definition at line 249 of file tlv320aic23b.h.

Referenced by aic23b_codec_start(), aic23b_get_analog_audio_path(), and aic23b_set_analog_audio_path().

#define AIC23B_AAPC_ADDRESS   0x04

Register address.

Definition at line 250 of file tlv320aic23b.h.

#define AIC23B_AAPC_BYP_OFFSET   3

Bypass bit-field offset.

Definition at line 263 of file tlv320aic23b.h.

#define AIC23B_AAPC_BYP_SIZE   1

Bypass bit-field size.

Definition at line 264 of file tlv320aic23b.h.

#define AIC23B_AAPC_DAC_OFFSET   4

DAC select bit-field offset.

Definition at line 261 of file tlv320aic23b.h.

#define AIC23B_AAPC_DAC_SIZE   1

DAC select bit-field size.

Definition at line 262 of file tlv320aic23b.h.

#define AIC23B_AAPC_DEFAULT   0x000A

Register default value.

Definition at line 251 of file tlv320aic23b.h.

#define AIC23B_AAPC_INSEL_LINE   0x0000

Input selected for ADC: line.

Definition at line 267 of file tlv320aic23b.h.

#define AIC23B_AAPC_INSEL_MIC   0x0001

Input selected for ADC: microphone.

Definition at line 268 of file tlv320aic23b.h.

#define AIC23B_AAPC_INSEL_OFFSET   2

Input select for ADC bit-field offset.

Definition at line 265 of file tlv320aic23b.h.

#define AIC23B_AAPC_INSEL_SIZE   1

Input select for ADC bit-field size.

Definition at line 266 of file tlv320aic23b.h.

#define AIC23B_AAPC_MICB_OFFSET   0

Microphone boost (+20 dB) bit-field offset.

Definition at line 271 of file tlv320aic23b.h.

#define AIC23B_AAPC_MICB_SIZE   1

Microphone boost (+20 dB) bit-field size.

Definition at line 272 of file tlv320aic23b.h.

#define AIC23B_AAPC_MICM_OFFSET   1

Microphone mute bit-field offset.

Definition at line 269 of file tlv320aic23b.h.

#define AIC23B_AAPC_MICM_SIZE   1

Microphone mute bit-field size.

Definition at line 270 of file tlv320aic23b.h.

#define AIC23B_AAPC_STA_0DB   0x0004

Added sidetone: 0 dB.

Definition at line 258 of file tlv320aic23b.h.

#define AIC23B_AAPC_STA_M12DB   0x0002

Added sidetone: -12 dB.

Definition at line 255 of file tlv320aic23b.h.

#define AIC23B_AAPC_STA_M18DB   0x0003

Added sidetone: -18 dB.

Definition at line 254 of file tlv320aic23b.h.

#define AIC23B_AAPC_STA_M6DB   0x0000

Added sidetone: -6 dB.

Definition at line 257 of file tlv320aic23b.h.

#define AIC23B_AAPC_STA_M9DB   0x0001

Added sidetone: -9 dB.

Definition at line 256 of file tlv320aic23b.h.

#define AIC23B_AAPC_STA_OFFSET   6

Sidetone addition bit-field offset.

Definition at line 252 of file tlv320aic23b.h.

#define AIC23B_AAPC_STA_SIZE   3

Sidetone addition bit-field size.

Definition at line 253 of file tlv320aic23b.h.

#define AIC23B_AAPC_STE_OFFSET   5

Sidetone enable bit-field offset.

Definition at line 259 of file tlv320aic23b.h.

#define AIC23B_AAPC_STE_SIZE   1

Sidetone enable bit-field size.

Definition at line 260 of file tlv320aic23b.h.

#define AIC23B_ADDRESS ( REG   )     REG##_ADDRESS

Returns the address of the REG register (e.g. AIC23B_LLICVC).

Definition at line 541 of file tlv320aic23b.h.

#define AIC23B_CTRL_ADDR_OFFSET   9

Control address bit-field offset.

Definition at line 92 of file tlv320aic23b.h.

#define AIC23B_CTRL_ADDR_SIZE   7

Control address bit-field size.

Definition at line 93 of file tlv320aic23b.h.

#define AIC23B_CTRL_DATA_OFFSET   0

Control data bit-field offset.

Definition at line 94 of file tlv320aic23b.h.

#define AIC23B_CTRL_DATA_SIZE   9

Control data bit-field size.

Definition at line 95 of file tlv320aic23b.h.

#define AIC23B_CTRL_INTERFACE_SPI   2

Control interface: Serial Peripheral Interface.

Definition at line 61 of file tlv320aic23b.h.

#define AIC23B_CTRL_INTERFACE_TWI   1

Control interface: Two-Wire Interface.

Definition at line 60 of file tlv320aic23b.h.

#define AIC23B_CTRL_SIZE   (AIC23B_CTRL_ADDR_SIZE + AIC23B_CTRL_DATA_SIZE)

Definition at line 91 of file tlv320aic23b.h.

Referenced by aic23b_codec_start(), and aic23b_resources_init().

#define AIC23B_DAIF   0x07

Register index.

Definition at line 391 of file tlv320aic23b.h.

Referenced by aic23b_codec_setup().

#define AIC23B_DAIF_ADDRESS   0x07

Register address.

Definition at line 392 of file tlv320aic23b.h.

#define AIC23B_DAIF_DEFAULT   0x0001

Register default value.

Definition at line 393 of file tlv320aic23b.h.

#define AIC23B_DAIF_FMT_DSP   0x0003

Data format: DSP format, frame sync followed by two data words.

Definition at line 413 of file tlv320aic23b.h.

#define AIC23B_DAIF_FMT_I2S   0x0002

Data format: I²S format, MSB first, left - 1 aligned.

Definition at line 412 of file tlv320aic23b.h.

Referenced by aic23b_codec_setup().

#define AIC23B_DAIF_FMT_LA   0x0001

Data format: MSB first, left aligned.

Definition at line 411 of file tlv320aic23b.h.

#define AIC23B_DAIF_FMT_OFFSET   0

Data format bit-field offset.

Definition at line 408 of file tlv320aic23b.h.

#define AIC23B_DAIF_FMT_RA   0x0000

Data format: MSB first, right aligned.

Definition at line 410 of file tlv320aic23b.h.

#define AIC23B_DAIF_FMT_SIZE   2

Data format bit-field size.

Definition at line 409 of file tlv320aic23b.h.

#define AIC23B_DAIF_IWL_16   0x0000

Input bit length: 16.

Definition at line 404 of file tlv320aic23b.h.

Referenced by aic23b_codec_setup().

#define AIC23B_DAIF_IWL_20   0x0001

Input bit length: 20.

Definition at line 405 of file tlv320aic23b.h.

Referenced by aic23b_codec_setup().

#define AIC23B_DAIF_IWL_24   0x0002

Input bit length: 24.

Definition at line 406 of file tlv320aic23b.h.

Referenced by aic23b_codec_setup().

#define AIC23B_DAIF_IWL_32   0x0003

Input bit length: 32.

Definition at line 407 of file tlv320aic23b.h.

Referenced by aic23b_codec_setup().

#define AIC23B_DAIF_IWL_OFFSET   2

Input bit length bit-field offset.

Definition at line 402 of file tlv320aic23b.h.

#define AIC23B_DAIF_IWL_SIZE   2

Input bit length bit-field size.

Definition at line 403 of file tlv320aic23b.h.

#define AIC23B_DAIF_LRP_OFFSET   4

DAC left/right phase bit-field offset.

Definition at line 400 of file tlv320aic23b.h.

#define AIC23B_DAIF_LRP_SIZE   1

DAC left/right phase bit-field size.

Definition at line 401 of file tlv320aic23b.h.

#define AIC23B_DAIF_LRSWAP_OFFSET   5

DAC left/right swap bit-field offset.

Definition at line 398 of file tlv320aic23b.h.

#define AIC23B_DAIF_LRSWAP_SIZE   1

DAC left/right swap bit-field size.

Definition at line 399 of file tlv320aic23b.h.

#define AIC23B_DAIF_MS_MASTER   0x0001

Master mode.

Definition at line 397 of file tlv320aic23b.h.

#define AIC23B_DAIF_MS_OFFSET   6

Master/slave mode bit-field offset.

Definition at line 394 of file tlv320aic23b.h.

#define AIC23B_DAIF_MS_SIZE   1

Master/slave mode bit-field size.

Definition at line 395 of file tlv320aic23b.h.

#define AIC23B_DAIF_MS_SLAVE   0x0000

Slave mode.

Definition at line 396 of file tlv320aic23b.h.

Referenced by aic23b_codec_setup().

#define AIC23B_DAPC   0x05

Register index.

Definition at line 302 of file tlv320aic23b.h.

Referenced by aic23b_codec_start(), aic23b_get_digital_audio_path(), and aic23b_set_digital_audio_path().

#define AIC23B_DAPC_ADCHP_OFFSET   0

ADC high-pass filter bit-field offset.

Definition at line 313 of file tlv320aic23b.h.

#define AIC23B_DAPC_ADCHP_SIZE   1

ADC high-pass filter bit-field size.

Definition at line 314 of file tlv320aic23b.h.

#define AIC23B_DAPC_ADDRESS   0x05

Register address.

Definition at line 303 of file tlv320aic23b.h.

#define AIC23B_DAPC_DACM_OFFSET   3

DAC soft mute bit-field offset.

Definition at line 305 of file tlv320aic23b.h.

#define AIC23B_DAPC_DACM_SIZE   1

DAC soft mute bit-field size.

Definition at line 306 of file tlv320aic23b.h.

#define AIC23B_DAPC_DEEMP_32KHZ   0x0001

De-emphasis: 32 kHz.

Definition at line 310 of file tlv320aic23b.h.

#define AIC23B_DAPC_DEEMP_44_1KHZ   0x0002

De-emphasis: 44.1 kHz.

Definition at line 311 of file tlv320aic23b.h.

#define AIC23B_DAPC_DEEMP_48KHZ   0x0003

De-emphasis: 48 kHz.

Definition at line 312 of file tlv320aic23b.h.

#define AIC23B_DAPC_DEEMP_NONE   0x0000

De-emphasis: none.

Definition at line 309 of file tlv320aic23b.h.

Referenced by aic23b_codec_start().

#define AIC23B_DAPC_DEEMP_OFFSET   1

De-emphasis control bit-field offset.

Definition at line 307 of file tlv320aic23b.h.

#define AIC23B_DAPC_DEEMP_SIZE   2

De-emphasis control bit-field size.

Definition at line 308 of file tlv320aic23b.h.

#define AIC23B_DAPC_DEFAULT   0x0008

Register default value.

Definition at line 304 of file tlv320aic23b.h.

#define AIC23B_DEFAULT ( REG   )     REG##_DEFAULT

Returns the default value of the REG register (e.g. AIC23B_LLICVC).

Definition at line 545 of file tlv320aic23b.h.

Referenced by aic23b_codec_setup(), aic23b_codec_start(), aic23b_codec_stop(), aic23b_configure_freq(), aic23b_reset(), and aic23b_write_reg().

#define AIC23B_DIA   0x09

Register index.

Definition at line 483 of file tlv320aic23b.h.

Referenced by aic23b_activate_dig_audio(), and aic23b_is_dig_audio_activated().

#define AIC23B_DIA_ACT_OFFSET   0

Activate interface bit-field offset.

Definition at line 486 of file tlv320aic23b.h.

#define AIC23B_DIA_ACT_SIZE   1

Activate interface bit-field size.

Definition at line 487 of file tlv320aic23b.h.

#define AIC23B_DIA_ADDRESS   0x09

Register address.

Definition at line 484 of file tlv320aic23b.h.

#define AIC23B_DIA_DEFAULT   0x0000

Register default value.

Definition at line 485 of file tlv320aic23b.h.

#define AIC23B_HP_VOL_MAX   ((S8)(+ 6))

#define AIC23B_HP_VOL_MIN   ((S8)(-72))

#define AIC23B_HP_VOL_OFFSET   0x79

#define AIC23B_INPUT_LINE   0

Input Selected: LINE IN.

Definition at line 79 of file tlv320aic23b.h.

#define AIC23B_INPUT_MIC   1

Input Selected: MIC.

Definition at line 80 of file tlv320aic23b.h.

#define AIC23B_LCHVC   0x02

#define AIC23B_LCHVC_ADDRESS   0x02

Register address.

Definition at line 182 of file tlv320aic23b.h.

#define AIC23B_LCHVC_DEFAULT   0x00F9

Register default value.

Definition at line 183 of file tlv320aic23b.h.

#define AIC23B_LCHVC_LHV_OFFSET   0

Left headphone volume control bit-field offset.

Definition at line 188 of file tlv320aic23b.h.

#define AIC23B_LCHVC_LHV_SIZE   7

Left headphone volume control bit-field size.

Definition at line 189 of file tlv320aic23b.h.

#define AIC23B_LCHVC_LRS_OFFSET   8

Left/right headphone channel simultaneous volume/mute update bit-field offset.

Definition at line 184 of file tlv320aic23b.h.

#define AIC23B_LCHVC_LRS_SIZE   1

Left/right headphone channel simultaneous volume/mute update bit-field size.

Definition at line 185 of file tlv320aic23b.h.

#define AIC23B_LCHVC_LZC_OFFSET   7

Left-channel zero-cross detect bit-field offset.

Definition at line 186 of file tlv320aic23b.h.

#define AIC23B_LCHVC_LZC_SIZE   1

Left-channel zero-cross detect bit-field size.

Definition at line 187 of file tlv320aic23b.h.

#define AIC23B_LEFT_CHANNEL   0x01

#define AIC23B_LIN_VOL_MAX   ((S8)(+12 * 2 / 3))

Definition at line 583 of file tlv320aic23b.h.

Referenced by aic23b_set_line_in_volume().

#define AIC23B_LIN_VOL_MIN   ((S8)(-34.5 * 2 / 3))

Definition at line 582 of file tlv320aic23b.h.

Referenced by aic23b_set_line_in_volume().

#define AIC23B_LIN_VOL_OFFSET   0x17

Definition at line 581 of file tlv320aic23b.h.

Referenced by aic23b_get_line_in_volume(), and aic23b_set_line_in_volume().

#define AIC23B_LLICVC   0x00

Register index.

Definition at line 111 of file tlv320aic23b.h.

Referenced by aic23b_codec_start(), aic23b_get_line_in_volume(), and aic23b_set_line_in_volume().

#define AIC23B_LLICVC_ADDRESS   0x00

Register address.

Definition at line 112 of file tlv320aic23b.h.

#define AIC23B_LLICVC_DEFAULT   0x0097

Register default value.

Definition at line 113 of file tlv320aic23b.h.

#define AIC23B_LLICVC_LIM_OFFSET   7

Left line input mute bit-field offset.

Definition at line 116 of file tlv320aic23b.h.

#define AIC23B_LLICVC_LIM_SIZE   1

Left line input mute bit-field size.

Definition at line 117 of file tlv320aic23b.h.

#define AIC23B_LLICVC_LIV_OFFSET   0

Left line input volume control bit-field offset.

Definition at line 118 of file tlv320aic23b.h.

#define AIC23B_LLICVC_LIV_SIZE   5

Left line input volume control bit-field size.

Definition at line 119 of file tlv320aic23b.h.

#define AIC23B_LLICVC_LRS_OFFSET   8

Left/right line simultaneous volume/mute update bit-field offset.

Definition at line 114 of file tlv320aic23b.h.

#define AIC23B_LLICVC_LRS_SIZE   1

Left/right line simultaneous volume/mute update bit-field size.

Definition at line 115 of file tlv320aic23b.h.

#define AIC23B_MASK ( REG,
BITFIELD   )     (((1 << REG##_##BITFIELD##_SIZE) - 1) << REG##_##BITFIELD##_OFFSET)

Returns the mask of the BITFIELD bit-field (e.g.

LRS) in its REG register (e.g. AIC23B_LLICVC).

Definition at line 560 of file tlv320aic23b.h.

#define AIC23B_MODE_ADC   1

Mode supported: ADC.

Definition at line 70 of file tlv320aic23b.h.

#define AIC23B_MODE_CODEC   3

Mode supported: CODEC.

Definition at line 71 of file tlv320aic23b.h.

#define AIC23B_MODE_DAC   0

Mode supported: DAC.

Definition at line 69 of file tlv320aic23b.h.

#define AIC23B_MUTED   SCHAR_MIN

#define AIC23B_OFFSET ( REG,
BITFIELD   )     REG##_##BITFIELD##_OFFSET

Returns the offset of the BITFIELD bit-field (e.g.

LRS) in its REG register (e.g. AIC23B_LLICVC).

Definition at line 550 of file tlv320aic23b.h.

Referenced by aic23b_reset().

#define AIC23B_PDC   0x06

#define AIC23B_PDC_ADC_OFFSET   2

ADC bit-field offset.

Definition at line 354 of file tlv320aic23b.h.

#define AIC23B_PDC_ADC_SIZE   1

ADC bit-field size.

Definition at line 355 of file tlv320aic23b.h.

#define AIC23B_PDC_ADDRESS   0x06

Register address.

Definition at line 342 of file tlv320aic23b.h.

#define AIC23B_PDC_CLK_OFFSET   6

Clock bit-field offset.

Definition at line 346 of file tlv320aic23b.h.

#define AIC23B_PDC_CLK_SIZE   1

Clock bit-field size.

Definition at line 347 of file tlv320aic23b.h.

#define AIC23B_PDC_DAC_OFFSET   3

DAC bit-field offset.

Definition at line 352 of file tlv320aic23b.h.

#define AIC23B_PDC_DAC_SIZE   1

DAC bit-field size.

Definition at line 353 of file tlv320aic23b.h.

#define AIC23B_PDC_DEFAULT   0x0007

Register default value.

Definition at line 343 of file tlv320aic23b.h.

#define AIC23B_PDC_LINE_OFFSET   0

Line input bit-field offset.

Definition at line 358 of file tlv320aic23b.h.

#define AIC23B_PDC_LINE_SIZE   1

Line input bit-field size.

Definition at line 359 of file tlv320aic23b.h.

#define AIC23B_PDC_MIC_OFFSET   1

Microphone input bit-field offset.

Definition at line 356 of file tlv320aic23b.h.

#define AIC23B_PDC_MIC_SIZE   1

Microphone input bit-field size.

Definition at line 357 of file tlv320aic23b.h.

#define AIC23B_PDC_OFF_OFFSET   7

Device power bit-field offset.

Definition at line 344 of file tlv320aic23b.h.

#define AIC23B_PDC_OFF_SIZE   1

Device power bit-field size.

Definition at line 345 of file tlv320aic23b.h.

#define AIC23B_PDC_OSC_OFFSET   5

Oscillator bit-field offset.

Definition at line 348 of file tlv320aic23b.h.

#define AIC23B_PDC_OSC_SIZE   1

Oscillator bit-field size.

Definition at line 349 of file tlv320aic23b.h.

#define AIC23B_PDC_OUT_OFFSET   4

Outputs bit-field offset.

Definition at line 350 of file tlv320aic23b.h.

#define AIC23B_PDC_OUT_SIZE   1

Outputs bit-field size.

Definition at line 351 of file tlv320aic23b.h.

#define AIC23B_RCHVC   0x03

#define AIC23B_RCHVC_ADDRESS   0x03

Register address.

Definition at line 216 of file tlv320aic23b.h.

#define AIC23B_RCHVC_DEFAULT   0x00F9

Register default value.

Definition at line 217 of file tlv320aic23b.h.

#define AIC23B_RCHVC_RHV_OFFSET   0

Right headphone volume control bit-field offset.

Definition at line 222 of file tlv320aic23b.h.

#define AIC23B_RCHVC_RHV_SIZE   7

Right headphone volume control bit-field size.

Definition at line 223 of file tlv320aic23b.h.

#define AIC23B_RCHVC_RLS_OFFSET   8

Right/left headphone channel simultaneous volume/mute update bit-field offset.

Definition at line 218 of file tlv320aic23b.h.

#define AIC23B_RCHVC_RLS_SIZE   1

Right/left headphone channel simultaneous volume/mute update bit-field size.

Definition at line 219 of file tlv320aic23b.h.

#define AIC23B_RCHVC_RZC_OFFSET   7

Right-channel zero-cross detect bit-field offset.

Definition at line 220 of file tlv320aic23b.h.

#define AIC23B_RCHVC_RZC_SIZE   1

Right-channel zero-cross detect bit-field size.

Definition at line 221 of file tlv320aic23b.h.

#define AIC23B_RIGHT_CHANNEL   0x02

#define AIC23B_RLICVC   0x01

Register index.

Definition at line 146 of file tlv320aic23b.h.

Referenced by aic23b_codec_start(), aic23b_get_line_in_volume(), and aic23b_set_line_in_volume().

#define AIC23B_RLICVC_ADDRESS   0x01

Register address.

Definition at line 147 of file tlv320aic23b.h.

#define AIC23B_RLICVC_DEFAULT   0x0097

Register default value.

Definition at line 148 of file tlv320aic23b.h.

#define AIC23B_RLICVC_RIM_OFFSET   7

Right line input mute bit-field offset.

Definition at line 151 of file tlv320aic23b.h.

#define AIC23B_RLICVC_RIM_SIZE   1

Right line input mute bit-field size.

Definition at line 152 of file tlv320aic23b.h.

#define AIC23B_RLICVC_RIV_OFFSET   0

Right line input volume control bit-field offset.

Definition at line 153 of file tlv320aic23b.h.

#define AIC23B_RLICVC_RIV_SIZE   5

Right line input volume control bit-field size.

Definition at line 154 of file tlv320aic23b.h.

#define AIC23B_RLICVC_RLS_OFFSET   8

Right/left line simultaneous volume/mute update bit-field offset.

Definition at line 149 of file tlv320aic23b.h.

#define AIC23B_RLICVC_RLS_SIZE   1

Right/left line simultaneous volume/mute update bit-field size.

Definition at line 150 of file tlv320aic23b.h.

#define AIC23B_RR   0x0A

Register index.

Definition at line 512 of file tlv320aic23b.h.

Referenced by aic23b_reset(), and aic23b_write_reg().

#define AIC23B_RR_ADDRESS   0x0F

Register address.

Definition at line 513 of file tlv320aic23b.h.

#define AIC23B_RR_DEFAULT   0x0000

Register default value.

Definition at line 514 of file tlv320aic23b.h.

#define AIC23B_RR_RES_OFFSET   0

Reset bit-field offset.

Definition at line 515 of file tlv320aic23b.h.

#define AIC23B_RR_RES_SIZE   9

Reset bit-field size.

Definition at line 516 of file tlv320aic23b.h.

#define AIC23B_SIZE ( REG,
BITFIELD   )     REG##_##BITFIELD##_SIZE

Returns the size of the BITFIELD bit-field (e.g.

LRS) of the REG register (e.g. AIC23B_LLICVC).

Definition at line 555 of file tlv320aic23b.h.

#define AIC23B_SRC   0x08

Register index.

Definition at line 442 of file tlv320aic23b.h.

Referenced by aic23b_configure_freq().

#define AIC23B_SRC_ADDRESS   0x08

Register address.

Definition at line 443 of file tlv320aic23b.h.

#define AIC23B_SRC_BOSR_OFFSET   1

Base oversampling rate bit-field offset.

Definition at line 451 of file tlv320aic23b.h.

#define AIC23B_SRC_BOSR_SIZE   1

Base oversampling rate bit-field size.

Definition at line 452 of file tlv320aic23b.h.

#define AIC23B_SRC_CLKIN_OFFSET   6

Clock input divider bit-field offset.

Definition at line 447 of file tlv320aic23b.h.

#define AIC23B_SRC_CLKIN_SIZE   1

Clock input divider bit-field size.

Definition at line 448 of file tlv320aic23b.h.

#define AIC23B_SRC_CLKOUT_OFFSET   7

Clock output divider bit-field offset.

Definition at line 445 of file tlv320aic23b.h.

#define AIC23B_SRC_CLKOUT_SIZE   1

Clock output divider bit-field size.

Definition at line 446 of file tlv320aic23b.h.

#define AIC23B_SRC_DEFAULT   0x0020

Register default value.

Definition at line 444 of file tlv320aic23b.h.

#define AIC23B_SRC_SR_OFFSET   2

Sampling rate control bit-field offset.

Definition at line 449 of file tlv320aic23b.h.

#define AIC23B_SRC_SR_SIZE   4

Sampling rate control bit-field size.

Definition at line 450 of file tlv320aic23b.h.

#define AIC23B_SRC_USB_OFFSET   0

USB clock mode select bit-field offset.

Definition at line 453 of file tlv320aic23b.h.

#define AIC23B_SRC_USB_SIZE   1

USB clock mode select bit-field size.

Definition at line 454 of file tlv320aic23b.h.


Function Documentation

void aic23b_activate_dig_audio ( Bool  act  ) 

Activates or deactivates the digital audio interface according to act.

Definition at line 560 of file tlv320aic23b.c.

References aic23b_dia_t::act, AIC23B_DIA, aic23b_read_reg(), aic23b_write_reg(), and aic23b_dia_t::data.

Referenced by aic23b_codec_start().

00561 {
00562   aic23b_dia_t dia;
00563   dia.data = aic23b_read_reg(AIC23B_DIA);
00564   dia.act = act;
00565   aic23b_write_reg(AIC23B_DIA, dia.data);
00566 }

void aic23b_adc_flush ( void   ) 

Flushes the sample buffer being input from the ADC.

Bool aic23b_adc_input ( void *  sample_buffer,
size_t  sample_length 
)

Input a sample buffer from the ADC.

Note:
The ADC must have been started beforehand.

Definition at line 1081 of file tlv320aic23b.c.

References aic23b_output_params, and AIC23B_SSC_RX_PDCA_CHANNEL.

Referenced by main().

01082 {
01083   if (!(pdca_get_transfer_status(AIC23B_SSC_RX_PDCA_CHANNEL) &
01084         PDCA_TRANSFER_COUNTER_RELOAD_IS_ZERO))
01085     return FALSE;
01086 
01087   if (sample_length)
01088   {
01089     pdca_reload_channel(AIC23B_SSC_RX_PDCA_CHANNEL, sample_buffer, sample_length * 2);
01090     pdca_get_reload_size(AIC23B_SSC_RX_PDCA_CHANNEL);
01091 
01092     if (aic23b_output_params.callback_opt & AUDIO_ADC_OUT_OF_SAMPLE_CB)
01093       pdca_enable_interrupt_transfer_complete(AIC23B_SSC_RX_PDCA_CHANNEL);
01094     if (aic23b_output_params.callback_opt & AUDIO_ADC_RELOAD_CB)
01095       pdca_enable_interrupt_reload_counter_zero(AIC23B_SSC_RX_PDCA_CHANNEL);
01096   }
01097 
01098   return TRUE;
01099 }

void aic23b_adc_setup ( U32  sample_rate_hz,
U8  num_channels,
U8  bits_per_sample,
Bool  swap_channels,
void(*)(U32 arg)  callback,
U32  callback_opt,
U32  pba_hz 
)

Sets the ADC up with new settings.

Note:
The ADC must have been started beforehand.

void aic23b_adc_start ( U32  sample_rate_hz,
U8  num_channels,
U8  bits_per_sample,
Bool  swap_channels,
void(*)(U32 arg)  callback,
U32  callback_opt,
U32  pba_hz 
)

Starts the ADC.

void aic23b_adc_stop ( void   ) 

Stops the ADC.

void aic23b_codec_flush ( void   ) 

Flushes the sample buffers being input from the ADC and output to the DAC.

Definition at line 1285 of file tlv320aic23b.c.

References AIC23B_SSC_RX_PDCA_CHANNEL, and AIC23B_SSC_TX_PDCA_CHANNEL.

Referenced by aic23b_codec_stop().

01286 {
01287   pdca_disable_interrupt_transfer_complete(AIC23B_SSC_RX_PDCA_CHANNEL);
01288   while (!(pdca_get_transfer_status(AIC23B_SSC_RX_PDCA_CHANNEL) &
01289            PDCA_TRANSFER_COMPLETE));
01290   pdca_disable_interrupt_transfer_complete(AIC23B_SSC_TX_PDCA_CHANNEL);
01291   while (!(pdca_get_transfer_status(AIC23B_SSC_TX_PDCA_CHANNEL) &
01292            PDCA_TRANSFER_COMPLETE));
01293 }

void aic23b_codec_setup ( U32  sample_rate_hz,
U8  num_channels,
U8  bits_per_sample,
Bool  swap_channels,
void(*)(U32 arg)  callback,
U32  callback_opt,
U32  pba_hz 
)

Sets the CODEC up with new settings.

Note:
The CODEC must have been started beforehand.

void aic23b_codec_start ( U32  sample_rate_hz,
U8  num_channels,
U8  bits_per_sample,
Bool  swap_channels,
void(*)(U32 arg)  callback,
U32  callback_opt,
U32  pba_hz 
)

Starts the CODEC.

Definition at line 1103 of file tlv320aic23b.c.

References aic23b_pdc_t::adc, aic23b_dapc_t::adchp, AIC23B_AAPC, aic23b_activate_dig_audio(), aic23b_codec_setup(), aic23b_codec_stop(), AIC23B_CTRL_SIZE, AIC23B_DAPC, AIC23B_DAPC_DEEMP_NONE, AIC23B_DEFAULT, AIC23B_LEFT_CHANNEL, AIC23B_LLICVC, AIC23B_PDC, AIC23B_RIGHT_CHANNEL, AIC23B_RLICVC, aic23b_set_analog_audio_path(), aic23b_set_digital_audio_path(), aic23b_set_headphone_volume(), aic23b_set_power_down_state(), AIC23B_SSC_CODEC_GPIO_MAP, aic23b_ssc_rx_pdca_int_handler(), AIC23B_SSC_RX_PDCA_INT_LEVEL, AIC23B_SSC_RX_PDCA_IRQ, aic23b_ssc_tx_pdca_int_handler(), AIC23B_SSC_TX_PDCA_INT_LEVEL, AIC23B_SSC_TX_PDCA_IRQ, aic23b_write_reg(), aic23b_aapc_t::byp, callback, aic23b_pdc_t::clk, aic23b_aapc_t::dac, aic23b_pdc_t::dac, aic23b_dapc_t::dacm, aic23b_rlicvc_t::data, aic23b_llicvc_t::data, aic23b_dapc_t::data, aic23b_aapc_t::data, aic23b_pdc_t::data, aic23b_dapc_t::deemp, aic23b_aapc_t::insel, aic23b_llicvc_t::lim, aic23b_pdc_t::line, aic23b_llicvc_t::liv, aic23b_llicvc_t::lrs, aic23b_pdc_t::mic, aic23b_aapc_t::micb, aic23b_aapc_t::micm, aic23b_pdc_t::off, aic23b_pdc_t::osc, aic23b_pdc_t::out, aic23b_rlicvc_t::rim, aic23b_rlicvc_t::riv, aic23b_rlicvc_t::rls, aic23b_aapc_t::sta, and aic23b_aapc_t::ste.

Referenced by main().

01110 {
01111 #if AIC23B_CTRL_INTERFACE == AIC23B_CTRL_INTERFACE_SPI
01112   static const spi_options_t AIC23B_SPI_OPTIONS =
01113   {
01114     .reg          = AIC23B_SPI_NPCS,
01115     .baudrate     = AIC23B_SPI_MASTER_SPEED,
01116     .bits         = AIC23B_CTRL_SIZE,
01117     .spck_delay   = 0,
01118     .trans_delay  = 0,
01119     .stay_act     = 0,
01120     .spi_mode     = 3,
01121     .modfdis      = 1
01122   };
01123   spi_setupChipReg(AIC23B_SPI, &AIC23B_SPI_OPTIONS, pba_hz);
01124 #endif
01125 
01126   aic23b_codec_stop();
01127 
01128   gpio_enable_module(AIC23B_SSC_CODEC_GPIO_MAP,
01129                      sizeof(AIC23B_SSC_CODEC_GPIO_MAP) / sizeof(AIC23B_SSC_CODEC_GPIO_MAP[0]));
01130 
01131   aic23b_pdc_t pdc;
01132   pdc.data  = AIC23B_DEFAULT(AIC23B_PDC);
01133   pdc.off   = 0;
01134   pdc.clk   = 0;
01135   pdc.osc   = 0;
01136   pdc.out   = 0;
01137   pdc.dac   = 0;
01138   pdc.adc   = 0;
01139 #if (AIC23B_INPUT==AIC23B_INPUT_LINE)
01140   pdc.mic   = 1;
01141   pdc.line  = 0;
01142 #elif (AIC23B_INPUT==AIC23B_INPUT_MIC)
01143   pdc.mic   = 0;
01144   pdc.line  = 1;
01145 #else
01146   #error No Input defined in file 'conf_tlv320aic23b.h'
01147 #endif
01148   aic23b_set_power_down_state(pdc);
01149 
01150   aic23b_codec_setup(sample_rate_hz,
01151                    num_channels,
01152                    bits_per_sample,
01153                    swap_channels,
01154                    callback,
01155                    callback_opt,
01156                    pba_hz);
01157 
01158   aic23b_aapc_t aapc;
01159   aapc.data  = AIC23B_DEFAULT(AIC23B_AAPC);
01160 #if (AIC23B_INPUT==AIC23B_INPUT_LINE)
01161   aapc.ste   = 0;
01162   aapc.dac   = 1;
01163   aapc.byp   = 0;
01164   aapc.insel = 0;
01165   aapc.micm  = 0;
01166   aapc.micb  = 1;
01167 #elif (AIC23B_INPUT==AIC23B_INPUT_MIC)
01168   aapc.ste   = 0;
01169   aapc.dac   = 1;
01170   aapc.sta   = 4;
01171   aapc.byp   = 0;
01172   aapc.insel = 1;
01173   aapc.micm  = 0;
01174   aapc.micb  = 1;
01175 #else
01176   #error No Input defined in file 'conf_tlv320aic23b.h'
01177 #endif
01178   aic23b_set_analog_audio_path(aapc);
01179 
01180   aic23b_dapc_t dapc;
01181   dapc.data   = AIC23B_DEFAULT(AIC23B_DAPC);
01182   dapc.dacm   = 0;
01183   dapc.deemp  = AIC23B_DAPC_DEEMP_NONE;
01184   dapc.adchp  = 0;
01185   aic23b_set_digital_audio_path(dapc);
01186 
01187 
01188   aic23b_llicvc_t llivc;
01189   llivc.data  = AIC23B_DEFAULT(AIC23B_LLICVC);
01190   llivc.liv   = 20;
01191   llivc.lim   = 0;
01192   llivc.lrs   = 1;
01193   aic23b_write_reg(AIC23B_LLICVC, llivc.data);
01194 
01195   aic23b_rlicvc_t rlivc;
01196   rlivc.data  = AIC23B_DEFAULT(AIC23B_RLICVC);
01197   rlivc.riv   = 20;
01198   rlivc.rim   = 0;
01199   rlivc.rls   = 1;
01200   aic23b_write_reg(AIC23B_RLICVC, rlivc.data);
01201 
01202   INTC_register_interrupt(&aic23b_ssc_rx_pdca_int_handler,
01203                           AIC23B_SSC_RX_PDCA_IRQ,
01204                           AIC23B_SSC_RX_PDCA_INT_LEVEL);
01205 
01206   // set an acceptable start volume
01207   aic23b_set_headphone_volume(AIC23B_LEFT_CHANNEL | AIC23B_RIGHT_CHANNEL,
01208                               -30,
01209                               TRUE);
01210 
01211   aic23b_activate_dig_audio(TRUE);
01212 
01213   INTC_register_interrupt(&aic23b_ssc_tx_pdca_int_handler,
01214                           AIC23B_SSC_TX_PDCA_IRQ,
01215                           AIC23B_SSC_TX_PDCA_INT_LEVEL);
01216 }

void aic23b_codec_stop ( void   ) 

Stops the CODEC.

Definition at line 1295 of file tlv320aic23b.c.

References aic23b_pdc_t::adc, aic23b_codec_flush(), AIC23B_DEFAULT, aic23b_output_params, AIC23B_PDC, aic23b_reset(), aic23b_set_power_down_state(), AIC23B_SSC, AIC23B_SSC_CODEC_GPIO_MAP, AIC23B_SSC_RX_PDCA_CHANNEL, AIC23B_SSC_TX_PDCA_CHANNEL, aic23b_pdc_t::clk, aic23b_pdc_t::dac, aic23b_pdc_t::data, aic23b_pdc_t::line, aic23b_pdc_t::mic, aic23b_pdc_t::off, aic23b_pdc_t::osc, and aic23b_pdc_t::out.

Referenced by aic23b_codec_start().

01296 {
01297   aic23b_codec_flush();
01298 
01299   aic23b_reset();
01300 
01301   aic23b_pdc_t pdc;
01302   pdc.data  = AIC23B_DEFAULT(AIC23B_PDC);
01303   pdc.off   = 1;
01304   pdc.clk   = 1;
01305   pdc.osc   = 1;
01306   pdc.out   = 1;
01307   pdc.dac   = 1;
01308   pdc.adc   = 1;
01309   pdc.mic   = 1;
01310   pdc.line  = 1;
01311   aic23b_set_power_down_state(pdc);
01312 
01313   pdca_disable(AIC23B_SSC_RX_PDCA_CHANNEL);
01314   pdca_disable(AIC23B_SSC_TX_PDCA_CHANNEL);
01315 
01316   ssc_i2s_reset(AIC23B_SSC);
01317 
01318   gpio_enable_gpio(AIC23B_SSC_CODEC_GPIO_MAP,
01319                    sizeof(AIC23B_SSC_CODEC_GPIO_MAP) / sizeof(AIC23B_SSC_CODEC_GPIO_MAP[0]));
01320 
01321   aic23b_output_params.num_channels             = 0;
01322   aic23b_output_params.callback                 = NULL;
01323   aic23b_output_params.callback_opt             = 0;
01324 }

void aic23b_configure_freq ( int  master_clock_hz,
int  sample_rate_hz 
)

Used to configure the codec frequency.

Definition at line 259 of file tlv320aic23b.c.

References AIC23B_DEFAULT, AIC23B_SRC, aic23b_write_reg(), aic23b_src_t::bosr, aic23b_src_t::clkin, aic23b_src_t::clkout, aic23b_src_t::data, aic23b_src_t::sr, and aic23b_src_t::usb.

Referenced by aic23b_codec_setup().

00260 {
00261   aic23b_src_t src;
00262 
00263   src.data    = AIC23B_DEFAULT(AIC23B_SRC);
00264   src.clkout  = 0;
00265   src.clkin   = 0;
00266 
00267   switch (master_clock_hz)
00268   {
00269    case 12000000:
00270     src.usb     = 1;
00271     if (sample_rate_hz < (8000 + 8021) / 2)
00272     { // 8000 Hz
00273       src.sr    = 0x3;
00274       src.bosr  = 0;
00275     }
00276     else if (sample_rate_hz < (8021 + 32000) / 2)
00277     { // 8021 Hz
00278       src.sr    = 0xB;
00279       src.bosr  = 1;
00280     }
00281     else if (sample_rate_hz < (32000 + 44100) / 2)
00282     { // 32000 Hz
00283       src.sr    = 0x6;
00284       src.bosr  = 0;
00285     }
00286     else if (sample_rate_hz < (44100 + 48000) / 2)
00287     { // 44100 Hz
00288       src.sr    = 0x8;
00289       src.bosr  = 1;
00290     }
00291     else if (sample_rate_hz < (48000 + 88200) / 2)
00292     { // 48000 Hz
00293       src.sr    = 0x0;
00294       src.bosr  = 0;
00295     }
00296     else if (sample_rate_hz < (88200 + 96000) / 2)
00297     { // 88200 Hz
00298       src.sr    = 0xF;
00299       src.bosr  = 1;
00300     }
00301     else
00302     { // 96000 Hz
00303       src.sr    = 0x7;
00304       src.bosr  = 0;
00305     }
00306     break;
00307   case 11289600:
00308     src.usb     = 0;
00309     if (sample_rate_hz < (8021 + 22050) / 2)
00310     { // 8021 Hz
00311       src.sr    = 0xB;
00312       src.bosr  = 0;
00313     }
00314     else if (sample_rate_hz < (22050 + 88200) / 2)
00315     { // 22050, 44100 and 48000 Hz
00316       src.sr    = 0x8;
00317       src.bosr  = 0;
00318     }
00319     else
00320     { // 88200 Hz
00321       src.sr    = 0xF;
00322       src.bosr  = 0;
00323     }
00324     break;
00325   case 18432000:
00326     src.usb   = 0;
00327     src.sr    = 0;
00328     src.bosr  = 1;
00329     break;
00330   default:
00331     //Not supported
00332     return;
00333   }
00334 
00335   aic23b_write_reg(AIC23B_SRC, src.data);
00336 }

void aic23b_dac_decrease_volume ( void   ) 

Decreases the output volume of the DAC.

Note:
The DAC must have been started beforehand.

Definition at line 795 of file tlv320aic23b.c.

References aic23b_get_headphone_volume(), AIC23B_LEFT_CHANNEL, AIC23B_MUTED, AIC23B_RIGHT_CHANNEL, and aic23b_set_headphone_volume().

00796 {
00797   S8 volume = aic23b_get_headphone_volume(AIC23B_LEFT_CHANNEL);
00798   if( volume != AIC23B_MUTED )
00799     volume--;
00800   aic23b_set_headphone_volume(AIC23B_LEFT_CHANNEL | AIC23B_RIGHT_CHANNEL,
00801                               volume,
00802                               TRUE);
00803 }

void aic23b_dac_flush ( void   ) 

Flushes the sample buffer being output to the DAC.

U8 aic23b_dac_get_average_headphone_volume ( void   ) 

Gets the average headphone volume.

Definition at line 423 of file tlv320aic23b.c.

References AIC23B_HP_VOL_MAX, AIC23B_HP_VOL_MIN, AIC23B_HP_VOL_OFFSET, AIC23B_LCHVC, AIC23B_RCHVC, aic23b_read_reg(), aic23b_rchvc_t::data, aic23b_lchvc_t::data, aic23b_lchvc_t::lhv, and aic23b_rchvc_t::rhv.

00424 {
00425   S32 volume, volume_avg = 0;
00426   aic23b_lchvc_t lchvc;
00427   aic23b_rchvc_t rchvc;
00428 
00429   lchvc.data = aic23b_read_reg(AIC23B_LCHVC);
00430   rchvc.data = aic23b_read_reg(AIC23B_RCHVC);
00431   volume_avg = (lchvc.lhv < AIC23B_HP_VOL_MIN + AIC23B_HP_VOL_OFFSET) ?
00432                0 : lchvc.lhv - AIC23B_HP_VOL_OFFSET - AIC23B_HP_VOL_MIN;
00433   volume = (rchvc.rhv < AIC23B_HP_VOL_MIN + AIC23B_HP_VOL_OFFSET) ?
00434            0 : rchvc.rhv - AIC23B_HP_VOL_OFFSET - AIC23B_HP_VOL_MIN;
00435   // Get the volume average
00436   volume_avg = (volume_avg + volume) / 2;
00437   // Recenter the volume
00438   volume_avg = (volume_avg * 255) / (AIC23B_HP_VOL_MAX - AIC23B_HP_VOL_MIN);
00439 
00440   return (U8) volume_avg;
00441 }

void aic23b_dac_increase_volume ( void   ) 

Increases the output volume of the DAC.

Note:
The DAC must have been started beforehand.

Definition at line 784 of file tlv320aic23b.c.

References aic23b_get_headphone_volume(), AIC23B_HP_VOL_MIN, AIC23B_LEFT_CHANNEL, AIC23B_RIGHT_CHANNEL, and aic23b_set_headphone_volume().

00785 {
00786   S8 volume = aic23b_get_headphone_volume(AIC23B_LEFT_CHANNEL);
00787   if( volume < AIC23B_HP_VOL_MIN )
00788     volume = AIC23B_HP_VOL_MIN;
00789   aic23b_set_headphone_volume(AIC23B_LEFT_CHANNEL | AIC23B_RIGHT_CHANNEL,
00790                               volume + 1,
00791                               TRUE);
00792 }

Bool aic23b_dac_is_headphone_volume_boosted ( void   ) 

Returns the state of the boost mode of the DAC.

Definition at line 453 of file tlv320aic23b.c.

00454 {
00455   return FALSE;
00456 }

Bool aic23b_dac_is_headphone_volume_muted ( void   ) 

Returns the state of the mute mode of the DAC.

Definition at line 448 of file tlv320aic23b.c.

00449 {
00450   return FALSE;
00451 }

void aic23b_dac_mute ( Bool  mute  ) 

Mute audio if mute is set to true.

Definition at line 805 of file tlv320aic23b.c.

References aic23b_output_params, and AIC23B_SSC_TX_PDCA_CHANNEL.

00806 {
00807 #if (AIC23B_MODE==AIC23B_MODE_DAC)
00808 /*  if(mute==TRUE) {
00809     pdca_disable(AIC23B_SSC_TX_PDCA_CHANNEL);
00810   }
00811   else {
00812        pdca_enable(AIC23B_SSC_TX_PDCA_CHANNEL);
00813   }
00814 */
00815   if (mute)
00816   {
00817     U32 save_dac_reload_callback_opt;
00818 
00819     // Disable the reload callback function
00820     save_dac_reload_callback_opt = aic23b_output_params.callback_opt;
00821     aic23b_output_params.callback_opt = 0;
00822     // Disable the transfer complete interruption and wait until the transfer is complete
00823     pdca_disable_interrupt_reload_counter_zero(AIC23B_SSC_TX_PDCA_CHANNEL);
00824     while (!(pdca_get_transfer_status(AIC23B_SSC_TX_PDCA_CHANNEL) & PDCA_TRANSFER_COMPLETE));
00825     // Re-enable the reload callback function
00826     aic23b_output_params.callback_opt = save_dac_reload_callback_opt;
00827   }
00828   else
00829   {
00830     // Re-enable the reload interrupt
00831     pdca_enable_interrupt_reload_counter_zero(AIC23B_SSC_TX_PDCA_CHANNEL);
00832   }
00833 
00834 #endif
00835 }

Bool aic23b_dac_output ( void *  sample_buffer,
size_t  sample_length 
)

Outputs a sample buffer to the DAC.

Note:
The DAC must have been started beforehand.

Definition at line 737 of file tlv320aic23b.c.

References aic23b_output_params, AIC23B_SSC_TX_FRAME_SYNC_PIN, and AIC23B_SSC_TX_PDCA_CHANNEL.

Referenced by main().

00738 {
00739   Bool global_interrupt_enabled;
00740 
00741   if (!(pdca_get_transfer_status(AIC23B_SSC_TX_PDCA_CHANNEL) &
00742         PDCA_TRANSFER_COUNTER_RELOAD_IS_ZERO))
00743     return FALSE;
00744 
00745   if (sample_length)
00746   {
00747     if (aic23b_output_params.num_channels == 1)
00748     {
00749       S16 *s16_sample_buffer = sample_buffer;
00750       int i;
00751 
00752       for (i = sample_length - 1; i >= 0; i--)
00753       {
00754         s16_sample_buffer[2 * i + 1] =
00755         s16_sample_buffer[2 * i]     = s16_sample_buffer[i];
00756       }
00757     }
00758 
00759     // The PDCA is not able to synchronize its start of transfer with the SSC
00760     // start of period, so this has to be done by polling the TF pin.
00761     // Not doing so may result in channels being swapped randomly.
00762     if ((global_interrupt_enabled = Is_global_interrupt_enabled()))
00763       Disable_global_interrupt();
00764     if (pdca_get_transfer_status(AIC23B_SSC_TX_PDCA_CHANNEL) &
00765         PDCA_TRANSFER_COMPLETE)
00766     {
00767       while (gpio_get_pin_value(AIC23B_SSC_TX_FRAME_SYNC_PIN));
00768       while (!gpio_get_pin_value(AIC23B_SSC_TX_FRAME_SYNC_PIN));
00769     }
00770     pdca_reload_channel(AIC23B_SSC_TX_PDCA_CHANNEL, sample_buffer, sample_length * 2);
00771     pdca_get_reload_size(AIC23B_SSC_TX_PDCA_CHANNEL);
00772     if (global_interrupt_enabled)
00773       Enable_global_interrupt();
00774 
00775     if (aic23b_output_params.callback_opt & AUDIO_DAC_OUT_OF_SAMPLE_CB)
00776       pdca_enable_interrupt_transfer_complete(AIC23B_SSC_TX_PDCA_CHANNEL);
00777     if (aic23b_output_params.callback_opt & AUDIO_DAC_RELOAD_CB)
00778       pdca_enable_interrupt_reload_counter_zero(AIC23B_SSC_TX_PDCA_CHANNEL);
00779   }
00780   return TRUE;
00781 }

void aic23b_dac_set_average_headphone_volume ( U8  volume  ) 

Sets the average headphone volume.

Definition at line 443 of file tlv320aic23b.c.

References AIC23B_LEFT_CHANNEL, AIC23B_RIGHT_CHANNEL, and aic23b_set_headphone_volume().

void aic23b_dac_setup ( U32  sample_rate_hz,
U8  num_channels,
U8  bits_per_sample,
Bool  swap_channels,
void(*)(U32 arg)  callback,
U32  callback_opt,
U32  pba_hz 
)

Sets the DAC up with new settings.

Note:
The DAC must have been started beforehand.

void aic23b_dac_start ( U32  sample_rate_hz,
U8  num_channels,
U8  bits_per_sample,
Bool  swap_channels,
void(*)(U32 arg)  callback,
U32  callback_opt,
U32  pba_hz 
)

Starts the DAC.

void aic23b_dac_stop ( void   ) 

Stops the DAC.

aic23b_aapc_t aic23b_get_analog_audio_path ( void   ) 

Gets the analog audio path.

Definition at line 510 of file tlv320aic23b.c.

References AIC23B_AAPC, aic23b_read_reg(), and aic23b_aapc_t::data.

00511 {
00512   aic23b_aapc_t aapc;
00513   aapc.data = aic23b_read_reg(AIC23B_AAPC);
00514   return aapc;
00515 }

aic23b_dapc_t aic23b_get_digital_audio_path ( void   ) 

Gets the digital audio path.

Definition at line 524 of file tlv320aic23b.c.

References AIC23B_DAPC, aic23b_read_reg(), and aic23b_dapc_t::data.

00525 {
00526   aic23b_dapc_t dapc;
00527   dapc.data = aic23b_read_reg(AIC23B_DAPC);
00528   return dapc;
00529 }

S8 aic23b_get_headphone_volume ( U8  ch  ) 

Gets the ch channel headphone volume.

Definition at line 458 of file tlv320aic23b.c.

References AIC23B_HP_VOL_MIN, AIC23B_HP_VOL_OFFSET, AIC23B_LCHVC, AIC23B_LEFT_CHANNEL, AIC23B_MUTED, AIC23B_RCHVC, aic23b_read_reg(), AIC23B_RIGHT_CHANNEL, aic23b_rchvc_t::data, aic23b_lchvc_t::data, aic23b_lchvc_t::lhv, and aic23b_rchvc_t::rhv.

Referenced by aic23b_dac_decrease_volume(), and aic23b_dac_increase_volume().

00459 {
00460   switch (ch)
00461   {
00462   case AIC23B_LEFT_CHANNEL:
00463     {
00464       aic23b_lchvc_t lchvc;
00465       lchvc.data = aic23b_read_reg(AIC23B_LCHVC);
00466       return (lchvc.lhv < AIC23B_HP_VOL_MIN + AIC23B_HP_VOL_OFFSET) ?
00467              AIC23B_MUTED :
00468              lchvc.lhv - AIC23B_HP_VOL_OFFSET;
00469     }
00470   case AIC23B_RIGHT_CHANNEL:
00471     {
00472       aic23b_rchvc_t rchvc;
00473       rchvc.data = aic23b_read_reg(AIC23B_RCHVC);
00474       return (rchvc.rhv < AIC23B_HP_VOL_MIN + AIC23B_HP_VOL_OFFSET) ?
00475              AIC23B_MUTED :
00476              rchvc.rhv - AIC23B_HP_VOL_OFFSET;
00477     }
00478   default:
00479     return AIC23B_MUTED;
00480   }
00481 }

S8 aic23b_get_line_in_volume ( U8  ch  ) 

Gets the ch line input channel volume.

Definition at line 367 of file tlv320aic23b.c.

References AIC23B_LEFT_CHANNEL, AIC23B_LIN_VOL_OFFSET, AIC23B_LLICVC, AIC23B_MUTED, aic23b_read_reg(), AIC23B_RIGHT_CHANNEL, AIC23B_RLICVC, aic23b_rlicvc_t::data, aic23b_llicvc_t::data, aic23b_llicvc_t::lim, aic23b_llicvc_t::liv, aic23b_rlicvc_t::rim, and aic23b_rlicvc_t::riv.

00368 {
00369   switch (ch)
00370   {
00371   case AIC23B_LEFT_CHANNEL:
00372     {
00373       aic23b_llicvc_t llicvc;
00374       llicvc.data = aic23b_read_reg(AIC23B_LLICVC);
00375       return (llicvc.lim) ?
00376              AIC23B_MUTED :
00377              llicvc.liv - AIC23B_LIN_VOL_OFFSET;
00378     }
00379   case AIC23B_RIGHT_CHANNEL:
00380     {
00381       aic23b_rlicvc_t rlicvc;
00382       rlicvc.data = aic23b_read_reg(AIC23B_RLICVC);
00383       return (rlicvc.rim) ?
00384              AIC23B_MUTED :
00385              rlicvc.riv - AIC23B_LIN_VOL_OFFSET;
00386     }
00387   default:
00388     return AIC23B_MUTED;
00389   }
00390 }

aic23b_pdc_t aic23b_get_power_down_state ( void   ) 

Gets the power down state.

Definition at line 538 of file tlv320aic23b.c.

References AIC23B_PDC, aic23b_read_reg(), and aic23b_pdc_t::data.

00539 {
00540   aic23b_pdc_t pdc;
00541   pdc.data = aic23b_read_reg(AIC23B_PDC);
00542   return pdc;
00543 }

Bool aic23b_is_dig_audio_activated ( void   ) 

Tells whether the digital audio interface is activated.

Definition at line 552 of file tlv320aic23b.c.

References aic23b_dia_t::act, AIC23B_DIA, aic23b_read_reg(), and aic23b_dia_t::data.

00553 {
00554   aic23b_dia_t dia;
00555   dia.data = aic23b_read_reg(AIC23B_DIA);
00556   return dia.act;
00557 }

U16 aic23b_read_reg ( U8  reg  ) 

void aic23b_reset ( void   ) 

Resets the CODEC.

Definition at line 569 of file tlv320aic23b.c.

References AIC23B_DEFAULT, AIC23B_OFFSET, aic23b_read_reg(), AIC23B_RR, aic23b_write_reg(), aic23b_rr_t::data, and aic23b_rr_t::res.

Referenced by aic23b_codec_stop().

00570 {
00571   aic23b_rr_t rr;
00572   rr.data = aic23b_read_reg(AIC23B_RR);
00573   rr.res = AIC23B_DEFAULT(AIC23B_RR) >> AIC23B_OFFSET(AIC23B_RR, RES);
00574   aic23b_write_reg(AIC23B_RR, rr.data);
00575 }

void aic23b_set_analog_audio_path ( aic23b_aapc_t  aapc  ) 

Sets the analog audio path to aapc.

Definition at line 518 of file tlv320aic23b.c.

References AIC23B_AAPC, aic23b_write_reg(), and aic23b_aapc_t::data.

Referenced by aic23b_codec_start().

00519 {
00520   aic23b_write_reg(AIC23B_AAPC, aapc.data);
00521 }

void aic23b_set_digital_audio_path ( aic23b_dapc_t  dapc  ) 

Sets the digital audio path to dapc.

Definition at line 532 of file tlv320aic23b.c.

References AIC23B_DAPC, aic23b_write_reg(), and aic23b_dapc_t::data.

Referenced by aic23b_codec_start().

00533 {
00534   aic23b_write_reg(AIC23B_DAPC, dapc.data);
00535 }

void aic23b_set_headphone_volume ( U8  ch_mask,
S8  vol,
Bool  z_cross 
)

Sets the ch_mask channels headphone volume to vol, with zero-cross detect if z_cross is TRUE.

Definition at line 483 of file tlv320aic23b.c.

References AIC23B_HP_VOL_MAX, AIC23B_HP_VOL_MIN, AIC23B_HP_VOL_OFFSET, AIC23B_LCHVC, AIC23B_LEFT_CHANNEL, AIC23B_RCHVC, aic23b_read_reg(), AIC23B_RIGHT_CHANNEL, aic23b_write_reg(), aic23b_rchvc_t::data, aic23b_lchvc_t::data, aic23b_lchvc_t::lhv, aic23b_lchvc_t::lrs, aic23b_lchvc_t::lzc, aic23b_rchvc_t::rhv, aic23b_rchvc_t::rls, and aic23b_rchvc_t::rzc.

Referenced by aic23b_codec_start(), aic23b_dac_decrease_volume(), aic23b_dac_increase_volume(), and aic23b_dac_set_average_headphone_volume().

00484 {
00485   if (ch_mask & AIC23B_LEFT_CHANNEL)
00486   {
00487     aic23b_lchvc_t lchvc;
00488     lchvc.data = aic23b_read_reg(AIC23B_LCHVC);
00489     lchvc.lrs = ((ch_mask & AIC23B_RIGHT_CHANNEL) != 0);
00490     lchvc.lzc = z_cross;
00491     lchvc.lhv = (vol < AIC23B_HP_VOL_MIN) ?
00492                 0 :
00493                 min(vol, AIC23B_HP_VOL_MAX) + AIC23B_HP_VOL_OFFSET;
00494     aic23b_write_reg(AIC23B_LCHVC, lchvc.data);
00495   }
00496   if (ch_mask & AIC23B_RIGHT_CHANNEL)
00497   {
00498     aic23b_rchvc_t rchvc;
00499     rchvc.data = aic23b_read_reg(AIC23B_RCHVC);
00500     rchvc.rls = 0;
00501     rchvc.rzc = z_cross;
00502     rchvc.rhv = (vol < AIC23B_HP_VOL_MIN) ?
00503                 0 :
00504                 min(vol, AIC23B_HP_VOL_MAX) + AIC23B_HP_VOL_OFFSET;
00505     aic23b_write_reg(AIC23B_RCHVC, rchvc.data);
00506   }
00507 }

void aic23b_set_line_in_volume ( U8  ch_mask,
S8  vol 
)

Sets the ch_mask line input channels volume to vol.

Definition at line 393 of file tlv320aic23b.c.

References AIC23B_LEFT_CHANNEL, AIC23B_LIN_VOL_MAX, AIC23B_LIN_VOL_MIN, AIC23B_LIN_VOL_OFFSET, AIC23B_LLICVC, aic23b_read_reg(), AIC23B_RIGHT_CHANNEL, AIC23B_RLICVC, aic23b_write_reg(), aic23b_rlicvc_t::data, aic23b_llicvc_t::data, aic23b_llicvc_t::lim, aic23b_llicvc_t::liv, aic23b_llicvc_t::lrs, aic23b_rlicvc_t::rim, aic23b_rlicvc_t::riv, and aic23b_rlicvc_t::rls.

00394 {
00395   if (ch_mask & AIC23B_LEFT_CHANNEL)
00396   {
00397     aic23b_llicvc_t llicvc;
00398     llicvc.data = aic23b_read_reg(AIC23B_LLICVC);
00399     llicvc.lrs = ((ch_mask & AIC23B_RIGHT_CHANNEL) != 0);
00400     if (vol < AIC23B_LIN_VOL_MIN) llicvc.lim = 1;
00401     else
00402     {
00403       llicvc.lim = 0;
00404       llicvc.liv = min(vol, AIC23B_LIN_VOL_MAX) + AIC23B_LIN_VOL_OFFSET;
00405     }
00406     aic23b_write_reg(AIC23B_LLICVC, llicvc.data);
00407   }
00408   else if (ch_mask & AIC23B_RIGHT_CHANNEL)
00409   {
00410     aic23b_rlicvc_t rlicvc;
00411     rlicvc.data = aic23b_read_reg(AIC23B_RLICVC);
00412     rlicvc.rls = 0;
00413     if (vol < AIC23B_LIN_VOL_MIN) rlicvc.rim = 1;
00414     else
00415     {
00416       rlicvc.rim = 0;
00417       rlicvc.riv = min(vol, AIC23B_LIN_VOL_MAX) + AIC23B_LIN_VOL_OFFSET;
00418     }
00419     aic23b_write_reg(AIC23B_RLICVC, rlicvc.data);
00420   }
00421 }

void aic23b_set_power_down_state ( aic23b_pdc_t  pdc  ) 

Sets the power down state to pdc.

Definition at line 546 of file tlv320aic23b.c.

References AIC23B_PDC, aic23b_write_reg(), and aic23b_pdc_t::data.

Referenced by aic23b_codec_start(), and aic23b_codec_stop().

00547 {
00548   aic23b_write_reg(AIC23B_PDC, pdc.data);
00549 }

void aic23b_write_reg ( U8  reg,
U16  val 
)


Generated on Fri Nov 27 14:08:36 2009 for AVR32 UC3 - Example of using an external Audio Codec TLV320AIC23B by  doxygen 1.5.5