libosmosdr  0.1.20151211
OsmoSDR library
osmosdr.h
1 /*
2  * Copyright (C) 2012 by Dimitri Stolnikov <horiz0n@gmx.net>
3  * Copyright (C) 2012 by Steve Markgraf <steve@steve-m.de>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef __OSMOSDR_H
20 #define __OSMOSDR_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #include <stdint.h>
27 #include <osmosdr_export.h>
28 
29 typedef struct osmosdr_dev osmosdr_dev_t;
30 
31 OSMOSDR_API uint32_t osmosdr_get_device_count(void);
32 
33 OSMOSDR_API const char* osmosdr_get_device_name(uint32_t index);
34 
46 OSMOSDR_API int osmosdr_get_device_usb_strings(uint32_t index,
47  char *manufact,
48  char *product,
49  char *serial);
50 
51 OSMOSDR_API int osmosdr_open(osmosdr_dev_t **dev, uint32_t index);
52 
53 OSMOSDR_API int osmosdr_close(osmosdr_dev_t *dev);
54 
55 /* configuration functions */
56 
68 OSMOSDR_API int osmosdr_get_usb_strings(osmosdr_dev_t *dev, char *manufact,
69  char *product, char *serial);
70 
78 OSMOSDR_API int osmosdr_set_center_freq(osmosdr_dev_t *dev, uint32_t freq);
79 
86 OSMOSDR_API uint32_t osmosdr_get_center_freq(osmosdr_dev_t *dev);
87 
98 OSMOSDR_API int osmosdr_get_tuner_gains(osmosdr_dev_t *dev, int *gains);
99 
114 OSMOSDR_API int osmosdr_set_tuner_gain(osmosdr_dev_t *dev, int gain);
115 
122 OSMOSDR_API int osmosdr_get_tuner_gain(osmosdr_dev_t *dev);
123 
132 OSMOSDR_API int osmosdr_set_tuner_gain_mode(osmosdr_dev_t *dev, int manual);
133 
134 /* set LNA gain in hdB */
135 OSMOSDR_API int osmosdr_set_tuner_lna_gain(osmosdr_dev_t *dev, int gain);
136 /* set mixer gain in hdB */
137 OSMOSDR_API int osmosdr_set_tuner_mixer_gain(osmosdr_dev_t *dev, int gain);
138 /* set mixer enhancement */
139 OSMOSDR_API int osmosdr_set_tuner_mixer_enh(osmosdr_dev_t *dev, int enh);
140 /* set IF stages gain */
141 OSMOSDR_API int osmosdr_set_tuner_if_gain(osmosdr_dev_t *dev, int stage, int gain);
142 
153 OSMOSDR_API uint32_t osmosdr_get_sample_rates(osmosdr_dev_t *dev, uint32_t *rates);
154 
162 OSMOSDR_API int osmosdr_set_sample_rate(osmosdr_dev_t *dev, uint32_t rate);
163 
170 OSMOSDR_API uint32_t osmosdr_get_sample_rate(osmosdr_dev_t *dev);
171 
172 /* this allows direct access to the FPGA register bank */
173 OSMOSDR_API int osmosdr_set_fpga_reg(osmosdr_dev_t *dev, uint8_t reg, uint32_t value);
174 
175 /* more access to OsmoSDR functions */
176 
177 /* set decimation (0 = off, 1 = 1:2, 2 = 1:4, 3 = 1:8, ... 6 = 1:64) */
178 OSMOSDR_API int osmosdr_set_fpga_decimation(osmosdr_dev_t *dev, int dec);
179 
180 /* set i/q swap / spectrum inversion (0 = off, 1 = on) */
181 OSMOSDR_API int osmosdr_set_fpga_iq_swap(osmosdr_dev_t *dev, int sw);
182 
183 /* configure scaling of i and q channel (scaled_i = (orig_i * igain) / 32768) */
184 OSMOSDR_API int osmosdr_set_fpga_iq_gain(osmosdr_dev_t *dev, uint16_t igain, uint16_t qgain);
185 
186 /* configure i and q offset correction (corrected_i = orig_i + iofs */
187 OSMOSDR_API int osmosdr_set_fpga_iq_ofs(osmosdr_dev_t *dev, int16_t iofs, int16_t qofs);
188 
189 /* streaming functions */
190 
191 OSMOSDR_API int osmosdr_reset_buffer(osmosdr_dev_t *dev);
192 
193 OSMOSDR_API int osmosdr_read_sync(osmosdr_dev_t *dev, void *buf, int len, int *n_read);
194 
195 typedef void(*osmosdr_read_async_cb_t)(unsigned char *buf, uint32_t len, void *ctx);
196 
210 OSMOSDR_API int osmosdr_read_async(osmosdr_dev_t *dev,
211  osmosdr_read_async_cb_t cb,
212  void *ctx,
213  uint32_t buf_num,
214  uint32_t buf_len);
215 
222 OSMOSDR_API int osmosdr_cancel_async(osmosdr_dev_t *dev);
223 
224 #ifdef __cplusplus
225 }
226 #endif
227 
228 #endif /* __OSMOSDR_H */
osmosdr_dev
Definition: libosmosdr.c:68