|
|
|
|
|
|
|
|
This code defaults to Teensy Pin 21, which was used on Tympan Rev C. |
|
|
This code defaults to Teensy Pin 21, which was used on Tympan Rev C. |
|
|
You can set the reset pin in the constructor |
|
|
You can set the reset pin in the constructor |
|
|
|
|
|
|
|
|
|
|
|
Note that this can configure the AIC for 32-bit per sample I2S transfers or 16-bit per sample. |
|
|
|
|
|
Defaults to 16 bits per sample to allow it to work with default Teensy audio library. |
|
|
|
|
|
|
|
|
Example Usage for Teensy: |
|
|
Example Usage for Teensy: |
|
|
|
|
|
|
|
|
#include <Audio.h> //Teensy Audio Library |
|
|
#include <Audio.h> //Teensy Audio Library |
|
|
int AIC3206_RESET_PIN 21 //What pin is your AIC3206 reset pin connected to? |
|
|
|
|
|
|
|
|
int AIC3206_RESET_PIN=21; //What pin is your AIC3206 reset pin connected to? |
|
|
AudioControlTLV320AIC3206 audioHardware(AIC3206_RESET_PIN); |
|
|
AudioControlTLV320AIC3206 audioHardware(AIC3206_RESET_PIN); |
|
|
AudioInputI2S i2s_in; //Digital audio *from* the AIC. |
|
|
AudioInputI2S i2s_in; //Digital audio *from* the AIC. |
|
|
AudioOutputI2S i2s_out; //Digital audio *to* the AIC. |
|
|
AudioOutputI2S i2s_out; //Digital audio *to* the AIC. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Choose the desired input |
|
|
//Choose the desired input |
|
|
audioHardware.inputSelect(AIC3206_INPUT_IN1); // use Input 1 |
|
|
audioHardware.inputSelect(AIC3206_INPUT_IN1); // use Input 1 |
|
|
//audioHardware.setMicBias(AIC3206_MIC_BIAS_2_5); // set mic bias to 2.5V |
|
|
|
|
|
//audioHardware.setHPFonADC(20.0); // in the hardware, add a highpass filter at 20Hz to block DC |
|
|
|
|
|
|
|
|
|
|
|
//Set the desired volume levels |
|
|
//Set the desired volume levels |
|
|
audioHardware.volume_dB(0); // headphone amplifier. -63.6 to +24 dB in 0.5dB steps. |
|
|
audioHardware.volume_dB(0); // headphone amplifier. -63.6 to +24 dB in 0.5dB steps. |
|
|
|
|
|
|
|
|
#ifndef control_tlv320aic3206_h_ |
|
|
#ifndef control_tlv320aic3206_h_ |
|
|
#define control_tlv320aic3206_h_ |
|
|
#define control_tlv320aic3206_h_ |
|
|
|
|
|
|
|
|
#include "TeensyAudioControl.h" |
|
|
|
|
|
|
|
|
#include "AudioControl.h" |
|
|
#include <Arduino.h> |
|
|
#include <Arduino.h> |
|
|
|
|
|
|
|
|
//convenience names to use with inputSelect() to set whnch analog inputs to use |
|
|
//convenience names to use with inputSelect() to set whnch analog inputs to use |
|
|
|
|
|
|
|
|
#define LEFT_CHAN 1 |
|
|
#define LEFT_CHAN 1 |
|
|
#define RIGHT_CHAN 2 |
|
|
#define RIGHT_CHAN 2 |
|
|
|
|
|
|
|
|
class AudioControlTLV320AIC3206: public TeensyAudioControl |
|
|
|
|
|
|
|
|
class AudioControlTLV320AIC3206: public AudioControl |
|
|
{ |
|
|
{ |
|
|
public: |
|
|
|
|
|
//GUI: inputs:0, outputs:0 //this line used for automatic generation of GUI node |
|
|
|
|
|
AudioControlTLV320AIC3206(void) { debugToSerial = false; }; |
|
|
|
|
|
AudioControlTLV320AIC3206(bool _debugToSerial) { debugToSerial = _debugToSerial; }; |
|
|
|
|
|
AudioControlTLV320AIC3206(int _resetPin) { debugToSerial = false; resetPinAIC = _resetPin; } |
|
|
|
|
|
AudioControlTLV320AIC3206(int _resetPin, bool _debugToSerial) { resetPinAIC = _resetPin; debugToSerial = _debugToSerial; }; |
|
|
|
|
|
bool enable(void); |
|
|
|
|
|
bool disable(void); |
|
|
|
|
|
bool outputSelect(int n); |
|
|
|
|
|
bool volume(float n); |
|
|
|
|
|
bool volume_dB(float n); |
|
|
|
|
|
bool inputLevel(float n); //dummy to be compatible with Teensy Audio Library |
|
|
|
|
|
bool inputSelect(int n); |
|
|
|
|
|
bool setInputGain_dB(float n); |
|
|
|
|
|
bool setMicBias(int n); |
|
|
|
|
|
bool updateInputBasedOnMicDetect(int setting = TYMPAN_INPUT_JACK_AS_MIC); |
|
|
|
|
|
bool enableMicDetect(bool); |
|
|
|
|
|
int readMicDetect(void); |
|
|
|
|
|
bool debugToSerial; |
|
|
|
|
|
unsigned int aic_readPage(uint8_t page, uint8_t reg); |
|
|
|
|
|
bool aic_writePage(uint8_t page, uint8_t reg, uint8_t val); |
|
|
|
|
|
void setHPFonADC(bool enable, float cutoff_Hz, float fs_Hz); |
|
|
|
|
|
float getHPCutoff_Hz(void) { return HP_cutoff_Hz; } |
|
|
|
|
|
float getSampleRate_Hz(void) { return sample_rate_Hz; } |
|
|
|
|
|
void setIIRCoeffOnADC(int chan, uint32_t *coeff); |
|
|
|
|
|
bool enableAutoMuteDAC(bool, uint8_t); |
|
|
|
|
|
private: |
|
|
|
|
|
void aic_reset(void); |
|
|
|
|
|
void aic_init(void); |
|
|
|
|
|
void aic_initDAC(void); |
|
|
|
|
|
void aic_initADC(void); |
|
|
|
|
|
|
|
|
|
|
|
bool aic_writeAddress(uint16_t address, uint8_t val); |
|
|
|
|
|
bool aic_goToPage(uint8_t page); |
|
|
|
|
|
int prevMicDetVal = -1; |
|
|
|
|
|
int resetPinAIC = 21; //AIC reset pin, Tympan Rev C |
|
|
|
|
|
float HP_cutoff_Hz = 0.0f; |
|
|
|
|
|
float sample_rate_Hz = 44100; //only used with HP_cutoff_Hz to design HP filter on ADC, if used |
|
|
|
|
|
void setIIRCoeffOnADC_Left(uint32_t *coeff); |
|
|
|
|
|
void setIIRCoeffOnADC_Right(uint32_t *coeff); |
|
|
|
|
|
|
|
|
public: |
|
|
|
|
|
//GUI: inputs:0, outputs:0 //this line used for automatic generation of GUI node |
|
|
|
|
|
AudioControlTLV320AIC3206(void) { debugToSerial = false; }; |
|
|
|
|
|
AudioControlTLV320AIC3206(bool _debugToSerial) { debugToSerial = _debugToSerial; }; |
|
|
|
|
|
AudioControlTLV320AIC3206(int _resetPin) { debugToSerial = false; resetPinAIC = _resetPin; } |
|
|
|
|
|
AudioControlTLV320AIC3206(int _resetPin, bool _debugToSerial) { resetPinAIC = _resetPin; debugToSerial = _debugToSerial; }; |
|
|
|
|
|
bool enable(void); |
|
|
|
|
|
bool disable(void); |
|
|
|
|
|
bool outputSelect(int n); |
|
|
|
|
|
bool volume(float n); |
|
|
|
|
|
bool volume_dB(float n); |
|
|
|
|
|
bool inputLevel(float n); //dummy to be compatible with Teensy Audio Library |
|
|
|
|
|
bool inputSelect(int n); |
|
|
|
|
|
bool setInputGain_dB(float n); |
|
|
|
|
|
bool setMicBias(int n); |
|
|
|
|
|
bool updateInputBasedOnMicDetect(int setting = AIC3206_INPUT_IN1); //which input to monitor |
|
|
|
|
|
bool enableMicDetect(bool); |
|
|
|
|
|
int readMicDetect(void); |
|
|
|
|
|
bool debugToSerial; |
|
|
|
|
|
unsigned int aic_readPage(uint8_t page, uint8_t reg); |
|
|
|
|
|
bool aic_writePage(uint8_t page, uint8_t reg, uint8_t val); |
|
|
|
|
|
void setHPFonADC(bool enable, float cutoff_Hz, float fs_Hz); |
|
|
|
|
|
float getHPCutoff_Hz(void) { return HP_cutoff_Hz; } |
|
|
|
|
|
float getSampleRate_Hz(void) { return sample_rate_Hz; } |
|
|
|
|
|
void setIIRCoeffOnADC(int chan, uint32_t *coeff); |
|
|
|
|
|
bool enableAutoMuteDAC(bool, uint8_t); |
|
|
|
|
|
private: |
|
|
|
|
|
void aic_reset(void); |
|
|
|
|
|
void aic_init(void); |
|
|
|
|
|
void aic_initDAC(void); |
|
|
|
|
|
void aic_initADC(void); |
|
|
|
|
|
|
|
|
|
|
|
bool aic_writeAddress(uint16_t address, uint8_t val); |
|
|
|
|
|
bool aic_goToPage(uint8_t page); |
|
|
|
|
|
int prevMicDetVal = -1; |
|
|
|
|
|
int resetPinAIC = 21; //AIC reset pin, Tympan Rev C |
|
|
|
|
|
float HP_cutoff_Hz = 0.0f; |
|
|
|
|
|
float sample_rate_Hz = 44100; //only used with HP_cutoff_Hz to design HP filter on ADC, if used |
|
|
|
|
|
void setIIRCoeffOnADC_Left(uint32_t *coeff); |
|
|
|
|
|
void setIIRCoeffOnADC_Right(uint32_t *coeff); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|