turn ftdi driver into echo server
[goodfet] / shellcode / chipcon / cc1110 / specan.h
1 /*
2  * Copyright 2010 Michael Ossmann
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2, or (at your option)
7  * any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; see the file COPYING.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street,
17  * Boston, MA 02110-1301, USA.
18  */
19
20 #define u8 unsigned char
21 #define u16 unsigned int
22 #define u32 unsigned long
23
24 /*
25  * There is one channel per column of the display.  The radio is tuned to one
26  * channel at a time and RSSI is displayed for that channel.
27  */
28 //#define NUM_CHANNELS 132
29 #define NUM_CHANNELS 10
30
31 /*
32  * wide mode (default): 44 MHz on screen, 333 kHz per channel
33  * narrow mode: 6.6 MHz on screen, 50 kHz per channel
34  */
35 #define WIDE 0
36 #define NARROW 1
37 #define ULTRAWIDE 2
38
39 /*
40  * short mode (default): displays RSSI >> 2
41  * tall mode: displays RSSI
42  */
43 #define SHORT 0
44 #define TALL 1
45
46 /* vertical scrolling */
47 #define SHORT_STEP  16
48 #define TALL_STEP   4
49 #define MAX_VSCROLL 208
50 #define MIN_VSCROLL 0
51
52 /* frequencies in MHz */
53 #define DEFAULT_FREQ     915
54 #define WIDE_STEP        5
55 #define NARROW_STEP      1
56 #define ULTRAWIDE_STEP   20
57 #define WIDE_MARGIN      13
58 #define NARROW_MARGIN    3
59 #define ULTRAWIDE_MARGIN 42
60
61 /* frequency bands supported by device */
62 #define BAND_300 0
63 #define BAND_400 1
64 #define BAND_900 2
65
66 /* band limits in MHz */
67 #define MIN_300  281
68 #define MAX_300  361
69 #define MIN_400  378
70 #define MAX_400  481
71 #define MIN_900  749
72 #define MAX_900  962
73
74 /* band transition points in MHz */
75 #define EDGE_400 369
76 #define EDGE_900 615
77
78 /* VCO transition points in Hz */
79 #define MID_300  318000000
80 #define MID_400  424000000
81 #define MID_900  848000000
82
83 /* channel spacing in Hz */
84 #define WIDE_SPACING      199952
85 #define NARROW_SPACING    49988
86 #define ULTRAWIDE_SPACING 666504
87
88 #define MIN(a, b)  (((a) < (b)) ? (a) : (b))
89 #define MAX(a, b)  (((a) > (b)) ? (a) : (b))
90
91
92 /* Keeping track of all this for each channel allows us to tune faster. */
93 typedef struct {
94         /* frequency setting */
95         u8 freq2;
96         u8 freq1;
97         u8 freq0;
98         
99         /* frequency calibration */
100         u8 fscal3;
101         u8 fscal2;
102         u8 fscal1;
103
104         /* signal strength */
105         u8 ss;
106         u8 max;
107 } channel_info;
108
109 void clear();
110 void plot(u8 col);
111 void putchar(char c);
112 u8 getkey();
113 void draw_ruler();
114 void draw_freq();
115 void radio_setup();
116 void set_filter();
117 void set_radio_freq(u32 freq);
118 void calibrate_freq(u32 freq, u8 ch);
119 u16 set_center_freq(u16 freq);
120 void tune(u8 ch);
121 void set_width(u8 w);
122 void poll_keyboard();
123 void main(void);