File: 0051-Fix-calculation-of-mag-2.patch

package info (click to toggle)
hackrf 2015.07.2-11
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 69,764 kB
  • ctags: 9,327
  • sloc: ansic: 13,907; python: 696; vhdl: 218; sh: 32; makefile: 15
file content (33 lines) | stat: -rw-r--r-- 902 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
From adbc5a6f26b8bdaff165f3c01843e58249ad6108 Mon Sep 17 00:00:00 2001
From: Jared Boone <jboone@earfeast.com>
Date: Mon, 17 Aug 2015 11:14:14 -0700
Subject: [PATCH 51/68] Fix calculation of mag^2.

---
 firmware/sgpio-rx/sgpio-rx.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

--- a/firmware/sgpio-rx/sgpio-rx.c
+++ b/firmware/sgpio-rx/sgpio-rx.c
@@ -53,7 +53,7 @@
 
     volatile uint32_t buffer[4096];
     uint32_t i = 0;
-	int16_t magsq;
+	uint32_t magsq;
 	int8_t sigi, sigq;
 
     sgpio_cpld_stream_enable(&sgpio_config);
@@ -68,11 +68,7 @@
 		/* 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)