Definition in file tlv320aic23b_with_cs2200.c.
#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"
#include "cycle_counter.h"
#include "cs2200.h"
#include "audio_example.h"
Go to the source code of this file.
Defines | |
#define | AIC23B_CTRL_RESET |
Default local image of the registers. | |
#define | AIC23B_REG_COUNT (sizeof(aic23b_ctrl) / sizeof(aic23b_ctrl[0])) |
Number of registers. | |
Functions | |
static void | aic23b_ssc_rx_pdca_int_handler (void) |
SSC RX PDCA interrupt handler managing the out-of-samples condition. | |
static void | aic23b_ssc_tx_pdca_int_handler (void) |
SSC TX PDCA interrupt handler managing the out-of-samples condition. | |
static void | aic23b_write_control_word (aic23b_ctrl_t ctrl) |
Writes the ctrl control word. | |
Mid-Level Interface | |
void | aic23b_activate_dig_audio (Bool act) |
Activates or deactivates the digital audio interface according to act. | |
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 | |
Bool | aic23b_adc_input (void *sample_buffer, size_t sample_length) |
Input a sample buffer from 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 opt), U32 callback_opt, U32 pba_hz) |
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_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. | |
Low-Level Interface | |
void | aic23b_configure_freq (int master_clock_hz, int sample_rate_hz) |
Used to configure the codec frequency. | |
U16 | aic23b_read_reg (U8 reg) |
Reads the reg register. | |
void | aic23b_write_reg (U8 reg, U16 val) |
Writes val to the reg register. | |
Variables | |
static aic23b_ctrl_t | aic23b_ctrl [] = AIC23B_CTRL_RESET |
Local image of the registers. | |
static const aic23b_ctrl_t | aic23b_ctrl_reset [] = AIC23B_CTRL_RESET |
Default local image of the registers. | |
struct { | |
void(* callback )(U32 arg) | |
U32 callback_opt | |
U8 num_channels | |
} | aic23b_output_params |
static const gpio_map_t | AIC23B_SSC_CODEC_GPIO_MAP |
Map of the SSC pins used by the TLV320AIC23B. | |
U32 | usb_stream_resync_frequency |
CS2200 out frequency. |
#define AIC23B_CTRL_RESET |
#define AIC23B_REG_COUNT (sizeof(aic23b_ctrl) / sizeof(aic23b_ctrl[0])) |
void aic23b_activate_dig_audio | ( | Bool | act | ) |
Activates or deactivates the digital audio interface according to act.
Definition at line 572 of file tlv320aic23b_with_cs2200.c.
References aic23b_dia_t::act, AIC23B_DIA, aic23b_read_reg(), aic23b_write_reg(), and aic23b_dia_t::data.
00573 { 00574 aic23b_dia_t dia; 00575 dia.data = aic23b_read_reg(AIC23B_DIA); 00576 dia.act = act; 00577 aic23b_write_reg(AIC23B_DIA, dia.data); 00578 }
Bool aic23b_adc_input | ( | void * | sample_buffer, | |
size_t | sample_length | |||
) |
Input a sample buffer from the ADC.
Definition at line 1141 of file tlv320aic23b_with_cs2200.c.
References aic23b_output_params, and AIC23B_SSC_RX_PDCA_CHANNEL.
01142 { 01143 if (!(pdca_get_transfer_status(AIC23B_SSC_RX_PDCA_CHANNEL) & 01144 PDCA_TRANSFER_COUNTER_RELOAD_IS_ZERO)) 01145 return FALSE; 01146 01147 if (sample_length) 01148 { 01149 pdca_reload_channel(AIC23B_SSC_RX_PDCA_CHANNEL, sample_buffer, sample_length * 2); 01150 pdca_get_reload_size(AIC23B_SSC_RX_PDCA_CHANNEL); 01151 01152 if (aic23b_output_params.callback_opt & AUDIO_ADC_OUT_OF_SAMPLE_CB) 01153 pdca_enable_interrupt_transfer_complete(AIC23B_SSC_RX_PDCA_CHANNEL); 01154 if (aic23b_output_params.callback_opt & AUDIO_ADC_RELOAD_CB) 01155 pdca_enable_interrupt_reload_counter_zero(AIC23B_SSC_RX_PDCA_CHANNEL); 01156 } 01157 01158 return TRUE; 01159 }
void aic23b_codec_flush | ( | void | ) |
Flushes the sample buffers being input from the ADC and output to the DAC.
Definition at line 1393 of file tlv320aic23b_with_cs2200.c.
References AIC23B_SSC_RX_PDCA_CHANNEL, and AIC23B_SSC_TX_PDCA_CHANNEL.
01394 { 01395 pdca_disable_interrupt_transfer_complete(AIC23B_SSC_RX_PDCA_CHANNEL); 01396 while (!(pdca_get_transfer_status(AIC23B_SSC_RX_PDCA_CHANNEL) & 01397 PDCA_TRANSFER_COMPLETE)); 01398 pdca_disable_interrupt_transfer_complete(AIC23B_SSC_TX_PDCA_CHANNEL); 01399 while (!(pdca_get_transfer_status(AIC23B_SSC_TX_PDCA_CHANNEL) & 01400 PDCA_TRANSFER_COMPLETE)); 01401 }
void aic23b_codec_setup | ( | U32 | sample_rate_hz, | |
U8 | num_channels, | |||
U8 | bits_per_sample, | |||
Bool | swap_channels, | |||
void(*)(U32 opt) | callback, | |||
U32 | callback_opt, | |||
U32 | pba_hz | |||
) |
Definition at line 1278 of file tlv320aic23b_with_cs2200.c.
References aic23b_configure_freq(), AIC23B_DAIF, AIC23B_DAIF_FMT_I2S, AIC23B_DAIF_IWL_16, AIC23B_DAIF_IWL_20, AIC23B_DAIF_IWL_24, AIC23B_DAIF_IWL_32, AIC23B_DAIF_MS_SLAVE, AIC23B_DEFAULT, AIC23B_MCLK_HZ, aic23b_output_params, AIC23B_SSC, AIC23B_SSC_RX_PDCA_CHANNEL, AIC23B_SSC_RX_PDCA_PID, AIC23B_SSC_TX_PDCA_CHANNEL, AIC23B_SSC_TX_PDCA_PID, aic23b_write_reg(), callback, aic23b_daif_t::data, aic23b_daif_t::fmt, aic23b_daif_t::iwl, aic23b_daif_t::lrp, aic23b_daif_t::lrswap, aic23b_daif_t::ms, and usb_stream_resync_frequency.
01285 { 01286 U32 master_clock = AIC23B_MCLK_HZ; // default configuration 01287 01288 // Change the CPU frequency 01289 // 01290 //Disable_global_interrupt(); 01291 01292 // Switch to OSC0 during OSC1 transition 01293 //pm_switch_to_osc0(&AVR32_PM, FOSC0, OSC0_STARTUP); 01294 01295 // Switch to PLL0 as the master clock 01296 //pm_switch_to_clock(&AVR32_PM, AVR32_PM_MCCTRL_MCSEL_PLL0); 01297 01298 if (sample_rate_hz < (8000 + 8021) / 2) 01299 { // 8000 Hz 01300 } 01301 else if (sample_rate_hz < (8021 + 32000) / 2) 01302 { // 8021 Hz 01303 } 01304 else if (sample_rate_hz < (32000 + 44100) / 2) 01305 { // 32000 Hz 01306 master_clock = usb_stream_resync_frequency = 8192000; 01307 cs2200_freq_clk_out(_32_BITS_RATIO(usb_stream_resync_frequency)); 01308 pba_hz = FCPU_HZ = FHSB_HZ = FPBA_HZ = FPBB_HZ = FMCK_HZ(8192000); 01309 cpu_delay_ms(50, pba_hz); 01310 } 01311 else if (sample_rate_hz < (44100 + 48000) / 2) 01312 { // 44100 Hz 01313 master_clock = usb_stream_resync_frequency = 11289600; 01314 cs2200_freq_clk_out(_32_BITS_RATIO(usb_stream_resync_frequency)); 01315 pba_hz = FCPU_HZ = FHSB_HZ = FPBA_HZ = FPBB_HZ = FMCK_HZ(11289600); 01316 cpu_delay_ms(50, pba_hz); 01317 } 01318 else if (sample_rate_hz < (48000 + 88200) / 2) 01319 { // 48000 Hz 01320 master_clock = usb_stream_resync_frequency = 12288000; 01321 cs2200_freq_clk_out(_32_BITS_RATIO(usb_stream_resync_frequency)); 01322 pba_hz = FCPU_HZ = FHSB_HZ = FPBA_HZ = FPBB_HZ = FMCK_HZ(12288000); 01323 cpu_delay_ms(50, pba_hz); 01324 } 01325 else if (sample_rate_hz < (88200 + 96000) / 2) 01326 { // 88200 Hz 01327 } 01328 else 01329 { // 96000 Hz 01330 } 01331 01332 //Enable_global_interrupt(); 01333 01334 ssc_i2s_init(AIC23B_SSC, 01335 sample_rate_hz, 01336 bits_per_sample, 01337 (bits_per_sample <= 16) ? 16 : 01338 (bits_per_sample <= 20) ? 20 : 01339 (bits_per_sample <= 24) ? 24 : 01340 32, 01341 SSC_I2S_MODE_STEREO_OUT_STEREO_IN, 01342 pba_hz); 01343 01344 pdca_channel_options_t aic23b_ssc_pdca_options_rx = 01345 { 01346 .addr = NULL, 01347 .size = 0, 01348 .r_addr = NULL, 01349 .r_size = 0, 01350 .pid = AIC23B_SSC_RX_PDCA_PID, 01351 .transfer_size = (bits_per_sample <= 8) ? PDCA_TRANSFER_SIZE_BYTE : 01352 (bits_per_sample <= 16) ? PDCA_TRANSFER_SIZE_HALF_WORD : 01353 PDCA_TRANSFER_SIZE_WORD 01354 01355 }; 01356 pdca_init_channel(AIC23B_SSC_RX_PDCA_CHANNEL, &aic23b_ssc_pdca_options_rx); 01357 pdca_enable(AIC23B_SSC_RX_PDCA_CHANNEL); 01358 01359 pdca_channel_options_t aic23b_ssc_pdca_options_tx = 01360 { 01361 .addr = NULL, 01362 .size = 0, 01363 .r_addr = NULL, 01364 .r_size = 0, 01365 .pid = AIC23B_SSC_TX_PDCA_PID, 01366 .transfer_size = (bits_per_sample <= 8) ? PDCA_TRANSFER_SIZE_BYTE : 01367 (bits_per_sample <= 16) ? PDCA_TRANSFER_SIZE_HALF_WORD : 01368 PDCA_TRANSFER_SIZE_WORD 01369 }; 01370 pdca_init_channel(AIC23B_SSC_TX_PDCA_CHANNEL, &aic23b_ssc_pdca_options_tx); 01371 pdca_enable(AIC23B_SSC_TX_PDCA_CHANNEL); 01372 01373 // Set codec frequency 01374 aic23b_configure_freq(master_clock, sample_rate_hz); 01375 01376 aic23b_daif_t daif; 01377 daif.data = AIC23B_DEFAULT(AIC23B_DAIF); 01378 daif.ms = AIC23B_DAIF_MS_SLAVE; 01379 daif.lrswap = swap_channels; 01380 daif.lrp = 0; 01381 daif.iwl = (bits_per_sample <= 16) ? AIC23B_DAIF_IWL_16 : 01382 (bits_per_sample <= 20) ? AIC23B_DAIF_IWL_20 : 01383 (bits_per_sample <= 24) ? AIC23B_DAIF_IWL_24 : 01384 AIC23B_DAIF_IWL_32; 01385 daif.fmt = AIC23B_DAIF_FMT_I2S; 01386 aic23b_write_reg(AIC23B_DAIF, daif.data); 01387 01388 aic23b_output_params.num_channels = num_channels; 01389 aic23b_output_params.callback = callback; 01390 aic23b_output_params.callback_opt = callback_opt; 01391 }
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 1163 of file tlv320aic23b_with_cs2200.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.
01170 { 01171 #if AIC23B_CTRL_INTERFACE == AIC23B_CTRL_INTERFACE_SPI 01172 static const spi_options_t AIC23B_SPI_OPTIONS = 01173 { 01174 .reg = AIC23B_SPI_NPCS, 01175 .baudrate = AIC23B_SPI_MASTER_SPEED, 01176 .bits = AIC23B_CTRL_SIZE, 01177 .spck_delay = 0, 01178 .trans_delay = 0, 01179 .stay_act = 0, 01180 .spi_mode = 3, 01181 .modfdis = 1 01182 }; 01183 spi_setupChipReg(AIC23B_SPI, &AIC23B_SPI_OPTIONS, pba_hz); 01184 #endif 01185 01186 aic23b_codec_stop(); 01187 01188 gpio_enable_module(AIC23B_SSC_CODEC_GPIO_MAP, 01189 sizeof(AIC23B_SSC_CODEC_GPIO_MAP) / sizeof(AIC23B_SSC_CODEC_GPIO_MAP[0])); 01190 01191 aic23b_pdc_t pdc; 01192 pdc.data = AIC23B_DEFAULT(AIC23B_PDC); 01193 pdc.off = 0; 01194 pdc.clk = 0; 01195 pdc.osc = 0; 01196 pdc.out = 0; 01197 pdc.dac = 0; 01198 pdc.adc = 0; 01199 #if (AIC23B_INPUT==AIC23B_INPUT_LINE) 01200 pdc.mic = 1; 01201 pdc.line = 0; 01202 #elif (AIC23B_INPUT==AIC23B_INPUT_MIC) 01203 pdc.mic = 0; 01204 pdc.line = 1; 01205 #else 01206 #error No Input defined in file 'conf_tlv320aic23b.h' 01207 #endif 01208 aic23b_set_power_down_state(pdc); 01209 01210 aic23b_codec_setup(sample_rate_hz, 01211 num_channels, 01212 bits_per_sample, 01213 swap_channels, 01214 callback, 01215 callback_opt, 01216 pba_hz); 01217 01218 aic23b_aapc_t aapc; 01219 aapc.data = AIC23B_DEFAULT(AIC23B_AAPC); 01220 #if (AIC23B_INPUT==AIC23B_INPUT_LINE) 01221 aapc.ste = 0; 01222 aapc.dac = 1; 01223 aapc.byp = 0; 01224 aapc.insel = 0; 01225 aapc.micm = 0; 01226 aapc.micb = 1; 01227 #elif (AIC23B_INPUT==AIC23B_INPUT_MIC) 01228 aapc.ste = 0; 01229 aapc.dac = 1; 01230 aapc.sta = 4; 01231 aapc.byp = 0; 01232 aapc.insel = 1; 01233 aapc.micm = 0; 01234 aapc.micb = 1; 01235 #else 01236 #error No Input defined in file 'conf_tlv320aic23b.h' 01237 #endif 01238 aic23b_set_analog_audio_path(aapc); 01239 01240 aic23b_dapc_t dapc; 01241 dapc.data = AIC23B_DEFAULT(AIC23B_DAPC); 01242 dapc.dacm = 0; 01243 dapc.deemp = AIC23B_DAPC_DEEMP_NONE; 01244 dapc.adchp = 0; 01245 aic23b_set_digital_audio_path(dapc); 01246 01247 01248 aic23b_llicvc_t llivc; 01249 llivc.data = AIC23B_DEFAULT(AIC23B_LLICVC); 01250 llivc.liv = 20; 01251 llivc.lim = 0; 01252 llivc.lrs = 1; 01253 aic23b_write_reg(AIC23B_LLICVC, llivc.data); 01254 01255 aic23b_rlicvc_t rlivc; 01256 rlivc.data = AIC23B_DEFAULT(AIC23B_RLICVC); 01257 rlivc.riv = 20; 01258 rlivc.rim = 0; 01259 rlivc.rls = 1; 01260 aic23b_write_reg(AIC23B_RLICVC, rlivc.data); 01261 01262 INTC_register_interrupt(&aic23b_ssc_rx_pdca_int_handler, 01263 AIC23B_SSC_RX_PDCA_IRQ, 01264 AIC23B_SSC_RX_PDCA_INT_LEVEL); 01265 01266 // set an acceptable start volume 01267 aic23b_set_headphone_volume(AIC23B_LEFT_CHANNEL | AIC23B_RIGHT_CHANNEL, 01268 -30, 01269 TRUE); 01270 01271 aic23b_activate_dig_audio(TRUE); 01272 01273 INTC_register_interrupt(&aic23b_ssc_tx_pdca_int_handler, 01274 AIC23B_SSC_TX_PDCA_IRQ, 01275 AIC23B_SSC_TX_PDCA_INT_LEVEL); 01276 }
void aic23b_codec_stop | ( | void | ) |
Stops the CODEC.
Definition at line 1403 of file tlv320aic23b_with_cs2200.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.
01404 { 01405 aic23b_codec_flush(); 01406 01407 aic23b_reset(); 01408 01409 aic23b_pdc_t pdc; 01410 pdc.data = AIC23B_DEFAULT(AIC23B_PDC); 01411 pdc.off = 1; 01412 pdc.clk = 1; 01413 pdc.osc = 1; 01414 pdc.out = 1; 01415 pdc.dac = 1; 01416 pdc.adc = 1; 01417 pdc.mic = 1; 01418 pdc.line = 1; 01419 aic23b_set_power_down_state(pdc); 01420 01421 pdca_disable(AIC23B_SSC_RX_PDCA_CHANNEL); 01422 pdca_disable(AIC23B_SSC_TX_PDCA_CHANNEL); 01423 01424 ssc_i2s_reset(AIC23B_SSC); 01425 01426 gpio_enable_gpio(AIC23B_SSC_CODEC_GPIO_MAP, 01427 sizeof(AIC23B_SSC_CODEC_GPIO_MAP) / sizeof(AIC23B_SSC_CODEC_GPIO_MAP[0])); 01428 01429 aic23b_output_params.num_channels = 0; 01430 aic23b_output_params.callback = NULL; 01431 aic23b_output_params.callback_opt = 0; 01432 }
void aic23b_configure_freq | ( | int | master_clock_hz, | |
int | sample_rate_hz | |||
) |
Used to configure the codec frequency.
Definition at line 265 of file tlv320aic23b_with_cs2200.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.
00266 { 00267 aic23b_src_t src; 00268 00269 src.data = AIC23B_DEFAULT(AIC23B_SRC); 00270 src.clkout = 0; 00271 src.clkin = 0; 00272 00273 switch (master_clock_hz) 00274 { 00275 case 12000000: 00276 src.usb = 1; 00277 if (sample_rate_hz < (8000 + 8021) / 2) 00278 { // 8000 Hz 00279 src.sr = 0x3; 00280 src.bosr = 0; 00281 } 00282 else if (sample_rate_hz < (8021 + 32000) / 2) 00283 { // 8021 Hz 00284 src.sr = 0xB; 00285 src.bosr = 1; 00286 } 00287 else if (sample_rate_hz < (32000 + 44100) / 2) 00288 { // 32000 Hz 00289 src.sr = 0x6; 00290 src.bosr = 0; 00291 } 00292 else if (sample_rate_hz < (44100 + 48000) / 2) 00293 { // 44100 Hz 00294 src.sr = 0x8; 00295 src.bosr = 1; 00296 } 00297 else if (sample_rate_hz < (48000 + 88200) / 2) 00298 { // 48000 Hz 00299 src.sr = 0x0; 00300 src.bosr = 0; 00301 } 00302 else if (sample_rate_hz < (88200 + 96000) / 2) 00303 { // 88200 Hz 00304 src.sr = 0xF; 00305 src.bosr = 1; 00306 } 00307 else 00308 { // 96000 Hz 00309 src.sr = 0x7; 00310 src.bosr = 0; 00311 } 00312 break; 00313 case 11289600: 00314 src.usb = 0; 00315 if (sample_rate_hz < (8021 + 22050) / 2) 00316 { // 8021 Hz 00317 src.sr = 0xB; 00318 src.bosr = 0; 00319 } 00320 else if (sample_rate_hz < (22050 + 88200) / 2) 00321 { // 22050, 44100 and 48000 Hz 00322 src.sr = 0x8; 00323 src.bosr = 0; 00324 } 00325 else 00326 { // 88200 Hz 00327 src.sr = 0xF; 00328 src.bosr = 0; 00329 } 00330 break; 00331 case 18432000: 00332 case 8192000: 00333 src.usb = 0; 00334 src.sr = 0; 00335 src.bosr = 1; 00336 break; 00337 case 12288000: 00338 src.usb = 0; 00339 src.sr = 6; 00340 src.bosr = 0; 00341 break; 00342 default: 00343 //Not supported 00344 return; 00345 } 00346 00347 aic23b_write_reg(AIC23B_SRC, src.data); 00348 }
void aic23b_dac_decrease_volume | ( | void | ) |
Decreases the output volume of the DAC.
Definition at line 855 of file tlv320aic23b_with_cs2200.c.
References aic23b_get_headphone_volume(), AIC23B_LEFT_CHANNEL, AIC23B_MUTED, AIC23B_RIGHT_CHANNEL, and aic23b_set_headphone_volume().
00856 { 00857 S8 volume = aic23b_get_headphone_volume(AIC23B_LEFT_CHANNEL); 00858 if( volume != AIC23B_MUTED ) 00859 volume--; 00860 aic23b_set_headphone_volume(AIC23B_LEFT_CHANNEL | AIC23B_RIGHT_CHANNEL, 00861 volume, 00862 TRUE); 00863 }
U8 aic23b_dac_get_average_headphone_volume | ( | void | ) |
Gets the average headphone volume.
Definition at line 435 of file tlv320aic23b_with_cs2200.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.
00436 { 00437 S32 volume, volume_avg = 0; 00438 aic23b_lchvc_t lchvc; 00439 aic23b_rchvc_t rchvc; 00440 00441 lchvc.data = aic23b_read_reg(AIC23B_LCHVC); 00442 rchvc.data = aic23b_read_reg(AIC23B_RCHVC); 00443 volume_avg = (lchvc.lhv < AIC23B_HP_VOL_MIN + AIC23B_HP_VOL_OFFSET) ? 00444 0 : lchvc.lhv - AIC23B_HP_VOL_OFFSET - AIC23B_HP_VOL_MIN; 00445 volume = (rchvc.rhv < AIC23B_HP_VOL_MIN + AIC23B_HP_VOL_OFFSET) ? 00446 0 : rchvc.rhv - AIC23B_HP_VOL_OFFSET - AIC23B_HP_VOL_MIN; 00447 // Get the volume average 00448 volume_avg = (volume_avg + volume) / 2; 00449 // Recenter the volume 00450 volume_avg = (volume_avg * 255) / (AIC23B_HP_VOL_MAX - AIC23B_HP_VOL_MIN); 00451 00452 return (U8) volume_avg; 00453 }
void aic23b_dac_increase_volume | ( | void | ) |
Increases the output volume of the DAC.
Definition at line 844 of file tlv320aic23b_with_cs2200.c.
References aic23b_get_headphone_volume(), AIC23B_HP_VOL_MIN, AIC23B_LEFT_CHANNEL, AIC23B_RIGHT_CHANNEL, and aic23b_set_headphone_volume().
00845 { 00846 S8 volume = aic23b_get_headphone_volume(AIC23B_LEFT_CHANNEL); 00847 if( volume < AIC23B_HP_VOL_MIN ) 00848 volume = AIC23B_HP_VOL_MIN; 00849 aic23b_set_headphone_volume(AIC23B_LEFT_CHANNEL | AIC23B_RIGHT_CHANNEL, 00850 volume + 1, 00851 TRUE); 00852 }
Bool aic23b_dac_is_headphone_volume_boosted | ( | void | ) |
Returns the state of the boost mode of the DAC.
Definition at line 465 of file tlv320aic23b_with_cs2200.c.
Bool aic23b_dac_is_headphone_volume_muted | ( | void | ) |
Returns the state of the mute mode of the DAC.
Definition at line 460 of file tlv320aic23b_with_cs2200.c.
void aic23b_dac_mute | ( | Bool | mute | ) |
Mute audio if mute is set to true.
Definition at line 865 of file tlv320aic23b_with_cs2200.c.
References aic23b_output_params, and AIC23B_SSC_TX_PDCA_CHANNEL.
00866 { 00867 #if (AIC23B_MODE==AIC23B_MODE_DAC) 00868 /* if(mute==TRUE) { 00869 pdca_disable(AIC23B_SSC_TX_PDCA_CHANNEL); 00870 } 00871 else { 00872 pdca_enable(AIC23B_SSC_TX_PDCA_CHANNEL); 00873 } 00874 */ 00875 if (mute) 00876 { 00877 U32 save_dac_reload_callback_opt; 00878 00879 // Disable the reload callback function 00880 save_dac_reload_callback_opt = aic23b_output_params.callback_opt; 00881 aic23b_output_params.callback_opt = 0; 00882 // Disable the transfer complete interruption and wait until the transfer is complete 00883 pdca_disable_interrupt_reload_counter_zero(AIC23B_SSC_TX_PDCA_CHANNEL); 00884 while (!(pdca_get_transfer_status(AIC23B_SSC_TX_PDCA_CHANNEL) & PDCA_TRANSFER_COMPLETE)); 00885 // Re-enable the reload callback function 00886 aic23b_output_params.callback_opt = save_dac_reload_callback_opt; 00887 } 00888 else 00889 { 00890 // Re-enable the reload interrupt 00891 pdca_enable_interrupt_reload_counter_zero(AIC23B_SSC_TX_PDCA_CHANNEL); 00892 } 00893 00894 #endif 00895 }
Bool aic23b_dac_output | ( | void * | sample_buffer, | |
size_t | sample_length | |||
) |
Outputs a sample buffer to the DAC.
Definition at line 797 of file tlv320aic23b_with_cs2200.c.
References aic23b_output_params, AIC23B_SSC_TX_FRAME_SYNC_PIN, and AIC23B_SSC_TX_PDCA_CHANNEL.
00798 { 00799 Bool global_interrupt_enabled; 00800 00801 if (!(pdca_get_transfer_status(AIC23B_SSC_TX_PDCA_CHANNEL) & 00802 PDCA_TRANSFER_COUNTER_RELOAD_IS_ZERO)) 00803 return FALSE; 00804 00805 if (sample_length) 00806 { 00807 if (aic23b_output_params.num_channels == 1) 00808 { 00809 S16 *s16_sample_buffer = sample_buffer; 00810 int i; 00811 00812 for (i = sample_length - 1; i >= 0; i--) 00813 { 00814 s16_sample_buffer[2 * i + 1] = 00815 s16_sample_buffer[2 * i] = s16_sample_buffer[i]; 00816 } 00817 } 00818 00819 // The PDCA is not able to synchronize its start of transfer with the SSC 00820 // start of period, so this has to be done by polling the TF pin. 00821 // Not doing so may result in channels being swapped randomly. 00822 if ((global_interrupt_enabled = Is_global_interrupt_enabled())) 00823 Disable_global_interrupt(); 00824 if (pdca_get_transfer_status(AIC23B_SSC_TX_PDCA_CHANNEL) & 00825 PDCA_TRANSFER_COMPLETE) 00826 { 00827 while (gpio_get_pin_value(AIC23B_SSC_TX_FRAME_SYNC_PIN)); 00828 while (!gpio_get_pin_value(AIC23B_SSC_TX_FRAME_SYNC_PIN)); 00829 } 00830 pdca_reload_channel(AIC23B_SSC_TX_PDCA_CHANNEL, sample_buffer, sample_length * 2); 00831 pdca_get_reload_size(AIC23B_SSC_TX_PDCA_CHANNEL); 00832 if (global_interrupt_enabled) 00833 Enable_global_interrupt(); 00834 00835 if (aic23b_output_params.callback_opt & AUDIO_DAC_OUT_OF_SAMPLE_CB) 00836 pdca_enable_interrupt_transfer_complete(AIC23B_SSC_TX_PDCA_CHANNEL); 00837 if (aic23b_output_params.callback_opt & AUDIO_DAC_RELOAD_CB) 00838 pdca_enable_interrupt_reload_counter_zero(AIC23B_SSC_TX_PDCA_CHANNEL); 00839 } 00840 return TRUE; 00841 }
void aic23b_dac_set_average_headphone_volume | ( | U8 | volume | ) |
Sets the average headphone volume.
Definition at line 455 of file tlv320aic23b_with_cs2200.c.
References AIC23B_LEFT_CHANNEL, AIC23B_RIGHT_CHANNEL, and aic23b_set_headphone_volume().
00456 { 00457 aic23b_set_headphone_volume(AIC23B_LEFT_CHANNEL | AIC23B_RIGHT_CHANNEL,volume,TRUE); 00458 }
aic23b_aapc_t aic23b_get_analog_audio_path | ( | void | ) |
Gets the analog audio path.
Definition at line 522 of file tlv320aic23b_with_cs2200.c.
References AIC23B_AAPC, aic23b_read_reg(), and aic23b_aapc_t::data.
00523 { 00524 aic23b_aapc_t aapc; 00525 aapc.data = aic23b_read_reg(AIC23B_AAPC); 00526 return aapc; 00527 }
aic23b_dapc_t aic23b_get_digital_audio_path | ( | void | ) |
Gets the digital audio path.
Definition at line 536 of file tlv320aic23b_with_cs2200.c.
References AIC23B_DAPC, aic23b_read_reg(), and aic23b_dapc_t::data.
00537 { 00538 aic23b_dapc_t dapc; 00539 dapc.data = aic23b_read_reg(AIC23B_DAPC); 00540 return dapc; 00541 }
S8 aic23b_get_headphone_volume | ( | U8 | ch | ) |
Gets the ch channel headphone volume.
Definition at line 470 of file tlv320aic23b_with_cs2200.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.
00471 { 00472 switch (ch) 00473 { 00474 case AIC23B_LEFT_CHANNEL: 00475 { 00476 aic23b_lchvc_t lchvc; 00477 lchvc.data = aic23b_read_reg(AIC23B_LCHVC); 00478 return (lchvc.lhv < AIC23B_HP_VOL_MIN + AIC23B_HP_VOL_OFFSET) ? 00479 AIC23B_MUTED : 00480 lchvc.lhv - AIC23B_HP_VOL_OFFSET; 00481 } 00482 case AIC23B_RIGHT_CHANNEL: 00483 { 00484 aic23b_rchvc_t rchvc; 00485 rchvc.data = aic23b_read_reg(AIC23B_RCHVC); 00486 return (rchvc.rhv < AIC23B_HP_VOL_MIN + AIC23B_HP_VOL_OFFSET) ? 00487 AIC23B_MUTED : 00488 rchvc.rhv - AIC23B_HP_VOL_OFFSET; 00489 } 00490 default: 00491 return AIC23B_MUTED; 00492 } 00493 }
S8 aic23b_get_line_in_volume | ( | U8 | ch | ) |
Gets the ch line input channel volume.
Definition at line 379 of file tlv320aic23b_with_cs2200.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.
00380 { 00381 switch (ch) 00382 { 00383 case AIC23B_LEFT_CHANNEL: 00384 { 00385 aic23b_llicvc_t llicvc; 00386 llicvc.data = aic23b_read_reg(AIC23B_LLICVC); 00387 return (llicvc.lim) ? 00388 AIC23B_MUTED : 00389 llicvc.liv - AIC23B_LIN_VOL_OFFSET; 00390 } 00391 case AIC23B_RIGHT_CHANNEL: 00392 { 00393 aic23b_rlicvc_t rlicvc; 00394 rlicvc.data = aic23b_read_reg(AIC23B_RLICVC); 00395 return (rlicvc.rim) ? 00396 AIC23B_MUTED : 00397 rlicvc.riv - AIC23B_LIN_VOL_OFFSET; 00398 } 00399 default: 00400 return AIC23B_MUTED; 00401 } 00402 }
aic23b_pdc_t aic23b_get_power_down_state | ( | void | ) |
Gets the power down state.
Definition at line 550 of file tlv320aic23b_with_cs2200.c.
References AIC23B_PDC, aic23b_read_reg(), and aic23b_pdc_t::data.
00551 { 00552 aic23b_pdc_t pdc; 00553 pdc.data = aic23b_read_reg(AIC23B_PDC); 00554 return pdc; 00555 }
Bool aic23b_is_dig_audio_activated | ( | void | ) |
Tells whether the digital audio interface is activated.
Definition at line 564 of file tlv320aic23b_with_cs2200.c.
References aic23b_dia_t::act, AIC23B_DIA, aic23b_read_reg(), and aic23b_dia_t::data.
00565 { 00566 aic23b_dia_t dia; 00567 dia.data = aic23b_read_reg(AIC23B_DIA); 00568 return dia.act; 00569 }
U16 aic23b_read_reg | ( | U8 | reg | ) |
Reads the reg register.
Definition at line 352 of file tlv320aic23b_with_cs2200.c.
References AIC23B_REG_COUNT, and aic23b_ctrl_t::data.
00353 { 00354 if (reg >= AIC23B_REG_COUNT) return 0x0000; 00355 return aic23b_ctrl[reg].data; 00356 }
void aic23b_reset | ( | void | ) |
Resets the CODEC.
Definition at line 581 of file tlv320aic23b_with_cs2200.c.
References AIC23B_DEFAULT, AIC23B_OFFSET, aic23b_read_reg(), AIC23B_RR, aic23b_write_reg(), aic23b_rr_t::data, and aic23b_rr_t::res.
00582 { 00583 aic23b_rr_t rr; 00584 rr.data = aic23b_read_reg(AIC23B_RR); 00585 rr.res = AIC23B_DEFAULT(AIC23B_RR) >> AIC23B_OFFSET(AIC23B_RR, RES); 00586 aic23b_write_reg(AIC23B_RR, rr.data); 00587 }
void aic23b_set_analog_audio_path | ( | aic23b_aapc_t | aapc | ) |
Sets the analog audio path to aapc.
Definition at line 530 of file tlv320aic23b_with_cs2200.c.
References AIC23B_AAPC, aic23b_write_reg(), and aic23b_aapc_t::data.
00531 { 00532 aic23b_write_reg(AIC23B_AAPC, aapc.data); 00533 }
void aic23b_set_digital_audio_path | ( | aic23b_dapc_t | dapc | ) |
Sets the digital audio path to dapc.
Definition at line 544 of file tlv320aic23b_with_cs2200.c.
References AIC23B_DAPC, aic23b_write_reg(), and aic23b_dapc_t::data.
00545 { 00546 aic23b_write_reg(AIC23B_DAPC, dapc.data); 00547 }
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 495 of file tlv320aic23b_with_cs2200.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.
00496 { 00497 if (ch_mask & AIC23B_LEFT_CHANNEL) 00498 { 00499 aic23b_lchvc_t lchvc; 00500 lchvc.data = aic23b_read_reg(AIC23B_LCHVC); 00501 lchvc.lrs = ((ch_mask & AIC23B_RIGHT_CHANNEL) != 0); 00502 lchvc.lzc = z_cross; 00503 lchvc.lhv = (vol < AIC23B_HP_VOL_MIN) ? 00504 0 : 00505 min(vol, AIC23B_HP_VOL_MAX) + AIC23B_HP_VOL_OFFSET; 00506 aic23b_write_reg(AIC23B_LCHVC, lchvc.data); 00507 } 00508 if (ch_mask & AIC23B_RIGHT_CHANNEL) 00509 { 00510 aic23b_rchvc_t rchvc; 00511 rchvc.data = aic23b_read_reg(AIC23B_RCHVC); 00512 rchvc.rls = 0; 00513 rchvc.rzc = z_cross; 00514 rchvc.rhv = (vol < AIC23B_HP_VOL_MIN) ? 00515 0 : 00516 min(vol, AIC23B_HP_VOL_MAX) + AIC23B_HP_VOL_OFFSET; 00517 aic23b_write_reg(AIC23B_RCHVC, rchvc.data); 00518 } 00519 }
void aic23b_set_line_in_volume | ( | U8 | ch_mask, | |
S8 | vol | |||
) |
Sets the ch_mask line input channels volume to vol.
Definition at line 405 of file tlv320aic23b_with_cs2200.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.
00406 { 00407 if (ch_mask & AIC23B_LEFT_CHANNEL) 00408 { 00409 aic23b_llicvc_t llicvc; 00410 llicvc.data = aic23b_read_reg(AIC23B_LLICVC); 00411 llicvc.lrs = ((ch_mask & AIC23B_RIGHT_CHANNEL) != 0); 00412 if (vol < AIC23B_LIN_VOL_MIN) llicvc.lim = 1; 00413 else 00414 { 00415 llicvc.lim = 0; 00416 llicvc.liv = min(vol, AIC23B_LIN_VOL_MAX) + AIC23B_LIN_VOL_OFFSET; 00417 } 00418 aic23b_write_reg(AIC23B_LLICVC, llicvc.data); 00419 } 00420 else if (ch_mask & AIC23B_RIGHT_CHANNEL) 00421 { 00422 aic23b_rlicvc_t rlicvc; 00423 rlicvc.data = aic23b_read_reg(AIC23B_RLICVC); 00424 rlicvc.rls = 0; 00425 if (vol < AIC23B_LIN_VOL_MIN) rlicvc.rim = 1; 00426 else 00427 { 00428 rlicvc.rim = 0; 00429 rlicvc.riv = min(vol, AIC23B_LIN_VOL_MAX) + AIC23B_LIN_VOL_OFFSET; 00430 } 00431 aic23b_write_reg(AIC23B_RLICVC, rlicvc.data); 00432 } 00433 }
void aic23b_set_power_down_state | ( | aic23b_pdc_t | pdc | ) |
Sets the power down state to pdc.
Definition at line 558 of file tlv320aic23b_with_cs2200.c.
References AIC23B_PDC, aic23b_write_reg(), and aic23b_pdc_t::data.
00559 { 00560 aic23b_write_reg(AIC23B_PDC, pdc.data); 00561 }
static void aic23b_ssc_rx_pdca_int_handler | ( | void | ) | [static] |
SSC RX PDCA interrupt handler managing the out-of-samples condition.
Definition at line 216 of file tlv320aic23b_with_cs2200.c.
References aic23b_output_params, and AIC23B_SSC_RX_PDCA_CHANNEL.
00217 { 00218 if (pdca_get_transfer_status(AIC23B_SSC_RX_PDCA_CHANNEL) & PDCA_TRANSFER_COMPLETE) 00219 { 00220 pdca_disable_interrupt_transfer_complete(AIC23B_SSC_RX_PDCA_CHANNEL); 00221 if (aic23b_output_params.callback_opt & AUDIO_ADC_OUT_OF_SAMPLE_CB) 00222 aic23b_output_params.callback(AUDIO_ADC_OUT_OF_SAMPLE_CB); 00223 } 00224 00225 if (pdca_get_transfer_status(AIC23B_SSC_RX_PDCA_CHANNEL) & PDCA_TRANSFER_COUNTER_RELOAD_IS_ZERO) 00226 { 00227 pdca_disable_interrupt_reload_counter_zero(AIC23B_SSC_RX_PDCA_CHANNEL); 00228 if (aic23b_output_params.callback_opt & AUDIO_ADC_RELOAD_CB) 00229 aic23b_output_params.callback(AUDIO_ADC_RELOAD_CB); 00230 } 00231 }
static void aic23b_ssc_tx_pdca_int_handler | ( | void | ) | [static] |
SSC TX PDCA interrupt handler managing the out-of-samples condition.
Definition at line 189 of file tlv320aic23b_with_cs2200.c.
References aic23b_output_params, and AIC23B_SSC_TX_PDCA_CHANNEL.
00190 { 00191 if (pdca_get_transfer_status(AIC23B_SSC_TX_PDCA_CHANNEL) & PDCA_TRANSFER_COMPLETE) 00192 { 00193 pdca_disable_interrupt_transfer_complete(AIC23B_SSC_TX_PDCA_CHANNEL); 00194 if (aic23b_output_params.callback_opt & AUDIO_DAC_OUT_OF_SAMPLE_CB) 00195 aic23b_output_params.callback(AUDIO_DAC_OUT_OF_SAMPLE_CB); 00196 } 00197 00198 if (pdca_get_transfer_status(AIC23B_SSC_TX_PDCA_CHANNEL) & PDCA_TRANSFER_COUNTER_RELOAD_IS_ZERO) 00199 { 00200 pdca_disable_interrupt_reload_counter_zero(AIC23B_SSC_TX_PDCA_CHANNEL); 00201 if (aic23b_output_params.callback_opt & AUDIO_DAC_RELOAD_CB) 00202 aic23b_output_params.callback(AUDIO_DAC_RELOAD_CB); 00203 } 00204 }
static void aic23b_write_control_word | ( | aic23b_ctrl_t | ctrl | ) | [static] |
Writes the ctrl control word.
Definition at line 236 of file tlv320aic23b_with_cs2200.c.
00237 { 00238 #if AIC23B_CTRL_INTERFACE == AIC23B_CTRL_INTERFACE_TWI 00239 int twi_status; 00240 aic23b_ctrl_t my_ctrl = ctrl; 00241 twi_package_t twi_package = 00242 { 00243 .chip = AIC23B_TWI_ADDRESS, 00244 .addr_length = AVR32_TWI_MMR_IADRSZ_NO_ADDR, 00245 .buffer = &my_ctrl, 00246 .length = sizeof(my_ctrl) 00247 }; 00248 do 00249 { 00250 twi_status=twi_master_write(AIC23B_TWI, &twi_package); 00251 } 00252 while( twi_status != TWI_SUCCESS ); 00253 #elif AIC23B_CTRL_INTERFACE == AIC23B_CTRL_INTERFACE_SPI 00254 spi_selectChip(AIC23B_SPI, AIC23B_SPI_NPCS); 00255 spi_write(AIC23B_SPI, *(U16 *)&ctrl); 00256 spi_unselectChip(AIC23B_SPI, AIC23B_SPI_NPCS); 00257 #endif 00258 }
void aic23b_write_reg | ( | U8 | reg, | |
U16 | val | |||
) |
Writes val to the reg register.
Definition at line 359 of file tlv320aic23b_with_cs2200.c.
References AIC23B_DEFAULT, AIC23B_REG_COUNT, AIC23B_RR, aic23b_write_control_word(), and aic23b_ctrl_t::data.
00360 { 00361 if (reg >= AIC23B_REG_COUNT) return; 00362 aic23b_ctrl[reg].data = val; 00363 if (reg == AIC23B_RR && aic23b_ctrl[reg].data == AIC23B_DEFAULT(AIC23B_RR)) 00364 { 00365 memcpy(aic23b_ctrl, aic23b_ctrl_reset, sizeof(aic23b_ctrl)); 00366 } 00367 aic23b_write_control_word(aic23b_ctrl[reg]); 00368 }
aic23b_ctrl_t aic23b_ctrl[] = AIC23B_CTRL_RESET [static] |
const aic23b_ctrl_t aic23b_ctrl_reset[] = AIC23B_CTRL_RESET [static] |
struct { ... } aic23b_output_params [static] |
const gpio_map_t AIC23B_SSC_CODEC_GPIO_MAP [static] |
Initial value:
{ {AIC23B_SSC_TX_CLOCK_PIN, AIC23B_SSC_TX_CLOCK_FUNCTION }, {AIC23B_SSC_TX_DATA_PIN, AIC23B_SSC_TX_DATA_FUNCTION }, {AIC23B_SSC_TX_FRAME_SYNC_PIN, AIC23B_SSC_TX_FRAME_SYNC_FUNCTION }, {AIC23B_SSC_RX_DATA_PIN, AIC23B_SSC_RX_DATA_FUNCTION }, {AIC23B_SSC_RX_FRAME_SYNC_PIN, AIC23B_SSC_RX_FRAME_SYNC_FUNCTION } }
Definition at line 129 of file tlv320aic23b_with_cs2200.c.
void(* callback)(U32 arg) |
U32 callback_opt |
Definition at line 172 of file tlv320aic23b_with_cs2200.c.
U8 num_channels |
Definition at line 170 of file tlv320aic23b_with_cs2200.c.