Microchip® Advanced Software Framework

ecc-sw.h File Reference

Hamming ECC software implementation.

This file contains a software Hamming ECC implementation.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include "compiler.h"

Macros

#define HAMMING_ERROR_ECC   2
 
#define HAMMING_ERROR_MULTIPLE_BITS   3
 
#define HAMMING_ERROR_SINGLE_BIT   1
 These are the possible errors when trying to verify a block of data encoded using a Hamming code: More...
 

Functions

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...
 

#define HAMMING_ERROR_ECC   2

Referenced by verify256().

#define HAMMING_ERROR_MULTIPLE_BITS   3

Referenced by verify256().

#define HAMMING_ERROR_SINGLE_BIT   1

These are the possible errors when trying to verify a block of data encoded using a Hamming code:

Errors

  • HAMMING_ERROR_SINGLE_BIT
  • HAMMING_ERROR_ECC
  • HAMMING_ERROR_MULTIPLE_BITS

Referenced by hamming_verify_256x(), and 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.

Parameters
puc_dataPointer to data to compute code for.
dw_sizeData size in bytes.
puc_codePointer 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.

Parameters
puc_dataPointer to data buffer to verify.
dw_sizeSize of the data in bytes.
puc_codePointer to original codes.
Returns
0 if the data is correct, HAMMING_ERROR_SINGLE_BIT if one or more block(s) have had a single bit corrected, or either HAMMING_ERROR_ECC or HAMMING_ERROR_MULTIPLE_BITS.

References HAMMING_ERROR_SINGLE_BIT, and verify256().