61 lines
2.0 KiB
C
61 lines
2.0 KiB
C
/**
|
|
* common.h — Общие определения и конфигурация для приёмника и передатчика
|
|
* OFDM + RS(255,223) FEC + PlutoSDR
|
|
*/
|
|
|
|
#ifndef COMMON_H
|
|
#define COMMON_H
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
#include <signal.h>
|
|
#include <getopt.h>
|
|
#include <time.h>
|
|
#include <unistd.h>
|
|
#include <iio.h>
|
|
#include <liquid/liquid.h>
|
|
|
|
// Параметры OFDM-модуляции
|
|
#define OFDM_M 64
|
|
#define OFDM_CP 16
|
|
#define OFDM_TAPER 4
|
|
|
|
// Параметры Рида-Соломона
|
|
#define RS_DATA 223
|
|
#define RS_ENC 255
|
|
|
|
// Параметры радиотракта по умолчанию
|
|
#define DEFAULT_FREQ 1265000000LL
|
|
#define DEFAULT_RATE 3840000LL
|
|
#define DEFAULT_BW 3000000LL
|
|
|
|
// Адреса PlutoSDR
|
|
#define TX_URI_DEFAULT "ip:192.168.3.1" // адрес Pluto передатчика
|
|
#define RX_URI_DEFAULT "ip:192.168.2.1" // адрес Pluto приемника
|
|
|
|
// Формат заголовка кадра
|
|
#define HDR_SIGNATURE_0 0xF0
|
|
#define HDR_SIGNATURE_1 0xAA
|
|
#define HDR_SIZE 12
|
|
|
|
// Макросы логирования
|
|
#define LOG_ERROR(fmt, ...) fprintf(stderr, "[ОШИБКА] " fmt "\n", ##__VA_ARGS__)
|
|
#define LOG_INFO(fmt, ...) fprintf(stderr, "[INFO] " fmt "\n", ##__VA_ARGS__)
|
|
|
|
// Глобальный флаг завершения
|
|
extern volatile sig_atomic_t stop;
|
|
|
|
// Прототипы общих функций
|
|
void setup_signal_handlers(void);
|
|
void print_usage(const char *prog_name, const char *mode);
|
|
void print_config(const char *mode, long long freq, long long rate,
|
|
long long bw, int fec_on);
|
|
int pluto_init(const char *uri, struct iio_context **ctx,
|
|
struct iio_device **phy, struct iio_device **dev, int is_tx);
|
|
void pluto_configure(struct iio_device *phy, long long freq, long long rate,
|
|
long long bw, double gain, int is_tx);
|
|
|
|
#endif |