1
0

checksum.c 879 B

1234567891011121314151617181920212223242526272829
  1. /*
  2. This software is subject to the license described in the License.txt file
  3. included with this software distribution. You may not use this file except
  4. in compliance with this license.
  5. Copyright (c) Dynastream Innovations Inc. 2016
  6. All rights reserved.
  7. */
  8. #include "types.h"
  9. #include "checksum.h"
  10. //////////////////////////////////////////////////////////////////////////////////
  11. // Public Functions
  12. //////////////////////////////////////////////////////////////////////////////////
  13. ///////////////////////////////////////////////////////////////////////
  14. UCHAR CheckSum_Calc8(const volatile void *pvDataPtr_, USHORT usSize_)
  15. {
  16. const UCHAR *pucDataPtr = (UCHAR *)pvDataPtr_;
  17. UCHAR ucCheckSum = 0;
  18. int i;
  19. // Calculate the CheckSum value (XOR of all bytes in the buffer).
  20. for (i = 0; i < usSize_; i++)
  21. ucCheckSum ^= pucDataPtr[i];
  22. return ucCheckSum;
  23. }