rtl-sdr.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * rtl-sdr, a poor man's SDR using a Realtek RTL2832 based DVB-stick
  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. #ifndef __RTL_SDR_H
  19. #define __RTL_SDR_H
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. #include <stdint.h>
  24. typedef int rtlsdr_dev_t;
  25. /* must be called once before using any other library functions */
  26. int rtlsdr_init(void);
  27. /* must be called once at application shutdown */
  28. void rtlsdr_exit(void);
  29. uint32_t rtlsdr_get_device_count(void);
  30. const char *rtlsdr_get_device_name(uint32_t index);
  31. rtlsdr_dev_t *rtlsdr_open(uint32_t index);
  32. int rtlsdr_close(rtlsdr_dev_t *dev);
  33. /* configuration functions */
  34. int rtlsdr_set_center_freq(rtlsdr_dev_t *dev, uint32_t freq);
  35. int rtlsdr_get_center_freq(rtlsdr_dev_t *dev);
  36. int rtlsdr_set_freq_correction(rtlsdr_dev_t *dev, int ppm);
  37. int rtlsdr_get_freq_correction(rtlsdr_dev_t *dev);
  38. int rtlsdr_set_tuner_gain(rtlsdr_dev_t *dev, int gain);
  39. int rtlsdr_get_tuner_gain(rtlsdr_dev_t *dev);
  40. /* this will select the baseband filters according to the requested sample rate */
  41. int rtlsdr_set_sample_rate(rtlsdr_dev_t *dev, uint32_t rate);
  42. int rtlsdr_get_sample_rate(rtlsdr_dev_t *dev);
  43. /* streaming functions */
  44. int rtlsdr_reset_buffer(rtlsdr_dev_t *dev);
  45. int rtlsdr_read_sync(rtlsdr_dev_t *dev, void *buf, uint32_t len, uint32_t *n_read);
  46. typedef void(*rtlsdr_async_read_cb_t)(const char *buf, uint32_t len, void *ctx);
  47. int rtlsdr_async_loop(rtlsdr_dev_t *dev, rtlsdr_async_read_cb_t cb, void *ctx);
  48. #ifdef __cplusplus
  49. }
  50. #endif
  51. #endif /* __RTL_SDR_H */