summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@mur.at>2015-02-18 00:48:39 (GMT)
committerChristian Pointner <equinox@mur.at>2015-02-18 00:48:39 (GMT)
commite8191d71ade086dc3f5d119a3c03098f620373a7 (patch)
treee96e428e10ff07622fc7985b5b91da175e212185
parentf3e09a0af08fd3d3401956b302b40df399bbb073 (diff)
hhd70: added rssi and RX TX commands
-rw-r--r--software/avr.lib/cc1101.c15
-rw-r--r--software/avr.lib/cc1101.h4
-rw-r--r--software/hhd70dongle/hhd70dongle.c10
3 files changed, 29 insertions, 0 deletions
diff --git a/software/avr.lib/cc1101.c b/software/avr.lib/cc1101.c
index 3436782..1c00e83 100644
--- a/software/avr.lib/cc1101.c
+++ b/software/avr.lib/cc1101.c
@@ -138,6 +138,16 @@ void cc1101_fasttxon(void)
cc1101_spi_strobe_command(CC1101_CMD_SFSTXON);
}
+void cc1101_rx(void)
+{
+ cc1101_spi_strobe_command(CC1101_CMD_SRX);
+}
+
+void cc1101_tx(void)
+{
+ cc1101_spi_strobe_command(CC1101_CMD_STX);
+}
+
char* cc1101_state_to_string(cc1101_state_t state)
{
switch(state) {
@@ -217,6 +227,11 @@ uint32_t cc1101_get_freq_hz(void)
return (uint32_t)((float)freq * drv.freq_corr);
}
+int8_t cc1101_get_rssi(void)
+{
+ return (int8_t)cc1101_spi_read_register(CC1101_REG_RO_RSSI);
+}
+
static char* cc1101_config_reg_to_string(uint8_t addr)
{
switch(addr) {
diff --git a/software/avr.lib/cc1101.h b/software/avr.lib/cc1101.h
index ce97d9d..83c99bf 100644
--- a/software/avr.lib/cc1101.h
+++ b/software/avr.lib/cc1101.h
@@ -48,11 +48,15 @@ void cc1101_idle(void);
void cc1101_osc_off(void);
void cc1101_calibrate(void);
void cc1101_fasttxon(void);
+void cc1101_rx(void);
+void cc1101_tx(void);
cc1101_state_t cc1101_get_state(void);
void cc1101_set_freq_hz(uint32_t hz);
uint32_t cc1101_get_freq_hz(void);
+int8_t cc1101_get_rssi(void);
+
void cc1101_dump_register(void);
#endif
diff --git a/software/hhd70dongle/hhd70dongle.c b/software/hhd70dongle/hhd70dongle.c
index ca2fa45..ce4e963 100644
--- a/software/hhd70dongle/hhd70dongle.c
+++ b/software/hhd70dongle/hhd70dongle.c
@@ -100,6 +100,14 @@ static void update_current_freq(void)
static void print_status(void)
{
printf("current state: %s\r\n", cc1101_state_to_string(cc1101_get_state()));
+
+ int16_t rssi = (int16_t)cc1101_get_rssi();
+ printf("rssi: ");
+ if(rssi < 0) {
+ printf("-");
+ rssi*=-1;
+ }
+ printf("%d.%01d dB\r\n", (uint16_t)(rssi / 2), (uint16_t)((rssi % 2)*5));
}
static void handle_cmd(uint8_t cmd)
@@ -126,6 +134,8 @@ static void handle_cmd(uint8_t cmd)
case 'O': osc_off_hhd70(); break;
case 'C': cc1101_calibrate(); print_status(); break;
case 'X': cc1101_fasttxon(); print_status(); break;
+ case 'R': cc1101_rx(); print_status(); break;
+ case 'T': cc1101_tx(); print_status(); break;
case 'f': print_actual_freq(); break;
case 's': print_status(); break;