First class data visualization and communication library with embedded devices. Code is maintained at github.com/Overdrivr/Telemetry
Dependents: telemetry_car_demo telemetry_demo_FRDM-TFC telemetry_example_01 telemetry_indexed_data_demo ... more
Diff: c_api/crc16.c
- Revision:
- 6:f5e1b079bffd
- Parent:
- 5:cd94bb58e096
- Child:
- 7:d224bddd5405
--- a/c_api/crc16.c Wed Mar 09 12:15:13 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -#include "crc16.h" - -uint16_t crc16(uint8_t* data, uint32_t len) -{ - uint16_t rem = 0; - uint16_t i=0; - for(i = 0 ; i < len ; i++) - { - rem = crc16_recursive(data[i],rem); - } - return rem; - } - -uint16_t crc16_recursive(uint8_t byte, uint16_t remainder) -{ - uint16_t n = 16; - - remainder = remainder ^ (byte << (n-8)); - uint16_t j = 0; - for(j = 1 ; j < 8 ; j++) - { - if(remainder & 0x8000) - { - remainder = (remainder << 1) ^ 0x1021; - } - else - { - remainder = remainder << 1; - } - remainder &= 0xffff; - } - - return remainder; -}