Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 2bcfde21a73ffa0573b5ca7b311a2f76 > files > 8

bladerf-doc-2018.12-0.rc3.1.mga7.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>libbladeRF: Device Configuration</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script><script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">libbladeRF
   &#160;<span id="projectnumber">1.7.2</span>
   </div>
   <div id="projectbrief">Nuand bladeRF library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>API&#160;Sections</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Device Configuration </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>This page presents an overview on how to configure a bladeRF device via the libbladeRF API. A complete boilerplate code listing may be found at the end of this page.</p>
<h2>Acquiring a device handle</h2>
<p>First, one must acquire a handle to a bladeRF device. Four common approaches to this are: </p><ul>
<li>
Open the first available device. </li>
<li>
Open a device with a specified serial number. </li>
<li>
Open a device with the specified USB bus and address values. </li>
<li>
Choose a device from a list of all available devices. </li>
</ul>
<p>The first three approaches can be implemented via a call to <a class="el" href="group___f_n___i_n_i_t.html#gab341ac98615f393da9158ea59cdb6a24">bladerf_open()</a> or <a class="el" href="group___f_n___i_n_i_t.html#gace4d5607aacba15ccd2d5361d5eb020e">bladerf_open_with_devinfo()</a>. Both of these functions offer the same functionality, but through a slightly different interface. Note that per the documentation of each of these functions, NULL can be specified as one of the arguments to specify, "open any available bladeRF device."</p>
<p><a class="el" href="group___f_n___i_n_i_t.html#gab341ac98615f393da9158ea59cdb6a24">bladerf_open()</a> takes a specially formatted "device identifier" string as an argument. This provides a simple means to give the user full control over how the desired device is specified, perhaps through a command-line argument or GUI text field.</p>
<p><a class="el" href="group___f_n___i_n_i_t.html#gace4d5607aacba15ccd2d5361d5eb020e">bladerf_open_with_devinfo()</a> uses a <a class="el" href="structbladerf__devinfo.html">bladerf_devinfo</a> structure to identify the device to open. This is generally a better choice when programatically deciding which device to open, as it alleviates the need to craft a device identifier string. This approach is taken in the below snippet, where argv[1] may contain a serial number string. In the case when argc &lt; 2, the <code>dev_info.serial</code> field is left as its wildcard ("any value") field from the <a class="el" href="group___f_n___i_n_i_t.html#ga3a046eac7a17ac794d50fbb2e086a136">bladerf_init_devinfo()</a> call.</p>
<div class="fragment"><div class="line">    <span class="keyword">struct </span>bladerf *dev = NULL;</div><div class="line">    <span class="keyword">struct </span><a class="code" href="structbladerf__devinfo.html">bladerf_devinfo</a> dev_info;</div><div class="line"></div><div class="line">    <span class="comment">/* Initialize the information used to identify the desired device</span></div><div class="line"><span class="comment">     * to all wildcard (i.e., &quot;any device&quot;) values */</span></div><div class="line">    <a class="code" href="group___f_n___i_n_i_t.html#ga3a046eac7a17ac794d50fbb2e086a136">bladerf_init_devinfo</a>(&amp;dev_info);</div><div class="line"></div><div class="line">    <span class="comment">/* Request a device with the provided serial number.</span></div><div class="line"><span class="comment">     * Invalid strings should simply fail to match a device. */</span></div><div class="line">    <span class="keywordflow">if</span> (argc &gt;= 2) {</div><div class="line">        strncpy(dev_info.serial, argv[1], <span class="keyword">sizeof</span>(dev_info.serial) - 1);</div><div class="line">    }</div><div class="line"></div><div class="line">    status = <a class="code" href="group___f_n___i_n_i_t.html#gace4d5607aacba15ccd2d5361d5eb020e">bladerf_open_with_devinfo</a>(&amp;dev, &amp;dev_info);</div><div class="line">    <span class="keywordflow">if</span> (status != 0) {</div><div class="line">        fprintf(stderr, <span class="stringliteral">&quot;Unable to open device: %s\n&quot;</span>,</div><div class="line">                <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line"></div><div class="line">        <span class="keywordflow">return</span> 1;</div><div class="line">    }</div></div><!-- fragment --><p> The last approach in the beginning of this section is a good choice for programs that need to present a list of available devices to a user. A list of connected bladeRF devices may be retrieved via <a class="el" href="group___f_n___i_n_i_t.html#ga21537e871d943798142176d9a29a5c46">bladerf_get_device_list()</a>. The contents of each <a class="el" href="structbladerf__devinfo.html">bladerf_devinfo</a> could then be presented to a user for selection, and the desired device's <a class="el" href="structbladerf__devinfo.html">bladerf_devinfo</a> can then be passed to <a class="el" href="group___f_n___i_n_i_t.html#gace4d5607aacba15ccd2d5361d5eb020e">bladerf_open_with_devinfo()</a>. The device list can then be freed using <a class="el" href="group___f_n___i_n_i_t.html#ga1bf915af51bd39fa6c18e002d8bfc37a">bladerf_free_device_list()</a>.</p>
<p><br />
</p>
<h2>Configuring Device parameters</h2>
<p>After acquiring a handle to a bladeRF device, the following must be configured prior to transmitting or receiving samples.</p>
<ul>
<li>
Frequency </li>
<li>
Gains </li>
<li>
Sample Rate </li>
<li>
Bandwidth </li>
</ul>
<p>Note that all of the above are configured on a per-module (i.e, RX or TX) basis.</p>
<h3>Selecting Appropriate Values </h3>
<p>To better understand each of the available gains controls, see Figures 1, 2, and 3 in the <a href="http://www.limemicro.com/download/lms6002dr2-datasheet-1.2r0.pdf" class="el">LMS6002D datasheet</a>. In general, one stage should be increased prior to increasing the following stage. For RX, increase the LNA gain, followed by RX VGA1, then RX VGA2. Similarly, increase TX VGA1 first, then TX VGA2.</p>
<p>The selection of sample rate and bandwidth are tightly coupled. In general, the sample rate must be high enough to ensure that all desired signals can be sampled without aliasing. However, note that the LMS6002D provides a discrete set of bandwidth options. This implies that one's sample rate selection will largely be influenced by the bandwidth option that most closely matches the desired value.</p>
<p>The bandwidth parameter controls the LMS6002D's RF front-end (RFFE) low-pass filter (LPF) setting. This should be configured to be less than the sample rate to ensure that the filter has reached maximum attenuation before reaching the desired sample rate value. Otherwise, noise and aliases may "fold" into the frequency range of interest.</p>
<p>Consult the plots in Figure 5 of the <a href="http://www.limemicro.com/download/lms6002dr2-datasheet-1.2r0.pdf" class="el">LMS6002D datasheet</a> for the RX/TX filter responses. Note that the filter ranges are listed in the datasheet are listed in terms of 0 to Fs/2, whereas <a class="el" href="group___f_n___b_a_n_d_w_i_d_t_h.html#ga1214e2bb1ec38f981015aeafdd846c29">bladerf_set_bandwidth()</a> assumes the total bandwidth (-Fs/2 to Fs/2) is being specified. Consider the plot for the 0.75 MHz filter (which corresponds to 1.5 MHz of total BW). At 1 MHz (2 MHZ of total BW), this filter offers over -45 dB of rejection. At ~1.8 MHz (3.6 MHz of total BW), this filter offers over -60 dB of rejection.</p>
<p>Therefore, when calling <a class="el" href="group___f_n___b_a_n_d_w_i_d_t_h.html#ga1214e2bb1ec38f981015aeafdd846c29">bladerf_set_bandwidth()</a> with a value of 1.5 MHz, a sample rate 2 MHz would be a preferred minimum, and a sample rate &gt;= 3.6 MHz would be an even better choice.</p>
<h3>Applying a set of values</h3>
<p>It is common for a program to apply all of these settings during its initialization. Therefore, the example in this page groups these parameters into a structure and then uses a <code>configure_module()</code> helper function to apply them:</p>
<div class="fragment"><div class="line"><span class="comment">/* The RX and TX modules are configured independently for these parameters */</span></div><div class="line"><span class="keyword">struct </span>module_config {</div><div class="line">    <a class="code" href="group___f_n___m_o_d_u_l_e.html#gab12571146a3d4c5d79ac497a74b3fb5e">bladerf_module</a> module;</div><div class="line"></div><div class="line">    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> frequency;</div><div class="line">    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> bandwidth;</div><div class="line">    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> samplerate;</div><div class="line"></div><div class="line">    <span class="comment">/* Gains */</span></div><div class="line">    <a class="code" href="group___f_n___g_a_i_n.html#ga61ff30f82a42e90653a4cf69d43f9cc2">bladerf_lna_gain</a> rx_lna;</div><div class="line">    <span class="keywordtype">int</span> vga1;</div><div class="line">    <span class="keywordtype">int</span> vga2;</div><div class="line">};</div></div><!-- fragment --><p> As shown in the below implementation of <code>configure_module()</code>, the general procedure for applying a parameter involves calling the corresponding function and checking the return value.</p>
<p>Note that some functions, such as <a class="el" href="group___f_n___s_a_m_p_l_i_n_g.html#ga248121816cd4621abf833df906ca0761">bladerf_set_sample_rate()</a> and <a class="el" href="group___f_n___b_a_n_d_w_i_d_t_h.html#ga1214e2bb1ec38f981015aeafdd846c29">bladerf_set_bandwidth()</a>, have optional <code>actual</code> output parameters that are set to NULL in this example. These <code>actual</code> values are used to provide feedback about the differences between the requested value and the actual value applied. Some error may occur in converting the sample rate into a rational fraction, as required by the underlying hardware. As previously, mentioned, the LMS600D provides a discrete set of RFFE LPF bandwidth settings. <a class="el" href="group___f_n___b_a_n_d_w_i_d_t_h.html#ga1214e2bb1ec38f981015aeafdd846c29">bladerf_set_bandwidth()</a> will choose the closest bandwidth setting, and report this via the optional <code>actual</code> parameter.</p>
<div class="fragment"><div class="line"><span class="keywordtype">int</span> configure_module(<span class="keyword">struct</span> bladerf *dev, <span class="keyword">struct</span> module_config *c)</div><div class="line">{</div><div class="line">    <span class="keywordtype">int</span> status;</div><div class="line"></div><div class="line">    status = <a class="code" href="group___f_n___t_u_n_i_n_g.html#ga466bda3044a773832c7679253cf38976">bladerf_set_frequency</a>(dev, c-&gt;module, c-&gt;frequency);</div><div class="line">    <span class="keywordflow">if</span> (status != 0) {</div><div class="line">        fprintf(stderr, <span class="stringliteral">&quot;Failed to set frequency = %u: %s\n&quot;</span>,</div><div class="line">                c-&gt;frequency, <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line">        <span class="keywordflow">return</span> status;</div><div class="line">    }</div><div class="line"></div><div class="line">    status = <a class="code" href="group___f_n___s_a_m_p_l_i_n_g.html#ga248121816cd4621abf833df906ca0761">bladerf_set_sample_rate</a>(dev, c-&gt;module, c-&gt;samplerate, NULL);</div><div class="line">    <span class="keywordflow">if</span> (status != 0) {</div><div class="line">        fprintf(stderr, <span class="stringliteral">&quot;Failed to set samplerate = %u: %s\n&quot;</span>,</div><div class="line">                c-&gt;samplerate, <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line">        <span class="keywordflow">return</span> status;</div><div class="line">    }</div><div class="line"></div><div class="line">    status = <a class="code" href="group___f_n___b_a_n_d_w_i_d_t_h.html#ga1214e2bb1ec38f981015aeafdd846c29">bladerf_set_bandwidth</a>(dev, c-&gt;module, c-&gt;bandwidth, NULL);</div><div class="line">    <span class="keywordflow">if</span> (status != 0) {</div><div class="line">        fprintf(stderr, <span class="stringliteral">&quot;Failed to set bandwidth = %u: %s\n&quot;</span>,</div><div class="line">                c-&gt;bandwidth, <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line">        <span class="keywordflow">return</span> status;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">switch</span> (c-&gt;module) {</div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group___f_n___m_o_d_u_l_e.html#ggab12571146a3d4c5d79ac497a74b3fb5ea8df9d0339c79bf7221af3a3897360c6f">BLADERF_MODULE_RX</a>:</div><div class="line">            <span class="comment">/* Configure the gains of the RX LNA, RX VGA1, and RX VGA2  */</span></div><div class="line">            status = <a class="code" href="group___f_n___g_a_i_n.html#ga0fb476f5db160d14f5d5b0de5ac26ed1">bladerf_set_lna_gain</a>(dev, c-&gt;rx_lna);</div><div class="line">            <span class="keywordflow">if</span> (status != 0) {</div><div class="line">                fprintf(stderr, <span class="stringliteral">&quot;Failed to set RX LNA gain: %s\n&quot;</span>,</div><div class="line">                        <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line">                <span class="keywordflow">return</span> status;</div><div class="line">            }</div><div class="line"></div><div class="line">            status = <a class="code" href="group___f_n___g_a_i_n.html#gaf03c4ba526c3cbf1f4372046ba76d371">bladerf_set_rxvga1</a>(dev, c-&gt;vga1);</div><div class="line">            <span class="keywordflow">if</span> (status != 0) {</div><div class="line">                fprintf(stderr, <span class="stringliteral">&quot;Failed to set RX VGA1 gain: %s\n&quot;</span>,</div><div class="line">                        <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line">                <span class="keywordflow">return</span> status;</div><div class="line">            }</div><div class="line"></div><div class="line">            status = <a class="code" href="group___f_n___g_a_i_n.html#gaa4a4d20aaec40727d45378f432023b93">bladerf_set_rxvga2</a>(dev, c-&gt;vga2);</div><div class="line">            <span class="keywordflow">if</span> (status != 0) {</div><div class="line">                fprintf(stderr, <span class="stringliteral">&quot;Failed to set RX VGA2 gain: %s\n&quot;</span>,</div><div class="line">                        <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line">                <span class="keywordflow">return</span> status;</div><div class="line">            }</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group___f_n___m_o_d_u_l_e.html#ggab12571146a3d4c5d79ac497a74b3fb5ea2b59868119a050b6f0e24631ffbb16e3">BLADERF_MODULE_TX</a>:</div><div class="line">            <span class="comment">/* Configure the TX VGA1 and TX VGA2 gains */</span></div><div class="line">            status = <a class="code" href="group___f_n___g_a_i_n.html#ga89706116066f01d7a6eeb9e18dbd0db3">bladerf_set_txvga1</a>(dev, c-&gt;vga1);</div><div class="line">            <span class="keywordflow">if</span> (status != 0) {</div><div class="line">                fprintf(stderr, <span class="stringliteral">&quot;Failed to set TX VGA1 gain: %s\n&quot;</span>,</div><div class="line">                        <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line">                <span class="keywordflow">return</span> status;</div><div class="line">            }</div><div class="line"></div><div class="line">            status = <a class="code" href="group___f_n___g_a_i_n.html#ga5a32dd46a54c815aa2005e50c1a5c894">bladerf_set_txvga2</a>(dev, c-&gt;vga2);</div><div class="line">            <span class="keywordflow">if</span> (status != 0) {</div><div class="line">                fprintf(stderr, <span class="stringliteral">&quot;Failed to set TX VGA2 gain: %s\n&quot;</span>,</div><div class="line">                        <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line">                <span class="keywordflow">return</span> status;</div><div class="line">            }</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">        <span class="keywordflow">default</span>:</div><div class="line">            status = <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga1a47b33b1f0561258584a0d13a7a1a56">BLADERF_ERR_INVAL</a>;</div><div class="line">            fprintf(stderr, <span class="stringliteral">&quot;%s: Invalid module specified (%d)\n&quot;</span>,</div><div class="line">                    __FUNCTION__, c-&gt;module);</div><div class="line"></div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">}</div><div class="line"></div></div><!-- fragment --><p><br />
 </p><h2>Complete listing</h2>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;stdlib.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;string.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;stdio.h&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="libblade_r_f_8h.html">libbladeRF.h</a>&gt;</span></div><div class="line"></div><div class="line"><span class="comment">/* The RX and TX modules are configured independently for these parameters */</span></div><div class="line"><span class="keyword">struct </span>module_config {</div><div class="line">    <a class="code" href="group___f_n___m_o_d_u_l_e.html#gab12571146a3d4c5d79ac497a74b3fb5e">bladerf_module</a> module;</div><div class="line"></div><div class="line">    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> frequency;</div><div class="line">    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> bandwidth;</div><div class="line">    <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> samplerate;</div><div class="line"></div><div class="line">    <span class="comment">/* Gains */</span></div><div class="line">    <a class="code" href="group___f_n___g_a_i_n.html#ga61ff30f82a42e90653a4cf69d43f9cc2">bladerf_lna_gain</a> rx_lna;</div><div class="line">    <span class="keywordtype">int</span> vga1;</div><div class="line">    <span class="keywordtype">int</span> vga2;</div><div class="line">};</div><div class="line"><span class="keywordtype">int</span> configure_module(<span class="keyword">struct</span> bladerf *dev, <span class="keyword">struct</span> module_config *c)</div><div class="line">{</div><div class="line">    <span class="keywordtype">int</span> status;</div><div class="line"></div><div class="line">    status = <a class="code" href="group___f_n___t_u_n_i_n_g.html#ga466bda3044a773832c7679253cf38976">bladerf_set_frequency</a>(dev, c-&gt;module, c-&gt;frequency);</div><div class="line">    <span class="keywordflow">if</span> (status != 0) {</div><div class="line">        fprintf(stderr, <span class="stringliteral">&quot;Failed to set frequency = %u: %s\n&quot;</span>,</div><div class="line">                c-&gt;frequency, <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line">        <span class="keywordflow">return</span> status;</div><div class="line">    }</div><div class="line"></div><div class="line">    status = <a class="code" href="group___f_n___s_a_m_p_l_i_n_g.html#ga248121816cd4621abf833df906ca0761">bladerf_set_sample_rate</a>(dev, c-&gt;module, c-&gt;samplerate, NULL);</div><div class="line">    <span class="keywordflow">if</span> (status != 0) {</div><div class="line">        fprintf(stderr, <span class="stringliteral">&quot;Failed to set samplerate = %u: %s\n&quot;</span>,</div><div class="line">                c-&gt;samplerate, <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line">        <span class="keywordflow">return</span> status;</div><div class="line">    }</div><div class="line"></div><div class="line">    status = <a class="code" href="group___f_n___b_a_n_d_w_i_d_t_h.html#ga1214e2bb1ec38f981015aeafdd846c29">bladerf_set_bandwidth</a>(dev, c-&gt;module, c-&gt;bandwidth, NULL);</div><div class="line">    <span class="keywordflow">if</span> (status != 0) {</div><div class="line">        fprintf(stderr, <span class="stringliteral">&quot;Failed to set bandwidth = %u: %s\n&quot;</span>,</div><div class="line">                c-&gt;bandwidth, <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line">        <span class="keywordflow">return</span> status;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">switch</span> (c-&gt;module) {</div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group___f_n___m_o_d_u_l_e.html#ggab12571146a3d4c5d79ac497a74b3fb5ea8df9d0339c79bf7221af3a3897360c6f">BLADERF_MODULE_RX</a>:</div><div class="line">            <span class="comment">/* Configure the gains of the RX LNA, RX VGA1, and RX VGA2  */</span></div><div class="line">            status = <a class="code" href="group___f_n___g_a_i_n.html#ga0fb476f5db160d14f5d5b0de5ac26ed1">bladerf_set_lna_gain</a>(dev, c-&gt;rx_lna);</div><div class="line">            <span class="keywordflow">if</span> (status != 0) {</div><div class="line">                fprintf(stderr, <span class="stringliteral">&quot;Failed to set RX LNA gain: %s\n&quot;</span>,</div><div class="line">                        <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line">                <span class="keywordflow">return</span> status;</div><div class="line">            }</div><div class="line"></div><div class="line">            status = <a class="code" href="group___f_n___g_a_i_n.html#gaf03c4ba526c3cbf1f4372046ba76d371">bladerf_set_rxvga1</a>(dev, c-&gt;vga1);</div><div class="line">            <span class="keywordflow">if</span> (status != 0) {</div><div class="line">                fprintf(stderr, <span class="stringliteral">&quot;Failed to set RX VGA1 gain: %s\n&quot;</span>,</div><div class="line">                        <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line">                <span class="keywordflow">return</span> status;</div><div class="line">            }</div><div class="line"></div><div class="line">            status = <a class="code" href="group___f_n___g_a_i_n.html#gaa4a4d20aaec40727d45378f432023b93">bladerf_set_rxvga2</a>(dev, c-&gt;vga2);</div><div class="line">            <span class="keywordflow">if</span> (status != 0) {</div><div class="line">                fprintf(stderr, <span class="stringliteral">&quot;Failed to set RX VGA2 gain: %s\n&quot;</span>,</div><div class="line">                        <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line">                <span class="keywordflow">return</span> status;</div><div class="line">            }</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group___f_n___m_o_d_u_l_e.html#ggab12571146a3d4c5d79ac497a74b3fb5ea2b59868119a050b6f0e24631ffbb16e3">BLADERF_MODULE_TX</a>:</div><div class="line">            <span class="comment">/* Configure the TX VGA1 and TX VGA2 gains */</span></div><div class="line">            status = <a class="code" href="group___f_n___g_a_i_n.html#ga89706116066f01d7a6eeb9e18dbd0db3">bladerf_set_txvga1</a>(dev, c-&gt;vga1);</div><div class="line">            <span class="keywordflow">if</span> (status != 0) {</div><div class="line">                fprintf(stderr, <span class="stringliteral">&quot;Failed to set TX VGA1 gain: %s\n&quot;</span>,</div><div class="line">                        <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line">                <span class="keywordflow">return</span> status;</div><div class="line">            }</div><div class="line"></div><div class="line">            status = <a class="code" href="group___f_n___g_a_i_n.html#ga5a32dd46a54c815aa2005e50c1a5c894">bladerf_set_txvga2</a>(dev, c-&gt;vga2);</div><div class="line">            <span class="keywordflow">if</span> (status != 0) {</div><div class="line">                fprintf(stderr, <span class="stringliteral">&quot;Failed to set TX VGA2 gain: %s\n&quot;</span>,</div><div class="line">                        <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line">                <span class="keywordflow">return</span> status;</div><div class="line">            }</div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">        <span class="keywordflow">default</span>:</div><div class="line">            status = <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga1a47b33b1f0561258584a0d13a7a1a56">BLADERF_ERR_INVAL</a>;</div><div class="line">            fprintf(stderr, <span class="stringliteral">&quot;%s: Invalid module specified (%d)\n&quot;</span>,</div><div class="line">                    __FUNCTION__, c-&gt;module);</div><div class="line"></div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="comment">/* Usage:</span></div><div class="line"><span class="comment"> *   libbladeRF_example_boilerplate [serial #]</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * If a serial number is supplied, the program will attempt to open the</span></div><div class="line"><span class="comment"> * device with the provided serial number.</span></div><div class="line"><span class="comment"> *</span></div><div class="line"><span class="comment"> * Otherwise, the first available device will be used.</span></div><div class="line"><span class="comment"> */</span></div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])</div><div class="line">{</div><div class="line">    <span class="keywordtype">int</span> status;</div><div class="line">    <span class="keyword">struct </span>module_config config;</div><div class="line"></div><div class="line">    <span class="keyword">struct </span>bladerf *dev = NULL;</div><div class="line">    <span class="keyword">struct </span><a class="code" href="structbladerf__devinfo.html">bladerf_devinfo</a> dev_info;</div><div class="line"></div><div class="line">    <span class="comment">/* Initialize the information used to identify the desired device</span></div><div class="line"><span class="comment">     * to all wildcard (i.e., &quot;any device&quot;) values */</span></div><div class="line">    <a class="code" href="group___f_n___i_n_i_t.html#ga3a046eac7a17ac794d50fbb2e086a136">bladerf_init_devinfo</a>(&amp;dev_info);</div><div class="line"></div><div class="line">    <span class="comment">/* Request a device with the provided serial number.</span></div><div class="line"><span class="comment">     * Invalid strings should simply fail to match a device. */</span></div><div class="line">    <span class="keywordflow">if</span> (argc &gt;= 2) {</div><div class="line">        strncpy(dev_info.serial, argv[1], <span class="keyword">sizeof</span>(dev_info.serial) - 1);</div><div class="line">    }</div><div class="line"></div><div class="line">    status = <a class="code" href="group___f_n___i_n_i_t.html#gace4d5607aacba15ccd2d5361d5eb020e">bladerf_open_with_devinfo</a>(&amp;dev, &amp;dev_info);</div><div class="line">    <span class="keywordflow">if</span> (status != 0) {</div><div class="line">        fprintf(stderr, <span class="stringliteral">&quot;Unable to open device: %s\n&quot;</span>,</div><div class="line">                <a class="code" href="group___r_e_t_c_o_d_e_s.html#ga689e0c91e6abb8b5575a929453e4dbcc">bladerf_strerror</a>(status));</div><div class="line"></div><div class="line">        <span class="keywordflow">return</span> 1;</div><div class="line">    }</div><div class="line">    <span class="comment">/* Set up RX module parameters */</span></div><div class="line">    config.module     = <a class="code" href="group___f_n___m_o_d_u_l_e.html#ggab12571146a3d4c5d79ac497a74b3fb5ea8df9d0339c79bf7221af3a3897360c6f">BLADERF_MODULE_RX</a>;</div><div class="line">    config.frequency  = 910000000;</div><div class="line">    config.bandwidth  = 2000000;</div><div class="line">    config.samplerate = 300000;</div><div class="line">    config.rx_lna     = <a class="code" href="group___f_n___g_a_i_n.html#gga61ff30f82a42e90653a4cf69d43f9cc2a44bfef7aeacd7e0698d613b222e16e7a">BLADERF_LNA_GAIN_MAX</a>;</div><div class="line">    config.vga1       = 30;</div><div class="line">    config.vga2       = 3;</div><div class="line"></div><div class="line">    status = configure_module(dev, &amp;config);</div><div class="line">    <span class="keywordflow">if</span> (status != 0) {</div><div class="line">        fprintf(stderr, <span class="stringliteral">&quot;Failed to configure RX module. Exiting.\n&quot;</span>);</div><div class="line">        <span class="keywordflow">goto</span> out;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="comment">/* Set up TX module parameters */</span></div><div class="line">    config.module     = <a class="code" href="group___f_n___m_o_d_u_l_e.html#ggab12571146a3d4c5d79ac497a74b3fb5ea2b59868119a050b6f0e24631ffbb16e3">BLADERF_MODULE_TX</a>;</div><div class="line">    config.frequency  = 918000000;</div><div class="line">    config.bandwidth  = 1500000;</div><div class="line">    config.samplerate = 250000;</div><div class="line">    config.vga1       = -14;</div><div class="line">    config.vga2       = 0;</div><div class="line"></div><div class="line">    status = configure_module(dev, &amp;config);</div><div class="line">    <span class="keywordflow">if</span> (status != 0) {</div><div class="line">        fprintf(stderr, <span class="stringliteral">&quot;Failed to configure TX module. Exiting.\n&quot;</span>);</div><div class="line">        <span class="keywordflow">goto</span> out;</div><div class="line">    }</div><div class="line"></div><div class="line">    <span class="comment">/* Application code goes here.</span></div><div class="line"><span class="comment">     *</span></div><div class="line"><span class="comment">     * Don&#39;t forget to call bladerf_enable_module() before attempting to</span></div><div class="line"><span class="comment">     * transmit or receive samples!</span></div><div class="line"><span class="comment">     */</span></div><div class="line"></div><div class="line">out:</div><div class="line">    <a class="code" href="group___f_n___i_n_i_t.html#ga78676b94de9a8aae49d72a9ef2f0e4d9">bladerf_close</a>(dev);</div><div class="line">    <span class="keywordflow">return</span> status;</div><div class="line">}</div></div><!-- fragment --></div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Wed Jun 29 2016 16:51:01 for libbladeRF by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.11
</small></address>
</body>
</html>