国产毛片a精品毛-国产毛片黄片-国产毛片久久国产-国产毛片久久精品-青娱乐极品在线-青娱乐精品

MSP430實(shí)現(xiàn)循環(huán)冗余算法

發(fā)布時(shí)間:2008-1-1 11:47    發(fā)布者:MSP430
關(guān)鍵詞: MSP430 , 循環(huán)冗余
/****************************************************************************** ; Code for application report slaa221 - "CRC Implementation with MSP430" ; ; E.Lenchak ; Texas Instruments, Inc ; March 2004 ; Built with IAR Embedded Workbench Version: 3.20A ;****************************************************************************** ; THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR ; REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, ; INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS ; FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR ; COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE. ; TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET ; POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY ; INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR ; YOUR USE OF THE PROGRAM. ; ; IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL, ; CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY ; THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED ; OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT ; OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM. ; EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF ; REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS ; OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF ; USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI''S ; AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF ; YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS ; (U.S.$500). ; ; Unless otherwise stated, the Program written and copyrighted ; by Texas Instruments is distributed as "freeware". You may, ; only under TI''s copyright in the Program, use and modify the ; Program without any charge or restriction. You may ; distribute to third parties, provided that you transfer a ; copy of this license to the third party and the third party ; agrees to these terms by its first use of the Program. You ; must reproduce the copyright notice and any other legend of ; ownership on each copy or partial copy, of the Program. ; ; You acknowledge and agree that the Program contains ; copyrighted material, trade secrets and other TI proprietary ; information and is protected by copyright laws, ; international copyright treaties, and trade secret laws, as ; well as other intellectual property laws. To protect TI''s ; rights in the Program, you agree not to decompile, reverse ; engineer, disassemble or otherwise translate any object code ; versions of the Program to a human-readable form. You agree ; that in no event will you alter, remove or destroy any ; copyright notice included in the Program. TI reserves all ; rights not specifically granted under this license. Except ; as specifically provided herein, nothing in this agreement ; shall be construed as conferring by implication, estoppel, ; or otherwise, upon you, any license or other right under any ; TI patents, copyrights or trade secrets. ; ; You may not use the Program in non-TI devices. ; ;******************************************************************************/ /********************************************************************************** FUNCTIONS: 16/32-bit CRC Algorithms, bitwsie and table methods ARGUMENTS: "bitwise algorithm function signature" return: CRC arg1: CRC init value arg2: CRC generator polynomial arg3: pointer to the message arg4: size of message in bytes "table-based algorithm function signature" return: CRC arg1: CRC init value arg2: pointer to CRC table (specific to generator polynomial) arg3: pointer to the message arg4: size of message in bytes ***********************************************************************************/ #ifdef __ICC430__ #include "MSP430x16x.h" #endif #include "..\inc\crc.h" /************************************** CRC MEMBERS (FUNCTIONS) **************************************/ // this is an equivalent C implementation to the assembly implementation unsigned short crc16MakeBitwise(unsigned short crc, unsigned short poly, unsigned char *pmsg, unsigned int msg_size) { unsigned int i, j, carry; unsigned char msg; unsigned short temp; temp = *pmsg++ << 8; temp |= *pmsg++; crc ^= temp; for(i = 0 ; i < msg_size-2 ; i ++) { msg = *pmsg++; for(j = 0 ; j < 8 ; j++) { carry = crc & 0x8000; crc = (crc << 1) | (msg >> 7); if(carry) crc ^= poly; msg <<= 1; } } for(i = 0 ; i < 2 ; i ++) { for(j = 0 ; j < 8 ; j++) { carry = crc & 0x8000; crc <<= 1; if(carry) crc ^= poly; } } return(crc ^ CRC16_FINAL_XOR); } // this is a C-optimized implementation unsigned short crc16MakeBitwise2(unsigned short crc, unsigned short poly, unsigned char *pmsg, unsigned int msg_size) { unsigned int i, j; unsigned short msg; for(i = 0 ; i < msg_size ; i ++) { msg = (*pmsg++ << 8); for(j = 0 ; j < 8 ; j++) { if((msg ^ crc) >> 15) crc = (crc << 1) ^ poly; else crc <<= 1; msg <<= 1; } } return(crc ^ CRC16_FINAL_XOR); } // this is an equivalent C implementation to the assembly implementation unsigned long crc32MakeBitwise(unsigned long crc, unsigned long poly, unsigned char *pmsg, unsigned int msg_size) { unsigned int i, j, carry; unsigned char msg; unsigned long temp; temp = (unsigned long)(*pmsg++) << 24; temp |= (unsigned long)(*pmsg++) << 16; temp |= (unsigned long)(*pmsg++) << 8; temp |= (unsigned long)(*pmsg++); crc ^= temp; for(i = 0 ; i < msg_size-4 ; i ++) { msg = *pmsg++; for(j = 0 ; j < 8 ; j++) { carry = crc >> 31; crc = (crc << 1) | (msg >> 7); if(carry) crc ^= poly; msg <<= 1; } } for(i = 0 ; i < 4 ; i ++) { for(j = 0 ; j < 8 ; j++) { carry = crc >> 31; crc <<= 1; if(carry) crc ^= poly; } } return(crc ^ CRC32_FINAL_XOR); } // this is a C-optimized implementation unsigned long crc32MakeBitwise2(unsigned long crc, unsigned long poly, unsigned char *pmsg, unsigned int msg_size) { unsigned int i, j; unsigned long msg; for(i = 0 ; i < msg_size ; i++) { msg = *pmsg++; msg <<= 24; for(j = 0 ; j < 8 ; j++) { if((msg ^ crc) >> 31) crc = (crc << 1) ^ poly; else crc <<= 1; msg <<= 1; } } return(crc ^ CRC32_FINAL_XOR); } unsigned short crc16MakeTableMethod(unsigned short crc, TBL_MEM unsigned short *table, unsigned char *pbuffer, unsigned int length) { while(length--) crc = table[((crc >> 8) ^ *pbuffer++)] ^ (crc << 8); // normal return(crc ^ CRC16_FINAL_XOR); } unsigned short crc16rMakeTableMethod(unsigned short crc, TBL_MEM unsigned short *table, unsigned char *pbuffer, unsigned int length) { while(length--) crc = table[(crc & 0xFF) ^ *pbuffer++] ^ (crc >> 8); // reflected return(crc ^ CRC16R_FINAL_XOR); } unsigned long crc32MakeTableMethod(unsigned long crc, TBL_MEM unsigned long *table, unsigned char *pbuffer, unsigned int length) { while(length--) crc = table[((crc >> 24) ^ *pbuffer++)] ^ (crc << 8); // normal return(crc ^ CRC32_FINAL_XOR); } unsigned long crc32rMakeTableMethod(unsigned long crc, TBL_MEM unsigned long *table, unsigned char *pbuffer, unsigned int length) { while(length--) crc = table[(crc ^ *pbuffer++) & 0xFFL] ^ (crc >> 8); // reflected return(crc ^ CRC32R_FINAL_XOR); } /************************************ CRC UTILITIES ************************************/ void crc16BuildTable(unsigned short *ptable, unsigned short poly) { unsigned int i, j; for(i = 0; i <= 255; i++) { ptable = i << 8; for(j = 0; j < 8; j++) ptable = (ptable << 1) ^ (ptable & 0x8000 ? poly : 0); } } void crc32BuildTable(unsigned long *ptable, unsigned long poly) { unsigned int i, j; for(i = 0; i <= 255; i++) { ptable = (long)i << 24; for(j = 0; j < 8; j++) ptable = (ptable << 1) ^ (ptable & 0x80000000 ? poly : 0); } } unsigned long bitReflect(unsigned long data, unsigned int width) { unsigned long result = 0; unsigned int i; for (i = 1; i < (width + 1); i++) { if(data & 1) result |= 0x1L << (width - i); data >>= 1; } return result;
本文地址:http://www.qingdxww.cn/thread-2831-1-1.html     【打印本頁(yè)】

本站部分文章為轉(zhuǎn)載或網(wǎng)友發(fā)布,目的在于傳遞和分享信息,并不代表本網(wǎng)贊同其觀點(diǎn)和對(duì)其真實(shí)性負(fù)責(zé);文章版權(quán)歸原作者及原出處所有,如涉及作品內(nèi)容、版權(quán)和其它問(wèn)題,我們將根據(jù)著作權(quán)人的要求,第一時(shí)間更正或刪除。
您需要登錄后才可以發(fā)表評(píng)論 登錄 | 立即注冊(cè)

廠商推薦

  • Microchip視頻專區(qū)
  • PIC18-Q71系列MCU概述
  • 為何選擇集成電平轉(zhuǎn)換?
  • 5分鐘詳解定時(shí)器/計(jì)數(shù)器E和波形擴(kuò)展!
  • 想要避免發(fā)生災(zāi)難,就用MPLAB® SiC電源仿真器!
  • 貿(mào)澤電子(Mouser)專區(qū)

相關(guān)在線工具

關(guān)于我們  -  服務(wù)條款  -  使用指南  -  站點(diǎn)地圖  -  友情鏈接  -  聯(lián)系我們
電子工程網(wǎng) © 版權(quán)所有   京ICP備16069177號(hào) | 京公網(wǎng)安備11010502021702
快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 岛国片在线观看 | 自拍偷拍亚洲第一页 | 自拍偷拍欧美视频 | 免费自拍偷拍视频 | 欧美日韩一区二区视频免费看 | 狠狠色丁香久久综合网 | 在线视频一区二区日韩国产 | 久久99这里只有精品 | 中文字幕毛片 | 国产国产人免费视频成69大陆 | 国产精品18久久久久久久久久 | 99久久精品男女性高爱 | 青青青青青国产免费手机看视频 | 免费国产成人高清在线观看麻豆 | 久草日韩 | 永久福利视频 | 亚洲视频色 | 特级毛片免费视频播放 | 97在线免费看视频 | 国产视频日本 | 涩999| 麻豆网站 mkv 下载 | 欧美亚洲一区二区三区四 | 麻豆视频www | 日本天堂在线视频 | 日韩在线观看一区 | 久久99久久成人免费播放 | 蜜桃tv在线观看 | 成都4片p高清完整版hd | 榴莲视频丝瓜无限视频app | 亚洲欧美二区三区久本道 | 日日艹夜夜艹 | 日韩一区二区不卡中文字幕 | 99re视频在线观看 | 国产区精品 | 中文字幕日本不卡 | 成人精品综合免费视频 | 色接久久 | 国产精品日本不卡一区二区 | 青青青视频精品中文字幕 | 日韩国产有码在线观看视频 |