Este es el último lugar donde buscaría dicha información: el código fuente del kernel de Linux . No encontrará la hoja de datos, pero encontrará el código fuente de un controlador para una tarjeta DVB con el mismo sintonizador. El mismo IC se puede encontrar en STB6000 sintonizador. Solo tienes que adaptar el código.
El código que proporcionaré está adaptado de ix2476.c
y ix2476.h
que no puedo encontrar en línea ahora, estaban en núcleos de Linux más antiguos.
El siguiente pseudocódigo es solo una adaptación del código original Copyright (C) 2008 Igor M. Liplianin ([email protected])
y sigue la misma licencia GNU GPL v2
. Solo eliminé las rutinas específicas del kernel y reescribí las rutinas de comunicación I2C.
#define IX2476_XTAL_KHZ (4000) // Replace accordingly
#define IX2476_PLL_STEP (IX2476_XTAL_KHZ / 8)
unsigned char by1, by2, by3, by4;
unsigned long int ix2476_calculate_pll_lpf_cutoff(unsigned long int baud) // PRIVATE
{
if (baud >= 39000000) return 30000; //LPF=30MHz
if ((39000000 > baud) && (baud >= 35000000)) return 28000; //LPF=28MHz
if ((35000000 > baud) && (baud >= 30000000)) return 26000; //LPF=26MHz
if ((30000000 > baud) && (baud >= 26000000)) return 24000; //LPF=24MHz
if ((26000000 > baud) && (baud >= 23000000)) return 22000; //LPF=22MHz
if ((23000000 > baud) && (baud >= 21000000)) return 20000; //LPF=20MHz
if ((21000000 > baud) && (baud >= 19000000)) return 18000; //LPF=18MHz
if ((19000000 > baud) && (baud >= 18000000)) return 16000; //LPF=16MHz
if ((18000000 > baud) && (baud >= 17000000)) return 14000; //LPF=14MHz
if ((17000000 > baud) && (baud >= 16000000)) return 12000; //LPF=12MHz
else return 10000; //LPF=10MHz
return 0;
}
void ix2476_calculate_pll_vco(unsigned long int freq, unsigned long int *div, unsigned long int *ba) // PRIVATE
{
*div = 1;
*ba = 6;
if ((950000 <= freq) && (freq < 1065000)) *div = 1, *ba = 6;
else if ((1065000 <= freq) && (freq < 1170000)) *div = 1, *ba = 7;
else if ((1170000 <= freq) && (freq < 1300000)) *div = 0, *ba = 1;
else if ((1300000 <= freq) && (freq < 1445000)) *div = 0, *ba = 2;
else if ((1445000 <= freq) && (freq < 1607000)) *div = 0, *ba = 3;
else if ((1607000 <= freq) && (freq < 1778000)) *div = 0, *ba = 4;
else if ((1778000 <= freq) && (freq < 1942000)) *div = 0, *ba = 5;
else if (1942000 <= freq) *div = 0, *ba = 6;
}
bool ix2476_isRfLocked() // PUBLIC
{
/**
Read 1 byte from address 0xC1. Replace with your code.
**/
i2c_start();
i2c_write(0xC1);
unsigned char byt = i2c_read(true); // ACK read
i2c_stop();
return (byt & 0x40);
}
void ix2476_set_params(unsigned long int freq, unsigned long int sr) // PUBLIC, freq = kHz, sr = kSymb/s (e.g. freq=1090000, sr=27500000)
{
// Frequency
unsigned long int data = freq / IX2476_PLL_STEP;
by1 = (data >> 8) & 0x1F;
by2 = data;
// Local oscillator
unsigned long int div, ba;
ix2476_calculate_pll_vco(freq, &div, &ba);
by4 = (ba << 5) | ((div & 1) << 1);
// LPF Cut-off
unsigned long int cutoff;
cutoff = ix2476_calculate_pll_lpf_cutoff(sr);
cutoff = ((cutoff / 1000) / 2) - 2;
unsigned long int pd2, pd3, pd4, pd5;
pd2 = (cutoff >> 1) & 0x04;
pd3 = (cutoff << 1) & 0x08;
pd4 = (cutoff << 2) & 0x08;
pd5 = (cutoff << 4) & 0x10;
by3 &= 0xE7;
by3 |= (pd5 | pd4);
by4 &= 0xF3;
by4 |= (pd3 | pd2);
unsigned long int reg2, reg3;
reg2 = by3;
reg3 = by4;
by3 &= 0xE3;
by4 &= 0xF3;
/* Write I2C: 0xC0 address followed by all 4 bytes */
i2c_start();
i2c_write(0xC0);
i2c_write(by1);
i2c_write(by2);
i2c_write(by3);
i2c_write(by4);
i2c_stop();
by3 |= 0x04;
waitmsec(10); //optional 10 ms wait
/* Write I2C: 0xC0 address followed by by3 */
i2c_start();
i2c_write(0xC0);
i2c_write(by3);
i2c_stop();
by3 = reg2 | 0x04;
by4 = reg3;
waitusec(10); //optional 10 us wait
/* Write I2C: 0xC0 address followed by 2 bytes */
i2c_start();
i2c_write(0xC0);
i2c_write(by3);
i2c_write(by4);
i2c_stop();
}
Ahora todo lo que tienes que hacer es encontrar el pinout.