From 6f9e7fdab838ab3ec0a20410c5c9d4373e6603a4 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sat, 15 Aug 2015 10:03:12 -0700 Subject: [PATCH 1/7] Adapt code to signed samples. Necessary due to change in CPLD to produce signed samples. --- firmware/sgpio-rx/sgpio-rx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firmware/sgpio-rx/sgpio-rx.c b/firmware/sgpio-rx/sgpio-rx.c index dbee1d3f..4993a7c3 100644 --- a/firmware/sgpio-rx/sgpio-rx.c +++ b/firmware/sgpio-rx/sgpio-rx.c @@ -69,8 +69,8 @@ void rx_test() { buffer[i & 4095] = SGPIO_REG_SS(SGPIO_SLICE_A); /* find the magnitude squared */ - sigi = (buffer[i & 4095] & 0xff) - 0x80; - sigq = ((buffer[i & 4095] >> 8) & 0xff) - 0x80; + sigi = buffer[i & 4095] & 0xff; + sigq = (buffer[i & 4095] >> 8) & 0xff; magsq = sigi * sigq; if ((uint16_t)magsq & 0x8000) { magsq ^= 0xffff; From f2c0531bc285db6a8b8c753a3bf128d3eabc6898 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Mon, 17 Aug 2015 11:12:52 -0700 Subject: [PATCH 2/7] Change frequency to center of 2.4GHz ISM. --- firmware/sgpio-rx/sgpio-rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/sgpio-rx/sgpio-rx.c b/firmware/sgpio-rx/sgpio-rx.c index 4993a7c3..105615b7 100644 --- a/firmware/sgpio-rx/sgpio-rx.c +++ b/firmware/sgpio-rx/sgpio-rx.c @@ -88,7 +88,7 @@ void rx_test() { int main(void) { - const uint64_t freq = 2700000000U; + const uint64_t freq = 2441000000U; pin_setup(); enable_1v8_power(); From adbc5a6f26b8bdaff165f3c01843e58249ad6108 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Mon, 17 Aug 2015 11:14:14 -0700 Subject: [PATCH 3/7] Fix calculation of mag^2. --- firmware/sgpio-rx/sgpio-rx.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/firmware/sgpio-rx/sgpio-rx.c b/firmware/sgpio-rx/sgpio-rx.c index 105615b7..d556d17c 100644 --- a/firmware/sgpio-rx/sgpio-rx.c +++ b/firmware/sgpio-rx/sgpio-rx.c @@ -56,7 +56,7 @@ void rx_test() { volatile uint32_t buffer[4096]; uint32_t i = 0; - int16_t magsq; + uint32_t magsq; int8_t sigi, sigq; sgpio_cpld_stream_enable(); @@ -71,11 +71,7 @@ void rx_test() { /* find the magnitude squared */ sigi = buffer[i & 4095] & 0xff; sigq = (buffer[i & 4095] >> 8) & 0xff; - magsq = sigi * sigq; - if ((uint16_t)magsq & 0x8000) { - magsq ^= 0xffff; - magsq++; - } + magsq = sigi * sigi + sigq * sigq; /* illuminate LED3 only when magsq exceeds threshold */ if (magsq > 0x3c00) From 69db61c5c1e06b295fc1d5d0b4f268b691d6d8fe Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Mon, 17 Aug 2015 11:14:55 -0700 Subject: [PATCH 4/7] Remove extra SGPIO API calls. Functions are now performed in rf_path_set_direction(). --- firmware/sgpio-rx/sgpio-rx.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/firmware/sgpio-rx/sgpio-rx.c b/firmware/sgpio-rx/sgpio-rx.c index d556d17c..4d6e48eb 100644 --- a/firmware/sgpio-rx/sgpio-rx.c +++ b/firmware/sgpio-rx/sgpio-rx.c @@ -29,9 +29,6 @@ #include void tx_test() { - sgpio_set_slice_mode(false); - sgpio_configure(TRANSCEIVER_MODE_TX); - // LSB goes out first, samples are 0x volatile uint32_t buffer[] = { 0xda808080, @@ -51,9 +48,6 @@ void tx_test() { } void rx_test() { - sgpio_set_slice_mode(false); - sgpio_configure(TRANSCEIVER_MODE_RX); - volatile uint32_t buffer[4096]; uint32_t i = 0; uint32_t magsq; From 149cd4effc0e8831d9bdf0b61e9af782468243c7 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Mon, 17 Aug 2015 11:15:40 -0700 Subject: [PATCH 5/7] Configure SGPIO slice mode early. --- firmware/sgpio-rx/sgpio-rx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/firmware/sgpio-rx/sgpio-rx.c b/firmware/sgpio-rx/sgpio-rx.c index 4d6e48eb..092d5cc3 100644 --- a/firmware/sgpio-rx/sgpio-rx.c +++ b/firmware/sgpio-rx/sgpio-rx.c @@ -80,6 +80,7 @@ int main(void) { const uint64_t freq = 2441000000U; + sgpio_set_slice_mode(false); pin_setup(); enable_1v8_power(); #ifdef HACKRF_ONE From f128a151177cb1a2ee949948ef666125db450efc Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Mon, 17 Aug 2015 11:15:58 -0700 Subject: [PATCH 6/7] Reduce mag^2 threshold a bit. --- firmware/sgpio-rx/sgpio-rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/sgpio-rx/sgpio-rx.c b/firmware/sgpio-rx/sgpio-rx.c index 092d5cc3..c00c820b 100644 --- a/firmware/sgpio-rx/sgpio-rx.c +++ b/firmware/sgpio-rx/sgpio-rx.c @@ -68,7 +68,7 @@ void rx_test() { magsq = sigi * sigi + sigq * sigq; /* illuminate LED3 only when magsq exceeds threshold */ - if (magsq > 0x3c00) + if (magsq > 0x1000) gpio_set(PORT_LED1_3, (PIN_LED3)); /* LED3 on */ else gpio_clear(PORT_LED1_3, (PIN_LED3)); /* LED3 off */ From 83d79be58463247ede4ab63758e46ca7ab5dc1b8 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Mon, 24 Aug 2015 10:20:57 -0700 Subject: [PATCH 7/7] Push rf_path_set_direction() calls into test functions. The tx_test() is now put into TX mode. --- firmware/sgpio-rx/sgpio-rx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/firmware/sgpio-rx/sgpio-rx.c b/firmware/sgpio-rx/sgpio-rx.c index c00c820b..a415f71c 100644 --- a/firmware/sgpio-rx/sgpio-rx.c +++ b/firmware/sgpio-rx/sgpio-rx.c @@ -38,6 +38,7 @@ void tx_test() { }; uint32_t i = 0; + rf_path_set_direction(RF_PATH_DIRECTION_TX); sgpio_cpld_stream_enable(); while(true) { @@ -53,6 +54,7 @@ void rx_test() { uint32_t magsq; int8_t sigi, sigq; + rf_path_set_direction(RF_PATH_DIRECTION_RX); sgpio_cpld_stream_enable(); gpio_set(PORT_LED1_3, (PIN_LED2)); /* LED2 on */ @@ -89,7 +91,6 @@ int main(void) { cpu_clock_init(); ssp1_init(); rf_path_init(); - rf_path_set_direction(RF_PATH_DIRECTION_RX); set_freq(freq);