These are the examples provided for [[/users/frank26080115/libraries/LPC1700CMSIS_Lib/]] Note, the entire "program" is not compilable!
crc32.c
00001 /***************************************************************************** 00002 * crc32.c: Ethernet CRC module file for NXP LPC230x Family Microprocessors 00003 * 00004 * Copyright(C) 2006, NXP Semiconductor 00005 * All rights reserved. 00006 * 00007 * History 00008 * 2006.09.01 ver 1.00 Prelimnary version, first Release 00009 * 00010 ******************************************************************************/ 00011 #include "lpc17xx_emac.h" /* LPC23xx/24xx definitions */ 00012 #include "crc32.h" 00013 00014 /****************************************************************************** 00015 ** Function name: CRC_init 00016 ** 00017 ** Descriptions: Begin CRC calculation. 00018 ** 00019 ** parameters: pointer to the CRC area. 00020 ** Returned value: None 00021 ** 00022 ******************************************************************************/ 00023 void crc32_init(uint32_t *pCRC) 00024 { 00025 *pCRC = 0xffffffff; 00026 } 00027 00028 /****************************************************************************** 00029 ** Function name: CRC32_add 00030 ** 00031 ** Descriptions: Calculate CRC value one at a time 00032 ** 00033 ** parameters: pointer to the CRC area, and passing value to get the CRC 00034 ** Returned value: None 00035 ** 00036 ******************************************************************************/ 00037 void crc32_add(uint32_t *pCRC, uint8_t val8) 00038 { 00039 uint32_t i, poly; 00040 uint32_t entry; 00041 uint32_t crc_in; 00042 uint32_t crc_out; 00043 00044 crc_in = *pCRC; 00045 poly = 0xEDB88320L; 00046 entry = (crc_in ^ ((uint32_t) val8)) & 0xFF; 00047 for (i = 0; i < 8; i++) 00048 { 00049 if (entry & 1) 00050 entry = (entry >> 1) ^ poly; 00051 else 00052 entry >>= 1; 00053 } 00054 crc_out = ((crc_in>>8) & 0x00FFFFFF) ^ entry; 00055 *pCRC = crc_out; 00056 return; 00057 } 00058 00059 /****************************************************************************** 00060 ** Function name: CRC32_end 00061 ** 00062 ** Descriptions: Finish CRC calculation 00063 ** 00064 ** parameters: pointer to the CRC area. 00065 ** Returned value: None 00066 ** 00067 ******************************************************************************/ 00068 void crc32_end(uint32_t *pCRC) 00069 { 00070 *pCRC ^= 0xffffffff; 00071 } 00072 00073 /****************************************************************************** 00074 ** Function name: CRC32_bfr 00075 ** 00076 ** Descriptions: Get the CRC value based on size of the string. 00077 ** 00078 ** parameters: Pointer to the string, size of the string. 00079 ** Returned value: CRC value 00080 ** 00081 ******************************************************************************/ 00082 uint32_t crc32_bfr(void *pBfr, uint32_t size) 00083 { 00084 uint32_t crc32; 00085 uint8_t *pu8; 00086 00087 crc32_init(&crc32); 00088 pu8 = (uint8_t *) pBfr; 00089 while (size-- != 0) 00090 { 00091 crc32_add(&crc32, *pu8); 00092 pu8++ ; 00093 } 00094 crc32_end(&crc32); 00095 return ( crc32 ); 00096 } 00097 00098 /********************************************************************************* 00099 ** End Of File 00100 *********************************************************************************/
Generated on Tue Jul 12 2022 17:28:08 by 1.7.2