1 /**
2  * \file
3  *
4  * \brief Hamming ECC software implementation.
5  *
6  * This file contains a software Hamming ECC implementation.
7  *
8  * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
9  *
10  * \asf_license_start
11  *
12  * \page License
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are met:
16  *
17  * 1. Redistributions of source code must retain the above copyright notice,
18  *    this list of conditions and the following disclaimer.
19  *
20  * 2. Redistributions in binary form must reproduce the above copyright notice,
21  *    this list of conditions and the following disclaimer in the documentation
22  *    and/or other materials provided with the distribution.
23  *
24  * 3. The name of Atmel may not be used to endorse or promote products derived
25  *    from this software without specific prior written permission.
26  *
27  * 4. This software may only be redistributed and used in connection with an
28  *    Atmel microcontroller product.
29  *
30  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
31  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
33  * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
34  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
38  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
39  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
40  * POSSIBILITY OF SUCH DAMAGE.
41  *
42  * \asf_license_stop
43  *
44  */
45 /*
46  * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
47  */
48 
49 #ifndef ECC_SW_H_INCLUDED
50 #define ECC_SW_H_INCLUDED
51 
52 #include "compiler.h"
53 
54 /**
55  *  These are the possible errors when trying to verify a block of data encoded
56  *  using a Hamming code:
57  *
58  *  \section Errors
59  *   - HAMMING_ERROR_SINGLE_BIT
60  *   - HAMMING_ERROR_ECC
61  *   - HAMMING_ERROR_MULTIPLE_BITS
62  */
63 
64 /*  A single bit was incorrect but has been recovered. */
65 #define HAMMING_ERROR_SINGLE_BIT         1
66 
67 /* The original code has been corrupted. */
68 #define HAMMING_ERROR_ECC               2
69 
70 /* Multiple bits are incorrect in the data and they cannot be corrected. */
71 #define HAMMING_ERROR_MULTIPLE_BITS      3
72 
73 
74 void hamming_compute_256x(const uint8_t *puc_data, uint32_t dw_size,
75 		uint8_t *puc_code);
76 uint32_t hamming_verify_256x(uint8_t *puc_data, uint32_t dw_size,
77 		const uint8_t *puc_code);
78 
79 #endif /* ECC_SW_H_INCLUDED */
80