You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.0 KiB
C

/*
* Copyright 2013-2019 Software Radio Systems Limited
10 years ago
*
* This file is part of srsLTE.
10 years ago
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
10 years ago
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE is distributed in the hope that it will be useful,
10 years ago
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
10 years ago
*
* A copy of the GNU Affero General Public License can be found in
10 years ago
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
/**********************************************************************************************
* File: agc.h
*
* Description: Automatic gain control
* This module is not currently used
*
* Reference:
*********************************************************************************************/
10 years ago
#ifndef SRSLTE_AGC_H
#define SRSLTE_AGC_H
10 years ago
#include <complex.h>
10 years ago
#include <stdbool.h>
#include <stdint.h>
#include "srslte/config.h"
10 years ago
7 years ago
#define SRSLTE_AGC_DEFAULT_TARGET 0.3
#define SRSLTE_AGC_DEFAULT_BW 0.7
10 years ago
typedef enum SRSLTE_API { SRSLTE_AGC_MODE_ENERGY = 0, SRSLTE_AGC_MODE_PEAK_AMPLITUDE } srslte_agc_mode_t;
10 years ago
typedef struct SRSLTE_API {
10 years ago
float bandwidth;
float gain;
float min_gain_db;
float max_gain_db;
10 years ago
float y_out;
bool lock;
bool isfirst;
void* uhd_handler;
float (*set_gain_callback)(void*, float);
srslte_agc_mode_t mode;
float target;
uint32_t nof_frames;
uint32_t frame_cnt;
float* y_tmp;
} srslte_agc_t;
10 years ago
SRSLTE_API int srslte_agc_init(srslte_agc_t* q, srslte_agc_mode_t mode);
10 years ago
SRSLTE_API int srslte_agc_init_acc(srslte_agc_t* q, srslte_agc_mode_t mode, uint32_t nof_frames);
10 years ago
SRSLTE_API int srslte_agc_init_uhd(srslte_agc_t* q,
srslte_agc_mode_t mode,
uint32_t nof_frames,
float(set_gain_callback)(void*, float),
void* uhd_handler);
10 years ago
SRSLTE_API void srslte_agc_free(srslte_agc_t* q);
10 years ago
SRSLTE_API void srslte_agc_reset(srslte_agc_t* q);
SRSLTE_API void srslte_agc_set_gain_range(srslte_agc_t* q, float min_gain_db, float max_gain_db);
SRSLTE_API void srslte_agc_set_bandwidth(srslte_agc_t* q, float bandwidth);
10 years ago
SRSLTE_API void srslte_agc_set_target(srslte_agc_t* q, float target);
10 years ago
SRSLTE_API float srslte_agc_get_rssi(srslte_agc_t* q);
10 years ago
SRSLTE_API float srslte_agc_get_output_level(srslte_agc_t* q);
SRSLTE_API float srslte_agc_get_gain(srslte_agc_t* q);
SRSLTE_API void srslte_agc_set_gain(srslte_agc_t* q, float init_gain_value_db);
SRSLTE_API void srslte_agc_lock(srslte_agc_t* q, bool enable);
10 years ago
SRSLTE_API void srslte_agc_process(srslte_agc_t* q, cf_t* signal, uint32_t len);
10 years ago
#endif // SRSLTE_AGC_H