LibJuno 0.30.0
LibJuno is a lightweight C99 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
juno_ccitt.c
Go to the documentation of this file.
1/*
2 MIT License
3
4 Copyright (c) 2025 Robin A. Onsay
5
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files
8 (the "Software"), to deal in the Software without restriction,
9 including without limitation the rights to use, copy, modify, merge,
10 publish, distribute, sublicense, and/or sell copies of the Software,
11 and to permit persons to whom the Software is furnished to do so,
12 subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be
15 included in all copies or substantial portions of the Software.
16*/
17#include "juno/crc/crc.h"
18#include <stdint.h>
19#include <stdio.h>
20#include "ccitt.h"
21
22uint16_t Juno_CrcCcittUpdate(uint16_t iCrc, const void *pcData, size_t zDataSize)
23{
24 register uint16_t crc = iCrc;
25 register const uint8_t *cp = pcData;
26 register size_t cnt = zDataSize;
27
28 while(cnt--) {
29 crc=((crc<<8)&M2_16)^ccitt_crctab[((crc>>8)&0xff)^*cp++];
30 }
31
32 return(crc);
33}
#define M2_16
Definition crc.h:26
uint16_t Juno_CrcCcittUpdate(uint16_t iCrc, const void *pcData, size_t zDataSize)
Definition juno_ccitt.c:22