TLV320: tweaks to library

pull/5/head
Chip Audette 8 years ago
parent df03165997
commit ce0032dd78
  1. 25
      control_tlv320aic3206.h
  2. 17
      control_tlv320aic_3206.cpp
  3. 19
      examples/Tympan_TLV320AIC3206/Tympan_TLV320AIC3206.ino
  4. 3
      keywords.txt

@ -1,11 +1,15 @@
/* Extension control files for TLV320AIC3206
* Copyright (c) 2016, Creare, bpf@creare.com
*
*
/*
control_tlv320aic3206
Created: BPF@creare.com Jan-Feb 2017
Purpose: Control module for TLV320AIC3206 compatible with Teensy Audio Library
License: MIT License. Use at your own risk.
*/
#ifndef control_tlv320_h_
#define control_tlv320_h_
#ifndef control_tlv320aic3206_h_
#define control_tlv320aic3206_h_
#include "AudioControl.h"
@ -15,19 +19,20 @@ public:
bool enable(void);
bool disable(void);
bool volume(float n);
bool inputLevel(float n);
bool volume_dB(float n);
bool inputLevel(float n); //dummy to be compatible with Teensy Audio Library
bool inputSelect(int n);
bool micGain(float n);
bool setInputGain_dB(float n);
bool setMicBias(int n);
private:
void aic_reset(void);
void aic_init(void);
void aic_init(void);
void aic_initDAC(void);
void aic_initADC(void);
unsigned int aic_readPage(uint8_t page, uint8_t reg);
bool aic_writePage(uint8_t page, uint8_t reg, uint8_t val);
bool aic_writeAddress(uint16_t address, uint8_t val);
bool aic_writeAddress(uint16_t address, uint8_t val);
bool aic_goToPage(uint8_t page);
};

@ -140,7 +140,7 @@ bool AudioControlTLV320AIC3206::enable(void)
delay(5);
aic_reset(); delay(100);
aic_init(); delay(100);
aic_init(); delay(100);
aic_initADC(); delay(100);
aic_initDAC(); delay(100);
@ -156,6 +156,7 @@ bool AudioControlTLV320AIC3206::disable(void) {
return true;
}
//dummy function to keep compatible with Teensy Audio Library
bool AudioControlTLV320AIC3206::inputLevel(float volume) {
return false;
}
@ -269,7 +270,7 @@ void AudioControlTLV320AIC3206::aic_initADC() {
}
// set MICPGA volume, 0-47.5dB in 0.5dB setps
bool AudioControlTLV320AIC3206::micGain(float volume) {
bool AudioControlTLV320AIC3206::setInputGain_dB(float volume) {
if (volume < 0.0) {
volume = 0.0; // 0.0 dB
Serial.println("WARNING: Attempting to set MIC volume outside range");
@ -298,8 +299,18 @@ bool AudioControlTLV320AIC3206::micGain(float volume) {
#define TYMPAN_DAC_VOLUME_LEFT_REG 0x0041 // page 0 reg 65
#define TYMPAN_DAC_VOLUME_RIGHT_REG 0x0042 // page 0 reg 66
// -63.6 to +24 dB in 0.5dB steps. uses signed 8-bit
//volume control, similar to Teensy Audio Board
// value between 0.0 and 1.0. Set to span -58 to +15 dB
bool AudioControlTLV320AIC3206::volume(float volume) {
volume = max(0.0, min(1.0, volume));
float vol_dB = -58.f + (15.0 - (-58.0f)) * volume;
volume_dB(vol_dB);
return true;
}
// -63.6 to +24 dB in 0.5dB steps. uses signed 8-bit
bool AudioControlTLV320AIC3206::volume_dB(float volume) {
// Constrain to limits
if (volume > 24.0) {

@ -18,21 +18,20 @@
// define audio classes and connections
AudioControlTLV320AIC3206 tlv320aic3206_1;
AudioInputI2S audioInput;
AudioOutputI2S audioOutput;
AudioConnection patchCord1(audioInput, 0, audioOutput, 0);
AudioConnection patchCord2(audioInput, 1, audioOutput, 1);
AudioInputI2S audioInput;
AudioOutputI2S audioOutput;
AudioConnection patchCord1(audioInput, 0, audioOutput, 0);
AudioConnection patchCord2(audioInput, 1, audioOutput, 1);
// define the setup
void setup(void)
{
//allocate the audio memory first
AudioMemory(160); //big number to accomodate the delay effect
AudioMemory(10); //big number to accomodate the delay effect
//begin the serial comms
Serial.begin(115200);
delay(500);
Serial.println("Tympan_TLV320AIC: starting...");
Serial.begin(115200); delay(500);
Serial.println("Tympan_TLV320AIC3206: starting...");
// Setup the TLV320
tlv320aic3206_1.enable(); // activate AIC
@ -51,8 +50,8 @@ void setup(void)
// tlv320aic3206_1.setMicBias(TYMPAN_MIC_BIAS_VSUPPLY); // set mic bias to supply voltage
// VOLUMES
tlv320aic3206_1.volume(10); // -63.6 to +24 dB in 0.5dB steps. uses float
tlv320aic3206_1.micGain(10); // set MICPGA volume, 0-47.5dB in 0.5dB setps
tlv320aic3206_1.volume_dB(10); // -63.6 to +24 dB in 0.5dB steps. uses float
tlv320aic3206_1.setInputGain_dB(10); // set MICPGA volume, 0-47.5dB in 0.5dB setps
Serial.println("Done");
}

@ -11,7 +11,8 @@ AudioControlTLV320AIC3206 KEYWORD1
inputSelect KEYWORD2
setMicBias KEYWORD2
volume KEYWORD2
micGain KEYWORD2
volume_dB KEYWORD2
setInputGain_dB KEYWORD2
AudioControlSGTL5000_Extended KEYWORD1
micBiasEnable KEYWORD2

Loading…
Cancel
Save