SDDC_Driver
Loading...
Searching...
No Matches
config.h
1/*
2 * This file is part of SDDC_Driver.
3 *
4 * =====================
5 * MIT License
6 * =====================
7 *
8 * Copyright (C) 2020 - Oscar Steila
9 * Copyright (C) 2020 - Howard Su
10 * Copyright (C) 2021 - Hayati Ayguen
11 * Copyright (C) 2025 - RenardSpark
12 *
13 * Permission is hereby granted, free of charge, to any person obtaining a copy
14 * of this software and associated documentation files (the "Software"), to deal
15 * in the Software without restriction, including without limitation the rights
16 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 * copies of the Software, and to permit persons to whom the Software is
18 * furnished to do so, subject to the following conditions:
19
20 * The above copyright notice and this permission notice shall be included in all
21 * copies or substantial portions of the Software.
22
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29 * SOFTWARE.
30 *
31 * SPDX-License-Identifier: MIT
32 */
33
34#ifndef _CONFIG_H_
35#define _CONFIG_H_
36
37#include "types.h"
38#include "../Interface.h"
39#include <math.h> // atan => PI
40#include <stdbool.h>
41#include <cstdio>
42
43//#define _DEBUG // defined in VS configuration
44#define VERBOSE_ERROR
45#define VERBOSE_WARN
46//#define VERBOSE_TRACE
47//#define VERBOSE_TRACEEXTREME
48
49// macro to call callback function with just status extHWstatusT
50#define EXTIO_STATUS_CHANGE(TAG, CB, STATUS) \
51 do { \
52 SendMessage(h_dialog, WM_USER + 1, STATUS, 0); \
53 if (CB) { \
54 DebugPrintln(TAG, "<==CALLBACK: %s", #STATUS); \
55 CB( -1, STATUS, 0, NULL );\
56 }\
57 }while(0)
58
59#ifdef VERBOSE_DEBUG
60 #define EnterFunction() \
61 DbgPrintf("==>%s\n", __FUNCDNAME__)
62
63 #define EnterFunction1(v1) \
64 DbgPrintf("==>%s(%d)\n", __FUNCDNAME__, (v1))
65#else
66 #define EnterFunction()
67 #define EnterFunction1(v1)
68#endif
69
70#ifdef VERBOSE_ERROR
71 #define ErrorPrint(tag, fmt, ...) fprintf(stderr, "[SDDC] ERROR - %s: %s (%s:%d) " fmt, tag, __FUNCTION__, __FILE__, __LINE__, ##__VA_ARGS__)
72 #define ErrorPrintln(tag, fmt, ...) fprintf(stderr, "[SDDC] ERROR - %s: " fmt " (%s:%d)\n", tag, ##__VA_ARGS__, __FILE__, __LINE__)
73#else
74 #define ErrorPrint(tag, fmt, ...)
75 #define ErrorPrintln(tag, fmt, ...)
76#endif
77
78#ifdef VERBOSE_WARN
79 #define WarnPrint(tag, fmt, ...) fprintf(stderr, "[SDDC] WARN - %s: " fmt, tag, ##__VA_ARGS__)
80 #define WarnPrintln(tag, fmt, ...) fprintf(stderr, "[SDDC] WARN - %s: " fmt "\n", tag, ##__VA_ARGS__)
81#else
82 #define WarnPrint(tag, fmt, ...)
83 #define WarnPrintln(tag, fmt, ...)
84#endif
85
86#ifdef _DEBUG
87 #define DebugPrint(tag, fmt, ...) fprintf(stderr, "[SDDC] DEBUG - %s: " fmt, tag, ##__VA_ARGS__)
88 #define DebugPrintln(tag, fmt, ...) fprintf(stderr, "[SDDC] DEBUG - %s: " fmt "\n", tag, ##__VA_ARGS__)
89#else
90 #define DebugPrint(tag, fmt, ...)
91 #define DebugPrintln(tag, fmt, ...)
92#endif
93
94#ifdef VERBOSE_TRACE
95 #define TracePrint(tag, fmt, ...) fprintf(stderr, "[SDDC] TRACE - %s: %d-%s(" fmt ")", tag, __LINE__, __FUNCTION__, ##__VA_ARGS__)
96 #define TracePrintln(tag, fmt, ...) fprintf(stderr, "[SDDC] TRACE - %s: %d-%s(" fmt ")\n", tag, __LINE__, __FUNCTION__, ##__VA_ARGS__)
97#else
98 #define TracePrint(tag, fmt, ...)
99 #define TracePrintln(tag, fmt, ...)
100#endif
101
102#ifdef VERBOSE_TRACEEXTREME
103 #define TraceExtremePrint(tag, fmt, ...) TracePrint(tag, fmt, ##__VA_ARGS__)
104 #define TraceExtremePrintln(tag, fmt, ...) TracePrintln(tag, fmt, ##__VA_ARGS__)
105#else
106 #define TraceExtremePrint(tag, fmt, ...)
107 #define TraceExtremePrintln(tag, fmt, ...)
108#endif
109
110#define SWNAME "SDDC_Driver"
111
112
113#define FFTN_R_ADC (8192-2048) // FFTN used for ADC real stream DDC tested at 2048, 8192, 32768, 131072
114
115// GAINFACTORS to be adjusted with lab reference source measured with HDSDR Smeter rms mode
116#define BBRF103_GAINFACTOR (7.8e-8f) // BBRF103
117#define HF103_GAINFACTOR (1.14e-8f) // HF103
118#define RX888_GAINFACTOR (0.695e-8f) // RX888
119#define RX888mk2_GAINFACTOR (1.08e-8f) // RX888mk2
120
121
122
123#define EXT_BLOCKLEN 512 * 64 /* 32768 only multiples of 512 */
124
125// URL definitions
126#define URL1B "16bit SDR Receiver"
127#define URL1 "<a>http://www.hdsdr.de/</a>"
128#define URL_HDSR "http://www.hdsdr.de/"
129#define URL_HDSDRA "<a>http://www.hdsdr.de/</a>"
130
131
132extern bool saveADCsamplesflag;
133
134// transferSize must be a multiple of 16 (maxBurst) * 1024 (SS packet size) = 16384
135const uint32_t transferSize = 131072;
136const uint32_t transferSamples = transferSize / sizeof(int16_t);
137const uint32_t concurrentTransfers = 16; // used to be 96, but I think it is too high
138
139const uint32_t DEFAULT_ADC_FREQ = 1000000; // ADC sampling frequency
140
141const uint32_t DEFAULT_TRANSFERS_PER_SEC = DEFAULT_ADC_FREQ / transferSamples;
142
143
144
145#define MIN_ADC_FREQ 50000000 // ADC sampling frequency minimum
146#define MAX_ADC_FREQ 140000000 // ADC sampling frequency minimum
147#define N2_BANDSWITCH 80000000 // threshold 5 or 6 SR bandwidths
148
149
150#endif // _CONFIG_H_