Skip to content

Commit

Permalink
Merge pull request #9 from ericek111/master
Browse files Browse the repository at this point in the history
move hw_flavour from the initializer into a separate API function
  • Loading branch information
f4exb authored Apr 27, 2022
2 parents 4c7f505 + e9cd752 commit fd0452e
Show file tree
Hide file tree
Showing 14 changed files with 94 additions and 1,970 deletions.
1 change: 0 additions & 1 deletion AUTHORS

This file was deleted.

1,716 changes: 0 additions & 1,716 deletions Doxyfile.in

This file was deleted.

11 changes: 0 additions & 11 deletions HOWTO

This file was deleted.

2 changes: 0 additions & 2 deletions README

This file was deleted.

7 changes: 0 additions & 7 deletions build.sh

This file was deleted.

62 changes: 0 additions & 62 deletions configure.ac

This file was deleted.

151 changes: 0 additions & 151 deletions git-version-gen

This file was deleted.

5 changes: 4 additions & 1 deletion include/mirisdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ MIRISDR_API const char *mirisdr_get_device_name (uint32_t index);
MIRISDR_API int mirisdr_get_device_usb_strings (uint32_t index, char *manufact, char *product, char *serial);

/* main */
MIRISDR_API int mirisdr_open (mirisdr_dev_t **p, mirisdr_hw_flavour_t hw_flavour, uint32_t index);
MIRISDR_API int mirisdr_open (mirisdr_dev_t **p, uint32_t index);
MIRISDR_API int mirisdr_close (mirisdr_dev_t *p);
MIRISDR_API int mirisdr_reset (mirisdr_dev_t *p); /* extra */
MIRISDR_API int mirisdr_reset_buffer (mirisdr_dev_t *p);
MIRISDR_API int mirisdr_get_usb_strings (mirisdr_dev_t *dev, char *manufact, char *product, char *serial);
MIRISDR_API int mirisdr_set_hw_flavour (mirisdr_dev_t *p, mirisdr_hw_flavour_t hw_flavour);

/* sync */
MIRISDR_API int mirisdr_read_sync (mirisdr_dev_t *p, void *buf, int len, int *n_read);
Expand Down Expand Up @@ -123,6 +124,8 @@ MIRISDR_API int mirisdr_get_mixer_gain (mirisdr_dev_t *p); /* extra
MIRISDR_API int mirisdr_get_mixbuffer_gain (mirisdr_dev_t *p); /* extra */
MIRISDR_API int mirisdr_get_lna_gain (mirisdr_dev_t *p); /* extra */
MIRISDR_API int mirisdr_get_baseband_gain (mirisdr_dev_t *p); /* extra */
MIRISDR_API int mirisdr_set_bias (mirisdr_dev_t *p, int bias); /* extra */
MIRISDR_API int mirisdr_get_bias (mirisdr_dev_t *p); /* extra */

#ifdef __cplusplus
}
Expand Down
15 changes: 13 additions & 2 deletions src/libmirisdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include "soft.c"
#include "sync.c"

int mirisdr_open (mirisdr_dev_t **p, mirisdr_hw_flavour_t hw_flavour, uint32_t index) {
int mirisdr_open (mirisdr_dev_t **p, uint32_t index) {
mirisdr_dev_t *dev = NULL;
libusb_device **list, *device = NULL;
struct libusb_device_descriptor dd;
Expand Down Expand Up @@ -147,8 +147,9 @@ int mirisdr_open (mirisdr_dev_t **p, mirisdr_hw_flavour_t hw_flavour, uint32_t i
dev->format_auto = MIRISDR_FORMAT_AUTO_ON;
dev->bandwidth = MIRISDR_BW_8MHZ;
dev->xtal = MIRISDR_XTAL_24M;
dev->bias = 0;

dev->hw_flavour = hw_flavour;
dev->hw_flavour = MIRISDR_HW_DEFAULT;

/* ISOC is more stable but works only on Unix systems */
#if !defined (_WIN32) || defined(__MINGW32__)
Expand Down Expand Up @@ -263,3 +264,13 @@ int mirisdr_get_usb_strings (mirisdr_dev_t *dev, char *manufact, char *product,

return 0;
}

int mirisdr_set_hw_flavour (mirisdr_dev_t *p, mirisdr_hw_flavour_t hw_flavour) {
if (!p) goto failed;

p->hw_flavour = hw_flavour;
return 0;

failed:
return -1;
}
5 changes: 4 additions & 1 deletion src/miri_fm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1322,11 +1322,14 @@ int main(int argc, char **argv)
exit(1);
}

r = mirisdr_open(&dongle.dev, hw_flavour, (uint32_t)dongle.dev_index);
r = mirisdr_open(&dongle.dev, (uint32_t)dongle.dev_index);
if (r < 0) {
fprintf(stderr, "Failed to open Mirics device #%d.\n", dongle.dev_index);
exit(1);
}

mirisdr_set_hw_flavour(dongle.dev, hw_flavour);

#if !defined (_WIN32) || defined(__MINGW32__)
sigact.sa_handler = sighandler;
sigemptyset(&sigact.sa_mask);
Expand Down
5 changes: 4 additions & 1 deletion src/miri_sdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,14 @@ int main(int argc, char **argv)
fprintf(stderr, "Using device %d: %s\n",
dev_index, mirisdr_get_device_name(dev_index));

r = mirisdr_open(&dev, hw_flavour, dev_index);
r = mirisdr_open(&dev, dev_index);
if (r < 0) {
fprintf(stderr, "Failed to open mirisdr device #%d.\n", dev_index);
exit(1);
}

mirisdr_set_hw_flavour(dev, hw_flavour);

#if !defined (_WIN32) || defined(__MINGW32__)
sigact.sa_handler = sighandler;
sigemptyset(&sigact.sa_mask);
Expand Down
24 changes: 24 additions & 0 deletions src/reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,27 @@ int mirisdr_write_reg (mirisdr_dev_t *p, uint8_t reg, uint32_t val) {
failed:
return -1;
}

#define CMD_RESET 0x40
#define CMD_WREG 0x41
#define CMD_RREG 0x42
#define CMD_START_STREAMING 0x43
#define CMD_DOWNLOAD 0x44
#define CMD_STOP_STREAMING 0x45
//WValue = Addr?
#define CMD_REEPROM 0x46
//WValue = Addr?
#define CMD_WEEPROM 0x47
#define CMD_READ_UNKNOWN 0x48
//wValue = gpio << 8 | val
#define CMD_WGPIO 0x49
#define CMD_EXT_WGPIO_BASE 0x4b
/*
RSP1
GPIO(0x13) & 0x01 = DSB_NOTCH
GPIO(0x13) & 0x04 = BROADCAST_NOTCH
*/
Loading

0 comments on commit fd0452e

Please sign in to comment.