From 54ac5a3d36b5fd68339a7f4753d862fd21af9389 Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Fri, 9 Oct 2015 21:32:37 +0100 Subject: Added dongle manager --- hw/sdr.h | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 14 deletions(-) (limited to 'hw/sdr.h') diff --git a/hw/sdr.h b/hw/sdr.h index 81ec57f..5a83e8e 100644 --- a/hw/sdr.h +++ b/hw/sdr.h @@ -1,8 +1,15 @@ #ifndef __RADIOLA_HW_SDR_H #define __RADIOLA_HW_SDR_H +#include + #include "hw.h" + +//list of supported devices RTLSDR is rtlsdr tunners, +//AUDIO is just used audio cards +//NET get or send some info to server/client +//PTT usb connected with audio link radios, trought PTT things typedef enum { DEVICE_NONE=0, @@ -22,6 +29,18 @@ typedef struct dongle_t int gain; } dongle_t; +#define DONGLE_SAMPLE_RATE 2048000 +#define DONGLE_CENTER_FREQ 100000000 +#define DONGLE_GAIN 1 + +//dongle pointer to dongle_t +#define DEF_DONGLE_VALUES(DONGLE)\ +{\ +(DONGLE)->freq=DONGLE_CENTER_FREQ;\ +(DONGLE)->rate=DONGLE_SAMPLE_RATE;\ +(DONGLE)->gain=DONGLE_GAIN;\ +} + typedef struct audio_t { @@ -30,32 +49,51 @@ typedef struct audio_t typedef struct sdr_t { - sdr_device dev_type; - dongle_t *dongle; - uint32_t d_used; - audio_t *audio; - uint32_t a_used; + dongle_t *dongle; //list of rtlsdr devices + uint32_t d_used; //not yes used + audio_t *audio; //audio devices used + uint32_t a_used; //not yet used } sdr_t; +//init structure + +sdr_t* sdr_init(); //index of device in oter list //return inner device list int sdr_open_device( sdr_t *sdr, int dev_index ); +//associate audio device that going to be used +//int sdr_open_audio( sdr_t *sdr, int dev_index );//?should be just device from list or device name? + + +//get device structure from sdr manager +dongle_t* sdr_get_device( sdr_t *sdr, int dev_index); + //get index in list of devices of structure from outer device index //? do we need? //int sdr_get_dongle_idx( sdr_t *sdr, int idx ); //close device by internal list index int sdr_close_device( sdr_t *sdr, int idx ); -int dongle_stop( sdr_t *sdr, int idx ); +//close sdr +//if there is opened audios then close +//if there is opened devices then close +int sdr_close( sdr_t *sdr ); + +//stop any action that associated with dongle +int dongle_stop( dongle_t *dongle ); //int dongle_open( sdr_t *); -int dongle_set_freq( sdr_t *sdr, int idx, uint32_t freq); -int dongle_set_gain( sdr_t *sdr, int idx, int gain); -int dongle_set_sample_rate( sdr_t *sdr, int idx, uint32_t srate ); - -uint32_t dongle_get_freq( sdr_t *sdr, int idx ); -int dongle_get_gain( sdr_t *sdr, int idx); -uint32_t dongle_get_sample_rate( sdr_t *sdr, int idx ); -int dongle_get_samples( sdr_t *sdr, int idx, uint8_t *buf, int len ); +//set dongle frequency +int dongle_set_freq( dongle_t *dongle, uint32_t freq); +//set gain +int dongle_set_gain( dongle_t *dongle, int gain); +int dongle_set_agc( dongle_t *dongle, int mode); +//set dongle sample rate +int dongle_set_sample_rate( dongle_t *dongle, uint32_t rate ); + +uint32_t dongle_get_freq( dongle_t *dongle ); +int dongle_get_gain( dongle_t *dongle ); +uint32_t dongle_get_sample_rate( dongle_t *dongle ); +int dongle_read_samples( dongle_t *dongle, uint8_t *buf, int len ); //int dongle_close(); #endif \ No newline at end of file -- cgit v1.2.3