-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrol.h
95 lines (81 loc) · 2.55 KB
/
control.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*
* control.h - Initialize peripherals and contol their operations.
* Copyright (C) 2018 Adam Morris <[email protected]>
* Copyright (C) 2018 Nicholas Borchardt <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SENIOR_PROJECT_CONTROL_H
#define SENIOR_PROJECT_CONTROL_H
// Include Standard Libraries
#include <errno.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
// Include SDR Library
#include "rtl-sdr.h"
// Define Macros
#define BSIZE 5079040 // 240000 Calibration Data
// 5760 Dead Space
// 4833280 Actual Data
#define NUM_SDRS 3
#define READ 0
#define SIZE 100
#define WRITE 1
// Declare variables and structures
static pthread_mutex_t file;
typedef struct rtlsdr_struct {
int blocksize;
uint32_t id;
uint8_t *buffer[2];
rtlsdr_dev_t *dev;
pthread_t collection_t, initialize_t;
} rtlsdr_struct;
struct rtlsdr_struct super;
struct rtlsdr_struct sdrs[3];
typedef struct thread_struct {
int id;
int freq;
rtlsdr_dev_t *dev;
} thread_struct;
extern volatile uint32_t freq[4];
/*
* sdrs_setup - Initializes the structures for each RTL-SDR.
*/
void sdrs_setup(void);
/*
* free_controls - Free malloc'd variables.
*/
void free_controls(void);
/*
* rtlsdr_setup - Sets up an individual RTL-SDR at the beginning of the program.
* @param id ID of RTL-SDR - expecting an integer from 0 to NUM_SDRS
*/
void rtlsdr_setup(int f, rtlsdr_dev_t *dev);
/*
* rtlsdr_bias - Sets bias of Supervisory RTL-SDR for data collection from the
* noise card or from the antenna's.
* @param i2c_val 2 byte value for register on RTL-SDR
*/
void rtlsdr_bias(int bias, uint8_t i2c_val);
/*
* collect - Colects the data as set up from the rtlsdr_setup function.
* @param id ID of RTL-SDR - expecting an integer from 0 to NUM_SDRS
* @param f frequency id - expecting an integer from 0 to 3
*/
void collect(int id, int f, rtlsdr_dev_t *dev);
#endif // SENIOR_PROJECT_CONTROL_H