Hamming ECC software implementation.
This file contains a software Hamming ECC implementation.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
#include "ecc-sw.h"
Functions | |
static void | compute256 (const uint8_t *data, uint8_t *code) |
Calculates the 22-bit hamming code for a 256-bytes block of data. More... | |
static uint32_t | count_bits_in_byte (uint8_t byte) |
Count and return the number of bits set to '1' in the given byte. More... | |
static uint32_t | count_bits_in_code256 (uint8_t *code) |
Count and return the number of bits set to '1' in the given hamming code. More... | |
void | hamming_compute_256x (const uint8_t *puc_data, uint32_t dw_size, uint8_t *puc_code) |
Computes 3-bytes hamming codes for a data block whose size is multiple of 256 bytes. More... | |
uint32_t | hamming_verify_256x (uint8_t *puc_data, uint32_t dw_size, const uint8_t *puc_code) |
Verify 3-bytes hamming codes for a data block whose size is multiple of 256 bytes. More... | |
static uint32_t | verify256 (uint8_t *puc_data, const uint8_t *puc_original_code) |
Verifies and corrects a 256-bytes block of data using the given 22-bits hamming code. More... | |
|
static |
Calculates the 22-bit hamming code for a 256-bytes block of data.
data | Data buffer to calculate code for. |
code | Pointer to a buffer where the code should be stored. |
References count_bits_in_byte().
Referenced by hamming_compute_256x(), and verify256().
|
static |
Count and return the number of bits set to '1' in the given byte.
byte | Byte to count. |
Referenced by compute256(), and count_bits_in_code256().
|
static |
Count and return the number of bits set to '1' in the given hamming code.
code | Hamming code. |
References count_bits_in_byte().
Referenced by verify256().
void hamming_compute_256x | ( | const uint8_t * | puc_data, |
uint32_t | dw_size, | ||
uint8_t * | puc_code | ||
) |
Computes 3-bytes hamming codes for a data block whose size is multiple of 256 bytes.
Each 256 bytes block gets its own code.
puc_data | Pointer to data to compute code for. |
dw_size | Data size in bytes. |
puc_code | Pointer to codes buffer. |
References compute256().
uint32_t hamming_verify_256x | ( | uint8_t * | puc_data, |
uint32_t | dw_size, | ||
const uint8_t * | puc_code | ||
) |
Verify 3-bytes hamming codes for a data block whose size is multiple of 256 bytes.
Each 256-bytes block is verified with its own code.
puc_data | Pointer to data buffer to verify. |
dw_size | Size of the data in bytes. |
puc_code | Pointer to original codes. |
References HAMMING_ERROR_SINGLE_BIT, and verify256().
|
static |
Verifies and corrects a 256-bytes block of data using the given 22-bits hamming code.
puc_data | Pointer to data buffer to check. |
puc_original_code | Pointer to hamming code to use for verifying the data. |
References compute256(), count_bits_in_code256(), HAMMING_ERROR_ECC, HAMMING_ERROR_MULTIPLE_BITS, and HAMMING_ERROR_SINGLE_BIT.
Referenced by hamming_verify_256x().