www.pudn.com > writemac.rar > dm643_flash_checksum.c


/* 
 *  Copyright 2003 by Spectrum Digital Incorporated. 
 *  All rights reserved. Property of Spectrum Digital Incorporated. 
 */ 
 
/* 
 *  ======== evmdm642_flash_checksum.c ======== 
 *  EVMDM642_FLASH_checksum() implementation 
 */ 
  
#include  
#include  
 
#include  
#include  
 
/* Calculate the checksum of a data range in Flash */ 
Uint32 EVMDM642_FLASH_checksum(Uint32 start, Uint32 length) 
{ 
    Int16 i; 
    Uint8 *pdata; 
    Uint32 checksum; 
     
    /* Establish source and destination */ 
    pdata = (Uint8 *)start; 
     
    /* Calculate checksum by adding each word to the total */ 
    checksum = 0; 
    for (i = 0; i < length; i++) 
    { 
        checksum += *pdata++; 
    } 
     
    return checksum; 
}