Double MSP (TLM and MAVLink) throughput for Gemini hardware (#3037)
[ExpressLRS.git] / src / lib / FEC / hamming.h
blob85e4046ed5ef4aea831890dc6cd53ce10f61de72
1 /***************************************************************************
2 * Hamming Encoding and Decoding Headers
4 * File : hamming.h
5 * Purpose : Header for Hamming encode and decode routines. Contains the
6 * prototypes to be used by programs linking to the Hamming
7 * library.
8 * Author : Michael Dipperstein
9 * Date : December 29, 2004
11 ****************************************************************************
12 * UPDATES
14 * $Id: hamming.h,v 1.2 2007/09/19 13:08:15 michael Exp $
15 * $Log: hamming.h,v $
16 * Revision 1.2 2007/09/19 13:08:15 michael
17 * Licensed under LGPL V3.
19 * Revision 1.1.1.1 2005/01/02 05:06:45 michael
20 * Initial version
23 ****************************************************************************
25 * Hamming: A collection of ANSI C Hamming Encoding/Decoding routines
26 * Copyright (C) 2004, 2007 by Michael Dipperstein (mdipperstein@gmail.com)
28 * This file is part of the Hamming library.
30 * The Hamming library is free software; you can redistribute it and/or
31 * modify it under the terms of the GNU Lesser General Public License as
32 * published by the Free Software Foundation; either version 3 of the
33 * License, or (at your option) any later version.
35 * The Hamming library is distributed in the hope that it will be useful,
36 * but WITHOUT ANY WARRANTY; without even the implied warranty of
37 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
38 * General Public License for more details.
40 * You should have received a copy of the GNU Lesser General Public License
41 * along with this program. If not, see <http://www.gnu.org/licenses/>.
43 ***************************************************************************/
44 #pragma once
46 /***************************************************************************
47 * INCLUDED FILES
48 ***************************************************************************/
49 #include <stdint.h>
51 /***************************************************************************
52 * CONSTANTS
53 ***************************************************************************/
54 /* number of uncoded data bits and data values */
55 #define DATA_BITS 4
56 #define DATA_VALUES (1 << DATA_BITS)
58 /* number of parity bits and data values */
59 #define PARITY_BITS 3
60 #define PARITY_VALUES (1 << PARITY_BITS)
62 /* number of code bits (data + parity) and data values */
63 #define CODE_BITS (DATA_BITS + PARITY_BITS)
64 #define CODE_VALUES (1 << CODE_BITS)
66 /***************************************************************************
67 * PROTOTYPES
68 ***************************************************************************/
69 uint8_t HammingTableEncode(uint8_t data);
70 uint8_t HammingTableDecode(uint8_t code);