Atmel Software Framework

tlv320aic23b.c File Reference
#include <stddef.h>
#include <string.h>
#include "compiler.h"
#include "audio.h"
#include "tlv320aic23b.h"
#include <avr32/io.h>
#include "intc.h"
#include "gpio.h"
#include "ssc_i2s.h"
#include "pdca.h"

Macros

#define AIC23B_CTRL_RESET
 Default local image of the registers. More...
 
#define AIC23B_REG_COUNT   (sizeof(aic23b_ctrl) / sizeof(aic23b_ctrl[0]))
 Number of registers. More...
 

Functions

static void aic23b_ssc_tx_pdca_int_handler (void)
 SSC TX PDCA interrupt handler managing the out-of-samples condition. More...
 
static void aic23b_write_control_word (aic23b_ctrl_t ctrl)
 SSC RX PDCA interrupt handler managing the out-of-samples condition. More...
 
Low-Level Interface
void aic23b_configure_freq (int master_clock_hz, int sample_rate_hz)
 Used to configure the codec frequency. More...
 
uint16_t aic23b_read_reg (uint8_t reg)
 Reads the reg register. More...
 
void aic23b_write_reg (uint8_t reg, uint16_t val)
 Writes val to the reg register. More...
 
Mid-Level Interface
int8_t aic23b_get_line_in_volume (uint8_t ch)
 Gets the ch line input channel volume. More...
 
void aic23b_set_line_in_volume (uint8_t ch_mask, int8_t vol)
 Sets the ch_mask line input channels volume to vol. More...
 
uint8_t aic23b_dac_get_average_headphone_volume (void)
 Gets the average headphone volume. More...
 
void aic23b_dac_set_average_headphone_volume (uint8_t volume)
 Sets the average headphone volume. More...
 
bool aic23b_dac_is_headphone_volume_muted (void)
 Returns the state of the mute mode of the DAC. More...
 
bool aic23b_dac_is_headphone_volume_boosted (void)
 Returns the state of the boost mode of the DAC. More...
 
int8_t aic23b_get_headphone_volume (uint8_t ch)
 Gets the ch channel headphone volume. More...
 
void aic23b_set_headphone_volume (uint8_t ch_mask, int8_t vol, bool z_cross)
 Sets the ch_mask channels headphone volume to vol, with zero-cross detect if z_cross is true. More...
 
aic23b_aapc_t aic23b_get_analog_audio_path (void)
 Gets the analog audio path. More...
 
void aic23b_set_analog_audio_path (aic23b_aapc_t aapc)
 Sets the analog audio path to aapc. More...
 
aic23b_dapc_t aic23b_get_digital_audio_path (void)
 Gets the digital audio path. More...
 
void aic23b_set_digital_audio_path (aic23b_dapc_t dapc)
 Sets the digital audio path to dapc. More...
 
aic23b_pdc_t aic23b_get_power_down_state (void)
 Gets the power down state. More...
 
void aic23b_set_power_down_state (aic23b_pdc_t pdc)
 Sets the power down state to pdc. More...
 
bool aic23b_is_dig_audio_activated (void)
 Tells whether the digital audio interface is activated. More...
 
void aic23b_activate_dig_audio (bool act)
 Activates or deactivates the digital audio interface according to act. More...
 
void aic23b_reset (void)
 Resets the CODEC. More...
 
High-Level Interface
void aic23b_dac_start (uint32_t sample_rate_hz, uint8_t num_channels, uint8_t bits_per_sample, bool swap_channels, void(*callback)(uint32_t arg), uint32_t callback_opt, uint32_t pba_hz)
 Starts the DAC. More...
 
void aic23b_dac_setup (uint32_t sample_rate_hz, uint8_t num_channels, uint8_t bits_per_sample, bool swap_channels, void(*callback)(uint32_t arg), uint32_t callback_opt, uint32_t pba_hz)
 Sets the DAC up with new settings. More...
 
bool aic23b_dac_output (void *sample_buffer, size_t sample_length)
 Outputs a sample buffer to the DAC. More...
 
void aic23b_dac_increase_volume (void)
 Increases the output volume of the DAC. More...
 
void aic23b_dac_decrease_volume (void)
 Decreases the output volume of the DAC. More...
 
void aic23b_dac_mute (bool mute)
 Mute audio if mute is set to true. More...
 
void aic23b_dac_flush (void)
 Flushes the sample buffer being output to the DAC. More...
 
void aic23b_dac_stop (void)
 Stops the DAC. More...
 

Variables

static aic23b_ctrl_t aic23b_ctrl [] = AIC23B_CTRL_RESET
 Local image of the registers. More...
 
static const aic23b_ctrl_t aic23b_ctrl_reset [] = AIC23B_CTRL_RESET
 Default local image of the registers. More...
 
struct {
   void(*   callback )(uint32_t arg)
 
   uint32_t   callback_opt
 
   uint8_t   num_channels
 
aic23b_output_params
 Output parameters. More...
 
static const gpio_map_t AIC23B_SSC_DAC_GPIO_MAP
 Map of the SSC pins used by the TLV320AIC23B. More...
 

#define AIC23B_CTRL_RESET

Default local image of the registers.

#define AIC23B_REG_COUNT   (sizeof(aic23b_ctrl) / sizeof(aic23b_ctrl[0]))

Number of registers.

Referenced by aic23b_read_reg(), and aic23b_write_reg().

static void aic23b_write_control_word ( aic23b_ctrl_t  ctrl)
static

SSC RX PDCA interrupt handler managing the out-of-samples condition.

Writes the ctrl control word.

References AIC23B_TWI, AIC23B_TWI_ADDRESS, twi_package_t::chip, spi_selectChip(), spi_unselectChip(), spi_write(), twi_master_write(), and TWI_SUCCESS.

Referenced by aic23b_write_reg().

aic23b_ctrl_t aic23b_ctrl[] = AIC23B_CTRL_RESET
static

Local image of the registers.

const aic23b_ctrl_t aic23b_ctrl_reset[] = AIC23B_CTRL_RESET
static

Default local image of the registers.

struct { ... } aic23b_output_params
Initial value:
=
{
.num_channels = 0,
.callback = NULL,
.callback_opt = 0
}
#define NULL
Definition: lwip-1.4.0/src/include/lwip/def.h:47

Output parameters.

Referenced by aic23b_dac_mute(), aic23b_dac_output(), aic23b_dac_setup(), aic23b_dac_stop(), and aic23b_ssc_tx_pdca_int_handler().

const gpio_map_t AIC23B_SSC_DAC_GPIO_MAP
static
Initial value:
=
{
}
#define AIC23B_SSC_TX_CLOCK_PIN
Definition: host/conf/conf_tlv320aic23b.h:113
#define AIC23B_SSC_TX_FRAME_SYNC_FUNCTION
Definition: host/conf/conf_tlv320aic23b.h:118
#define AIC23B_SSC_TX_CLOCK_FUNCTION
Definition: host/conf/conf_tlv320aic23b.h:114
#define AIC23B_SSC_TX_DATA_PIN
Definition: host/conf/conf_tlv320aic23b.h:115
#define AIC23B_SSC_TX_DATA_FUNCTION
Definition: host/conf/conf_tlv320aic23b.h:116
#define AIC23B_SSC_TX_FRAME_SYNC_PIN
Definition: host/conf/conf_tlv320aic23b.h:117

Map of the SSC pins used by the TLV320AIC23B.

void(* callback)(uint32_t arg)
uint32_t callback_opt
uint8_t num_channels