way better start sequence, faster too
This commit is contained in:
+8
-75
@@ -1,60 +1,15 @@
|
||||
#include "globals.h"
|
||||
#include "Tuner_Patch_Lithio_V102_p224.h"
|
||||
#ifndef DEEPELEC_DP_66X
|
||||
#include "Tuner_Patch_Lithio_V205_p512.h"
|
||||
#endif
|
||||
#include <Wire.h>
|
||||
|
||||
const unsigned char tuner_init_tab[] PROGMEM = {
|
||||
9, 0x20, 0x36, 0x01, 0x00, 0x00, 0x01, 0x68, 0x01, 0x2C,
|
||||
7, 0x20, 0x37, 0x01, 0x00, 0x00, 0x0F, 0xA0,
|
||||
7, 0x20, 0x39, 0x01, 0x00, 0x00, 0x00, 0x64,
|
||||
11, 0x20, 0x3C, 0x01, 0x00, 0x3C, 0x00, 0x78, 0x00, 0x64, 0x00, 0xC8,
|
||||
11, 0x20, 0x46, 0x01, 0x01, 0xF4, 0x07, 0xD0, 0x00, 0xC8, 0x00, 0xC8,
|
||||
9, 0x20, 0x48, 0x01, 0x00, 0x00, 0x02, 0x58, 0x00, 0xF0,
|
||||
9, 0x20, 0x49, 0x01, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x8C,
|
||||
9, 0x20, 0x4A, 0x01, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x8C,
|
||||
7, 0x20, 0x4B, 0x01, 0x00, 0x00, 0x0F, 0xA0,
|
||||
7, 0x30, 0x15, 0x01, 0x00, 0x80, 0x00, 0x01,
|
||||
13, 0x30, 0x16, 0x01, 0x00, 0x21, 0x00, 0x02, 0x00, 0x10, 0x01, 0x00, 0x12, 0xc0,
|
||||
7, 0x30, 0x0d, 0x01, 0x00, 0x80, 0x00, 0xe0
|
||||
};
|
||||
|
||||
const unsigned char tuner_init_tab4000[] PROGMEM = {
|
||||
3, 0x14, 0x00, 0x01,
|
||||
2, 0xff, 50,
|
||||
9, 0x40, 0x04, 0x01, 0x00, 0x3D, 0x09, 0x00, 0x00, 0x00,
|
||||
5, 0x40, 0x05, 0x01, 0x00, 0x01,
|
||||
2, 0xff, 100,
|
||||
};
|
||||
|
||||
const unsigned char tuner_init_tab9216[] PROGMEM = {
|
||||
3, 0x14, 0x00, 0x01,
|
||||
2, 0xff, 50,
|
||||
9, 0x40, 0x04, 0x01, 0x00, 0x8C, 0xA0, 0x00, 0x00, 0x00,
|
||||
5, 0x40, 0x05, 0x01, 0x00, 0x01,
|
||||
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(TEF668X_ADDRESS);
|
||||
for (uint16_t i = 0; i < len; i++) Wire.write(buf[i]);
|
||||
uint8_t r = Wire.endTransmission();
|
||||
if (!Data_Accelerator) delay(2);
|
||||
if (!Data_Accelerator) delay(1);
|
||||
return (r == 0) ? true : false;
|
||||
}
|
||||
|
||||
@@ -84,14 +39,7 @@ static void Tuner_Patch_Load(const unsigned char *pLutBytes, uint16_t size) {
|
||||
}
|
||||
}
|
||||
|
||||
bool Tuner_Table_Write(const unsigned char *tab) {
|
||||
if (tab[1] == 0xff) {
|
||||
delay(tab[2]);
|
||||
return true;
|
||||
} else return Tuner_WriteBuffer((unsigned char *)&tab[1], tab[0]);
|
||||
}
|
||||
|
||||
void Tuner_Reset(void) {
|
||||
void Tuner_Reset() {
|
||||
Wire.beginTransmission(TEF668X_ADDRESS);
|
||||
Wire.write(0x1e);
|
||||
Wire.write(0x5a);
|
||||
@@ -102,14 +50,11 @@ void Tuner_Reset(void) {
|
||||
}
|
||||
|
||||
void Tuner_Patch(byte TEF) {
|
||||
Tuner_Reset();
|
||||
delay(100);
|
||||
Wire.beginTransmission(TEF668X_ADDRESS);
|
||||
Wire.write(0x1c);
|
||||
Wire.write(0x00);
|
||||
Wire.write(0x00);
|
||||
Wire.endTransmission();
|
||||
delay(100);
|
||||
Wire.beginTransmission(TEF668X_ADDRESS);
|
||||
Wire.write(0x1c);
|
||||
Wire.write(0x00);
|
||||
@@ -119,16 +64,17 @@ void Tuner_Patch(byte TEF) {
|
||||
case 102:
|
||||
Tuner_Patch_Load(pPatchBytes102, PatchSize102);
|
||||
break;
|
||||
#ifndef DEEPELEC_DP_66X
|
||||
case 205:
|
||||
Tuner_Patch_Load(pPatchBytes205, PatchSize205);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
Wire.beginTransmission(TEF668X_ADDRESS);
|
||||
Wire.write(0x1c);
|
||||
Wire.write(0x00);
|
||||
Wire.write(0x00);
|
||||
Wire.endTransmission();
|
||||
delay(100);
|
||||
Wire.beginTransmission(TEF668X_ADDRESS);
|
||||
Wire.write(0x1c);
|
||||
Wire.write(0x00);
|
||||
@@ -138,28 +84,15 @@ void Tuner_Patch(byte TEF) {
|
||||
case 102:
|
||||
Tuner_Patch_Load(pLutBytes102, LutSize102);
|
||||
break;
|
||||
#ifndef DEEPELEC_DP_66X
|
||||
case 205:
|
||||
Tuner_Patch_Load(pLutBytes205, LutSize205);
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
Wire.beginTransmission(TEF668X_ADDRESS);
|
||||
Wire.write(0x1c);
|
||||
Wire.write(0x00);
|
||||
Wire.write(0x00);
|
||||
Wire.endTransmission();
|
||||
}
|
||||
|
||||
void Tuner_I2C_Init() {
|
||||
Wire.begin();
|
||||
Wire.setClock(400000);
|
||||
delay(5);
|
||||
}
|
||||
|
||||
void Tuner_Init(const unsigned char *table) {
|
||||
uint16_t r;
|
||||
const unsigned char *p = table;
|
||||
|
||||
for (uint16_t i = 0; i < sizeof(tuner_init_tab); i += (pgm_read_byte(p + i) + 1)) {
|
||||
if (1 != (r = Tuner_Table_Write(p + i))) break;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user