libmirisdr 0.0.20130608
MiriSDR library
tuner_msi001.h
1/*
2 * Mirics MSi001 tuner driver
3 *
4 * Copyright (C) 2012 by Eric Wild <la@tfc-server.de>
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <stdint.h>
21
22#define c(v) ((v<0)?printf("err! %s %s:%i\n", #v, __FILE__, __LINE__):0)
23#define MHZ(x) ((x)*1000*1000)
24#define KHZ(x) ((x)*1000)
25
26enum mode{
27 AM_MODE1=0,
28 AM_MODE2=1,
29 VHF_MODE=2,
30 B3_MODE=3,
31 B45_MODE=4,
32 BL_MODE=5
33};
34
35enum xtal{
36 XTAL19_2Mz=0,
37 XTAL22M=1,
38 XTAL24_576M=2,
39 XTAL26M=3,
40 XTAL38_4M=4
41};
42
43enum am_mixgainred{
44 r1_mixbu_p0_0 = 0,
45 r1_mixbu_p0_6 = 1,
46 r1_mixbu_p0_12 = 2,
47 r1_mixbu_p0_18 = 3,
48 r1_mixbu_p1_24 = 3
49};
50
51struct state{
52 enum mode m;
53 enum xtal x;
54 double freq_hz;
55 uint32_t minus_bbgain;
56 enum am_mixgainred am_mixgainred;
57 uint32_t mixl;
58 uint32_t lnagr;
59 uint32_t reg[6];
60};
61
62struct r0_modes_{
63 char* bits;
64 unsigned char value;
65 char* name;
66 unsigned char lodiv;
67};
68
69struct iffreqs_{
70 uint32_t xtalfreq;
71 uint32_t fref1;
72 uint32_t fif1;
73};
74
75int msi001_init(void *dev, uint32_t freq);
76
77//######
78#define R0_FIL_MODE_SH 12
79#define R0_FIL_BW_SH 14
80#define R0_XTAL_SEL_SH 17
81#define R0_IF_LPMODE_SH 20
82#define R0_VCO_LPMODE_SH 23
83
84#define FIL_MODE_450K_IF 0x2
85#define FIL_MODE_ZERO_IF 0x3
86
87//######
88#define R2_INT_SH 16
89
90//######
91#define R1_MIXBU_SH 10
92#define R1_MIXL_SH 12
93#define R1_LNAGR_SH 13
94#define R1_DCCAL_SH 14
95
96#define R1_DCCAL 0x05 // continuous, no speedup
97//######
Definition: tuner_msi001.h:69
Definition: tuner_msi001.h:62
Definition: tuner_msi001.h:51