checksum.c 881 B

12345678910111213141516171819202122232425262728293031
  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 in compliance
  4. with this license.
  5. Copyright (c) Dynastream Innovations Inc. 2014
  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. }