Merge pull request #485 from ohmytime/Add_XTAL_Support
Support 12M and 55M oscillators
This commit is contained in:
+17
-1
@@ -3,6 +3,7 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <TimeLib.h> // https://github.com/PaulStoffregen/Time
|
#include <TimeLib.h> // https://github.com/PaulStoffregen/Time
|
||||||
#include "SPIFFS.h"
|
#include "SPIFFS.h"
|
||||||
|
#include "constants.h"
|
||||||
|
|
||||||
unsigned long rdstimer = 0;
|
unsigned long rdstimer = 0;
|
||||||
unsigned long bitStartTime = 0;
|
unsigned long bitStartTime = 0;
|
||||||
@@ -123,12 +124,27 @@ uint16_t TEF6686::TestAF() {
|
|||||||
|
|
||||||
void TEF6686::init(byte TEF) {
|
void TEF6686::init(byte TEF) {
|
||||||
uint8_t bootstatus;
|
uint8_t bootstatus;
|
||||||
|
int xtalADC = 0;
|
||||||
Tuner_I2C_Init();
|
Tuner_I2C_Init();
|
||||||
devTEF_APPL_Get_Operation_Status(&bootstatus);
|
devTEF_APPL_Get_Operation_Status(&bootstatus);
|
||||||
if (bootstatus == 0) {
|
if (bootstatus == 0) {
|
||||||
Tuner_Patch(TEF);
|
Tuner_Patch(TEF);
|
||||||
delay(50);
|
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);
|
power(1);
|
||||||
Tuner_Init(tuner_init_tab);
|
Tuner_Init(tuner_init_tab);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
extern const unsigned char tuner_init_tab[] PROGMEM;
|
extern const unsigned char tuner_init_tab[] PROGMEM;
|
||||||
extern const unsigned char tuner_init_tab9216[] PROGMEM;
|
extern const unsigned char tuner_init_tab9216[] PROGMEM;
|
||||||
extern const unsigned char tuner_init_tab4000[] 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 {
|
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,
|
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,
|
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) {
|
bool Tuner_WriteBuffer(unsigned char *buf, uint16_t len) {
|
||||||
Wire.beginTransmission(0x64);
|
Wire.beginTransmission(0x64);
|
||||||
for (uint16_t i = 0; i < len; i++) Wire.write(buf[i]);
|
for (uint16_t i = 0; i < len; i++) Wire.write(buf[i]);
|
||||||
|
|||||||
@@ -23,6 +23,10 @@
|
|||||||
#define BATTERY_LOW_VALUE 3.0
|
#define BATTERY_LOW_VALUE 3.0
|
||||||
#define BATTERY_FULL_VALUE 4.2
|
#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
|
#define LANGUAGE_CHS 14
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user