⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sma_crc16.c

📁 sharp的arm920t 7A400的评估板附带光盘Sharp KEVLH7A400 v0.3b Welcome to the SHARP KEV7A400 Evaluation board
💻 C
字号:
/*********************************************************************** 
 * $Workfile:   SMA_crc16.c  $ 
 * $Revision:   1.0  $ 
 * $Author:   kovitzp  $ 
 * $Date:   Aug 21 2002 16:30:34  $ 
 * 
 * Project: CRC16
 * 
 * Description: 
 *  This module contains the necessary code to compute the CRC-16
 *  4 bits at a time.
 * 
 * Revision History: 
 * $Log:   //smaicnt2/pvcs/VM/CHIPS/archives/SOC/Source/SMA_crc16.c-arc  $ 
 * 
 *    Rev 1.0   Aug 21 2002 16:30:34   kovitzp
 * Initial revision.
 * 
 *********************************************************************** 
 * 
 *  Copyright (c) 2002 Sharp Microelectronics of the Americas 
 * 
 *  All rights reserved 
 * 
 *  SHARP MICROELECTRONICS OF THE AMERICAS MAKES NO REPRESENTATION 
 *  OR WARRANTIES WITH RESPECT TO THE PERFORMANCE OF THIS SOFTWARE, 
 *  AND SPECIFICALLY DISCLAIMS ANY RESPONSIBILITY FOR ANY DAMAGES, 
 *  SPECIAL OR CONSEQUENTIAL, CONNECTED WITH THE USE OF THIS SOFTWARE. 
 * 
 *  SHARP MICROELECTRONICS OF THE AMERICAS PROVIDES THIS SOFTWARE SOLELY 
 *  FOR THE PURPOSE OF SOFTWARE DEVELOPMENT INCORPORATING THE USE OF A 
 *  SHARP MICROCONTROLLER OR SYSTEM-ON-CHIP PRODUCT. USE OF THIS SOURCE 
 *  FILE IMPLIES ACCEPTANCE OF THESE CONDITIONS. 
 * 
 **********************************************************************/ 
#include "SMA_crc16.h"

/* nibble at a time CRC16 table */
static UNS_16 crc_tbl1[] =
{

    0x0000, 0xCC01, 0xD801, 0x1400, 0xF001, 0x3C00, 0x2800, 0xE401,
    0xA001, 0x6C00, 0x7800, 0xB401, 0x5000, 0x9C01, 0x8801, 0x4400,
};

/*********************************************************************** 
 * 
 * Function: crc16
 * 
 * Purpose: 
 *  return the CRC-16 for a block of data
 * 
 * Processing: 
 *  table driven CRC-16 algorithm. See crcv3.txt
 * 
 * Parameters: 
 *  buffer: a pointer to the array to compute the CRC-16
 *  length: the number of bytes in buffer
 * 
 * Outputs: None. 
 * 
 * Returns: 
 *  the CRC-16
 *
 * Notes: None
 * 
 **********************************************************************/ 
UNS_16 crc16(UNS_8 * buffer, UNS_32 length)
{
    UNS_16 acc1 = 0xFFFF;
    while (length--)
    {
        /* 
         * Nibble-at-a-time processing. Note that because this is
         * using the reflected algorithm, the lo-nibble is pro-
         * cessed first.
         */
         acc1 = crc_tbl1[(*buffer ^ acc1) & 15] ^ (acc1 >> 4);
         acc1 = crc_tbl1[((*buffer >> 4) ^ acc1) & 15] ^ (acc1 >> 4);
         buffer++;
    }
    return acc1;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -