bladerf_lib.h 3.54 KB
Newer Older
1
2
3
4
5
/*
 * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The OpenAirInterface Software Alliance licenses this file to You under
Cedric Roux's avatar
Cedric Roux committed
6
 * the OAI Public License, Version 1.1  (the "License"); you may not use this file
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 * except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.openairinterface.org/?page_id=698
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *-------------------------------------------------------------------------------
 * For more information about the OpenAirInterface (OAI) Software Alliance:
 *      contact@openairinterface.org
 */

nikaeinn's avatar
nikaeinn committed
22
23
24
25
/** bladerf_lib.h
 *
 * Author: navid nikaein
 */
26
27

#include <libbladeRF.h>
28
29

#include "common_lib.h"
Cedric Roux's avatar
Cedric Roux committed
30
#include "LOG/log.h"
31

32
33
34
35
36
/** @addtogroup _BLADERF_PHY_RF_INTERFACE_
 * @{
 */

/*! \brief BladeRF specific data structure */ 
37
38
typedef struct {

39
  //! opaque BladeRF device struct. An empty ("") or NULL device identifier will result in the first encountered device being opened (using the first discovered backend)
40
  struct bladerf *dev;
41
42
  
  //! Number of buffers
43
  unsigned int num_buffers;
44
  //! Buffer size 
45
  unsigned int buffer_size;
46
  //! Number of transfers
47
  unsigned int num_transfers;
48
  //! RX timeout
navid's avatar
navid committed
49
  unsigned int rx_timeout_ms;
50
  //! TX timeout
navid's avatar
navid committed
51
  unsigned int tx_timeout_ms;
52
  //! Metadata for RX
53
  struct bladerf_metadata meta_rx;
54
  //!Metadata for TX
55
  struct bladerf_metadata meta_tx;
56
  //! Sample rate
57
  unsigned int sample_rate;
58
  //! time offset between transmiter timestamp and receiver timestamp;
59
  double tdiff;
60
  //! TX number of forward samples use brf_time_offset to get this value
61
62
63
64
65
66
  int tx_forward_nsamps; //166 for 20Mhz


  // --------------------------------
  // Debug and output control
  // --------------------------------
67
  //! Number of underflows
68
  int num_underflows;
69
  //! Number of overflows
70
  int num_overflows;
71
  //! number of sequential errors
72
  int num_seq_errors;
73
  //! number of RX errors
74
  int num_rx_errors;
75
  //! Number of TX errors
76
77
  int num_tx_errors;

78
  //! timestamp of current TX
navid's avatar
navid committed
79
  uint64_t tx_current_ts;
80
  //! timestamp of current RX
navid's avatar
navid committed
81
  uint64_t rx_current_ts;
82
  //! number of actual samples transmitted
navid's avatar
navid committed
83
  uint64_t tx_actual_nsamps;
84
  //! number of actual samples received
navid's avatar
navid committed
85
  uint64_t rx_actual_nsamps;
86
  //! number of TX samples
navid's avatar
navid committed
87
  uint64_t tx_nsamps;
88
  //! number of RX samples
navid's avatar
navid committed
89
  uint64_t rx_nsamps;
90
  //! number of TX count
91
  uint64_t tx_count;
92
  //! number of RX count
93
  uint64_t rx_count;
94
  //! timestamp of RX packet
95
96
97
  openair0_timestamp rx_timestamp;

} brf_state_t;
98
99
100
/*
 * func prototypes 
 */
101
102
103
104
105
106
107
108
109
110
/*! \brief BladeRF Init function (not used at the moment)
 * \param device RF frontend parameters set by application
 */
int trx_brf_init(openair0_device *device);

/*! \brief get current timestamp
 *\param device the hardware to use 
 *\param module the bladeRf module
 */
openair0_timestamp trx_get_timestamp(openair0_device *device, bladerf_module module);
111

112
113
114
115
116
117
118
119
120
121
/*! \brief Get BladeRF log level
 * \param log_level log level
 * \returns log level of BLADERF device
 */
int get_brf_log_level(int log_level);

/*! \brief bladeRF error report 
 * \param status 
 * \returns 0 on success
 */
122
int brf_error(int status);
123

124
/*@}*/