diff options
Diffstat (limited to 'software/rda1846dongle/rda1846.c')
-rw-r--r-- | software/rda1846dongle/rda1846.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/software/rda1846dongle/rda1846.c b/software/rda1846dongle/rda1846.c index c7f612c..6607ec8 100644 --- a/software/rda1846dongle/rda1846.c +++ b/software/rda1846dongle/rda1846.c @@ -130,6 +130,7 @@ char* rda1846_rf_band_to_string(rf_band_t b) switch(b) { case b_2m: return "2m (134-174 MHz)"; + case b_1m5: return "1.5m (200-260 MHz)"; case b_70cm: return "70cm (400-520 MHz)"; } return ""; @@ -198,7 +199,10 @@ void rda1846_soft_reset(void) void rda1846_set_band(rf_band_t b) { - if(!rda1846_write_register(RDA1846_REG_RF_BAND, b == b_2m ? RDA1846_RF_BAND_2M : RDA1846_RF_BAND_70CM)) + uint16_t data = RDA1846_RF_BAND_2M; + if(b == b_1m5) data = RDA1846_RF_BAND_1M5; + if(b == b_70cm) data = RDA1846_RF_BAND_70CM; + if(!rda1846_write_register(RDA1846_REG_RF_BAND, data)) rf_band_ = b; } @@ -226,8 +230,9 @@ channel_bw_t rda1846_get_bw(void) uint8_t rda1846_set_freq_kHz(int32_t freq) { - if(freq < (rf_band_ == b_2m ? RDA1846_BAND_2M_LOW : RDA1846_BAND_70CM_LOW) || - freq > (rf_band_ == b_2m ? RDA1846_BAND_2M_HIGH : RDA1846_BAND_70CM_HIGH)) + if((rf_band_ == b_2m && (freq < RDA1846_BAND_2M_LOW || freq > RDA1846_BAND_2M_HIGH)) || + (rf_band_ == b_1m5 && (freq < RDA1846_BAND_1M5_LOW || freq > RDA1846_BAND_1M5_HIGH)) || + (rf_band_ == b_70cm && (freq < RDA1846_BAND_70CM_LOW || freq > RDA1846_BAND_70CM_HIGH)) ) return 1; freq = freq<<3; @@ -240,7 +245,10 @@ uint8_t rda1846_set_freq_kHz(int32_t freq) static int32_t corr_freq(int32_t f) { - return (int32_t)(((float)f)/(rf_band_ == b_2m ? RDA1846_FREQ_CORR_2M : RDA1846_FREQ_CORR_70CM)); + float corr = RDA1846_FREQ_CORR_2M; + if(rf_band_ == b_1m5) corr = RDA1846_FREQ_CORR_1M5; + if(rf_band_ == b_70cm) corr = RDA1846_FREQ_CORR_70CM; + return (int32_t)(((float)f)/corr); } int32_t rda1846_get_freq_kHz(void) |