summaryrefslogtreecommitdiff
path: root/include/tuner_e4000.h
blob: 4c78f3ea8a6de23d0ad6346313c6fe7e748fb4f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#ifndef __TUNER_E4000_H
#define __TUNER_E4000_H

/**

@file

@brief   E4000 tuner module declaration

One can manipulate E4000 tuner through E4000 module.
E4000 module is derived from tuner module.



@par Example:
@code

// The example is the same as the tuner example in tuner_base.h except the listed lines.



#include "tuner_e4000.h"


...



int main(void)
{
	TUNER_MODULE        *pTuner;
	E4000_EXTRA_MODULE *pTunerExtra;

	TUNER_MODULE          TunerModuleMemory;
	BASE_INTERFACE_MODULE BaseInterfaceModuleMemory;
//	I2C_BRIDGE_MODULE     I2cBridgeModuleMemory;

	unsigned long BandwidthMode;


	...



	// Build E4000 tuner module.
	BuildE4000Module(
		&pTuner,
		&TunerModuleMemory,
		&BaseInterfaceModuleMemory,
		&I2cBridgeModuleMemory,
		0xac,								// I2C device address is 0xac in 8-bit format.
		CRYSTAL_FREQ_16384000HZ,			// Crystal frequency is 16.384 MHz.
		E4000_AGC_INTERNAL					// The E4000 AGC mode is internal AGC mode.
		);





	// Get E4000 tuner extra module.
	pTunerExtra = (T2266_EXTRA_MODULE *)(pTuner->pExtra);





	// ==== Initialize tuner and set its parameters =====

	...

	// Set E4000 bandwidth.
	pTunerExtra->SetBandwidthMode(pTuner, E4000_BANDWIDTH_6MHZ);





	// ==== Get tuner information =====

	...

	// Get E4000 bandwidth.
	pTunerExtra->GetBandwidthMode(pTuner, &BandwidthMode);



	// See the example for other tuner functions in tuner_base.h


	return 0;
}


@endcode

*/





//#include "tuner_base.h"





// The following context is implemented for E4000 source code.


// Definition (implemeted for E4000)
#define E4000_1_SUCCESS			1
#define E4000_1_FAIL			0
#define E4000_I2C_SUCCESS		1
#define E4000_I2C_FAIL			0



// Function (implemeted for E4000)
int
I2CReadByte(void *pTuner,
    unsigned char NoUse,
    unsigned char RegAddr,
    unsigned char *pReadingByte
    );

int
I2CWriteByte(
    void *pTuner,
	unsigned char NoUse,
	unsigned char RegAddr,
	unsigned char WritingByte
	);

int
I2CWriteArray(void *pTuner,
    unsigned char NoUse,
    unsigned char RegStartAddr,
    unsigned char ByteNum,
    unsigned char *pWritingBytes
    );



// Functions (from E4000 source code)
int tunerreset (void *pTuner);
int Tunerclock(void *pTuner);
int Qpeak(void *pTuner);
int DCoffloop(void *pTuner);
int GainControlinit(void *pTuner);

int Gainmanual(void *pTuner);
int E4000_gain_freq(void *pTuner, int frequency);
int PLL(void *pTuner, int Ref_clk, int Freq);
int LNAfilter(void *pTuner, int Freq);
int IFfilter(void *pTuner, int bandwidth, int Ref_clk);
int freqband(void *pTuner, int Freq);
int DCoffLUT(void *pTuner);
int GainControlauto(void *pTuner);

int E4000_sensitivity(void *pTuner, int Freq, int bandwidth);
int E4000_linearity(void *pTuner, int Freq, int bandwidth);
int E4000_high_linearity(void *pTuner);
int E4000_nominal(void *pTuner, int Freq, int bandwidth);


// The following context is E4000 tuner API source code

// Definitions

// Bandwidth in Hz
enum E4000_BANDWIDTH_HZ
{
	E4000_BANDWIDTH_6000000HZ = 6000000,
	E4000_BANDWIDTH_7000000HZ = 7000000,
	E4000_BANDWIDTH_8000000HZ = 8000000,
};


// Manipulaing functions
void
e4000_GetTunerType(
    void *pTuner,
	int *pTunerType
	);

void
e4000_GetDeviceAddr(
    void *pTuner,
	unsigned char *pDeviceAddr
	);

int
e4000_Initialize(
    void *pTuner
	);

int
e4000_SetRfFreqHz(
    void *pTuner,
	unsigned long RfFreqHz
	);

int
e4000_GetRfFreqHz(
    void *pTuner,
	unsigned long *pRfFreqHz
	);





// Extra manipulaing functions
int
e4000_GetRegByte(
    void *pTuner,
	unsigned char RegAddr,
	unsigned char *pReadingByte
	);

int
e4000_SetBandwidthHz(
    void *pTuner,
	unsigned long BandwidthHz
	);

int
e4000_GetBandwidthHz(
    void *pTuner,
	unsigned long *pBandwidthHz
	);

#endif