2014-03-03 11:09:26 -08:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* \section COPYRIGHT
|
|
|
|
*
|
2015-11-13 04:22:33 -08:00
|
|
|
* Copyright 2013-2015 Software Radio Systems Limited
|
2014-03-03 11:09:26 -08:00
|
|
|
*
|
|
|
|
* \section LICENSE
|
|
|
|
*
|
2015-03-18 05:31:13 -07:00
|
|
|
* This file is part of the srsLTE library.
|
2014-03-03 11:09:26 -08:00
|
|
|
*
|
2015-03-18 05:31:13 -07:00
|
|
|
* srsLTE is free software: you can redistribute it and/or modify
|
2015-05-08 08:05:40 -07:00
|
|
|
* it under the terms of the GNU Affero General Public License as
|
2014-03-03 11:09:26 -08:00
|
|
|
* published by the Free Software Foundation, either version 3 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
2015-03-18 05:31:13 -07:00
|
|
|
* srsLTE is distributed in the hope that it will be useful,
|
2014-03-03 11:09:26 -08:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2015-05-08 08:05:40 -07:00
|
|
|
* GNU Affero General Public License for more details.
|
2014-03-03 11:09:26 -08:00
|
|
|
*
|
2015-05-08 08:05:40 -07:00
|
|
|
* A copy of the GNU Affero General Public License can be found in
|
2014-03-03 11:09:26 -08:00
|
|
|
* the LICENSE file in the top-level directory of this distribution
|
|
|
|
* and at http://www.gnu.org/licenses/.
|
|
|
|
*
|
|
|
|
*/
|
2015-12-10 02:11:57 -08:00
|
|
|
|
|
|
|
#ifndef RF_H
|
|
|
|
#define RF_H
|
2014-03-03 11:09:26 -08:00
|
|
|
|
2015-12-10 02:11:57 -08:00
|
|
|
#include <sys/time.h>
|
2014-03-03 11:09:26 -08:00
|
|
|
#include <stdbool.h>
|
2014-07-21 07:19:17 -07:00
|
|
|
#include <stdint.h>
|
2015-12-17 00:30:49 -08:00
|
|
|
#include <pthread.h>
|
|
|
|
|
2015-03-18 05:16:28 -07:00
|
|
|
#include "srslte/config.h"
|
2014-06-17 06:20:00 -07:00
|
|
|
|
2015-12-10 02:11:57 -08:00
|
|
|
typedef struct {
|
|
|
|
void *handler;
|
|
|
|
void *dev;
|
2015-12-17 00:30:49 -08:00
|
|
|
|
|
|
|
// The following variables are for threaded RX gain control
|
|
|
|
pthread_t thread_gain;
|
|
|
|
pthread_cond_t cond;
|
|
|
|
pthread_mutex_t mutex;
|
|
|
|
double cur_rx_gain;
|
|
|
|
double new_rx_gain;
|
|
|
|
bool tx_gain_same_rx;
|
|
|
|
float tx_rx_gain_offset;
|
2015-12-16 09:02:25 -08:00
|
|
|
} srslte_rf_t;
|
2014-06-17 06:20:00 -07:00
|
|
|
|
2016-01-14 03:08:33 -08:00
|
|
|
typedef struct {
|
|
|
|
float dc_gain;
|
|
|
|
float dc_phase;
|
|
|
|
float iq_i;
|
|
|
|
float iq_q;
|
|
|
|
} srslte_rf_cal_t;
|
|
|
|
|
2015-12-18 03:38:25 -08:00
|
|
|
typedef struct {
|
|
|
|
enum {
|
|
|
|
SRSLTE_RF_ERROR_LATE,
|
|
|
|
SRSLTE_RF_ERROR_UNDERFLOW,
|
|
|
|
SRSLTE_RF_ERROR_OVERFLOW,
|
|
|
|
SRSLTE_RF_ERROR_OTHER
|
|
|
|
} type;
|
|
|
|
int opt;
|
|
|
|
const char *msg;
|
|
|
|
} srslte_rf_error_t;
|
|
|
|
|
|
|
|
typedef void (*srslte_rf_error_handler_t)(srslte_rf_error_t error);
|
2014-07-21 07:19:17 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API int srslte_rf_open(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
char *args);
|
2014-07-21 07:19:17 -07:00
|
|
|
|
2017-02-10 05:06:58 -08:00
|
|
|
SRSLTE_API int srslte_rf_open_multi(srslte_rf_t *h,
|
|
|
|
char *args,
|
2017-10-10 04:24:23 -07:00
|
|
|
uint32_t nof_channels);
|
2017-08-17 01:23:28 -07:00
|
|
|
|
2017-08-31 05:22:42 -07:00
|
|
|
SRSLTE_API int srslte_rf_open_devname(srslte_rf_t *h,
|
2017-02-10 05:06:58 -08:00
|
|
|
char *devname,
|
2017-10-10 04:24:23 -07:00
|
|
|
char *args,
|
|
|
|
uint32_t nof_channels);
|
2015-12-17 00:30:49 -08:00
|
|
|
|
2016-01-14 03:08:33 -08:00
|
|
|
SRSLTE_API const char *srslte_rf_name(srslte_rf_t *h);
|
|
|
|
|
2015-12-17 00:30:49 -08:00
|
|
|
SRSLTE_API int srslte_rf_start_gain_thread(srslte_rf_t *rf,
|
|
|
|
bool tx_gain_same_rx);
|
2015-09-12 06:00:21 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API int srslte_rf_close(srslte_rf_t *h);
|
2015-09-12 06:00:21 -07:00
|
|
|
|
2016-01-14 03:08:33 -08:00
|
|
|
SRSLTE_API void srslte_rf_set_tx_cal(srslte_rf_t *h, srslte_rf_cal_t *cal);
|
|
|
|
|
|
|
|
SRSLTE_API void srslte_rf_set_rx_cal(srslte_rf_t *h, srslte_rf_cal_t *cal);
|
|
|
|
|
2017-11-23 10:46:34 -08:00
|
|
|
SRSLTE_API int srslte_rf_start_rx_stream(srslte_rf_t *h, bool now);
|
2014-07-21 07:19:17 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API int srslte_rf_stop_rx_stream(srslte_rf_t *h);
|
2015-09-10 02:42:27 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API void srslte_rf_flush_buffer(srslte_rf_t *h);
|
2015-12-03 10:40:35 -08:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API bool srslte_rf_has_rssi(srslte_rf_t *h);
|
2014-07-21 07:19:17 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API float srslte_rf_get_rssi(srslte_rf_t *h);
|
2014-07-21 07:19:17 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API bool srslte_rf_rx_wait_lo_locked(srslte_rf_t *h);
|
2015-05-16 14:24:18 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API void srslte_rf_set_master_clock_rate(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
double rate);
|
2015-05-19 11:22:58 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API bool srslte_rf_is_master_clock_dynamic(srslte_rf_t *h);
|
2015-09-30 08:23:26 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API double srslte_rf_set_rx_srate(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
double freq);
|
2015-05-19 11:22:58 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API double srslte_rf_set_rx_gain(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
double gain);
|
2015-04-20 00:25:29 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API void srslte_rf_set_tx_rx_gain_offset(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
double offset);
|
2015-05-27 04:27:49 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API double srslte_rf_set_rx_gain_th(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
double gain);
|
2015-10-28 04:41:01 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API double srslte_rf_get_rx_gain(srslte_rf_t *h);
|
2015-09-27 12:51:10 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API double srslte_rf_get_tx_gain(srslte_rf_t *h);
|
2014-07-21 07:19:17 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API void srslte_rf_suppress_stdout(srslte_rf_t *h);
|
2015-03-05 09:36:15 -08:00
|
|
|
|
2015-12-18 03:38:25 -08:00
|
|
|
SRSLTE_API void srslte_rf_register_error_handler(srslte_rf_t *h,
|
|
|
|
srslte_rf_error_handler_t error_handler);
|
2014-07-21 07:19:17 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API double srslte_rf_set_rx_freq(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
double freq);
|
2015-03-05 09:36:15 -08:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API int srslte_rf_recv(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
void *data,
|
|
|
|
uint32_t nsamples,
|
|
|
|
bool blocking);
|
2014-07-21 07:19:17 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API int srslte_rf_recv_with_time(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
void *data,
|
|
|
|
uint32_t nsamples,
|
|
|
|
bool blocking,
|
|
|
|
time_t *secs,
|
|
|
|
double *frac_secs);
|
2014-07-21 07:19:17 -07:00
|
|
|
|
2017-02-08 14:21:07 -08:00
|
|
|
SRSLTE_API int srslte_rf_recv_with_time_multi(srslte_rf_t *h,
|
|
|
|
void **data,
|
|
|
|
uint32_t nsamples,
|
|
|
|
bool blocking,
|
|
|
|
time_t *secs,
|
|
|
|
double *frac_secs);
|
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API double srslte_rf_set_tx_srate(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
double freq);
|
2014-07-21 07:19:17 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API double srslte_rf_set_tx_gain(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
double gain);
|
2014-07-21 07:19:17 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API double srslte_rf_set_tx_freq(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
double freq);
|
2015-02-24 02:19:42 -08:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API void srslte_rf_get_time(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
time_t *secs,
|
|
|
|
double *frac_secs);
|
2015-04-14 01:41:17 -07:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API int srslte_rf_send(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
void *data,
|
|
|
|
uint32_t nsamples,
|
|
|
|
bool blocking);
|
2015-03-02 02:11:44 -08:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API int srslte_rf_send2(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
void *data,
|
|
|
|
uint32_t nsamples,
|
|
|
|
bool blocking,
|
|
|
|
bool start_of_burst,
|
|
|
|
bool end_of_burst);
|
2015-03-02 02:11:44 -08:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API int srslte_rf_send(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
void *data,
|
|
|
|
uint32_t nsamples,
|
|
|
|
bool blocking);
|
2014-03-03 11:09:26 -08:00
|
|
|
|
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API int srslte_rf_send_timed(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
void *data,
|
|
|
|
int nsamples,
|
|
|
|
time_t secs,
|
|
|
|
double frac_secs);
|
2015-02-24 02:19:42 -08:00
|
|
|
|
2015-12-16 09:02:25 -08:00
|
|
|
SRSLTE_API int srslte_rf_send_timed2(srslte_rf_t *h,
|
2015-12-10 02:11:57 -08:00
|
|
|
void *data,
|
|
|
|
int nsamples,
|
|
|
|
time_t secs,
|
|
|
|
double frac_secs,
|
|
|
|
bool is_start_of_burst,
|
|
|
|
bool is_end_of_burst);
|
2015-03-02 02:11:44 -08:00
|
|
|
|
2017-08-28 04:05:27 -07:00
|
|
|
SRSLTE_API int srslte_rf_send_timed_multi(srslte_rf_t *rf,
|
|
|
|
void *data[4],
|
|
|
|
int nsamples,
|
|
|
|
time_t secs,
|
|
|
|
double frac_secs,
|
|
|
|
bool blocking,
|
|
|
|
bool is_start_of_burst,
|
|
|
|
bool is_end_of_burst);
|
|
|
|
|
2017-07-25 04:17:36 -07:00
|
|
|
SRSLTE_API int srslte_rf_send_multi(srslte_rf_t *rf,
|
|
|
|
void *data[4],
|
|
|
|
int nsamples,
|
|
|
|
bool blocking,
|
|
|
|
bool is_start_of_burst,
|
|
|
|
bool is_end_of_burst);
|
|
|
|
|
2015-10-28 04:41:01 -07:00
|
|
|
#endif
|
2015-12-10 02:11:57 -08:00
|
|
|
|