Definition in file tpa6130.c.
#include "pdca.h"
#include "abdac.h"
#include "gpio.h"
#include "intc.h"
#include "board.h"
#include "tpa6130.h"
#include "conf_tpa6130.h"
#include "audio.h"
#include "twi.h"
Go to the source code of this file.
Defines | |
#define | BRIDGE_TIED_LOAD 0x20 |
#define | DUAL_MONO_HP 0x10 |
#define | HIZ_L 0x80 |
#define | HIZ_R 0x40 |
#define | HP_EN_L 0x80 |
#define | HP_EN_R 0x40 |
#define | MUTE_L 0x80 |
#define | MUTE_R 0x40 |
#define | STEREO_HP 0x00 |
#define | SW_SHUTDOWN 0x01 |
#define | THERMAL 0x02 |
#define | TPA6130_CONTROL 0x1 |
#define | TPA6130_CONTROL_DEFAULT 0x00 |
#define | TPA6130_I2C_ADDRESS_VERSION 0x4 |
#define | TPA6130_I2C_ADDRESS_VERSION_DEFAULT 0x02 |
#define | TPA6130_MAX_VOLUME 0x3F |
#define | TPA6130_OUTPUT_IMPEDANCE 0x3 |
#define | TPA6130_OUTPUT_IMPEDANCE_DEFAULT 0x00 |
#define | TPA6130_VOLUME_AND_MUTE 0x2 |
#define | TPA6130_VOLUME_AND_MUTE_DEFAULT 0x0F |
#define | TWI_READ_HW 0 |
#define | TWI_READ_SR 1 |
#define | VERSION 0x02 |
Functions | |
static void | tpa6130_abdac_tx_pdca_int_handler (void) |
void | tpa6130_dac_decrease_volume (void) |
Decreases the output volume of the amplifier by one step. | |
void | tpa6130_dac_flush (void) |
Flushes the sample buffer being output to the ABDAC. | |
U8 | tpa6130_dac_get_volume (void) |
Returns the current volume of the DAC. The volume is in the range 0 - 255. | |
void | tpa6130_dac_increase_volume (void) |
Increases the output volume of the amplifier by one step. Stops at the maximum volume and thus does not wrap to the lowest volume. | |
Bool | tpa6130_dac_is_volume_boosted (void) |
Returns the state of the boost mode of the DAC. | |
Bool | tpa6130_dac_is_volume_muted (void) |
Returns the state of the mute mode of the DAC. | |
void | tpa6130_dac_mute (Bool mute) |
No more audio if input is true. | |
Bool | tpa6130_dac_output (void *sample_buffer, size_t sample_length) |
Outputs a sample buffer to the DACs. The input requires a sample buffer that consists of words (32-bit) which contain two (16-bit) samples, one for each channel. | |
void | tpa6130_dac_set_volume (U8 volume) |
Set the volume of the DAC. | |
void | tpa6130_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 DACs up with new settings. | |
void | tpa6130_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 ABDAC. | |
void | tpa6130_dac_stop (void) |
Stops the ABDAC and puts the amplifier in low power mode. Additionally it sets all used pins to the GPIO state. The counter part of this function is tpa6130_dac_start(...). | |
S8 | tpa6130_get_volume (void) |
Gets the current volume settings. | |
S8 | tpa6130_init (void) |
Probes and initializes the amplifier. Probes the TWI bus for the amplifier by using the slave address specified in the configuration (TPA6130_TWI_ADDRESS). If the device responds with an ACK the version register is read out and compared to the valid versions (TPA6130_VERSION). Last step is to set volume to 0, unmute and set the configuration specified in the conf_tpa6130.h file (stereo, mono ..). | |
void | tpa6130_powerup (void) |
Powers up the amplifier from low power mode. | |
static U8 | tpa6130_read_data (U8 reg, Bool shadow) |
Reads data from a register. The shadow parameter is used to specify if the data should be read from a driver internal register shadowing or directly from the device. | |
void | tpa6130_set_volume (S8 volume) |
Sets the volume of the amplifier. Valid values are between 0 (min -59dB) and 63 (max 4dB) altough the function takes care of any values higher than that by setting it to max. A volume of 0 will mute both channels. Any other value will unmute them. | |
void | tpa6130_shutdown (void) |
Shuts down the amplifier and sets it into low power mode. This is the software low power mode described in the datasheet. | |
static void | tpa6130_write_data (U8 reg, U8 data) |
Writes data to a register. | |
Variables | |
static const gpio_map_t | TPA6130_ABDAC_GPIO_MAP |
struct { | |
void(* callback )(U32 arg) | |
U32 callback_opt | |
U8 num_channels | |
} | tpa6130_output_param |
struct { | |
U8 control | |
U8 i2c_address_version | |
U8 output_impedance | |
U8 volume_and_mute | |
} | tpa6130_shadow_regs |
#define HP_EN_L 0x80 |
#define HP_EN_R 0x40 |
#define MUTE_L 0x80 |
Definition at line 85 of file tpa6130.c.
Referenced by tpa6130_dac_decrease_volume(), tpa6130_dac_get_volume(), tpa6130_dac_increase_volume(), tpa6130_dac_mute(), and tpa6130_set_volume().
#define MUTE_R 0x40 |
Definition at line 86 of file tpa6130.c.
Referenced by tpa6130_dac_decrease_volume(), tpa6130_dac_get_volume(), tpa6130_dac_increase_volume(), tpa6130_dac_mute(), and tpa6130_set_volume().
#define SW_SHUTDOWN 0x01 |
#define TPA6130_CONTROL 0x1 |
Definition at line 64 of file tpa6130.c.
Referenced by tpa6130_init(), tpa6130_powerup(), and tpa6130_shutdown().
#define TPA6130_I2C_ADDRESS_VERSION 0x4 |
#define TPA6130_VOLUME_AND_MUTE 0x2 |
Definition at line 65 of file tpa6130.c.
Referenced by tpa6130_dac_mute(), tpa6130_get_volume(), tpa6130_init(), and tpa6130_set_volume().
#define TWI_READ_HW 0 |
Definition at line 100 of file tpa6130.c.
Referenced by tpa6130_init(), tpa6130_powerup(), and tpa6130_shutdown().
#define TWI_READ_SR 1 |
#define VERSION 0x02 |
static void tpa6130_abdac_tx_pdca_int_handler | ( | void | ) | [static] |
Definition at line 198 of file tpa6130.c.
References tpa6130_output_param.
Referenced by tpa6130_dac_start().
00199 { 00200 if (pdca_get_transfer_status(TPA6130_ABDAC_PDCA_CHANNEL) & PDCA_TRANSFER_COMPLETE) 00201 { 00202 pdca_disable_interrupt_transfer_complete(TPA6130_ABDAC_PDCA_CHANNEL); 00203 if (tpa6130_output_param.callback_opt & AUDIO_DAC_OUT_OF_SAMPLE_CB) 00204 tpa6130_output_param.callback(AUDIO_DAC_OUT_OF_SAMPLE_CB); 00205 } 00206 00207 if (pdca_get_transfer_status(TPA6130_ABDAC_PDCA_CHANNEL) & PDCA_TRANSFER_COUNTER_RELOAD_IS_ZERO) 00208 { 00209 pdca_disable_interrupt_reload_counter_zero(TPA6130_ABDAC_PDCA_CHANNEL); 00210 if (tpa6130_output_param.callback_opt & AUDIO_DAC_RELOAD_CB) 00211 tpa6130_output_param.callback(AUDIO_DAC_RELOAD_CB); 00212 } 00213 }
void tpa6130_dac_decrease_volume | ( | void | ) |
Decreases the output volume of the amplifier by one step.
Decreases the output volume of the DACs.
Stops at the lowest possible volume.
Definition at line 621 of file tpa6130.c.
00622 { 00623 S8 volume = tpa6130_get_volume()& (~(MUTE_L | MUTE_R));; 00624 if( volume > TPA6130_VOL_MIN ) 00625 --volume; 00626 tpa6130_set_volume( volume ); 00627 }
void tpa6130_dac_flush | ( | void | ) |
Flushes the sample buffer being output to the ABDAC.
Flushes the sample buffer being output to the DACs.
Definition at line 631 of file tpa6130.c.
00632 { 00633 pdca_disable_interrupt_transfer_complete(TPA6130_ABDAC_PDCA_CHANNEL); 00634 pdca_disable_interrupt_reload_counter_zero(TPA6130_ABDAC_PDCA_CHANNEL); 00635 00636 /*TODO Do we really want to wait here? Or do we just don't care when 00637 * the buffer is empty/flushed */ 00638 //while(!pdca_get_transfer_status(TPA6130_ABDAC_PDCA_CHANNEL) & 00639 // PDCA_TRANSFER_COMPLETE); 00640 pdca_disable (TPA6130_ABDAC_PDCA_CHANNEL ); 00641 pdca_load_channel (TPA6130_ABDAC_PDCA_CHANNEL,0x0, 0); 00642 pdca_reload_channel(TPA6130_ABDAC_PDCA_CHANNEL,0x0, 0); 00643 pdca_enable (TPA6130_ABDAC_PDCA_CHANNEL ); 00644 }
U8 tpa6130_dac_get_volume | ( | void | ) |
Returns the current volume of the DAC. The volume is in the range 0 - 255.
Returns the current volume of the DAC.
Definition at line 587 of file tpa6130.c.
00588 { 00589 // return volume is num display step for LCD 00590 // volume scale is between 10 and 245 00591 // 0 is -100db 00592 // 245 is max volume 00593 U16 raw_volume; 00594 raw_volume = (tpa6130_get_volume() & (~(MUTE_L | MUTE_R))); 00595 return (U8) ((raw_volume * 255) / TPA6130_VOL_MAX); 00596 }
void tpa6130_dac_increase_volume | ( | void | ) |
Increases the output volume of the amplifier by one step. Stops at the maximum volume and thus does not wrap to the lowest volume.
Increases the output volume of the DACs.
Definition at line 609 of file tpa6130.c.
00610 { 00611 S8 volume = tpa6130_get_volume()& (~(MUTE_L | MUTE_R)); 00612 if( volume < TPA6130_VOL_MIN ) 00613 volume = TPA6130_VOL_MIN; 00614 tpa6130_set_volume(volume+1); 00615 }
Bool tpa6130_dac_is_volume_boosted | ( | void | ) |
Bool tpa6130_dac_is_volume_muted | ( | void | ) |
void tpa6130_dac_mute | ( | Bool | mute | ) |
No more audio if input is true.
Definition at line 527 of file tpa6130.c.
00528 { 00529 // //1st Version Mute Audio for Play/Pause 00530 /* int volume=tpa6130_get_volume(); 00531 if(mute==TRUE) { 00532 //Mute volume 00533 volume= volume|MUTE_L|MUTE_R; 00534 } 00535 else { 00536 //Unmute volume 00537 volume= volume&(~(MUTE_L|MUTE_R)); 00538 00539 } 00540 tpa6130_write_data(TPA6130_VOLUME_AND_MUTE,volume); 00541 */ 00542 //2n Version Stop PDCA >> No lost of audio when pause 00543 /* if(mute==TRUE) { 00544 pdca_disable(TPA6130_ABDAC_PDCA_CHANNEL); 00545 } 00546 else { 00547 pdca_enable(TPA6130_ABDAC_PDCA_CHANNEL); 00548 } 00549 */ 00550 00551 // 3rd Version wait until the current buffers are empty and disable the interrutps 00552 S8 volume = tpa6130_get_volume(); 00553 if (mute) 00554 { 00555 U32 save_dac_reload_callback_opt; 00556 00557 // Mute the audio stream 00558 volume = volume | MUTE_L | MUTE_R; 00559 tpa6130_write_data(TPA6130_VOLUME_AND_MUTE, volume); 00560 // Disable the reload channel of the interrupt 00561 save_dac_reload_callback_opt = tpa6130_output_param.callback_opt; 00562 tpa6130_output_param.callback_opt = 0; 00563 // Disable the reload interruption and wait until the transfer is complete 00564 pdca_disable_interrupt_reload_counter_zero(TPA6130_ABDAC_PDCA_CHANNEL); 00565 while (!(pdca_get_transfer_status(TPA6130_ABDAC_PDCA_CHANNEL) & PDCA_TRANSFER_COMPLETE)); 00566 // Restore the reload callback function 00567 tpa6130_output_param.callback_opt = save_dac_reload_callback_opt; 00568 } 00569 else 00570 { 00571 // Re-enable the interrupts 00572 pdca_enable_interrupt_reload_counter_zero(TPA6130_ABDAC_PDCA_CHANNEL); 00573 // Un-mute the audio stream 00574 volume = volume & (~(MUTE_L | MUTE_R)); 00575 tpa6130_write_data(TPA6130_VOLUME_AND_MUTE, volume); 00576 } 00577 }
Bool tpa6130_dac_output | ( | void * | sample_buffer, | |
size_t | sample_length | |||
) |
Outputs a sample buffer to the DACs. The input requires a sample buffer that consists of words (32-bit) which contain two (16-bit) samples, one for each channel.
Outputs a sample buffer to the DACs.
Definition at line 481 of file tpa6130.c.
Referenced by main().
00482 { 00483 //int global_interrupt_enabled; 00484 00485 /*Wait until the PDCA loads the reload value to its transfer 00486 * counter register(TCRR=0). Then we are ready to set up a new 00487 * transfer */ 00488 if(!(pdca_get_transfer_status(TPA6130_ABDAC_PDCA_CHANNEL) & 00489 PDCA_TRANSFER_COUNTER_RELOAD_IS_ZERO)) 00490 { 00491 return FALSE; 00492 } 00493 00494 /* Nothing to do if we get no data. */ 00495 if(sample_length) 00496 { 00497 00498 /*TODO Do we really need to adjust the buffer for mono*/ 00499 00500 /* While reloading the PDC we do not need any active interrupt*/ 00501 //if((global_interrupt_enabled = Is_global_interrupt_enabled())) 00502 // Disable_global_interrupt(); 00503 00504 /*FIXME This assumes a stereo 16-bit sample size */ 00505 // one sample here consists of 2x16-bit (16-bit stereo) 00506 pdca_reload_channel(TPA6130_ABDAC_PDCA_CHANNEL, 00507 sample_buffer, sample_length); 00508 00509 //if(global_interrupt_enabled) 00510 // Enable_global_interrupt(); 00511 00512 /*TODO enable transfer complete interrupt 00513 * Is it possible to move this to setup or other places?*/ 00514 if(tpa6130_output_param.callback_opt & AUDIO_DAC_OUT_OF_SAMPLE_CB) 00515 pdca_enable_interrupt_transfer_complete(TPA6130_ABDAC_PDCA_CHANNEL); 00516 if (tpa6130_output_param.callback_opt & AUDIO_DAC_RELOAD_CB) 00517 pdca_enable_interrupt_reload_counter_zero(TPA6130_ABDAC_PDCA_CHANNEL); 00518 } 00519 return TRUE; 00520 }
void tpa6130_dac_set_volume | ( | U8 | volume | ) |
Set the volume of the DAC.
Definition at line 600 of file tpa6130.c.
00601 { 00602 tpa6130_set_volume(volume); 00603 }
void tpa6130_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 DACs up with new settings.
Definition at line 407 of file tpa6130.c.
Referenced by tpa6130_dac_start().
00414 { 00415 // save input parameters to local driver data 00416 tpa6130_output_param.num_channels = num_channels; 00417 tpa6130_output_param.callback = callback; 00418 tpa6130_output_param.callback_opt = callback_opt; 00419 00420 /* Probe for amplifier and initialize it */ 00421 tpa6130_init(); 00422 00423 #if defined(TPA6130_DAC_CLOCK_SET_CALLBACK) 00424 TPA6130_DAC_CLOCK_SET_CALLBACK(sample_rate_hz); 00425 #else 00426 /* ABDAC configuration 00427 * The ABDAC needs the input frequency of its generic clock (bus_hz) 00428 * Here we use the configuration value from the conf_tpa6130.h file 00429 * (TPA6130_ABDAC_GCLK_INPUT_HZ). 00430 * The sample rate specifies the desired sample rate for the ABDAC. 00431 * The generic clock input must be greater than 256*sample_rate_hz 00432 * or the setup of the ABDAC will fail silently here. 00433 * TODO we could add asserts here to detect wrong settings during 00434 * compile time. 00435 */ 00436 if(!abdac_set_dac_sample_rate(sample_rate_hz)) { 00437 // if it is not possible to set correctly the sample rate 00438 // Use default set function 00439 abdac_set_dac_hz(TPA6130_ABDAC, TPA6130_ABDAC_GCLK_INPUT_HZ,sample_rate_hz); 00440 } 00441 #endif 00442 00443 if(swap_channels) 00444 { 00445 abdac_swap_channels(TPA6130_ABDAC); 00446 } 00447 abdac_enable(TPA6130_ABDAC); 00448 00449 /* PDCA setup */ 00450 /*FIXME we use only word as transfer size for now. 00451 * half-word transfer size will only write to channel0 00452 * of the ABDAC, this can be used to implement mono */ 00453 pdca_channel_options_t tpa6130_abdac_pdca_options = 00454 { 00455 .addr = NULL, 00456 .size = 0, 00457 .r_addr = 0, 00458 .r_size = 0, 00459 .pid = TPA6130_ABDAC_PDCA_PID, 00460 .transfer_size = PDCA_TRANSFER_SIZE_WORD 00461 }; 00462 00463 /* Initialize the PCDA for the ABDAC 00464 * The channel number can be set in the configuration file 00465 * with the define TPA6130_ABDAC_PDCA_CHANNEL. 00466 */ 00467 pdca_init_channel(TPA6130_ABDAC_PDCA_CHANNEL, 00468 &tpa6130_abdac_pdca_options); 00469 /* Enable the PDCA channel. Since we did not provide any data 00470 * yet the channel is in idle mode */ 00471 pdca_enable(TPA6130_ABDAC_PDCA_CHANNEL); 00472 00473 }
void tpa6130_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 ABDAC.
sample_rate_hz | Sample rate for the ABDAC. | |
num_channels | number of channel | |
bits_per_sample | number of bit per sample | |
swap_channels | TRUE -> swap the channels | |
callback | Provide a functions that handles callback. | |
callback_opt | Callback flag | |
pba_hz | Speed of the peripheral bus A. |
Definition at line 367 of file tpa6130.c.
Referenced by main().
00374 { 00375 /* stop ABDAC if running*/ 00376 tpa6130_dac_stop(); 00377 00378 /* configure used pins for ABDAC */ 00379 gpio_enable_module(TPA6130_ABDAC_GPIO_MAP, 00380 sizeof(TPA6130_ABDAC_GPIO_MAP) / 00381 sizeof(TPA6130_ABDAC_GPIO_MAP[0])); 00382 00383 /* configure and start PDC and ABDAC*/ 00384 tpa6130_dac_setup(sample_rate_hz, 00385 num_channels, 00386 bits_per_sample, 00387 swap_channels, 00388 callback, 00389 callback_opt, 00390 pba_hz); 00391 00392 /* Register a interrupt service routine for the ABDAC channel of 00393 * the PDCA 00394 */ 00395 INTC_register_interrupt(&tpa6130_abdac_tx_pdca_int_handler, 00396 TPA6130_ABDAC_PDCA_IRQ, 00397 TPA6130_ABDAC_PDCA_INT_LEVEL); 00398 00399 tpa6130_powerup(); 00400 00401 }
void tpa6130_dac_stop | ( | void | ) |
Stops the ABDAC and puts the amplifier in low power mode. Additionally it sets all used pins to the GPIO state. The counter part of this function is tpa6130_dac_start(...).
Stops the DACs.
Definition at line 650 of file tpa6130.c.
Referenced by tpa6130_dac_start().
00651 { 00652 /* Disable amplifier 1st */ 00653 tpa6130_shutdown(); 00654 00655 /* Flush the dac */ 00656 // Don't flush the DAC when stop 00657 //tpa6130_dac_flush(); 00658 00659 /* Disable ABDAC */ 00660 abdac_disable(TPA6130_ABDAC); 00661 00662 /* Stop PDCA */ 00663 pdca_disable(TPA6130_ABDAC_PDCA_CHANNEL); 00664 00665 /* Set used GPIO pins to GPIO state */ 00666 gpio_enable_gpio(TPA6130_ABDAC_GPIO_MAP, 00667 sizeof(TPA6130_ABDAC_GPIO_MAP) 00668 / sizeof(TPA6130_ABDAC_GPIO_MAP[0])); 00669 00670 tpa6130_output_param.num_channels = 0; 00671 tpa6130_output_param.callback = NULL; 00672 tpa6130_output_param.callback_opt = 0; 00673 }
S8 tpa6130_get_volume | ( | void | ) |
Gets the current volume settings.
Definition at line 353 of file tpa6130.c.
Referenced by main(), tpa6130_dac_decrease_volume(), tpa6130_dac_get_volume(), tpa6130_dac_increase_volume(), and tpa6130_dac_mute().
00354 { 00355 return tpa6130_read_data(TPA6130_VOLUME_AND_MUTE, TWI_READ_SR); 00356 }
S8 tpa6130_init | ( | void | ) |
Probes and initializes the amplifier. Probes the TWI bus for the amplifier by using the slave address specified in the configuration (TPA6130_TWI_ADDRESS). If the device responds with an ACK the version register is read out and compared to the valid versions (TPA6130_VERSION). Last step is to set volume to 0, unmute and set the configuration specified in the conf_tpa6130.h file (stereo, mono ..).
Definition at line 289 of file tpa6130.c.
Referenced by main(), and tpa6130_dac_setup().
00290 { 00291 /* Check if the device responds on the TWI bus*/ 00292 if(twi_probe(TPA6130_TWI, TPA6130_TWI_ADDRESS) != TWI_SUCCESS) 00293 return TWI_NO_CHIP_FOUND; 00294 /* If the device has no valid version we can not use it */ 00295 if(tpa6130_read_data(TPA6130_I2C_ADDRESS_VERSION, TWI_READ_HW)!= VERSION) 00296 { 00297 return -8; 00298 } 00299 /* un-mute the output channels, the volume is still 0 and 00300 * should be increased by an application (fade-in/fade-out) */ 00301 tpa6130_write_data(TPA6130_VOLUME_AND_MUTE, tpa6130_shadow_regs.volume_and_mute); 00302 /* set stereo/mono mode and enable both amplifiers (left/right) */ 00303 tpa6130_write_data(TPA6130_CONTROL,(TPA6130_MODE << 4) | HP_EN_L | HP_EN_R); 00304 00305 return TWI_SUCCESS; 00306 }
void tpa6130_powerup | ( | void | ) |
Powers up the amplifier from low power mode.
Powers up the amplifier from low power mode. This is the software low power mode described in the datasheet.
Definition at line 319 of file tpa6130.c.
Referenced by tpa6130_dac_start().
00320 { 00321 U8 data; 00322 data = tpa6130_read_data(TPA6130_CONTROL, TWI_READ_HW); 00323 tpa6130_write_data(TPA6130_CONTROL, data & (~SW_SHUTDOWN)); 00324 }
static U8 tpa6130_read_data | ( | U8 | reg, | |
Bool | shadow | |||
) | [static] |
Reads data from a register. The shadow parameter is used to specify if the data should be read from a driver internal register shadowing or directly from the device.
reg | Register index. | |
shadow | Read from device (shadow=FALSE) or from shadowed register (shadow=TRUE). |
Definition at line 250 of file tpa6130.c.
References tpa6130_shadow_regs, and TPA6130_TWI_ADDRESS.
Referenced by tpa6130_get_volume(), tpa6130_init(), tpa6130_powerup(), and tpa6130_shutdown().
00251 { 00252 U8 data; 00253 /*If we want to read from the shadowed registers */ 00254 if(shadow) 00255 { 00256 data = *((U8 *) &tpa6130_shadow_regs + reg - 1); 00257 } 00258 else 00259 { 00260 twi_package_t twi_package = 00261 { 00262 .chip = TPA6130_TWI_ADDRESS, 00263 .addr_length = 1,//AVR32_TWI_MMR_IADRSZ_ONE_BYTE, 00264 .addr = reg, 00265 .buffer = &data, 00266 .length = sizeof(data) 00267 }; 00268 twi_master_read(TPA6130_TWI, &twi_package); 00269 } 00270 //print_dbg("Read reg "); 00271 //print_dbg_ulong(reg); 00272 //print_dbg(" = 0x"); 00273 //print_dbg_hex(data); 00274 //print_dbg("\n"); 00275 00276 return data; 00277 }
void tpa6130_set_volume | ( | S8 | volume | ) |
Sets the volume of the amplifier. Valid values are between 0 (min -59dB) and 63 (max 4dB) altough the function takes care of any values higher than that by setting it to max. A volume of 0 will mute both channels. Any other value will unmute them.
Sets the volume of the amplifier. Valid values are between 0 (min -59dB) and 63 (max 4dB) altough the function takes care of any values higher than that by setting it to max.
Definition at line 332 of file tpa6130.c.
Referenced by main(), tpa6130_dac_decrease_volume(), tpa6130_dac_increase_volume(), and tpa6130_dac_set_volume().
00333 { 00334 S8 new_volume = volume; 00335 00336 if(volume > TPA6130_VOL_MAX) 00337 { 00338 new_volume = TPA6130_VOL_MAX; 00339 } 00340 else if(volume <= TPA6130_VOL_MIN ) 00341 { 00342 // MUTE Left and Right; 00343 new_volume = MUTE_L|MUTE_R; 00344 } 00345 00346 tpa6130_write_data(TPA6130_VOLUME_AND_MUTE, new_volume ); 00347 }
void tpa6130_shutdown | ( | void | ) |
Shuts down the amplifier and sets it into low power mode. This is the software low power mode described in the datasheet.
Definition at line 311 of file tpa6130.c.
Referenced by tpa6130_dac_stop().
00312 { 00313 U8 data; 00314 data = tpa6130_read_data(TPA6130_CONTROL, TWI_READ_HW); 00315 tpa6130_write_data(TPA6130_CONTROL, data | SW_SHUTDOWN); 00316 }
static void tpa6130_write_data | ( | U8 | reg, | |
U8 | data | |||
) | [static] |
Writes data to a register.
reg | Register index. Use the defines in this file. | |
data | Register data. Macros from this file can be used to ease writing to the bitfields. |
Definition at line 220 of file tpa6130.c.
References tpa6130_shadow_regs, and TPA6130_TWI_ADDRESS.
Referenced by tpa6130_dac_mute(), tpa6130_init(), tpa6130_powerup(), tpa6130_set_volume(), and tpa6130_shutdown().
00221 { 00222 U16 message = (reg << 8) | data; 00223 int twi_status; 00224 00225 twi_package_t twi_package = 00226 { 00227 .chip = TPA6130_TWI_ADDRESS, 00228 .addr_length = 0,//AVR32_TWI_MMR_IADRSZ_NO_ADDR, 00229 .buffer = &message, 00230 .length = sizeof(message) 00231 }; 00232 00233 do 00234 { 00235 twi_status=twi_master_write(TPA6130_TWI, &twi_package); 00236 } 00237 while( twi_status != TWI_SUCCESS ); 00238 00239 /* Save write value to shadow registers */ 00240 *(((U8 *) &tpa6130_shadow_regs) + reg - 1) = data; 00241 }
void(* callback)(U32 arg) |
Referenced by tpa6130_dac_setup(), and tpa6130_dac_start().
U32 callback_opt |
U8 num_channels |
const gpio_map_t TPA6130_ABDAC_GPIO_MAP [static] |
Initial value:
{ {TPA6130_DATA0_PIN, TPA6130_DATA0_FUNCTION}, {TPA6130_DATA1_PIN, TPA6130_DATA1_FUNCTION}, {TPA6130_DATAN0_PIN, TPA6130_DATAN0_FUNCTION}, {TPA6130_DATAN1_PIN, TPA6130_DATAN1_FUNCTION} }
Definition at line 111 of file tpa6130.c.
Referenced by tpa6130_dac_start(), and tpa6130_dac_stop().
struct { ... } tpa6130_output_param [static] |
struct { ... } tpa6130_shadow_regs [static] |
Referenced by tpa6130_init(), tpa6130_read_data(), and tpa6130_write_data().