This commit is contained in:
Liz 2025-03-27 15:40:01 -04:00
parent c798fc14c9
commit 0422cb7113
3 changed files with 30 additions and 1 deletions

View file

@ -1012,6 +1012,11 @@ bool Adafruit_TLV320DAC3100::getGPIO1Input() {
return gpio1_in.read();
}
/*!
* @brief Set the DIN pin mode
* @param mode The DIN pin mode/function
* @return true: success false: failure
*/
bool Adafruit_TLV320DAC3100::setDINMode(tlv320_din_mode_t mode) {
if (!setPage(0)) {
return false;
@ -1026,6 +1031,10 @@ bool Adafruit_TLV320DAC3100::setDINMode(tlv320_din_mode_t mode) {
return din_mode.write(mode);
}
/*!
* @brief Get the current DIN pin mode
* @return Current DIN mode setting
*/
tlv320_din_mode_t Adafruit_TLV320DAC3100::getDINMode() {
if (!setPage(0)) {
return TLV320_DIN_DISABLED;
@ -1040,6 +1049,10 @@ tlv320_din_mode_t Adafruit_TLV320DAC3100::getDINMode() {
return (tlv320_din_mode_t)din_mode.read();
}
/*!
* @brief Get the current DIN pin input value
* @return Current DIN input state (true or false)
*/
bool Adafruit_TLV320DAC3100::getDINInput() {
if (!setPage(0)) {
return false;
@ -2209,6 +2222,12 @@ bool Adafruit_TLV320DAC3100::validatePLLConfig(uint8_t P, uint8_t R, uint8_t J,
return true;
}
/*!
* @brief Read a register value from the device
* @param page The page number to access
* @param reg The register address within the page
* @return The value of the register
*/
uint8_t Adafruit_TLV320DAC3100::readRegister(uint8_t page, uint8_t reg) {
setPage(page);
Adafruit_BusIO_Register dac_reg = Adafruit_BusIO_Register(i2c_dev, reg);

View file

@ -69,7 +69,7 @@
#define TLV320DAC3100_REG_VOL_ADC_READ 0x75 ///< VOL/MICDET-Pin Gain Register
// Page 1
#define TLV320DAC3100_REG_BCLK_CTRL2 0x1D
#define TLV320DAC3100_REG_BCLK_CTRL2 0x1D ///< BCLK Control Register 2
#define TLV320DAC3100_REG_HP_SPK_ERR_CTL \
0x1E ///< Headphone and Speaker Error Control Register
#define TLV320DAC3100_REG_HP_DRIVERS 0x1F ///< Headphone Drivers Register
@ -223,6 +223,10 @@ public:
configureHeadphoneDriver(bool left_powered, bool right_powered,
tlv320_hp_common_t common = TLV320_HP_COMMON_1_35V,
bool powerDownOnSCD = false);
/*!
* @brief Check if headphone outputs have detected a short circuit
* @return true if short circuit detected, false if not
*/
bool isHeadphoneShorted(void);
bool enableSpeaker(bool en);
bool speakerEnabled(void);

View file

@ -176,6 +176,9 @@ typedef enum {
TLV320_VOL_RATE_2KHZ = 0b111, ///< 2 kHz (MCLK) or 1.37 kHz (RC)
} tlv320_vol_rate_t;
/*!
* @brief Headphone common-mode settings
*/
typedef enum {
TLV320_HP_COMMON_1_35V = 0b00, ///< Common-mode voltage 1.35V
TLV320_HP_COMMON_1_50V = 0b01, ///< Common-mode voltage 1.50V
@ -254,6 +257,9 @@ typedef enum {
TLV320_SPK_GAIN_24DB = 0b11, ///< 24 dB gain
} tlv320_spk_gain_t;
/*!
* @brief BCLK source settings
*/
typedef enum {
TLV320DAC3100_BCLK_SRC_DAC_CLK = 0,
TLV320DAC3100_BCLK_SRC_DAC_MOD_CLK = 1,