libhackrf/firmware: merge txvga gain into one gain range of 0-47
This commit is contained in:
@ -407,13 +407,14 @@ bool max2837_set_vga_gain(const uint32_t gain_db) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool max2837_set_txvga_gain(const uint32_t gain_db, const uint32_t plus16) {
|
bool max2837_set_txvga_gain(const uint32_t gain_db) {
|
||||||
uint16_t val = 31-gain_db;
|
uint16_t val=0;
|
||||||
if(gain_db > 31)/* 0b111111 mind the bit 6 weigth*/
|
if(gain_db <16){
|
||||||
return false;
|
val = 31-gain_db;
|
||||||
|
val |= (1 << 5); // bit6: 16db
|
||||||
if(!plus16)
|
} else{
|
||||||
val |= 0x20; /* +16db */
|
val = 31-(gain_db-16);
|
||||||
|
}
|
||||||
|
|
||||||
set_MAX2837_TXVGA_GAIN(val);
|
set_MAX2837_TXVGA_GAIN(val);
|
||||||
max2837_reg_commit(29);
|
max2837_reg_commit(29);
|
||||||
|
@ -47,7 +47,7 @@ extern void max2837_set_frequency(uint32_t freq);
|
|||||||
bool max2837_set_lpf_bandwidth(const uint32_t bandwidth_hz);
|
bool max2837_set_lpf_bandwidth(const uint32_t bandwidth_hz);
|
||||||
bool max2837_set_lna_gain(const uint32_t gain_db);
|
bool max2837_set_lna_gain(const uint32_t gain_db);
|
||||||
bool max2837_set_vga_gain(const uint32_t gain_db);
|
bool max2837_set_vga_gain(const uint32_t gain_db);
|
||||||
bool max2837_set_txvga_gain(const uint32_t gain_db, const uint32_t plus16);
|
bool max2837_set_txvga_gain(const uint32_t gain_db);
|
||||||
|
|
||||||
extern void max2837_tx(void);
|
extern void max2837_tx(void);
|
||||||
extern void max2837_rx(void);
|
extern void max2837_rx(void);
|
||||||
|
@ -790,9 +790,7 @@ usb_request_status_t usb_vendor_request_set_txvga_gain(
|
|||||||
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
usb_endpoint_t* const endpoint, const usb_transfer_stage_t stage)
|
||||||
{
|
{
|
||||||
if( stage == USB_TRANSFER_STAGE_SETUP ) {
|
if( stage == USB_TRANSFER_STAGE_SETUP ) {
|
||||||
const uint8_t value = max2837_set_txvga_gain(
|
const uint8_t value = max2837_set_txvga_gain(endpoint->setup.index);
|
||||||
endpoint->setup.index, endpoint->setup.value);
|
|
||||||
|
|
||||||
endpoint->buffer[0] = value;
|
endpoint->buffer[0] = value;
|
||||||
usb_endpoint_schedule(endpoint->in, &endpoint->buffer, 1);
|
usb_endpoint_schedule(endpoint->in, &endpoint->buffer, 1);
|
||||||
usb_endpoint_schedule_ack(endpoint->out);
|
usb_endpoint_schedule_ack(endpoint->out);
|
||||||
|
@ -857,7 +857,7 @@ int ADDCALL hackrf_set_vga_gain(hackrf_device* device, uint32_t value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ADDCALL hackrf_set_txvga_gain(hackrf_device* device, uint32_t value, uint32_t plus16db)
|
int ADDCALL hackrf_set_txvga_gain(hackrf_device* device, uint32_t value)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
@ -870,7 +870,7 @@ int ADDCALL hackrf_set_txvga_gain(hackrf_device* device, uint32_t value, uint32_
|
|||||||
device->usb_device,
|
device->usb_device,
|
||||||
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
|
LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE,
|
||||||
HACKRF_VENDOR_REQUEST_SET_TXVGA_GAIN,
|
HACKRF_VENDOR_REQUEST_SET_TXVGA_GAIN,
|
||||||
plus16db,
|
0,
|
||||||
value,
|
value,
|
||||||
NULL,
|
NULL,
|
||||||
0,
|
0,
|
||||||
|
@ -130,13 +130,19 @@ extern ADDAPI int ADDCALL hackrf_version_string_read(hackrf_device* device, char
|
|||||||
|
|
||||||
extern ADDAPI int ADDCALL hackrf_set_freq(hackrf_device* device, const uint64_t freq_hz);
|
extern ADDAPI int ADDCALL hackrf_set_freq(hackrf_device* device, const uint64_t freq_hz);
|
||||||
|
|
||||||
|
/* external amp, bool on/off */
|
||||||
extern ADDAPI int ADDCALL hackrf_set_amp_enable(hackrf_device* device, const uint8_t value);
|
extern ADDAPI int ADDCALL hackrf_set_amp_enable(hackrf_device* device, const uint8_t value);
|
||||||
|
|
||||||
extern ADDAPI int ADDCALL hackrf_board_partid_serialno_read(hackrf_device* device, read_partid_serialno_t* read_partid_serialno);
|
extern ADDAPI int ADDCALL hackrf_board_partid_serialno_read(hackrf_device* device, read_partid_serialno_t* read_partid_serialno);
|
||||||
|
|
||||||
|
/* range 0-40 step 8db */
|
||||||
extern ADDAPI int ADDCALL hackrf_set_lna_gain(hackrf_device* device, uint32_t value);
|
extern ADDAPI int ADDCALL hackrf_set_lna_gain(hackrf_device* device, uint32_t value);
|
||||||
|
|
||||||
|
/* range 0-62 step 2db */
|
||||||
extern ADDAPI int ADDCALL hackrf_set_vga_gain(hackrf_device* device, uint32_t value);
|
extern ADDAPI int ADDCALL hackrf_set_vga_gain(hackrf_device* device, uint32_t value);
|
||||||
extern ADDAPI int ADDCALL hackrf_set_txvga_gain(hackrf_device* device, uint32_t value, uint32_t plus16db);
|
|
||||||
|
/* range 0-47 step 1db */
|
||||||
|
extern ADDAPI int ADDCALL hackrf_set_txvga_gain(hackrf_device* device, uint32_t value);
|
||||||
|
|
||||||
extern ADDAPI const char* ADDCALL hackrf_error_name(enum hackrf_error errcode);
|
extern ADDAPI const char* ADDCALL hackrf_error_name(enum hackrf_error errcode);
|
||||||
extern ADDAPI const char* ADDCALL hackrf_board_id_name(enum hackrf_board_id board_id);
|
extern ADDAPI const char* ADDCALL hackrf_board_id_name(enum hackrf_board_id board_id);
|
||||||
|
Reference in New Issue
Block a user