LibJuno 0.42.0
LibJuno is a lightweight C99 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
juno_binhex.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 "binhex.h"
20
21uint16_t Juno_CrcBinhexUpdate(uint16_t iCrc, const void *pcData, size_t zDataSize)
22{
23 register uint16_t crc = iCrc;
24 register const uint8_t *cp = pcData;
25 register size_t cnt = zDataSize;
26
27 while(cnt--) {
28 crc=((crc<<8)&M2_16)^binhex_crctab[((crc>>8)&0xff)^*cp++];
29 }
30
31 return(crc);
32}
static const uint16_t binhex_crctab[256]
Definition binhex.h:18
#define M2_16
Definition crc.h:26
uint16_t Juno_CrcBinhexUpdate(uint16_t iCrc, const void *pcData, size_t zDataSize)
Definition juno_binhex.c:21