summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@mur.at>2013-03-06 04:08:12 +0000
committerChristian Pointner <equinox@mur.at>2013-03-06 04:08:12 +0000
commita1a6c7034362d5c4935b729a12aa2a90f22827e7 (patch)
treeffff207bad80af72fb7cd75fad78ff453d0d32b8
parentrda1846dongle: api contains now most needed functions (diff)
rda1846dongle: fixed dtmf freq2val converters
some more debug commands git-svn-id: https://svn.spreadspace.org/mur.sat@696 7de4ea59-55d0-425e-a1af-a3118ea81d4c
-rw-r--r--software/rda1846dongle/rda1846.h2
-rw-r--r--software/rda1846dongle/rda1846_defines.h8
-rw-r--r--software/rda1846dongle/rda1846dongle.c48
3 files changed, 48 insertions, 10 deletions
diff --git a/software/rda1846dongle/rda1846.h b/software/rda1846dongle/rda1846.h
index 6cf4f38..e755bee 100644
--- a/software/rda1846dongle/rda1846.h
+++ b/software/rda1846dongle/rda1846.h
@@ -39,7 +39,7 @@ void rda1846_soft_reset(void);
int16_t rda1846_get_rssi(void);
int16_t rda1846_get_vssi(void);
uint16_t rda1846_get_flags(void);
-uint8_t rda1846_get_dtmf(uint8_t* , uint8_t* , uint8_t* );
+uint8_t rda1846_get_dtmf(uint8_t*, uint8_t*, uint8_t*);
int32_t rda1846_get_freq_kHz(void);
uint8_t rda1846_set_freq_kHz(int32_t freq);
diff --git a/software/rda1846dongle/rda1846_defines.h b/software/rda1846dongle/rda1846_defines.h
index 242df4e..ab4b496 100644
--- a/software/rda1846dongle/rda1846_defines.h
+++ b/software/rda1846dongle/rda1846_defines.h
@@ -182,10 +182,12 @@
#define RDA1846_DTMF_EN 0x0100
// DTMF tone freq
-#define dtmf_tone_freq_hz(value) (value/4.096)
-#define dtmf_tone_freq_value(hz) (hz*4.096)
+#include <math.h>
-// DTMF frequencies @ 12.288 MHz - these are defaults...
+#define dtmf_tone_freq_hz(value) (uint16_t)round(value/4.096)
+#define dtmf_tone_freq_value(hz) (uint16_t)round(hz*4.096)
+
+// DTMF frequencies @ 12.288 MHz - these are the defaults...
#define RDA1846_DTMF_C0 0x61 // 697 Hz
#define RDA1846_DTMF_C1 0x5B // 770 Hz
#define RDA1846_DTMF_C2 0x53 // 852 Hz
diff --git a/software/rda1846dongle/rda1846dongle.c b/software/rda1846dongle/rda1846dongle.c
index 8a011b7..9e0c1b6 100644
--- a/software/rda1846dongle/rda1846dongle.c
+++ b/software/rda1846dongle/rda1846dongle.c
@@ -40,6 +40,7 @@
#include "usbio.h"
#include "rda1846.h"
+#include "rda1846_defines.h"
#define DEFAULT_FREQ 145900
int32_t current_freq_kHz = DEFAULT_FREQ;
@@ -48,9 +49,9 @@ static int32_t print_actual_freq(void)
{
int32_t f = rda1846_get_freq_kHz();
if(f < 0)
- printf("actual frequency: NaN MHz");
+ printf("actual frequency: NaN MHz\r\n");
else
- printf("actual frequency: %d.%03d MHz", (uint16_t)(f / 1000), (uint16_t)(f % 1000));
+ printf("actual frequency: %d.%03d MHz\r\n", (uint16_t)(f / 1000), (uint16_t)(f % 1000));
return f;
}
@@ -68,17 +69,52 @@ static void update_current_freq(void)
current_freq_kHz = DEFAULT_FREQ;
}
+static void print_status(void)
+{
+ int16_t rssi = rda1846_get_rssi();
+ if(rssi < 0)
+ printf("rssi: NaN dB\r\n");
+ else
+ printf("rssi: %d.%03d dB\r\n", (uint16_t)(rssi / 8), (uint16_t)((rssi % 8)*125));
+
+ int16_t vssi = rda1846_get_vssi();
+ if(vssi < 0)
+ printf("vssi: NaN mV\r\n");
+ else
+ printf("vssi: %d mV\r\n", vssi);
+
+ uint16_t flags = rda1846_get_flags();
+ if(vssi < 0)
+ printf("flags: ERROR\r\n");
+ else
+ printf("flags: %04X\r\n", flags);
+
+ print_actual_freq();
+}
+
+static void print_dtmf(void)
+{
+ uint8_t idx1, idx2, code;
+ if(rda1846_get_dtmf(&idx1, &idx2, &code))
+ printf("DTMF: ERROR\r\n");
+ else
+ printf("DTMF: tone1=%d, tone2=%d, code=0x%02X\r\n", idx1, idx2, code);
+}
+
+
static void handle_cmd(uint8_t cmd)
{
switch(cmd) {
- case '0': led_off(); printf("ok\r\n"); break;
- case '1': led_on(); printf("ok\r\n"); break;
- case 't': led_toggle(); printf("ok\r\n"); break;
+ case '0': led_off(); printf("led OFF\r\n"); break;
+ case '1': led_on(); printf("led ON\r\n"); break;
+ case 't': led_toggle(); printf("led TOGGLE\r\n"); break;
case '!': reset2bootloader(); break;
case 'f': print_actual_freq(); break;
+ case 's': print_status(); break;
+ case 'd': print_dtmf(); break;
case '+': current_freq_kHz+=500; update_current_freq(); break;
case '-': current_freq_kHz-=500; update_current_freq(); break;
- default: printf("ERROR: unknown command\r\n"); return;
+ default: printf("\r\n"); return;
}
}