Atmel Software Framework

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AUDIO - TPA6130A2 Audio Amplifier

Software Driver for the TPA6130A2 Audio Amplifier.

The TPA6130A2 is connected to the AVR UC3 through the ABDAC hardware module for the data stream and through the TWI hardware module for the control stream.

Modules

 

Macros

#define TPA6130_MODE_MONO   1
 
#define TPA6130_MODE_STEREO   0
 
#define TPA6130_SIG_DIFF   0
 
#define TPA6130_SIG_POS   1
 
#define TPA6130_TWI_ADDRESS   0x60
 

Functions

void tpa6130_dac_decrease_volume (void)
 Decreases the output volume of the DACs. More...
 
void tpa6130_dac_flush (void)
 Flushes the sample buffer being output to the DACs. More...
 
uint8_t tpa6130_dac_get_volume (void)
 Returns the current volume of the DAC. More...
 
void tpa6130_dac_increase_volume (void)
 Increases the output volume of the DACs. More...
 
bool tpa6130_dac_is_volume_boosted (void)
 Returns the state of the boost mode of the DAC. More...
 
bool tpa6130_dac_is_volume_muted (void)
 Returns the state of the mute mode of the DAC. More...
 
void tpa6130_dac_mute (bool mute)
 No more audio if input is true. More...
 
bool tpa6130_dac_output (void *sample_buffer, size_t sample_length)
 Outputs a sample buffer to the DACs. More...
 
void tpa6130_dac_set_volume (uint8_t volume)
 Set the volume of the DAC. More...
 
void tpa6130_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 DACs up with new settings. More...
 
void tpa6130_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 ABDAC. More...
 
void tpa6130_dac_stop (void)
 Stops the DACs. More...
 
int8_t tpa6130_get_volume (void)
 Gets the current volume settings. More...
 
int8_t 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 ..). More...
 
void tpa6130_powerup (void)
 Powers up the amplifier from low power mode. This is the software low power mode described in the datasheet. More...
 
void tpa6130_set_volume (int8_t volume)
 Sets the volume of the amplifier. Valid values are between 0 (min -59dB) and 63 (max 4dB) although the function takes care of any values higher than that by setting it to max. More...
 
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. More...
 

Volume Control

#define TPA6130_VOL_MIN   ((int8_t)( 0))
 
#define TPA6130_VOL_MAX   ((int8_t)( 63))
 

#define TPA6130_MODE_MONO   1
#define TPA6130_MODE_STEREO   0
#define TPA6130_SIG_DIFF   0
#define TPA6130_SIG_POS   1
#define TPA6130_TWI_ADDRESS   0x60
#define TPA6130_VOL_MAX   ((int8_t)( 63))
#define TPA6130_VOL_MIN   ((int8_t)( 0))

void tpa6130_dac_decrease_volume ( void  )

Decreases the output volume of the DACs.

Note
The DACs must have been started beforehand.

Decreases the output volume of the DACs.

Stops at the lowest possible volume.

References MUTE_L, MUTE_R, tpa6130_get_volume(), tpa6130_set_volume(), TPA6130_VOL_MIN, and volume.

void tpa6130_dac_flush ( void  )

Flushes the sample buffer being output to the DACs.

Flushes the sample buffer being output to the DACs.

References pdca_disable(), pdca_disable_interrupt_reload_counter_zero(), pdca_disable_interrupt_transfer_complete(), pdca_enable(), pdca_load_channel(), pdca_reload_channel(), and TPA6130_ABDAC_PDCA_CHANNEL.

uint8_t tpa6130_dac_get_volume ( void  )

Returns the current volume of the DAC.

Returns the current volume of the DAC.

References MUTE_L, MUTE_R, tpa6130_get_volume(), and TPA6130_VOL_MAX.

void tpa6130_dac_increase_volume ( void  )

Increases the output volume of the DACs.

Note
The DACs must have been started beforehand.

Increases the output volume of the DACs.

References MUTE_L, MUTE_R, tpa6130_get_volume(), tpa6130_set_volume(), TPA6130_VOL_MIN, and volume.

bool tpa6130_dac_is_volume_boosted ( void  )

Returns the state of the boost mode of the DAC.

Note
The DAC must have been started beforehand.
bool tpa6130_dac_is_volume_muted ( void  )

Returns the state of the mute mode of the DAC.

Note
The DAC must have been started beforehand.
bool tpa6130_dac_output ( void *  sample_buffer,
size_t  sample_length 
)

Outputs a sample buffer to the DACs.

Note
The DACs must have been started beforehand.

Outputs a sample buffer to the DACs.

Note
The DACs must have been started beforehand.

References AUDIO_DAC_OUT_OF_SAMPLE_CB, AUDIO_DAC_RELOAD_CB, pdca_enable_interrupt_reload_counter_zero(), pdca_enable_interrupt_transfer_complete(), pdca_get_transfer_status(), pdca_reload_channel(), PDCA_TRANSFER_COUNTER_RELOAD_IS_ZERO, TPA6130_ABDAC_PDCA_CHANNEL, and tpa6130_output_param.

Referenced by main().

void tpa6130_dac_set_volume ( uint8_t  volume)

Set the volume of the DAC.

References tpa6130_set_volume().

void tpa6130_dac_setup ( uint32_t  sample_rate_hz,
uint8_t  num_channels,
uint8_t  bits_per_sample,
bool  swap_channels,
void(*)(uint32_t arg callback,
uint32_t  callback_opt,
uint32_t  pba_hz 
)
void tpa6130_dac_start ( uint32_t  sample_rate_hz,
uint8_t  num_channels,
uint8_t  bits_per_sample,
bool  swap_channels,
void(*)(uint32_t arg callback,
uint32_t  callback_opt,
uint32_t  pba_hz 
)

Starts the ABDAC.

Parameters
sample_rate_hzSample rate for the ABDAC.
num_channelsnumber of channel
bits_per_samplenumber of bit per sample
swap_channelstrue -> swap the channels
callbackProvide a functions that handles callback.
callback_optCallback flag
pba_hzSpeed of the peripheral bus A.

References callback, gpio_enable_module(), irq_register_handler, TPA6130_ABDAC_PDCA_IRQ, tpa6130_dac_setup(), tpa6130_dac_stop(), and tpa6130_powerup().

Referenced by dsp_process_init(), and main().

void tpa6130_dac_stop ( void  )
int8_t tpa6130_get_volume ( void  )

Gets the current volume settings.

Returns
Current volume settings. Value is between 0 (-59dB) and 63 (4dB).

References tpa6130_read_data(), TPA6130_VOLUME_AND_MUTE, and TWI_READ_SR.

Referenced by dsp_process_init(), main(), state_machine_idle(), tpa6130_dac_decrease_volume(), tpa6130_dac_get_volume(), tpa6130_dac_increase_volume(), and tpa6130_dac_mute().

int8_t 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 ..).

Note
This function is called by tpa6130_dac_setup()
Returns
A positive value upon success and a negative value upon failure.
A positive value upon success and a negative value upon failure.

References HP_EN_L, HP_EN_R, TPA6130_CONTROL, TPA6130_I2C_ADDRESS_VERSION, TPA6130_MODE, tpa6130_read_data(), tpa6130_shadow_regs, TPA6130_TWI_ADDRESS, TPA6130_VOLUME_AND_MUTE, tpa6130_write_data(), TWI_NO_CHIP_FOUND, twi_probe(), TWI_READ_HW, TWI_SUCCESS, and VERSION.

Referenced by dsp_process_init(), main(), and tpa6130_dac_setup().

void tpa6130_powerup ( void  )

Powers up the amplifier from low power mode. This is the software low power mode described in the datasheet.

Powers up the amplifier from low power mode. This is the software low power mode described in the datasheet.

References data, SW_SHUTDOWN, TPA6130_CONTROL, tpa6130_read_data(), tpa6130_write_data(), and TWI_READ_HW.

Referenced by tpa6130_dac_start().

void tpa6130_set_volume ( int8_t  volume)

Sets the volume of the amplifier. Valid values are between 0 (min -59dB) and 63 (max 4dB) although the function takes care of any values higher than that by setting it to max.

Sets the volume of the amplifier. Valid values are between 0 (min -59dB) and 63 (max 4dB) although the function takes care of any values higher than that by setting it to max.

References MUTE_L, MUTE_R, TPA6130_VOL_MAX, TPA6130_VOL_MIN, TPA6130_VOLUME_AND_MUTE, tpa6130_write_data(), and volume.

Referenced by dsp_process_init(), main(), state_machine_idle(), tpa6130_dac_decrease_volume(), tpa6130_dac_increase_volume(), and tpa6130_dac_set_volume().

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.

References data, SW_SHUTDOWN, TPA6130_CONTROL, tpa6130_read_data(), tpa6130_write_data(), and TWI_READ_HW.

Referenced by tpa6130_dac_stop().