CM_RDUSER.c 1000 B

123456789101112131415161718192021222324252627282930313233
  1. // Read User Zone
  2. //
  3. // The Read Large User Zone function is used to read data from CryptoMemory devices
  4. // that have greater than 256 bytes in each user zone (AT88SC6416C, and larger)
  5. // CryptoMemory Library Include Files
  6. #include "CM_LIB.h"
  7. #include "CM_I2C.h"
  8. #include "CM_I2C_L.h"
  9. #include "CM_GPA.h"
  10. // Read User Zone
  11. uint8_t cm_ReadLargeZone(uint32_t uiCryptoAddr, uint8_t* pucBuffer, uint8_t ucCount)
  12. {
  13. uint8_t ucReturn;
  14. ucCM_InsBuff[0] = 0xb2;
  15. ucCM_InsBuff[1] = (uint8_t)(uiCryptoAddr>>8);
  16. ucCM_InsBuff[2] = (uint8_t)uiCryptoAddr;
  17. ucCM_InsBuff[3] = ucCount;
  18. // Three bytes of the command must be included in the polynominals
  19. cm_GPAcmd3(ucCM_InsBuff);
  20. // Read the data
  21. if ((ucReturn = cm_ReadCommand(ucCM_InsBuff, pucBuffer, ucCount)) != SUCCESS) return ucReturn;
  22. // Include the data in the polynominals and decrypt if required
  23. cm_GPAdecrypt(ucCM_Encrypt, pucBuffer, ucCount);
  24. return SUCCESS;
  25. }