summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--software/rda1846dongle/rda1846.c47
-rw-r--r--software/rda1846dongle/rda1846.h5
-rw-r--r--software/rda1846dongle/rda1846_defines.h1
-rw-r--r--software/rda1846dongle/rda1846dongle.c74
4 files changed, 106 insertions, 21 deletions
diff --git a/software/rda1846dongle/rda1846.c b/software/rda1846dongle/rda1846.c
index eeb5ba1..9f8f356 100644
--- a/software/rda1846dongle/rda1846.c
+++ b/software/rda1846dongle/rda1846.c
@@ -129,20 +129,18 @@ void rda1846_reg_init(void)
rda1846_write_register(RDA1846_REG_CTL, RDA1846_CTL_SOFT_RST);
rda1846_write_register(RDA1846_REG_CTL, RDA1846_CTL_PDN);
- rda1846_write_register(RDA1846_REG_RF_BAND, RDA1846_RF_BAND_2M);
-// rda1846_write_register(RDA1846_REG_RF_BAND, RDA1846_RF_BAND_70CM);
-
// set crystal frequency (12.288 MHz)
rda1846_write_register(RDA1846_REG_XTAL, RDA1846_XTAL_FREQ);
rda1846_write_register(RDA1846_REG_ADCLK, RDA1846_ADCLK_FREQ);
rda1846_write_register(RDA1846_REG_CLK_MODE, RDA1846_CLK_MODE);
-// rda1846_write_register(RDA1846_REG_CTL, RDA1846_CTL_CH_12K5 | RDA1846_CTL_RX_M_TX_M | RDA1846_CTL_PDN);
- rda1846_write_register(RDA1846_REG_CTL, RDA1846_CTL_CH_25K | RDA1846_CTL_RX_M_TX_M | RDA1846_CTL_PDN);
+ rda1846_write_register(RDA1846_REG_RF_BAND, RDA1846_RF_BAND_2M);
+ rda1846_write_register(RDA1846_REG_CTL, RDA1846_CTL_CH_12K5 | RDA1846_CTL_RX_M_TX_M | RDA1846_CTL_PDN);
-// rda1846_write_register(RDA1846_REG_TX_VOICE, RDA1846_TX_VOICE_NONE);
- rda1846_write_register(RDA1846_REG_TX_VOICE, RDA1846_TX_VOICE_MIC);
+ rda1846_write_register(RDA1846_REG_TX_VOICE, RDA1846_TX_VOICE_NONE);
+// rda1846_write_register(RDA1846_REG_TX_VOICE, RDA1846_TX_VOICE_MIC);
// rda1846_write_register(RDA1846_REG_TX_VOICE, RDA1846_TX_VOICE_TONE2);
+// rda1846_write_register(RDA1846_REG_DTMF_T2, 6689);
// rda1846_write_register(RDA1846_REG_DTMF_CTL, RDA1846_DTMF_DUAL | RDA1846_DTMF_EN);
// rda1846_write_register(RDA1846_REG_INT, RDA1846_INT_DTMF_IDLE);
@@ -176,6 +174,39 @@ void rda1846_wakeup(void)
}
+void rda1846_set_band_2m(void)
+{
+ rda1846_write_register(RDA1846_REG_RF_BAND, RDA1846_RF_BAND_2M);
+}
+
+void rda1846_set_band_70cm(void)
+{
+ rda1846_write_register(RDA1846_REG_RF_BAND, RDA1846_RF_BAND_70CM);
+}
+
+void rda1846_set_bw_12k5(void)
+{
+ uint16_t data;
+ if(rda1846_read_register(RDA1846_REG_CTL, &data))
+ return;
+
+ data &= RDA1846_CTL_CH_RESET;
+ data |= RDA1846_CTL_CH_12K5;
+ rda1846_write_register(RDA1846_REG_CTL, data);
+}
+
+void rda1846_set_bw_25k(void)
+{
+ uint16_t data;
+ if(rda1846_read_register(RDA1846_REG_CTL, &data))
+ return;
+
+ data &= RDA1846_CTL_CH_RESET;
+ data |= RDA1846_CTL_CH_25K;
+ rda1846_write_register(RDA1846_REG_CTL, data);
+}
+
+
void rda1846_idle(void)
{
uint16_t data;
@@ -359,7 +390,7 @@ void rda1846_dump_register(void)
RDA1846_REG_CTL, RDA1846_REG_INT, RDA1846_REG_GPIO,
RDA1846_REG_PA_BIAS, RDA1846_REG_TX_VOICE, RDA1846_REG_VOX_OPEN, RDA1846_REG_VOX_SHUT,
RDA1846_REG_SUBAUDIO, RDA1846_REG_RX_VOICE, RDA1846_REG_SQ_OPEN, RDA1846_REG_SQ_SHUT,
- RDA1846_REG_DTMF_CTL, RDA1846_REG_DTMF_OUT,
+ RDA1846_REG_DTMF_CTL, RDA1846_REG_DTMF_OUT, RDA1846_REG_DTMF_T1, RDA1846_REG_DTMF_T2,
RDA1846_REG_RSSI, RDA1846_REG_VSSI, RDA1846_REG_FLAG };
int i;
diff --git a/software/rda1846dongle/rda1846.h b/software/rda1846dongle/rda1846.h
index 12b2c5a..7e22a7e 100644
--- a/software/rda1846dongle/rda1846.h
+++ b/software/rda1846dongle/rda1846.h
@@ -40,6 +40,11 @@ void rda1846_soft_reset(void);
void rda1846_powerdown(void);
void rda1846_wakeup(void);
+void rda1846_set_band_2m(void);
+void rda1846_set_band_70cm(void);
+void rda1846_set_bw_12k5(void);
+void rda1846_set_bw_25k(void);
+
void rda1846_idle(void);
void rda1846_receive(void);
void rda1846_transmit(void);
diff --git a/software/rda1846dongle/rda1846_defines.h b/software/rda1846dongle/rda1846_defines.h
index bfcc5e8..e6fca56 100644
--- a/software/rda1846dongle/rda1846_defines.h
+++ b/software/rda1846dongle/rda1846_defines.h
@@ -87,6 +87,7 @@
// ctl
#define RDA1846_CTL_CH_25K 0x3000
#define RDA1846_CTL_CH_12K5 0x0000
+#define RDA1846_CTL_CH_RESET 0xCFFF
#define RDA1846_CTL_TAIL_ELIM 0x0800
diff --git a/software/rda1846dongle/rda1846dongle.c b/software/rda1846dongle/rda1846dongle.c
index 310e2ad..d6f1b85 100644
--- a/software/rda1846dongle/rda1846dongle.c
+++ b/software/rda1846dongle/rda1846dongle.c
@@ -43,15 +43,30 @@
#include "rda1846.h"
#include "rda1846_defines.h"
-#define DEFAULT_FREQ 145900
-//#define DEFAULT_FREQ 409750
-int32_t current_freq_kHz = DEFAULT_FREQ;
+#define DEFAULT_FREQ_2M 145900
+#define DEFAULT_FREQ_70CM 435000
+int32_t default_freq = DEFAULT_FREQ_2M;
+int32_t current_freq_kHz = DEFAULT_FREQ_2M;
+
+static void reset_rda(void)
+{
+ printf("soft resetting RDA1846.\r\n");
+ rda1846_soft_reset();
+ current_freq_kHz = default_freq = DEFAULT_FREQ_2M;
+}
+
+static void reinit_rda(void)
+{
+ printf("initializing RDA1846.\r\n");
+ rda1846_reg_init();
+ current_freq_kHz = default_freq = DEFAULT_FREQ_2M;
+}
static void set_default_freq(void)
{
+ current_freq_kHz = default_freq;
printf("setting frequency to %d.%03d MHz .. ", (uint16_t)(current_freq_kHz / 1000),
(uint16_t)(current_freq_kHz % 1000));
- current_freq_kHz = DEFAULT_FREQ;
if(rda1846_set_freq_kHz(current_freq_kHz))
printf("error\r\n");
else
@@ -83,7 +98,35 @@ static void update_current_freq(void)
/* current_freq_kHz = print_actual_freq(); */
/* if(current_freq_kHz < 0) */
- /* current_freq_kHz = DEFAULT_FREQ; */
+ /* current_freq_kHz = default_freq; */
+}
+
+static void set_band_2m(void)
+{
+ printf("setting band to 2m\r\n");
+ rda1846_set_band_2m();
+ default_freq = DEFAULT_FREQ_2M;
+ set_default_freq();
+}
+
+static void set_band_70cm(void)
+{
+ printf("setting band to 70cm\r\n");
+ rda1846_set_band_70cm();
+ default_freq = DEFAULT_FREQ_70CM;
+ set_default_freq();
+}
+
+static void set_bw_12k5(void)
+{
+ printf("setting band to 12.5 kHz\r\n");
+ rda1846_set_bw_12k5();
+}
+
+static void set_bw_25k(void)
+{
+ printf("setting band to 25 kHz\r\n");
+ rda1846_set_bw_25k();
}
static void print_status(void)
@@ -127,12 +170,17 @@ static void handle_cmd(uint8_t cmd)
case '0': rda1846_gpio_AA(); led_off(); printf("led OFF\r\n"); break;
case '1': rda1846_gpio_55(); led_on(); printf("led ON\r\n"); break;
case 't': led_toggle(); printf("led TOGGLE\r\n"); break;
- case '!': reset2bootloader(); break;
+ case '!': rda1846_soft_reset(); reset2bootloader(); break;
- case 'r': rda1846_soft_reset(); printf("soft resetting RDA1846.\r\n"); break;
- case 'i': rda1846_reg_init(); printf("initializing RDA1846.\r\n"); break;
+ case 'r': reset_rda(); break;
+ case 'i': reinit_rda(); break;
case 'F': set_default_freq(); break;
+ case '2': set_band_2m(); break;
+ case '7': set_band_70cm(); break;
+ case 'b': set_bw_12k5(); break;
+ case 'B': set_bw_25k(); break;
+
case 'g': rda1846_gpio_off(); printf("GPIO off\r\n"); break;
case 'G': rda1846_gpio_default(); printf("GPIO to defaults\r\n"); break;
@@ -141,12 +189,12 @@ static void handle_cmd(uint8_t cmd)
case 'd': print_dtmf(); break;
case 'D': rda1846_dump_register(); break;
- case 'p': rda1846_powerdown(); break;
- case 'P': rda1846_wakeup(); break;
+ case 'p': rda1846_powerdown(); printf("powered down.\r\n"); break;
+ case 'P': rda1846_wakeup(); printf("woke up ...\r\n"); break;
- case 'I': rda1846_idle(); break;
- case 'R': rda1846_receive(); break;
- case 'T': rda1846_transmit(); break;
+ case 'I': rda1846_idle(); printf("idle.\r\n"); break;
+ case 'R': rda1846_receive(); printf("receiving ...\r\n"); break;
+ case 'T': rda1846_transmit(); printf("transmitting ...\r\n"); break;
case '+': current_freq_kHz+=25; update_current_freq(); break;
case '-': current_freq_kHz-=25; update_current_freq(); break;