#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 "twim.h"
Macros | |
#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 | |
ISR (tpa6130_abdac_tx_pdca_int_handler, TPA6130_ABDAC_PDCA_IRQ_GROUP, TPA6130_ABDAC_PDCA_INT_LEVEL) | |
void | tpa6130_dac_decrease_volume (void) |
Decreases the output volume of the amplifier by one step. More... | |
void | tpa6130_dac_flush (void) |
Flushes the sample buffer being output to the ABDAC. More... | |
uint8_t | tpa6130_dac_get_volume (void) |
Returns the current volume of the DAC. The volume is in the range 0 - 255. More... | |
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. 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. The input requires a sample buffer that consists of words (32-bit) which contain two (16-bit) samples, one for each channel. 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 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(...) 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. More... | |
static uint8_t | tpa6130_read_data (uint8_t 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. 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. A volume of 0 will mute both channels. Any other value will unmute them. 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... | |
static void | tpa6130_write_data (uint8_t reg, uint8_t data) |
Writes data to a register. More... | |
Variables | |
static const gpio_map_t | TPA6130_ABDAC_GPIO_MAP |
struct { | |
void(* callback )(uint32_t arg) | |
uint32_t callback_opt | |
uint8_t num_channels | |
} | tpa6130_output_param |
struct { | |
uint8_t control | |
uint8_t i2c_address_version | |
uint8_t output_impedance | |
uint8_t volume_and_mute | |
} | tpa6130_shadow_regs |
Driver internal shadow register set. More... | |
#define BRIDGE_TIED_LOAD 0x20 |
#define DUAL_MONO_HP 0x10 |
#define HIZ_L 0x80 |
#define HIZ_R 0x40 |
#define HP_EN_L 0x80 |
Referenced by tpa6130_init().
#define HP_EN_R 0x40 |
Referenced by tpa6130_init().
#define MUTE_L 0x80 |
#define MUTE_R 0x40 |
#define STEREO_HP 0x00 |
#define SW_SHUTDOWN 0x01 |
Referenced by tpa6130_powerup(), and tpa6130_shutdown().
#define THERMAL 0x02 |
#define TPA6130_CONTROL 0x1 |
Referenced by tpa6130_init(), tpa6130_powerup(), and tpa6130_shutdown().
#define TPA6130_CONTROL_DEFAULT 0x00 |
#define TPA6130_I2C_ADDRESS_VERSION 0x4 |
Referenced by tpa6130_init().
#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 |
Referenced by tpa6130_dac_mute(), tpa6130_get_volume(), tpa6130_init(), and tpa6130_set_volume().
#define TPA6130_VOLUME_AND_MUTE_DEFAULT 0x0F |
#define TWI_READ_HW 0 |
Referenced by tpa6130_init(), tpa6130_powerup(), and tpa6130_shutdown().
#define TWI_READ_SR 1 |
Referenced by tpa6130_get_volume().
#define VERSION 0x02 |
Referenced by tpa6130_init().
ISR | ( | tpa6130_abdac_tx_pdca_int_handler | , |
TPA6130_ABDAC_PDCA_IRQ_GROUP | , | ||
TPA6130_ABDAC_PDCA_INT_LEVEL | |||
) |
|
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). |
References twi_package_t::chip, data, tpa6130_shadow_regs, TPA6130_TWI_ADDRESS, and twi_master_read().
Referenced by tpa6130_get_volume(), tpa6130_init(), tpa6130_powerup(), and tpa6130_shutdown().
|
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. |
References twi_package_t::chip, tpa6130_shadow_regs, TPA6130_TWI_ADDRESS, twi_master_write(), and TWI_SUCCESS.
Referenced by tpa6130_dac_mute(), tpa6130_init(), tpa6130_powerup(), tpa6130_set_volume(), and tpa6130_shutdown().
void(* callback)(uint32_t arg) |
uint32_t callback_opt |
uint8_t control |
uint8_t i2c_address_version |
uint8_t num_channels |
uint8_t output_impedance |
|
static |
struct { ... } tpa6130_output_param |
Referenced by ISR(), tpa6130_dac_mute(), tpa6130_dac_output(), tpa6130_dac_setup(), and tpa6130_dac_stop().
struct { ... } tpa6130_shadow_regs |
Driver internal shadow register set.
Referenced by tpa6130_init(), tpa6130_read_data(), and tpa6130_write_data().
uint8_t volume_and_mute |