pwm period is now 200us instead of the default 20ms veml6040 config is now AF_BIT | TRIG_BIT

Dependencies:   mbed MMA8451Q USBDevice WakeUp vt100

Fork of afero_node_suntory_2017_06_15 by Orefatoi

util/CheckSum.cpp

Committer:
wataloh
Date:
2016-12-20
Revision:
0:20bce0dcc921

File content as of revision 0:20bce0dcc921:

#include "CheckSum.h"

uint32_t *CheckSum::table = NULL;

CheckSum::CheckSum()
{
    reset();
}

void
CheckSum::reset()
{
    checkSum = 0xFFFFFFFF;
    if(table==NULL)
    {
        table = new uint32_t[256];
        for (uint32_t i = 0; i < 256; i++)
        {
            uint32_t c = i;
            for (int j = 0; j < 8; j++)
            {
                c = (c & 1) ? (0xEDB88320 ^ (c >> 1)) : (c >> 1);
            }
            table[i] = c;
        }
    }
}

void
CheckSum::calc(uint8_t *buf, size_t len)
{
    for (size_t i = 0; i < len; i++)
    {
        checkSum = table[(checkSum ^ buf[i]) & 0xFF] ^ (checkSum >> 8);
    }
}

CheckSum::CheckSumCRC32
CheckSum::get()
{
    CheckSumCRC32 crc32;
    crc32.uint32 = checkSum ^ 0xFFFFFFFF;
    return crc32; 
}