diff options
author | Daniel Friesel <derf@finalrewind.org> | 2016-02-05 17:33:02 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2016-02-05 17:33:02 +0100 |
commit | f88c1fde18146fd1bf543399da0f6584c3fd4a81 (patch) | |
tree | d93b2d30ac2b83cc739e1ee550179c1792b1e37e /src/hamming.h | |
parent | 4bf560b6f3ef6089af04dfc56d078b9978496b07 (diff) |
add (untested) Hamming forward error correction code and corresponding class
The system now uses a FECModem instance, which inherits the receive methods
etc. from Modem.
Up next: Make the modem's buffer read methods private and expose them in
error-corrected FECModem methods instead
Diffstat (limited to 'src/hamming.h')
-rw-r--r-- | src/hamming.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/hamming.h b/src/hamming.h new file mode 100644 index 0000000..9828baa --- /dev/null +++ b/src/hamming.h @@ -0,0 +1,37 @@ +#ifndef HAMMING_H_ +#define HAMMING_H_ + +#include <avr/pgmspace.h> + +enum HammingResult : uint8_t { + NO_ERROR = 0, + ERROR_IN_PARITY = 0xfe, + UNCORRECTABLE = 0xff, +}; + +const uint8_t hammingParityLow[] PROGMEM = +{ 0, 3, 5, 6, 6, 5, 3, 0, 7, 4, 2, 1, 1, 2, 4, 7 }; + +const uint8_t hammingParityHigh[] PROGMEM = +{ 0, 9, 10, 3, 11, 2, 1, 8, 12, 5, 6, 15, 7, 14, 13, 4 }; + +const uint8_t PROGMEM hammingParityCheck[] = { + NO_ERROR, + ERROR_IN_PARITY, + ERROR_IN_PARITY, + 0x01, + ERROR_IN_PARITY, + 0x02, + 0x04, + 0x08, + ERROR_IN_PARITY, + 0x10, + 0x20, + 0x40, + 0x80, + UNCORRECTABLE, + UNCORRECTABLE, + UNCORRECTABLE +}; + +#endif /* HAMMING_H_ */ |