CRC8 calc

try
http://www.nongnu.org/avr-libc/

which has a selection of crc routines:

http://www.nongnu.org/avr-libc/user-manual/group__util__crc.html

I cannot remember where I got this, but this in an example of one that works in the arduino environment.
I modified it because I wanted to calculate the crc a byte at a time (it was for an application where data
was being read off a serial line, and I did not want to waste the buffer space).
Perhaps you can modify it for crc8.

This was in an include file crc16.h

/**************************************************************************
//
// crc16.c - generate a ccitt 16 bit cyclic redundancy check (crc)
/
//      The code in this module generates the crc for a block of data.
//
**************************************************************************/
/*
//                                16  12  5
// The CCITT CRC 16 polynomial is X + X + X + 1.
// In binary, this is the bit pattern 1 0001 0000 0010 0001, and in hex it
//  is 0x11021.
// A 17 bit register is simulated by testing the MSB before shifting
//  the data, which affords us the luxury of specifiy the polynomial as a
//  16 bit value, 0x1021.
// Due to the way in which we process the CRC, the bits of the polynomial
//  are stored in reverse order. This makes the polynomial 0x8408.
*/

/* RH: modified original routine to a class called one char at a time */

#define POLY 0x8408

/*
// note: when the crc is included in the message, the valid crc is:
//      0xF0B8, before the complement and byte swap,
//      0x0F47, after complement, before the byte swap,
//      0x470F, after the complement and the byte swap.
*/

  
  class Calc_Crc16 {
  private:
  unsigned int data;
  unsigned int crc;
  
  public:
  const static short crc_ok = 0X470F;

  Calc_Crc16() : crc ( 0XFFFF) 
  {
    
  } 
  
  void reset()
  {
        crc = 0XFFFF;
  }

  void next (char dval)
  {
    int i;
                  for (i = 0, data = (unsigned int)0xff & dval;
                  i < 8;
                  i++, data >>= 1) {
                    if ((crc & 0x0001) ^ (data & 0x0001))
                         {  crc = (crc >> 1) ^ POLY;}
                    else
                         {  crc >>= 1;}
                  }    
  }
  
  // taking copies of variables so this can be called validly more than once
  short get_crc() { 
       short crc1 = ~crc;      
       short data1 = crc1;
       crc1 = (crc1 << 8) | (data1 >> 8 & 0xFF);
       return crc1;
   }

  }
;

This code snippet shows how to include, declare and use the routine above:

#include "crc16.h"

Calc_Crc16 crc16;

void set_tag_from_eprom()
{
  g_tag = 0;
  crc16.reset();
  for (g_decode_index = 0; g_decode_index < 4; g_decode_index++)
  {
    g_arr_decode[g_decode_index] = EEPROM.read(EEPROM_TAG_ADD + g_decode_index);   
    crc16.next(g_arr_decode[g_decode_index]);
  }
  if (crc16.get_crc() == crc16.crc_ok)
  {
    g_tag = g_arr_decode[1];
    report_error_now();
  }  
} // end function