-
Notifications
You must be signed in to change notification settings - Fork 1
/
kiwi.h
165 lines (125 loc) · 5.58 KB
/
kiwi.h
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
/*
--------------------------------------------------------------------------------
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Boston, MA 02110-1301, USA.
--------------------------------------------------------------------------------
*/
// Copyright (c) 2015 John Seamons, ZL4VO/KF6VO
#pragma once
#include "types.h"
#include "kiwi.gen.h"
#include "str.h"
#include "printf.h"
#include "datatypes.h"
#include "coroutines.h"
#include "cfg.h"
#include "non_block.h"
#define I 0
#define Q 1
#define NIQ 2
// for backward compatibility with old versions of the antenna switch extension
#define RX_CHANS 32
// The hardware returns RXO_BITS (typically 24-bits) and scaling down by RXOUT_SCALE
// will convert this to a +/- 1.0 float.
// But the CuteSDR code assumes a scaling of +/- 32.0k, so we scale up by CUTESDR_SCALE.
#define RXOUT_SCALE (RXO_BITS-1) // s24 -> +/- 1.0
#define CUTESDR_SCALE 15 // +/- 1.0 -> +/- 32.0k (s16 equivalent)
#define CUTESDR_MAX_VAL ((float) ((1 << CUTESDR_SCALE) - 1))
#define CUTESDR_MAX_PWR (CUTESDR_MAX_VAL * CUTESDR_MAX_VAL)
typedef enum { KiwiSDR_1 = 1, KiwiSDR_2 = 2 } model_e;
typedef enum { PLATFORM_BBG_BBB = 0, PLATFORM_BB_AI = 1, PLATFORM_BB_AI64 = 2, PLATFORM_RPI = 3 } platform_e;
const char * const platform_s[] = { "beaglebone-black", "bbai", "bbai64", "rpi" };
typedef enum { DAILY_RESTART_NO = 0, DAILY_RESTART = 1, DAILY_REBOOT = 2} daily_restart_e;
typedef struct {
model_e model;
platform_e platform;
bool dbgUs;
bool ext_clk;
bool allow_admin_conns;
bool spectral_inversion, spectral_inversion_lockout;
float rf_attn_dB;
int CAT_fd, CAT_ch;
// lat/lon returned by ipinfo lookup
bool ipinfo_ll_valid;
float ipinfo_lat, ipinfo_lon;
// low-res lat/lon from timezone process
int lowres_lat, lowres_lon;
daily_restart_e daily_restart;
int ant_switch_nch;
} kiwi_t;
extern kiwi_t kiwi;
extern int version_maj, version_min;
extern bool background_mode, need_hardware, is_multi_core, any_preempt_autorun,
DUC_enable_start, rev_enable_start, web_nocache, kiwi_reg_debug, cmd_debug,
have_ant_switch_ext, gps_e1b_only, disable_led_task, debug_printfs, force_camp,
snr_local_time, log_local_ip, DRM_enable, have_snd_users, admin_keepalive;
extern int wf_sim, wf_real, wf_time, ev_dump, wf_flip, wf_exit, wf_start, tone, down, navg,
rx_cordic, rx_cic, rx_cic2, rx_dump, wf_cordic, wf_cic, wf_mult, wf_mult_gen, meas, monitors_max,
rx_yield, gps_chans, wf_max, rx_num, wf_num, do_slice, do_gps, do_sdr, wf_olap,
spi_clkg, spi_speed, spi_mode,
spi_delay, do_fft, noisePwr, unwrap, rev_iq, ineg, qneg, fft_file, fftsize, fftuse, bg, dx_print,
port, print_stats, ecpu_cmds, ecpu_tcmds, serial_number, ip_limit_mins, is_locked, test_flag, n_camp,
use_spidev, inactivity_timeout_mins, S_meter_cal, waterfall_cal, current_nusers, debug_v, debian_ver,
utc_offset, dst_offset, reg_kiwisdr_com_status, kiwi_reg_lo_kHz, kiwi_reg_hi_kHz,
debian_maj, debian_min, gps_debug, gps_var, gps_lo_gain, gps_cg_gain, use_foptim, web_caching_debug,
drm_nreg_chans, snr_meas_interval_hrs, snr_all, snr_HF, ant_connected;
extern char **main_argv;
extern u4_t ov_mask, snd_intr_usec;
extern float g_genfreq, g_genampl, g_mixfreq, max_thr;
extern double ui_srate, ui_srate_kHz, freq_offset_kHz, freq_offmax_kHz;
#define freq_offset freq_offset_kHz // ant switch ext compatibility
extern TYPEREAL DC_offset_I, DC_offset_Q;
extern kstr_t *cpu_stats_buf;
extern char *tzone_id, *tzone_name;
extern cfg_t cfg_ipl;
extern char *fpga_file;
extern lock_t spi_lock;
extern int p0, p1, p2;
extern double p_f[8];
extern int p_i[8];
typedef enum { DOM_SEL_NAM=0, DOM_SEL_DUC=1, DOM_SEL_PUB=2, DOM_SEL_SIP=3, DOM_SEL_REV=4 } dom_sel_e;
typedef enum { RX4_WF4=0, RX8_WF2=1, RX3_WF3=2, RX14_WF0=3 } firmware_e;
#define KEEPALIVE_SEC 60
#define KEEPALIVE_SEC_NO_AUTH 20 // don't hang the rx channel as long if waiting for password entry
// print_stats
#define STATS_GPS 0x01
#define STATS_GPS_SOLN 0x02
#define STATS_TASK 0x04
#define IDENT_LEN_MIN 16 // e.g. "wsprdaemon_v3.0a" is 16 chars
void kiwi_restart();
void fpga_init();
void update_freqs(bool *update_cfg = NULL);
void update_vars_from_config(bool called_at_init = false);
void cfg_adm_transition();
void dump();
void c2s_sound_init();
void c2s_sound_setup(void *param);
void c2s_sound(void *param);
void c2s_sound_shutdown(void *param);
void c2s_waterfall_init();
void c2s_waterfall_compression(int rx_chan, bool compression);
void c2s_waterfall_no_sync(int rx_chan, bool no_sync);
void c2s_waterfall_setup(void *param);
void c2s_waterfall(void *param);
void c2s_waterfall_shutdown(void *param);
void c2s_mon_setup(void *param);
void c2s_mon(void *param);
void c2s_admin_setup(void *param);
void c2s_admin_shutdown(void *param);
void c2s_admin(void *param);
void c2s_mfg_setup(void *param);
void c2s_mfg(void *param);
extern bool update_pending, update_in_progress, backup_in_progress;
extern int pending_maj, pending_min;
extern bool sd_copy_in_progress;
void stat_task(void *param);