#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 "twi.h"
#include "ssc_i2s.h"
#include "pdca.h"
#include "cs2200.h"
#include "conf_audio_player.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_rx_pdca_int_handler (void) |
SSC RX PDCA interrupt handler managing the out-of-samples condition. More... | |
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) |
Writes the ctrl control word. 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 | |
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... | |
bool | aic23b_adc_input (void *sample_buffer, size_t sample_length) |
Input a sample buffer from the ADC. More... | |
void | aic23b_codec_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 CODEC. More... | |
void | aic23b_codec_setup (uint32_t sample_rate_hz, uint8_t num_channels, uint8_t bits_per_sample, bool swap_channels, void(*callback)(uint32_t opt), uint32_t callback_opt, uint32_t pba_hz) |
void | aic23b_codec_flush (void) |
Flushes the sample buffers being input from the ADC and output to the DAC. More... | |
void | aic23b_codec_stop (void) |
Stops the CODEC. 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_CODEC_GPIO_MAP |
Map of the SSC pins used by the TLV320AIC23B. More... | |
uint32_t | usb_stream_resync_frequency |
CS2200 out frequency. 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 |
SSC RX PDCA interrupt handler managing the out-of-samples condition.
References aic23b_output_params, AIC23B_SSC_RX_PDCA_CHANNEL, AUDIO_ADC_OUT_OF_SAMPLE_CB, AUDIO_ADC_RELOAD_CB, pdca_disable_interrupt_reload_counter_zero(), pdca_disable_interrupt_transfer_complete(), pdca_get_transfer_status(), PDCA_TRANSFER_COMPLETE, and PDCA_TRANSFER_COUNTER_RELOAD_IS_ZERO.
Referenced by aic23b_codec_start().
|
static |
SSC TX PDCA interrupt handler managing the out-of-samples condition.
References aic23b_output_params, AIC23B_SSC_TX_PDCA_CHANNEL, AUDIO_DAC_OUT_OF_SAMPLE_CB, AUDIO_DAC_RELOAD_CB, pdca_disable_interrupt_reload_counter_zero(), pdca_disable_interrupt_transfer_complete(), pdca_get_transfer_status(), PDCA_TRANSFER_COMPLETE, and PDCA_TRANSFER_COUNTER_RELOAD_IS_ZERO.
Referenced by aic23b_codec_start().
|
static |
Writes the ctrl control word.
References AIC23B_TWI, AIC23B_TWI_ADDRESS, twi_package_t::chip, twi_master_write(), and TWI_SUCCESS.
Referenced by aic23b_write_reg().
|
static |
Local image of the registers.
|
static |
Default local image of the registers.
struct { ... } aic23b_output_params |
Output parameters.
Referenced by aic23b_adc_input(), aic23b_codec_setup(), aic23b_codec_stop(), aic23b_dac_mute(), aic23b_dac_output(), aic23b_ssc_rx_pdca_int_handler(), and aic23b_ssc_tx_pdca_int_handler().
|
static |
Map of the SSC pins used by the TLV320AIC23B.
void(* callback)(uint32_t arg) |
uint32_t callback_opt |
uint8_t num_channels |
uint32_t usb_stream_resync_frequency |
CS2200 out frequency.
Referenced by aic23b_codec_setup(), usb_stream_init(), and usb_stream_input().