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

📄 crccheck.c

📁 PIC_Hi-Tech_C_Mike_Pearces_Dallas_1-wire_routines工程源码
💻 C
字号:

unsigned char CRC;       //-- CRC Value, must be cleared before each run

//***********************************************************************
//                           CRC_Calc
//                            V0.0.0
//                         4 August 2000
//
// This calculates the CRC for one byte of data for Dallas DS182x devices
// To do a string of bytes, just feed each into this function without
// resetting the CRC value.
// Note: Before each CRC Generation set CRC = 0.
//***********************************************************************
//  Version 0.0.0 - 4 August 2000
//  First draft of code - not actually working yet!!!
//***********************************************************************
void CRC_Calc(Data)
{
 unsigned char temp,count,carry;
 for(count=0;count<8;count++)
 {
  temp=Data ^ CRC;
  carry=0;
  if((temp & 0x01)==1)
  {
   carry=1;
  }
  temp=CRC;
  if(temp !=0)
  {
   temp=temp ^ 0x18;
  }
  temp = temp >>1;
  temp &=0x7F;     // ensure bit 8 is clear
  if(carry==1)
  {
   temp |= 0x80;   // Move carry into top bit
  }
  CRC=temp;        // Store the CRC
  Data = Data >>1; // position the next data for adding to the CRC
 }
}

⌨️ 快捷键说明

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