2 * Copyright (C) 2015 "IoT.bzh"
3 * Author "Manuel Bachmann"
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef RADIO_RTLSDR_H
19 #define RADIO_RTLSDR_H
21 /* -------------- RADIO RTLSDR DEFINITIONS ------------------ */
27 #include "radio-api.h"
28 #include "local-def.h"
30 #define pthread_signal(n, m) pthread_mutex_lock(m); pthread_cond_signal(n); pthread_mutex_unlock(m)
31 #define pthread_wait(n, m) pthread_mutex_lock(m); pthread_cond_wait(n, m); pthread_mutex_unlock(m)
32 #define BUF_LEN 16*16384
34 typedef struct dongle_ctx dongle_ctx;
35 typedef struct demod_ctx demod_ctx;
36 typedef struct output_ctx output_ctx;
37 typedef struct dev_ctx dev_ctx_T;
41 unsigned char thr_finished;
42 uint16_t buf[BUF_LEN];
48 unsigned char thr_finished;
52 int pre_r, pre_j, now_r, now_j, index;
53 int pre_index, now_index;
62 unsigned char thr_finished;
71 int used; /* TODO: radio is free ??? */
76 unsigned char should_run;
83 PUBLIC unsigned int _radio_dev_count (void);
84 PUBLIC const char* _radio_dev_name (unsigned int);
86 PUBLIC unsigned char _radio_on (unsigned int, radioCtxHandleT *);
87 PUBLIC void _radio_off (unsigned int);
88 PUBLIC void _radio_stop (unsigned int);
89 PUBLIC void _radio_play (unsigned int);
90 PUBLIC void _radio_set_mode (unsigned int, Mode);
91 PUBLIC void _radio_set_freq (unsigned int, double);
92 PUBLIC void _radio_set_mute (unsigned int, unsigned char);
94 STATIC void* _dongle_thread_fn (void *);
95 STATIC void* _demod_thread_fn (void *);
96 STATIC void* _output_thread_fn (void *);
97 STATIC unsigned char _radio_dev_init (struct dev_ctx *, unsigned int);
98 STATIC unsigned char _radio_dev_free (struct dev_ctx *);
99 STATIC void _radio_apply_params (struct dev_ctx *);
100 STATIC void _radio_start_threads (struct dev_ctx *);
101 STATIC void _radio_stop_threads (struct dev_ctx *);
103 static unsigned int init_dev_count = 0;
104 static struct dev_ctx **dev_ctx = NULL;
106 #endif /* RADIO_RTLSDR_H */