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
Diff: util/CheckSum.cpp
- Revision:
- 2:dfe671e31221
diff -r b2a9a6f2c30e -r dfe671e31221 util/CheckSum.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/util/CheckSum.cpp Tue Jan 24 10:00:28 2017 +0000 @@ -0,0 +1,52 @@ +#include "CheckSum.h" + +uint32_t *CheckSum::table = NULL; + +CheckSum::CheckSum() +{ + reset(); + reset_table(); +} + +void +CheckSum::reset() +{ + checkSum = 0xFFFFFFFF; +} + +void +CheckSum::reset_table() +{ + 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 +PREFERENCES::_crc32 +CheckSum::get() +{ +// CheckSumCRC32 crc32; + PREFERENCES::_crc32 ret; + ret.ui32 = checkSum ^ 0xFFFFFFFF; + return ret; +}