You've already forked TEF6686_ESP32
Support 12M and 55M oscillators
Depending on the voltage of IO15, different crystal oscillators are supported. IO15: 0V → 9.216M IO15: 1V → 12M IO15: 2V → 55.466M IO15: (2V~3.3V] → 4M
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include <Arduino.h>
|
||||
#include <TimeLib.h> // https://github.com/PaulStoffregen/Time
|
||||
#include "SPIFFS.h"
|
||||
#include "constants.h"
|
||||
|
||||
unsigned long rdstimer = 0;
|
||||
unsigned long bitStartTime = 0;
|
||||
@@ -123,12 +124,27 @@ uint16_t TEF6686::TestAF() {
|
||||
|
||||
void TEF6686::init(byte TEF) {
|
||||
uint8_t bootstatus;
|
||||
int xtalADC = 0;
|
||||
Tuner_I2C_Init();
|
||||
devTEF_APPL_Get_Operation_Status(&bootstatus);
|
||||
if (bootstatus == 0) {
|
||||
Tuner_Patch(TEF);
|
||||
delay(50);
|
||||
if (digitalRead(15) == LOW) Tuner_Init(tuner_init_tab9216); else Tuner_Init(tuner_init_tab4000);
|
||||
|
||||
xtalADC = analogRead(15);
|
||||
if (xtalADC > XTAL_0V_ADC && xtalADC < XTAL_0V_ADC + XTAL_ADC_TOL) {
|
||||
Tuner_Init(tuner_init_tab9216);
|
||||
log_v("XTAL : 9.216M");
|
||||
} else if (xtalADC > XTAL_1V_ADC - XTAL_ADC_TOL && xtalADC < XTAL_1V_ADC + XTAL_ADC_TOL) {
|
||||
Tuner_Init(tuner_init_tab12000);
|
||||
log_v("XTAL : 12M");
|
||||
} else if (xtalADC > XTAL_2V_ADC - XTAL_ADC_TOL && xtalADC < XTAL_2V_ADC + XTAL_ADC_TOL) {
|
||||
Tuner_Init(tuner_init_tab55000);
|
||||
log_v("XTAL : 55M");
|
||||
} else if (xtalADC > XTAL_2V_ADC + XTAL_ADC_TOL) {
|
||||
Tuner_Init(tuner_init_tab4000);
|
||||
log_v("XTAL : 4M");
|
||||
}
|
||||
power(1);
|
||||
Tuner_Init(tuner_init_tab);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
extern const unsigned char tuner_init_tab[] PROGMEM;
|
||||
extern const unsigned char tuner_init_tab9216[] PROGMEM;
|
||||
extern const unsigned char tuner_init_tab4000[] PROGMEM;
|
||||
extern const unsigned char tuner_init_tab12000[] PROGMEM;
|
||||
extern const unsigned char tuner_init_tab55000[] PROGMEM;
|
||||
|
||||
enum RDS_GROUPS {
|
||||
RDS_GROUP_0A, RDS_GROUP_0B, RDS_GROUP_1A, RDS_GROUP_1B, RDS_GROUP_2A, RDS_GROUP_2B, RDS_GROUP_3A, RDS_GROUP_3B,
|
||||
|
||||
@@ -50,6 +50,22 @@ const unsigned char tuner_init_tab9216[] PROGMEM = {
|
||||
2, 0xff, 100,
|
||||
};
|
||||
|
||||
const unsigned char tuner_init_tab12000[] PROGMEM = {
|
||||
3, 0x14, 0x00, 0x01,
|
||||
2, 0xff, 50,
|
||||
9, 0x40, 0x04, 0x01, 0x00, 0xB7, 0x1B, 0x00, 0x00, 0x00,
|
||||
5, 0x40, 0x05, 0x01, 0x00, 0x01,
|
||||
2, 0xff, 100,
|
||||
};
|
||||
|
||||
const unsigned char tuner_init_tab55000[] PROGMEM = {
|
||||
3, 0x14, 0x00, 0x01,
|
||||
2, 0xff, 50,
|
||||
9, 0x40, 0x04, 0x01, 0x03, 0x4E, 0x5A, 0xAE, 0x00, 0x01,
|
||||
5, 0x40, 0x05, 0x01, 0x00, 0x01,
|
||||
2, 0xff, 100,
|
||||
};
|
||||
|
||||
bool Tuner_WriteBuffer(unsigned char *buf, uint16_t len) {
|
||||
Wire.beginTransmission(0x64);
|
||||
for (uint16_t i = 0; i < len; i++) Wire.write(buf[i]);
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
#define BATTERY_LOW_VALUE 3.0
|
||||
#define BATTERY_FULL_VALUE 4.2
|
||||
|
||||
#define XTAL_0V_ADC 0
|
||||
#define XTAL_1V_ADC 1050
|
||||
#define XTAL_2V_ADC 2250
|
||||
#define XTAL_ADC_TOL 300
|
||||
|
||||
#define LANGUAGE_CHS 14
|
||||
|
||||
|
||||
Reference in New Issue
Block a user