summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2017-01-22 15:29:13 -0800
committerKeith Packard <keithp@keithp.com>2017-02-20 11:16:52 -0800
commitd96224c2fdc535d08de23aec30d62d4ada9fb8d3 (patch)
tree9172440e8b576a4427556a8d9f129c1650887244
parentbc076747f6cc00508aef909a3a5bd3edf8c9bd66 (diff)
altos/chaoskey: use both halves of the CRC
When pulling 16 bits from the 32-bit crc, instead of just using the low bits, xor the two halves together. This appears to even out the number of zero and one bits. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--src/chaoskey-v1.0/Makefile1
-rw-r--r--src/stmf0/ao_crc.h3
2 files changed, 3 insertions, 1 deletions
diff --git a/src/chaoskey-v1.0/Makefile b/src/chaoskey-v1.0/Makefile
index f6b78d07..f2c168ba 100644
--- a/src/chaoskey-v1.0/Makefile
+++ b/src/chaoskey-v1.0/Makefile
@@ -14,6 +14,7 @@ INC = \
ao_task.h \
ao_adc_fast.h \
ao_power.h \
+ ao_crc.h \
stm32f0.h
#
diff --git a/src/stmf0/ao_crc.h b/src/stmf0/ao_crc.h
index 7acc6f9c..b6d91023 100644
--- a/src/stmf0/ao_crc.h
+++ b/src/stmf0/ao_crc.h
@@ -35,7 +35,8 @@
static inline uint16_t
ao_crc_in_32_out_16(uint32_t v) {
stm_crc.dr.u32 = v;
- return stm_crc.dr.u16;
+ v = stm_crc.dr.u32;
+ return v ^ (v >> 16);
}
static inline uint16_t