123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- /**********************************************************************
- * © 2010 Microchip Technology Inc.
- *
- * FileName: SSL_EEPROMTest_CRC16.c
- * Dependencies: Header (.h) files if applicable, see below
- * Processor: PIC18
- * Compiler: C18 v3.41
- *
- * SOFTWARE LICENSE AGREEMENT:
- * Microchip Technology Inc. (“Microchip”) licenses this software to you
- * solely for use with Microchip PIC® microcontroller
- * products. The software is owned by Microchip and is protected under
- * applicable copyright laws. All rights reserved.
- *
- * SOFTWARE IS PROVIDED “AS IS.” MICROCHIP EXPRESSLY DISCLAIMS ANY
- * WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED, INCLUDING BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL MICROCHIP
- * BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR CONSEQUENTIAL
- * DAMAGES, LOST PROFITS OR LOST DATA, HARM TO YOUR EQUIPMENT, COST OF
- * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
- * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF),
- * ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER SIMILAR COSTS.
- *
- * REVISION HISTORY:
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * Author Date Comments on this revision
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * CT 09/15/2008 Initial Revision
- * Mike Cahill 11/11/10 Updated for HI-TECH v9.80
- * MVL 02/22/2011 Updated with HI-TECH v9.81
- * VR 07/11/2012 Downgrade to C18 v3.41
- *
- * Version 1.03
- *
- *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- * ADDITIONAL NOTES:
- *
- **********************************************************************/
- #include "SSL_FLASH_CRC.h"
- uint16_t crc_Result = 0;
- uint16_t partialCRC_Result = 0;
- uint16_t tempCRC = 0;
- uint8_t Buffer;
- uint8_t rom *data_F = 0;
- uint16_t volatile startAddress = FLASH_STARTADDRESS;
- uint16_t volatile endAddress = FLASH_ENDADDRESS;
- /*******************************************************************************
- * Description:
- * The " SSL_8bits_EEPROMtest_CRC16 " function Calculates
- * the CRC of the data starting fromnAddress
- * "EEPROM_STARTADDRESS" to "EEPROM_ENDADDRESS". This function
- * \returns the final CRC Value.
- * CRC-16 is used as a divisor.
- *
- * CRC-16 = 1 1000 0000 0000 0101= 8005(hex)
- * Input: startAddress : start Address from which the CRC needs to be calculated
- * endAddress : This address indicates the Final address upto which the CRC is calculated
- * Return Values:
- crc_Result : Returns the final CRC result.
- *
- *******************************************************************************/
- uint16_t SSL_FLASHtest_CRC( void )
- {
- uint16_t i;
- for(i=startAddress; i<endAddress ; i++)
- {
- partialCRC_Result=0;
- Buffer = *(data_F+i);
- //Buffer=Read_b_eep(i);
- FLASH_CRC_Checksum();
- crc_Result= crc_Result + partialCRC_Result;
- }
- return crc_Result;
- }
- /*******************************************************************************
- * Description : Calculates the Partial Checksum for FLASH_BYTES
- *****************************************************************************/
- void FLASH_CRC_Checksum()
- {
- uint16_t i;
- tempCRC=0;
-
- for(i=8u; i>0u; i--)
- {
- if ( (Buffer ^ (tempCRC)) & 0x80 )
- {
- (tempCRC) = ((tempCRC)<< 1) ^ EEPROM_GEN_POLY ;
- }
- else
- {
- (tempCRC) <<= 1 ;
- }
- Buffer <<= 1 ;
- }
- partialCRC_Result= partialCRC_Result+tempCRC;
- }
|