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
util/CheckSum.cpp@0:20bce0dcc921, 2016-12-20 (annotated)
- Committer:
- wataloh
- Date:
- Tue Dec 20 01:51:02 2016 +0000
- Revision:
- 0:20bce0dcc921
kl25z teensy merged
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wataloh | 0:20bce0dcc921 | 1 | #include "CheckSum.h" |
wataloh | 0:20bce0dcc921 | 2 | |
wataloh | 0:20bce0dcc921 | 3 | uint32_t *CheckSum::table = NULL; |
wataloh | 0:20bce0dcc921 | 4 | |
wataloh | 0:20bce0dcc921 | 5 | CheckSum::CheckSum() |
wataloh | 0:20bce0dcc921 | 6 | { |
wataloh | 0:20bce0dcc921 | 7 | reset(); |
wataloh | 0:20bce0dcc921 | 8 | } |
wataloh | 0:20bce0dcc921 | 9 | |
wataloh | 0:20bce0dcc921 | 10 | void |
wataloh | 0:20bce0dcc921 | 11 | CheckSum::reset() |
wataloh | 0:20bce0dcc921 | 12 | { |
wataloh | 0:20bce0dcc921 | 13 | checkSum = 0xFFFFFFFF; |
wataloh | 0:20bce0dcc921 | 14 | if(table==NULL) |
wataloh | 0:20bce0dcc921 | 15 | { |
wataloh | 0:20bce0dcc921 | 16 | table = new uint32_t[256]; |
wataloh | 0:20bce0dcc921 | 17 | for (uint32_t i = 0; i < 256; i++) |
wataloh | 0:20bce0dcc921 | 18 | { |
wataloh | 0:20bce0dcc921 | 19 | uint32_t c = i; |
wataloh | 0:20bce0dcc921 | 20 | for (int j = 0; j < 8; j++) |
wataloh | 0:20bce0dcc921 | 21 | { |
wataloh | 0:20bce0dcc921 | 22 | c = (c & 1) ? (0xEDB88320 ^ (c >> 1)) : (c >> 1); |
wataloh | 0:20bce0dcc921 | 23 | } |
wataloh | 0:20bce0dcc921 | 24 | table[i] = c; |
wataloh | 0:20bce0dcc921 | 25 | } |
wataloh | 0:20bce0dcc921 | 26 | } |
wataloh | 0:20bce0dcc921 | 27 | } |
wataloh | 0:20bce0dcc921 | 28 | |
wataloh | 0:20bce0dcc921 | 29 | void |
wataloh | 0:20bce0dcc921 | 30 | CheckSum::calc(uint8_t *buf, size_t len) |
wataloh | 0:20bce0dcc921 | 31 | { |
wataloh | 0:20bce0dcc921 | 32 | for (size_t i = 0; i < len; i++) |
wataloh | 0:20bce0dcc921 | 33 | { |
wataloh | 0:20bce0dcc921 | 34 | checkSum = table[(checkSum ^ buf[i]) & 0xFF] ^ (checkSum >> 8); |
wataloh | 0:20bce0dcc921 | 35 | } |
wataloh | 0:20bce0dcc921 | 36 | } |
wataloh | 0:20bce0dcc921 | 37 | |
wataloh | 0:20bce0dcc921 | 38 | CheckSum::CheckSumCRC32 |
wataloh | 0:20bce0dcc921 | 39 | CheckSum::get() |
wataloh | 0:20bce0dcc921 | 40 | { |
wataloh | 0:20bce0dcc921 | 41 | CheckSumCRC32 crc32; |
wataloh | 0:20bce0dcc921 | 42 | crc32.uint32 = checkSum ^ 0xFFFFFFFF; |
wataloh | 0:20bce0dcc921 | 43 | return crc32; |
wataloh | 0:20bce0dcc921 | 44 | } |