altos/chaoskey: use both halves of the CRC
authorKeith Packard <keithp@keithp.com>
Sun, 22 Jan 2017 23:29:13 +0000 (15:29 -0800)
committerKeith Packard <keithp@keithp.com>
Mon, 20 Feb 2017 19:16:52 +0000 (11:16 -0800)
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>
src/chaoskey-v1.0/Makefile
src/stmf0/ao_crc.h

index f6b78d0772f9d52a56dde60e52e9c4801434a54b..f2c168baf3cf1a99f3fe7cc55b5c9b1aaf01e1aa 100644 (file)
@@ -14,6 +14,7 @@ INC = \
        ao_task.h \
        ao_adc_fast.h \
        ao_power.h \
+       ao_crc.h \
        stm32f0.h
 
 #
index 7acc6f9c0e33df5cb610271d73f3669ffbe982c5..b6d91023bde46e4fa8ba37df4a1647f850973d47 100644 (file)
@@ -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