COSA
An Object-Oriented Platform for Arduino Programming
HammingCodec_8_4.cpp
Go to the documentation of this file.
1 
21 #include "HammingCodec_8_4.hh"
22 
23 // Encoding table; 4-bit code to 8-bit symbol
24 const uint8_t HammingCodec_8_4::s_symbols[16] __PROGMEM = {
25  0x0f, 0x18, 0x24, 0x33, 0x42, 0x55, 0x69, 0x7e,
26  0x81, 0x96, 0xaa, 0xbd, 0xcc, 0xdb, 0xe7, 0xf0
27 };
28 
29 // Decoding table; 8-bit symbol to 4-bit code (packed table)
30 const uint8_t HammingCodec_8_4::s_codes[128] __PROGMEM = {
31  0x08, 0x40, 0x20, 0x00, 0x10, 0x00, 0x00, 0x00,
32  0x11, 0x13, 0x15, 0x91, 0x11, 0x11, 0x11, 0x10,
33  0x22, 0x23, 0x22, 0x22, 0x26, 0xa2, 0x22, 0x20,
34  0x33, 0x33, 0x23, 0x33, 0x13, 0x33, 0x3b, 0x73,
35  0x44, 0x44, 0x45, 0x44, 0x46, 0x44, 0xc4, 0x40,
36  0x55, 0x45, 0x55, 0x55, 0x15, 0x5d, 0x55, 0x75,
37  0x66, 0x46, 0x26, 0x6e, 0x66, 0x66, 0x66, 0x76,
38  0xf7, 0x73, 0x75, 0x77, 0x76, 0x77, 0x77, 0x77,
39  0x88, 0x88, 0x88, 0x98, 0x88, 0xa8, 0xc8, 0x80,
40  0x98, 0x99, 0x99, 0x99, 0x19, 0x9d, 0x9b, 0x99,
41  0xa8, 0xaa, 0x2a, 0xae, 0xaa, 0xaa, 0xab, 0xaa,
42  0xfb, 0xb3, 0xbb, 0x9b, 0xbb, 0xab, 0xbb, 0xbb,
43  0xc8, 0x4c, 0xcc, 0xce, 0xcc, 0xcd, 0xcc, 0xcc,
44  0xfd, 0xdd, 0xd5, 0x9d, 0xdd, 0xdd, 0xcd, 0xdd,
45  0xfe, 0xee, 0xee, 0xee, 0xe6, 0xae, 0xce, 0xee,
46  0xff, 0xff, 0xff, 0xfe, 0xff, 0xfd, 0xfb, 0x7f
47 };
48 
49 /*
50  * Calculating the start symbol (8-bits per symbol):
51  * 0x55, 0x55 => 0101.0101, 0101.0101 (preamble 7-bit).
52  * 0x55, 0x5a => 0101.0101, 0101.1010
53  */
54 const uint8_t HammingCodec_8_4::s_preamble[8] __PROGMEM = {
55  0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x5a
56 };
const uint8_t HammingCodec_8_4::s_symbols[16] __PROGMEM