diff options
| author | Yukihiro Matz Matsumoto <[email protected]> | 2013-03-27 11:32:54 +0900 |
|---|---|---|
| committer | Yukihiro Matz Matsumoto <[email protected]> | 2013-03-27 11:32:54 +0900 |
| commit | d9e15a02a70992de0bbb7ddcf035d4ccc78c7a2e (patch) | |
| tree | a2aabd8eac8f8e3fd26be9f4d4ac02afe3e1a866 /src/crc.c | |
| parent | d4bb9b42e7e525c3b447f6cea74f2867789c3bc6 (diff) | |
| parent | e03e697549f0981d38a3e2a5c6241e0e305ade40 (diff) | |
| download | mruby-d9e15a02a70992de0bbb7ddcf035d4ccc78c7a2e.tar.gz mruby-d9e15a02a70992de0bbb7ddcf035d4ccc78c7a2e.zip | |
Merge branch 'masuidrive-new_mrb_format'
Diffstat (limited to 'src/crc.c')
| -rw-r--r-- | src/crc.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -6,6 +6,8 @@ #include <limits.h> #include <stdint.h> +#include <sys/types.h> + // Calculate CRC (CRC-16-CCITT) // // 0000_0000_0000_0000_0000_0000_0000_0000 @@ -16,10 +18,11 @@ #define CRC_CARRY_BIT (0x01000000) uint16_t -calc_crc_16_ccitt(unsigned char *src, int nbytes) +calc_crc_16_ccitt(const uint8_t *src, size_t nbytes, uint16_t crc) { - uint32_t crcwk = 0ul; - int ibyte, ibit; + size_t ibyte; + uint32_t ibit; + uint32_t crcwk = crc << 8; for (ibyte = 0; ibyte < nbytes; ibyte++) { crcwk |= *src++; @@ -32,3 +35,4 @@ calc_crc_16_ccitt(unsigned char *src, int nbytes) } return (uint16_t)(crcwk >> 8); } + |
