Skip to content

Commit

Permalink
[TEF668X] Add DAC configuration via GPIO
Browse files Browse the repository at this point in the history
  • Loading branch information
kkonradpl committed Jul 5, 2024
1 parent fc64e72 commit 6cd8d09
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ConfigTEF668X.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@

/* RDS DAVN GPIO mode (true) or I2C polling (false) */
#define TUNER_TEF668X_RDS_DAVN false

/* RDS DAVN pin (GPIO) */
#define TUNER_TEF668X_PIN_RDS_DAVN PB7

/* DAC configuration via GPIO */
#define TUNER_TEF668X_DAC_CONF false
/* DAC configuration pin (GPIO) */
#define TUNER_TEF668X_PIN_DAC_CONF PB3

/* Versions of tuner patches embedded into firmware
Warning: There is no enough space on AVR for all of them at once */
#define TUNER_TEF668X_PATCH_V101 0
Expand Down
15 changes: 15 additions & 0 deletions src/Controllers/Tuner/TEF668X/TEF668X.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ TEF668X::setup()
{
#if TUNER_TEF668X_RDS_DAVN
pinMode(TUNER_TEF668X_PIN_RDS_DAVN, INPUT);
#endif
#if TUNER_TEF668X_DAC_CONF
pinMode(TUNER_TEF668X_PIN_DAC_CONF, INPUT);
#endif
i2c.init();
}
Expand Down Expand Up @@ -83,6 +86,14 @@ TEF668X::start()
/* The delay of 16 ms seems to be sufifcent for 6687/V205, but
longer delay can improve compability with untested versions. */

#if TUNER_TEF668X_DAC_CONF
if (!digitalRead(TUNER_TEF668X_PIN_DAC_CONF))
{
/* Output MPX by default when the pin is low */
i2c.write(MODULE_FM, FM_Set_Specials, 1, 1);
}
#endif

timerQuality.set(this->qualityInterval);
#if TUNER_TEF668X_RDS_DAVN == false
timerRds.set(this->rdsInterval);
Expand Down Expand Up @@ -345,12 +356,16 @@ TEF668X::setOutputMode(OutputMode value)
switch (value)
{
case OUTPUT_MODE_STEREO:
#if TUNER_TEF668X_DAC_CONF == false
i2c.write(MODULE_FM, FM_Set_Specials, 1, 0);
#endif
i2c.write(MODULE_FM, FM_Set_Stereo_Min, 2, 0, 400);
return true;

case OUTPUT_MODE_MONO:
#if TUNER_TEF668X_DAC_CONF == false
i2c.write(MODULE_FM, FM_Set_Specials, 1, 0);
#endif
i2c.write(MODULE_FM, FM_Set_Stereo_Min, 2, 2, 400);
return true;

Expand Down

0 comments on commit 6cd8d09

Please sign in to comment.