2 * Copyright (C) 2015 "IoT.bzh"
3 * Author "Manuel Bachmann"
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 3 of the License, or
8 * (at your option) any later version.
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.
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/>.
19 #ifndef RADIO_RTLSDR_H
20 #define RADIO_RTLSDR_H
22 /* -------------- RADIO RTLSDR DEFINITIONS ------------------ */
28 #include "radio-api.h"
29 #include "local-def.h"
31 #define pthread_signal(n, m) pthread_mutex_lock(m); pthread_cond_signal(n); pthread_mutex_unlock(m)
32 #define pthread_wait(n, m) pthread_mutex_lock(m); pthread_cond_wait(n, m); pthread_mutex_unlock(m)
33 #define BUF_LEN 16*16384
35 typedef struct dongle_ctx dongle_ctx;
36 typedef struct demod_ctx demod_ctx;
37 typedef struct output_ctx output_ctx;
38 typedef struct dev_ctx dev_ctx_T;
42 unsigned char thr_finished;
43 uint16_t buf[BUF_LEN];
49 unsigned char thr_finished;
53 int pre_r, pre_j, now_r, now_j, index;
54 int pre_index, now_index;
63 unsigned char thr_finished;
72 int used; /* TODO: radio is free ??? */
77 unsigned char should_run;
84 PUBLIC unsigned int _radio_dev_count (void);
85 PUBLIC const char* _radio_dev_name (unsigned int);
87 PUBLIC unsigned char _radio_on (unsigned int, radioCtxHandleT *);
88 PUBLIC void _radio_off (unsigned int);
89 PUBLIC void _radio_stop (unsigned int);
90 PUBLIC void _radio_play (unsigned int);
91 PUBLIC void _radio_set_mode (unsigned int, Mode);
92 PUBLIC void _radio_set_freq (unsigned int, double);
93 PUBLIC void _radio_set_mute (unsigned int, unsigned char);
95 STATIC void* _dongle_thread_fn (void *);
96 STATIC void* _demod_thread_fn (void *);
97 STATIC void* _output_thread_fn (void *);
98 STATIC unsigned char _radio_dev_init (struct dev_ctx *, unsigned int);
99 STATIC unsigned char _radio_dev_free (struct dev_ctx *);
100 STATIC void _radio_apply_params (struct dev_ctx *);
101 STATIC void _radio_start_threads (struct dev_ctx *);
102 STATIC void _radio_stop_threads (struct dev_ctx *);
104 static unsigned int init_dev_count = 0;
105 static struct dev_ctx **dev_ctx = NULL;
107 #endif /* RADIO_RTLSDR_H */