srsLTE/srslte/include/srslte/agc/agc.h

106 lines
3.1 KiB
C
Raw Normal View History

2014-07-21 08:54:25 -07:00
/**
*
* \section COPYRIGHT
*
2015-05-08 08:05:40 -07:00
* Copyright 2013-2015 The srsLTE Developers. See the
2014-07-21 08:54:25 -07:00
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the srsLTE library.
2014-07-21 08:54:25 -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-07-21 08:54:25 -07:00
* 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,
2014-07-21 08:54:25 -07: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-07-21 08:54:25 -07:00
*
2015-05-08 08:05:40 -07:00
* A copy of the GNU Affero General Public License can be found in
2014-07-21 08:54:25 -07:00
* 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:
*********************************************************************************************/
2014-07-21 08:54:25 -07:00
#ifndef AGC_
#define AGC_
#include <stdbool.h>
#include <stdint.h>
#include <complex.h>
#include "srslte/config.h"
2014-07-21 08:54:25 -07:00
2015-05-08 01:35:39 -07:00
#define SRSLTE_AGC_DEFAULT_TARGET 0.7
2015-05-16 14:24:18 -07:00
#define SRSLTE_AGC_DEFAULT_BW (5e-1)
2015-04-20 00:25:29 -07:00
typedef enum SRSLTE_API {
SRSLTE_AGC_MODE_ENERGY = 0,
SRSLTE_AGC_MODE_PEAK_AMPLITUDE
} srslte_agc_mode_t;
2014-07-21 08:54:25 -07:00
typedef struct SRSLTE_API{
2014-07-21 08:54:25 -07:00
float bandwidth;
2015-04-20 00:25:29 -07:00
double gain;
2014-07-21 08:54:25 -07:00
float y_out;
bool lock;
bool isfirst;
2015-04-20 00:25:29 -07:00
void *uhd_handler;
double (*set_gain_callback) (void*,double);
srslte_agc_mode_t mode;
float target;
2015-04-21 02:09:08 -07:00
uint32_t nof_frames;
uint32_t frame_cnt;
float *y_tmp;
} srslte_agc_t;
2014-07-21 08:54:25 -07:00
2015-04-20 00:25:29 -07:00
SRSLTE_API int srslte_agc_init(srslte_agc_t *q, srslte_agc_mode_t mode);
2015-04-21 02:09:08 -07:00
SRSLTE_API int srslte_agc_init_acc(srslte_agc_t *q, srslte_agc_mode_t mode, uint32_t nof_frames);
2015-04-20 00:25:29 -07:00
SRSLTE_API int srslte_agc_init_uhd(srslte_agc_t *q,
srslte_agc_mode_t mode,
2015-04-21 02:09:08 -07:00
uint32_t nof_frames,
2015-04-20 00:25:29 -07:00
double (set_gain_callback)(void*, double),
void *uhd_handler);
2014-07-21 08:54:25 -07:00
SRSLTE_API void srslte_agc_free(srslte_agc_t *q);
2014-07-21 08:54:25 -07:00
SRSLTE_API void srslte_agc_reset(srslte_agc_t *q);
SRSLTE_API void srslte_agc_set_bandwidth(srslte_agc_t *q,
2015-04-20 00:25:29 -07:00
float bandwidth);
SRSLTE_API void srslte_agc_set_target(srslte_agc_t *q,
float target);
2014-07-21 08:54:25 -07:00
SRSLTE_API float srslte_agc_get_rssi(srslte_agc_t *q);
2014-07-21 08:54:25 -07:00
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);
SRSLTE_API void srslte_agc_lock(srslte_agc_t *q,
bool enable);
2014-07-21 08:54:25 -07:00
SRSLTE_API void srslte_agc_process(srslte_agc_t *q,
2015-04-21 02:09:08 -07:00
cf_t *signal,
uint32_t len);
2014-07-21 08:54:25 -07:00
#endif // AGC_