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

Committer:
wataloh
Date:
Tue Jan 24 10:00:28 2017 +0000
Revision:
2:dfe671e31221
latest

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wataloh 2:dfe671e31221 1 #include "CheckSum.h"
wataloh 2:dfe671e31221 2
wataloh 2:dfe671e31221 3 uint32_t *CheckSum::table = NULL;
wataloh 2:dfe671e31221 4
wataloh 2:dfe671e31221 5 CheckSum::CheckSum()
wataloh 2:dfe671e31221 6 {
wataloh 2:dfe671e31221 7 reset();
wataloh 2:dfe671e31221 8 reset_table();
wataloh 2:dfe671e31221 9 }
wataloh 2:dfe671e31221 10
wataloh 2:dfe671e31221 11 void
wataloh 2:dfe671e31221 12 CheckSum::reset()
wataloh 2:dfe671e31221 13 {
wataloh 2:dfe671e31221 14 checkSum = 0xFFFFFFFF;
wataloh 2:dfe671e31221 15 }
wataloh 2:dfe671e31221 16
wataloh 2:dfe671e31221 17 void
wataloh 2:dfe671e31221 18 CheckSum::reset_table()
wataloh 2:dfe671e31221 19 {
wataloh 2:dfe671e31221 20 if(table==NULL)
wataloh 2:dfe671e31221 21 {
wataloh 2:dfe671e31221 22 table = new uint32_t[256];
wataloh 2:dfe671e31221 23 for (uint32_t i = 0; i < 256; i++)
wataloh 2:dfe671e31221 24 {
wataloh 2:dfe671e31221 25 uint32_t c = i;
wataloh 2:dfe671e31221 26 for (int j = 0; j < 8; j++)
wataloh 2:dfe671e31221 27 {
wataloh 2:dfe671e31221 28 c = (c & 1) ? (0xEDB88320 ^ (c >> 1)) : (c >> 1);
wataloh 2:dfe671e31221 29 }
wataloh 2:dfe671e31221 30 table[i] = c;
wataloh 2:dfe671e31221 31 }
wataloh 2:dfe671e31221 32 }
wataloh 2:dfe671e31221 33 }
wataloh 2:dfe671e31221 34
wataloh 2:dfe671e31221 35 void
wataloh 2:dfe671e31221 36 CheckSum::calc(uint8_t *buf, size_t len)
wataloh 2:dfe671e31221 37 {
wataloh 2:dfe671e31221 38 for (size_t i = 0; i < len; i++)
wataloh 2:dfe671e31221 39 {
wataloh 2:dfe671e31221 40 checkSum = table[(checkSum ^ buf[i]) & 0xFF] ^ (checkSum >> 8);
wataloh 2:dfe671e31221 41 }
wataloh 2:dfe671e31221 42 }
wataloh 2:dfe671e31221 43
wataloh 2:dfe671e31221 44 //CheckSum::CheckSumCRC32
wataloh 2:dfe671e31221 45 PREFERENCES::_crc32
wataloh 2:dfe671e31221 46 CheckSum::get()
wataloh 2:dfe671e31221 47 {
wataloh 2:dfe671e31221 48 // CheckSumCRC32 crc32;
wataloh 2:dfe671e31221 49 PREFERENCES::_crc32 ret;
wataloh 2:dfe671e31221 50 ret.ui32 = checkSum ^ 0xFFFFFFFF;
wataloh 2:dfe671e31221 51 return ret;
wataloh 2:dfe671e31221 52 }