Skip to content

Commit

Permalink
add bias tee support (purple dongle)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladisslav2011 authored and ericek111 committed Apr 14, 2022
1 parent 0ddb34e commit b1e058c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/mirisdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,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
1 change: 1 addition & 0 deletions src/libmirisdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ int mirisdr_open (mirisdr_dev_t **p, uint32_t index) {
dev->format_auto = MIRISDR_FORMAT_AUTO_ON;
dev->bandwidth = MIRISDR_BW_8MHZ;
dev->xtal = MIRISDR_XTAL_24M;
dev->bias = 0;

dev->hw_flavour = MIRISDR_HW_DEFAULT;

Expand Down
22 changes: 21 additions & 1 deletion src/soft.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ hw_switch_freq_plan_t *hw_switch_freq_plan[2] = {
hw_switch_freq_plan_sdrplay
};

#define BIAS_GPIO 3

void update_reg_8(mirisdr_dev_t *p)
{
mirisdr_write_reg(p, 0x08, p->reg8|(p->bias?(1<<(BIAS_GPIO+8)):0));
}

int mirisdr_set_soft(mirisdr_dev_t *p)
{
uint32_t reg0 = 0, reg2 = 2, reg5 = 5, reg3 = 3;
Expand Down Expand Up @@ -313,7 +320,9 @@ int mirisdr_set_soft(mirisdr_dev_t *p)
// mirisdr_write_reg(p, 0x08, band_select[i]);
// }

mirisdr_write_reg(p, 0x08, switch_plan.band_select_word);
//mirisdr_write_reg(p, 0x08, switch_plan.band_select_word);
p->reg8=switch_plan.band_select_word;
update_reg_8(p);

mirisdr_write_reg(p, 0x09, 0x0e);
mirisdr_write_reg(p, 0x09, reg3);
Expand Down Expand Up @@ -590,3 +599,14 @@ mirisdr_band_t mirisdr_get_band (mirisdr_dev_t *p)
return p->band;
}

int mirisdr_set_bias (mirisdr_dev_t *p, int bias)
{
p->bias=bias;
update_reg_8(p);
return 0;
}

int mirisdr_get_bias (mirisdr_dev_t *p)
{
return p->bias;
}
2 changes: 2 additions & 0 deletions src/structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,7 @@ struct mirisdr_dev {
unsigned char *xfer_out;
uint32_t addr;
int driver_active;
int bias;
int reg8;
};

0 comments on commit b1e058c

Please sign in to comment.