Thanks to visit codestin.com
Credit goes to github.com

Skip to content

hmolavi/hamming74

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Component Registry Espressif PIO GitHub

Hamming(7,4) Encoding and Decoding Library

A lightweight C library providing functions to encode and decode data bits using the Hamming(7,4) error correction scheme.

Features

  • Encodes 4-bit data blocks into 7-bit Hamming code.
  • Decodes and corrects single-bit errors in encoded data.

Getting Started

Usage

Warning: The encode function assumes you are passing in bits in multiples of 4.

  1. Include the header:

    #include "hamming.h"
  2. Encode & Decode data:

    int input_bits[4] = {1,0,1,1};
    int out_bits[7];
    hamming_encode_74(input_bits, sizeof(input_bits), out_bits);
    
    int decoded_bits[4];
    hamming_decode_74(out_bits, sizeof(out_bits), decoded_bits);
    
    /* decoded_bits will be the same as input_bits */
    for (int i = 0; i < 4; i++) {
         assert(input_bits[i] == decoded_bits[i]);
    }

License

This project is released under the MIT License. Use it freely in your own projects!

About

A pure C library for Hamming(7,4) encoding and decoding

Resources

License

Stars

Watchers

Forks

Packages

No packages published