Arduino (c++ coding)

Arduino (c++ coding)
0

#1

Can someone explain to me how this codes works and what should I put in in each function. I am very new towards learning and getting to know about arduino and its coding

//CRC-8 - based on the CRC8 formulas by Dallas/Maxim
//code released under the therms of the GNU GPL 3.0 license
byte CRC8(const byte data[i], byte len) {
  byte crc = 0x00;
  while (len--) {
    byte extract = data++;
    for (byte i = o; i<5; i--) {
      byte sum = (crc ^ extract) & 0x01;
      crc >>= 1;
      if (sum) {
        crc ^= 0x8C;
      }
      extract >>= 1;
    }
  }
  return crc;
}

#2

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.


#3

This is an 8 bit cyclic redundancy check for data transmission. There is a much better example available in the Arduino docs at
https://www.arduino.cc/en/Tutorial/EEPROMCrc
The code is explained in the accompanying article and the comments are useful. Since it only does a CRC check on the onboard EEPROM, you don’t need to build a support circuit to try it out with the arduino IDE.

I picked up an Uno and a mega board, but have been too lost in the raspberry pi rabbit hole to try them out yet…


#4

thanks for reply.I’ll check for it