Sony PlayStation2 Study
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
417 B

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright (c) 2013 Google, Inc
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include "crc.h"
  7. uint32_t crc8(const uint8_t *vptr, size_t len ){
  8. const uint8_t * data = vptr;
  9. uint32_t crc = 0;
  10. uint32_t i, j;
  11. for( j = len; j; j--, data++ ){
  12. crc ^= (*data << 8);
  13. for (i = 8; i; i--) {
  14. if (crc & 0x8000) crc ^= (0x1070 << 3);
  15. crc <<= 1;
  16. };
  17. };
  18. return (crc >> 8) & 0xff;
  19. };