mirror of
https://github.com/rtlsdrblog/rtl-sdr-blog.git
synced 2024-12-31 21:37:13 +01:00
add rtl_biast, add biast EEPROM hack
This commit is contained in:
parent
9d3d8a5faf
commit
65ea7235bc
2
README
2
README
@ -10,3 +10,5 @@ Modified RTL-SDR Blog Version
|
|||||||
1) VCO PLL current fix - Improves stability at frequencies above ~1.5 GHz https://www.rtl-sdr.com/beta-testing-a-modified-rtl-sdr-driver-for-l-band-heat-issues/
|
1) VCO PLL current fix - Improves stability at frequencies above ~1.5 GHz https://www.rtl-sdr.com/beta-testing-a-modified-rtl-sdr-driver-for-l-band-heat-issues/
|
||||||
2) RTL_TCP ring buffer enhancement by Stephen Blinick https://www.rtl-sdr.com/significantly-improving-rtl_tcps-performance-with-ring-buffers/
|
2) RTL_TCP ring buffer enhancement by Stephen Blinick https://www.rtl-sdr.com/significantly-improving-rtl_tcps-performance-with-ring-buffers/
|
||||||
3) Enabled direct sampling for rtl_tcp
|
3) Enabled direct sampling for rtl_tcp
|
||||||
|
4) rtl_biast program added, including the ability to turn on/off any GPIO
|
||||||
|
5) Hack to force the bias tee to always be on by setting the unused IR endpoint bit to 0 in the EEPROM with "rtl_eeprom -i 0"
|
||||||
|
@ -12,4 +12,5 @@
|
|||||||
/usr/local/bin/rtl_fm
|
/usr/local/bin/rtl_fm
|
||||||
/usr/local/bin/rtl_eeprom
|
/usr/local/bin/rtl_eeprom
|
||||||
/usr/local/bin/rtl_adsb
|
/usr/local/bin/rtl_adsb
|
||||||
/usr/local/bin/rtl_power
|
/usr/local/bin/rtl_power
|
||||||
|
/usr/local/bin/rtl_biast
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
build/src/rtl_biast
Executable file
BIN
build/src/rtl_biast
Executable file
Binary file not shown.
Binary file not shown.
BIN
build/src/rtl_fm
BIN
build/src/rtl_fm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -389,6 +389,16 @@ RTLSDR_API int rtlsdr_cancel_async(rtlsdr_dev_t *dev);
|
|||||||
*/
|
*/
|
||||||
RTLSDR_API int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on);
|
RTLSDR_API int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Enable or disable any GPIO.
|
||||||
|
* \param dev the device handle given by rtlsdr_open()
|
||||||
|
* \param gpio_pin GPIO pin number for ON
|
||||||
|
* \param on 1 for GPIO on. 0 for GPIO off.
|
||||||
|
*/
|
||||||
|
RTLSDR_API int rtlsdr_set_gpio(rtlsdr_dev_t *dev, int gpio_pin, int on);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -91,7 +91,9 @@ add_executable(rtl_fm rtl_fm.c)
|
|||||||
add_executable(rtl_eeprom rtl_eeprom.c)
|
add_executable(rtl_eeprom rtl_eeprom.c)
|
||||||
add_executable(rtl_adsb rtl_adsb.c)
|
add_executable(rtl_adsb rtl_adsb.c)
|
||||||
add_executable(rtl_power rtl_power.c)
|
add_executable(rtl_power rtl_power.c)
|
||||||
set(INSTALL_TARGETS rtlsdr_shared rtlsdr_static rtl_sdr rtl_tcp rtl_test rtl_fm rtl_eeprom rtl_adsb rtl_power)
|
add_executable(rtl_biast rtl_biast.c)
|
||||||
|
|
||||||
|
set(INSTALL_TARGETS rtlsdr_shared rtlsdr_static rtl_sdr rtl_tcp rtl_test rtl_fm rtl_eeprom rtl_adsb rtl_power rtl_biast)
|
||||||
|
|
||||||
target_link_libraries(rtl_sdr rtlsdr_shared convenience_static
|
target_link_libraries(rtl_sdr rtlsdr_shared convenience_static
|
||||||
${LIBUSB_LIBRARIES}
|
${LIBUSB_LIBRARIES}
|
||||||
@ -121,6 +123,10 @@ target_link_libraries(rtl_power rtlsdr_shared convenience_static
|
|||||||
${LIBUSB_LIBRARIES}
|
${LIBUSB_LIBRARIES}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
)
|
)
|
||||||
|
target_link_libraries(rtl_biast rtlsdr_shared convenience_static
|
||||||
|
${LIBUSB_LIBRARIES}
|
||||||
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
|
)
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
target_link_libraries(rtl_fm m)
|
target_link_libraries(rtl_fm m)
|
||||||
target_link_libraries(rtl_adsb m)
|
target_link_libraries(rtl_adsb m)
|
||||||
@ -140,6 +146,7 @@ target_link_libraries(rtl_fm libgetopt_static)
|
|||||||
target_link_libraries(rtl_eeprom libgetopt_static)
|
target_link_libraries(rtl_eeprom libgetopt_static)
|
||||||
target_link_libraries(rtl_adsb libgetopt_static)
|
target_link_libraries(rtl_adsb libgetopt_static)
|
||||||
target_link_libraries(rtl_power libgetopt_static)
|
target_link_libraries(rtl_power libgetopt_static)
|
||||||
|
target_link_libraries(rtl_biast libgetopt_static)
|
||||||
set_property(TARGET rtl_sdr APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
set_property(TARGET rtl_sdr APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
||||||
set_property(TARGET rtl_tcp APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
set_property(TARGET rtl_tcp APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
||||||
set_property(TARGET rtl_test APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
set_property(TARGET rtl_test APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
||||||
@ -147,6 +154,7 @@ set_property(TARGET rtl_fm APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
|||||||
set_property(TARGET rtl_eeprom APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
set_property(TARGET rtl_eeprom APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
||||||
set_property(TARGET rtl_adsb APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
set_property(TARGET rtl_adsb APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
||||||
set_property(TARGET rtl_power APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
set_property(TARGET rtl_power APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
||||||
|
set_property(TARGET rtl_biast APPEND PROPERTY COMPILE_DEFINITIONS "rtlsdr_STATIC" )
|
||||||
endif()
|
endif()
|
||||||
########################################################################
|
########################################################################
|
||||||
# Install built library files & utilities
|
# Install built library files & utilities
|
||||||
|
@ -125,6 +125,7 @@ struct rtlsdr_dev {
|
|||||||
int dev_lost;
|
int dev_lost;
|
||||||
int driver_active;
|
int driver_active;
|
||||||
unsigned int xfer_errors;
|
unsigned int xfer_errors;
|
||||||
|
int force_bt;
|
||||||
};
|
};
|
||||||
|
|
||||||
void rtlsdr_set_gpio_bit(rtlsdr_dev_t *dev, uint8_t gpio, int val);
|
void rtlsdr_set_gpio_bit(rtlsdr_dev_t *dev, uint8_t gpio, int val);
|
||||||
@ -368,6 +369,7 @@ static rtlsdr_dongle_t known_devices[] = {
|
|||||||
#define BULK_TIMEOUT 0
|
#define BULK_TIMEOUT 0
|
||||||
|
|
||||||
#define EEPROM_ADDR 0xa0
|
#define EEPROM_ADDR 0xa0
|
||||||
|
#define EEPROM_SIZE 256
|
||||||
|
|
||||||
enum usb_reg {
|
enum usb_reg {
|
||||||
USB_SYSCTL = 0x2000,
|
USB_SYSCTL = 0x2000,
|
||||||
@ -1447,6 +1449,7 @@ int rtlsdr_open(rtlsdr_dev_t **out_dev, uint32_t index)
|
|||||||
struct libusb_device_descriptor dd;
|
struct libusb_device_descriptor dd;
|
||||||
uint8_t reg;
|
uint8_t reg;
|
||||||
ssize_t cnt;
|
ssize_t cnt;
|
||||||
|
uint8_t buf[EEPROM_SIZE];
|
||||||
|
|
||||||
dev = malloc(sizeof(rtlsdr_dev_t));
|
dev = malloc(sizeof(rtlsdr_dev_t));
|
||||||
if (NULL == dev)
|
if (NULL == dev)
|
||||||
@ -1609,6 +1612,7 @@ found:
|
|||||||
|
|
||||||
/* enable spectrum inversion */
|
/* enable spectrum inversion */
|
||||||
rtlsdr_demod_write_reg(dev, 1, 0x15, 0x01, 1);
|
rtlsdr_demod_write_reg(dev, 1, 0x15, 0x01, 1);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case RTLSDR_TUNER_UNKNOWN:
|
case RTLSDR_TUNER_UNKNOWN:
|
||||||
fprintf(stderr, "No supported tuner found\n");
|
fprintf(stderr, "No supported tuner found\n");
|
||||||
@ -1618,6 +1622,14 @@ found:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Hack to force the Bias T to always be on if we set the IR-Endpoint bit in the EEPROM to 0. */
|
||||||
|
//force_bt = 0;
|
||||||
|
r = rtlsdr_read_eeprom(dev, buf, 0, EEPROM_SIZE);
|
||||||
|
dev->force_bt = (buf[7] & 0x02) ? 0 : 1;
|
||||||
|
if(dev->force_bt) rtlsdr_set_gpio(dev, 0, 1);
|
||||||
|
|
||||||
|
|
||||||
if (dev->tuner->init)
|
if (dev->tuner->init)
|
||||||
r = dev->tuner->init(dev);
|
r = dev->tuner->init(dev);
|
||||||
|
|
||||||
@ -2014,8 +2026,24 @@ int rtlsdr_set_bias_tee(rtlsdr_dev_t *dev, int on)
|
|||||||
if (!dev)
|
if (!dev)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if(dev->force_bt) return 1; // If force_bt is on from the EEPROM, do not allow bias tee to turn off
|
||||||
|
|
||||||
rtlsdr_set_gpio_output(dev, 0);
|
rtlsdr_set_gpio_output(dev, 0);
|
||||||
rtlsdr_set_gpio_bit(dev, 0, on);
|
rtlsdr_set_gpio_bit(dev, 0, on);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int rtlsdr_set_gpio(rtlsdr_dev_t *dev, int gpio_pin, int on)
|
||||||
|
{
|
||||||
|
if (!dev)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if(dev->force_bt) return 1; // If force_bt is on from the EEPROM, do not allow bias tee to turn off
|
||||||
|
|
||||||
|
rtlsdr_set_gpio_output(dev, gpio_pin);
|
||||||
|
rtlsdr_set_gpio_bit(dev, gpio_pin, on);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
125
src/rtl_biast.c
Normal file
125
src/rtl_biast.c
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
* rtl-sdr, turns your Realtek RTL2832 based DVB dongle into a SDR receiver
|
||||||
|
* rtl_eeprom, EEPROM modification tool
|
||||||
|
* Copyright (C) 2012 by Steve Markgraf <steve@steve-m.de>
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <unistd.h>
|
||||||
|
#else
|
||||||
|
#include <windows.h>
|
||||||
|
#include "getopt/getopt.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "rtl-sdr.h"
|
||||||
|
#include "convenience/convenience.h"
|
||||||
|
|
||||||
|
#define EEPROM_SIZE 256
|
||||||
|
#define MAX_STR_SIZE 256
|
||||||
|
#define STR_OFFSET 0x09
|
||||||
|
|
||||||
|
static rtlsdr_dev_t *dev = NULL;
|
||||||
|
|
||||||
|
typedef struct rtlsdr_config {
|
||||||
|
uint16_t vendor_id;
|
||||||
|
uint16_t product_id;
|
||||||
|
char manufacturer[MAX_STR_SIZE];
|
||||||
|
char product[MAX_STR_SIZE];
|
||||||
|
char serial[MAX_STR_SIZE];
|
||||||
|
int have_serial;
|
||||||
|
int enable_ir;
|
||||||
|
int remote_wakeup;
|
||||||
|
} rtlsdr_config_t;
|
||||||
|
|
||||||
|
|
||||||
|
void usage(void)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"rtl_biast, a tool for turning the RTL-SDR.com \n"
|
||||||
|
"bias tee or any GPIO ON and OFF. Example to turn on the \n"
|
||||||
|
"bias tee: rtl_biast -d 0 -b 1\n"
|
||||||
|
"Any GPIO: rtl_biast -d 0 -g 1 -b 1\n\n"
|
||||||
|
"Usage:\n"
|
||||||
|
"\t[-d device_index (default: 0)]\n"
|
||||||
|
"\t[-b bias_on (default: 0)]\n"
|
||||||
|
"\t[-g GPIO select (default: 0)]\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i, r, opt;
|
||||||
|
int dev_index = 0;
|
||||||
|
int dev_given = 0;
|
||||||
|
uint32_t bias_on = 0;
|
||||||
|
uint32_t gpio_pin = 0;
|
||||||
|
int device_count;
|
||||||
|
char *filename = NULL;
|
||||||
|
FILE *file = NULL;
|
||||||
|
char *manuf_str = NULL;
|
||||||
|
char *product_str = NULL;
|
||||||
|
char *serial_str = NULL;
|
||||||
|
uint8_t buf[EEPROM_SIZE];
|
||||||
|
rtlsdr_config_t conf;
|
||||||
|
int flash_file = 0;
|
||||||
|
int default_config = 0;
|
||||||
|
int change = 0;
|
||||||
|
int ir_endpoint = 0;
|
||||||
|
char ch;
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "d:b:g:h?")) != -1) {
|
||||||
|
switch (opt) {
|
||||||
|
case 'd':
|
||||||
|
dev_index = verbose_device_search(optarg);
|
||||||
|
dev_given = 1;
|
||||||
|
break;
|
||||||
|
case 'b':
|
||||||
|
bias_on = atoi(optarg);
|
||||||
|
break;
|
||||||
|
case 'g':
|
||||||
|
gpio_pin = atoi(optarg);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dev_given) {
|
||||||
|
dev_index = verbose_device_search("0");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dev_index < 0) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
r = rtlsdr_open(&dev, dev_index);
|
||||||
|
|
||||||
|
rtlsdr_set_gpio(dev, gpio_pin, bias_on);
|
||||||
|
//rtlsdr_set_bias_tee(dev, bias_on);
|
||||||
|
|
||||||
|
//rtlsdr_set_direct_sampling(dev, 1);
|
||||||
|
|
||||||
|
exit:
|
||||||
|
rtlsdr_close(dev);
|
||||||
|
|
||||||
|
return r >= 0 ? r : -r;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user