<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">// Dallas 1-wire 16-bit CRC calculation. Developed from Maxim Application Note 27.
uint16_t crc16( uint8_t *data, uint8_t len)
{
      uint16_t crc=0;
      
      for (uint8_t i=0; i&lt;len;i++) 
      {
            uint8_t inbyte = data[i];
            for (uint8_t j=0;j&lt;8;j++) 
            {
                  uint8_t mix = (byte(crc)^ inbyte) &amp; 0x01;
                  crc = crc &gt;&gt; 1;
                  if (mix) 
                        crc = crc ^ 0xA001;
                  
                  inbyte = inbyte &gt;&gt; 1;
            }
      }
      return crc;
}
</pre></body></html>