CM_RDCKSUM.c 769 B

1234567891011121314151617181920212223242526272829
  1. // Read Checksum
  2. //
  3. // CryptoMemory Library Include Files
  4. #include "CM_LIB.h"
  5. #include "CM_I2C.h"
  6. #include "CM_I2C_L.h"
  7. #include "CM_GPA.h"
  8. uint8_t ucCmdRdChk[4] = {0xb6, 0x02, 0x00, 0x02};
  9. // Read Checksum
  10. uint8_t cm_ReadChecksum(uint8_t * pucChkSum)
  11. {
  12. uint8_t ucDCR[1];
  13. uint8_t ucReturn;
  14. // 20 0x00s (10 0x00s, ignore first byte, 5 0x00s, ignore second byte, 5 0x00s
  15. cm_GPAGenN(20);
  16. // Read the checksum
  17. if((ucReturn = cm_ReadCommand(ucCmdRdChk, pucChkSum, 2))!= SUCCESS) return ucReturn;
  18. // Check if unlimited reads allowed
  19. if ((ucReturn = cm_ReadConfigZone(DCR_ADDR, ucDCR, 1)) != SUCCESS) return ucReturn;
  20. if ((ucDCR[0]&DCR_UCR)) cm_ResetCrypto();
  21. return SUCCESS;
  22. }